I have a simple Asp.Net Core Web API application. For this example I have followed the official documentation here:
But Application Insights for the same request is only capturing warning level logs and up. This following image if from Live Metrics in Application Insights.
The same goes when querying logs in Application Insights.
What else it is needed for an application to log information level and be captured by Application Insights?
CodePudding user response:
Your config is wrong. The LogLevel needs to be specified under the Logging section
{
"ApplicationInsights": {
"LogLevel": {
"Default": "Information"
},
"InstrumentationKey": "my-instrumentation-key",
"EnableAdaptiveSampling": false,
"EnablePerformanceCounterCollectionModule": false
},
"Logging": {
"LogLevel": {
"Default": "Information"
}
},
"AllowedHosts": "*"
}
A valid config would be
{
"ApplicationInsights": {
"InstrumentationKey": "my-instrumentation-key",
"EnableAdaptiveSampling": false,
"EnablePerformanceCounterCollectionModule": false
},
"Logging": {
"LogLevel": {
"Default": "Warning"
},
"ApplicationInsights": {
"LogLevel": {
"Default": "Information"
}
}
}
}
See the docs