Skip to content

Logging - Overview

Our logging framework of choice is Serilog. The features that will benefit us most include:

  • Message templates
  • Multiple sinks
  • Structured data

Application configuration

The ILogger interface of Microsoft.Extensions.Logging is used with Serilog registered as the logger.

Note: The codebase currently uses an ILog wrapper but this is under discussion.

Non-exceptional logging

Log levels Verbose, Debug, and Information should be used habitually to provide insight into the flow of the running app.

Examples

- API activity
    ○ Requests and responses
- External service communications
    ○ Request and responses
- MediatR routing
- Event dispatches
- SQL commands
    ○ Trace would be appropriate
- Startup behavior
    ○ Configuration loaded
    ○ IOC registrations

Decorator pattern

MediatR behaviors provide the decorator pattern to reduce the need to add log statements regarding infrastructure. For example, this is used to log CQRS activity. Logging - CQRS

Log aggregation

Although TBD, the plan is to utilze sinks to aggregate logs across the orchestration and services. The leading option is to use ELK as recommended by ETR