You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is currently the following comments and code in the wrapper for Microsoft.Extensions.Logging that does context data capture:
// MEL keeps an array of scope handlers. We can ask one of them for the current scope data.
// Get the array of ScopeLoggers (logger.ScopeLoggers[])
var getLoggersArrayFunc = _getLoggersArray ??= VisibilityBypasser.Instance.GeneratePropertyAccessor<dynamic>(logger.GetType(), "ScopeLoggers");
var loggers = getLoggersArrayFunc(logger);
// Get the first ScopeLogger in the array (logger.ScopeLoggers[0])
// If there is more than one scope logger, they've all received the same data, so the first
// one should be fine
object firstLogger = loggers.GetValue(0);
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 ScopeLoggers in the array, and only the last one had the ExternalScopeProvider 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).
The text was updated successfully, but these errors were encountered:
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.
See this issue for more context: #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).
The text was updated successfully, but these errors were encountered: