Closed nr-ahemsath closed 7 months ago
Yes, this is a bug I've also encountered. It's actually the last ScopeLogger which has the ExternalScopeProvider set.
To avoid this bug, you have to remove all other logging providers so that the Console logging provider is the one and only provider, making it both the first and last.
This can be seen here in Microsoft's repo, that the ExternalScopeProvider is only set on the last ScopeLogger, the rest are null. https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Logging/src/LoggerFactory.cs#L250
See this issue for more context: https://github.com/newrelic/newrelic-dotnet-agent/issues/2251
There is currently the following comments and code in the wrapper for Microsoft.Extensions.Logging that does context data capture:
However, the statement "if there is more than one scope logger, they've all the received the same data" does not appear to be true in at least one scenario. The linked feature request describes the scenario of having an ASP.NET Core webapi application configured to use MEL's built-in Console logger with the "IncludeScopes" option set to true. Debugging through the agent in this scenario, I found that there were three
ScopeLogger
s in the array, and only the last one had theExternalScopeProvider
property set to something other than null.I'm not really sure what the difference is between the scenario the customer described and how our integration tests for context data capture with MEL differ (other than that the integration tests use a simple console app, not an ASP.NET Core web app, which might have other logging configuration baked in going on).