1

I have a .NET Core 2.1 application (Web API) where I added logging providers for the Console and ApplicationInsights.
I followed the instructions from this article to learn, how the logger works. Later I added ApplicationInsights Provider what I learned from this example.

My configuration file just looks like that:

  "Logging": {
    "LogLevel": {
      "Default": "Trace"
    }
  },

Nothing else.
I expect to get all log messages to appear in ApplicationInsights, but however only warning messages, error messages and critical messages appear there.
All logs with level < warning does not appear there.

If I add a specific log level "debug" for ApplicationInsights, this also does not work.

Any ideas what I might do wrong?

Stuart
  • 6,630
  • 2
  • 24
  • 40
David Mason
  • 915
  • 1
  • 9
  • 27

1 Answers1

1

If you read thoroughly the documentation page that you posted, in the sub-section

ILogger logs

it is stated that the default logging level is =< Warning.

You will find an official Microsoft link on how to change minimum logging levels here.

What you need to do to change log level for Application Insights is set your configuration file like below:

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    },
    "ApplicationInsights": {
      "LogLevel": {
        "Microsoft": "Error"
      }
    }
  }
}
Stelios Giakoumidis
  • 2,153
  • 1
  • 7
  • 19
  • "If levels are specified in Logging.{providername}.LogLevel, they override anything set in Logging.LogLevel." For me that means that if I keep the providers log level empty, this takes the default configuration from above. However this seems not to be the case. Only if I explicitly add LogLevel.Default = "Debug" in ApplicationInsights-Section the log level is shown... – David Mason May 26 '20 at 11:27