serilog-extensions-logging-file icon indicating copy to clipboard operation
serilog-extensions-logging-file copied to clipboard

I can't make LogLevel work

Open rodrigomocca opened this issue 5 years ago • 1 comments

Hi, I'm trying the extension, and it's working great, but I can't get Debug Levels logged. I've settled up the app.settings like this:

"Logging": {
    "PathFormat": "Logs/log-{Date}.txt",
    "LogLevel": {
      "Default": "Debug",
      "Microsoft": "Information"
    }
  },

And the Startup.cs like this: loggerFactory.AddFile(Configuration.GetSection("Logging"));

I'm trying really simple from a controller: _logger.LogDebug("TestController");

But the log is not in the file. If I change _logger.LogDebug("TestController") to _logger.LogInformation("TestController"); the log shows in the log file as expected.

What I'm doing wrong?

Thanks for your help.

rodrigomocca avatar May 06 '20 14:05 rodrigomocca

I'm a bit late to the party, but hopefully this will help someone else.

What I just discovered is that the config that comes with ASP.Net Core apps does limit the output. This is sort of undercommunicated, and contrary to some of the information out there. In any case, if you have the below config somewhere (appsettings.Development.json?) it makes it impossible to increase the verbosity using the parameter passed to AddFile.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  }
}

Edit: To clarify, you don't have to pass these parameters to AddFile for them to limit the output

lkarabeg avatar Jul 21 '20 21:07 lkarabeg