Logging

This page gives some information about logging in Tax Balance.

On this page

Implementation

We rely on the logging API shipped with .NET. For more information visit the official documentation. We are using the third-party logging provider Serilog.

As per default we deploy Tax Balance with the following sinks:

  • ApplicationInsights

  • Async

  • AzureEventHub

  • AzureTableStorage

  • Console

  • Elasticsearch

  • Email

  • EventLog

  • File

  • LiteDB

  • MSSqlServer

  • PeriodicBatching

  • Seq

  • SyslogMessages

Information about the above-mentioned sinks and further sinks can be found on the GitHub documentation.

Log level

Dependent on the provider certain Log level will be condensed or renamed. The following table depicts differences:

.NET API Method

Description

ApplicationInsights (SeverityLevel)

Seq

.NET API Method

Description

ApplicationInsights (SeverityLevel)

Seq

Trace (0)

LogTrace

Contain the most detailed messages. These messages may contain sensitive app data. These messages are disabled by default and should not be enabled in production.

Verbose

Verbose (0)

Verbose

Debug (1)

LogDebug

For debugging and development. Use with caution in production due to the high volume.

Debug

Verbose (0)

Debug

Information (2)

LogInformation

Tracks the general flow of the app. May have long-term value.

Information

Information (1)

Information

Warning (3)

LogWarning

For abnormal or unexpected events. Typically includes errors or conditions that don't cause the app to fail.

Warning

Warning (2)

Warning

Error (4)

LogError

For errors and exceptions that cannot be handled. These messages indicate a failure in the current operation or request, not an app-wide failure.

Error

Error (3)

Error

Critical (5)

LogCritical

For failures that require immediate attention. Examples: data loss scenarios, out of disk space.

Fatal

Critical (4)

Fatal

Minimum level

The default minimum level is Information. This means that levels Information, Warning, Error, Critical will be logged.

Configuration

Logging can be configured in appsettings.json file located in the application directory. Configuration takes place in the Serilog section.

The Using value is an array, with the above-mentioned sinks. Make sure to prepend Serilog.Sinks. to a sink value.

The WriteTo value is an array, with sink specific configuration. Usually, it consists of the sinks Name and an Args object for the sink specific parameters. See sink GitHub documentation for further information.

The default configuration of Tax Balance contains valid configuration for the sinks Console, ApplicationInsights and File.

Structured logging with Seq

To achieve the best logging experience, we recommend to you use a logging sink which supports structured logging, e.g., ApplicationInsights or Seq.

Seq is a self-hosted search, analysis, and alerting server built for structured log data.

Install a Seq instance following the official documentation and configure the sink according to the sinks documentation.

Â