serilog / serilog-extensions-logging

Serilog provider for Microsoft.Extensions.Logging
Apache License 2.0
309 stars 99 forks source link

Using LogContext.SetPropertyName to override ILogger scope values #120

Closed cd21h closed 5 years ago

cd21h commented 5 years ago

Hi,

the following code gives different results for Serilog logger and MS.Extensions.Logging within Asp.Net Core application

using (LogContext.PushProperty("CorrelationId", "my-correlation-id"))
{
    Log.Information("test-serilog"); // Serilog logger
    _logger.LogInformation("test-ms-logging"); // MS Logger
    return await ProcessRequest(request, false).ConfigureAwait(false);
}

Is this by design?

nblumhardt commented 5 years ago

(Reformatted your comment to show the first line of code.)

I think this comes down to the order in which the log context enrichment and the MEL enrichment are applied; I wouldn't call it "by design" but given there's not really any clearly-better way to implement it I think we could leave this as-is. Does it cause problems for you?

nblumhardt commented 5 years ago

Will close for now as "by design", although unintentionally, but let us know if there are problems around this - thanks!