-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ApplicationInsightsLogger doesn't respect Category LogLevel #2653
Comments
I'm not clear on what this means. There is no example for targeting a category, which might help. Are you saying that the application insights logger doesn't respect the standard way of configuring log levels. Isn't that a bug? "A specific log provider is not specified, so LogLevel applies to all the enabled logging providers except for the Windows EventLog." |
So, what I had previously, which didn't work: "Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware": "None"
}
} and now this, which does seem to work: "Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware": "None"
},
"ApplicationInsights": {
"LogLevel": {
"Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware": "None"
}
}
} I want to apply the category filter to all loggers, so I need to keep it in the general section too. The duplication is unfortunate. I also don't quite understand the justification for requiring an explicit override for the ApplicationInsights logger which is given in your link:
Why does this prevent the LogLevel for the specific category - applied in the general section - being applied to the application insights logger? Thanks in advance for any further info. |
If you used Microsoft.ApplicationInsights.AspNetCore package, and enabled application insights using the one liner services.AddApplicationInsightsTelemetry(), then it automatically inserts a Filter rule to only send Warning or above to ApplicationInsightsLoggerProvider. Since this is a specific rule, it wins over the general one you have. Hence you need to give more specific filter to override. |
I think the request here is (please @stevendarby correct me if I'm wrong): you have to write the Normally, a provider such as AppInsights, when not otherwise specified, is expected to use what is written in the common section But, if we write something like:
... sadly the traces with
... this works. I think the problem here is that, by default, ApplicationInsights use "Warning" as default severity level. If you don't specify the |
^ This is true for application insights logger provider as well. |
^ This is not the behavior of ApplicationInsightsLoggingProvider. It is the case when you use Microsoft.ApplicationInsights.AspNetCore package, to enable all telemetry (tracing, logging, metrics, etc.) with a one-liner (AddApplicationInsightsTelemetry()). |
This issue is stale because it has been open 300 days with no activity. Remove stale label or this will be closed in 7 days. Commenting will instruct the bot to automatically remove the label. |
As per dotnet/aspnetcore#42950 I have added the following to my appsettings.json
Logging:LogLevel
section in order to filter out logging by the ASP.NET Core ExceptionHandlerMiddleware:"Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware": "None"
I can confirm this works for the ConsoleLogger. However, I'm still seeing exceptions tracked in application insights with the category "Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware" which suggests to me that the app insights logger isn't respecting its configured log level.
I can provide a repo if really needed.
The text was updated successfully, but these errors were encountered: