Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 2.98 KB

Logging.md

File metadata and controls

52 lines (36 loc) · 2.98 KB

Logging

We use Microsoft.Extensions.Logging for logging abstractions and Serilog as the implementation.

For more documentation on logging, read the references listed at the bottom.

Log levels

We use the following convention for log levels:

  • Trace : Used for parts of a method to capture a flow.
  • Debug : Used for diagnostics information.
  • Information : Used for general successful information. Generally the default minimum.
  • Warning : Used for anything that can potentially cause application oddities. Automatically recoverable.
  • Error : Used for anything that is fatal to the current operation but not to the whole process. Potentially recoverable.
  • Critical : Used for anything that is forcing a shutdown to prevent data loss or corruption. Not recoverable.

Log providers

We use Serilog to implement log providers (called sinks).

The loggers are configured inside the LoggingConfiguration.cs file.

Logging

To log, you simply need to get a ILogger and use the appropriate methods.

var myLogger = myServiceProvider.GetService<ILogger<MyType>>();

myLogger.LogInformation("This is an information log.");

Diagnostics

Multiple logging features can be tested from the diagnostics screen. This is configured in LoggersDiagnosticsViewModel and SummaryDiagnosticsViewModel.

  • You can test the different log levels / providers.
  • You can enable / disable console logging.
  • You can enable / disable file logging.
  • You can see if a log file exists.
  • You can share the logs / app summary by email, etc.

References