Home > Software engineering >  Application Insights does not capture information level logging
Application Insights does not capture information level logging

Time:10-03

I have a simple Asp.Net Core Web API application. For this example I have followed the official documentation here: enter image description 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.

enter image description here

The same goes when querying logs in Application Insights.

enter image description here

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

  • Related