opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

[Serilog Extensions] Add Activity Enricher

Open CodeBlanch opened this issue 3 years ago • 0 comments

We have a Serilog Extensions project now which currently contains a sink for routing logs emitted through Serilog into an OpenTelemetryLoggerProvider.

One thing that might be nice to also have in that project is an enricher which will push Activity/span data onto logs.

The use case for this would be Serilog being used for logs into some other sink (flat files, DB, whatever) and OpenTelemetry being used for Traces/Metrics.

Something like this...

ILogger logger = new LoggerConfiguration()
    .Enrich.WithOpenTelemetry() // <- Registers enricher
    .WriteTo.RollingFile(
        new JsonFormatter(renderMessage: true), 
        @"C:\logs\log-{Date}.txt")    
    .CreateLogger();

CodeBlanch avatar Jul 18 '22 16:07 CodeBlanch