Home > database >  How to use Logging level parameter from appsettings.json for Serilog?
How to use Logging level parameter from appsettings.json for Serilog?

Time:10-14

When i am trying to use Logging inside appsettings.json for config Serilog, it is ingore my LovLevel option.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Warning"
    },
    "FilePath": "Loggs//log.log"
  }
}

I can only fix it with adding MinimumLevel option:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Warning"
    },
    "MinimumLevel": {
      "Default": "Debug"
    },
    "FilePath": "Loggs//log.log"
  }
}

Can i setup my minlevel of logs without adding "MinimumLevel" option and use "LowLevel" instead?

CodePudding user response:

You need to set Default as your MinimumLevel.

E.g.

{
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Warning"
    },
    "FilePath": "Loggs//log.log"
  }
}
  • Related