serilog-settings-configuration icon indicating copy to clipboard operation
serilog-settings-configuration copied to clipboard

Correct way to make Serilog read Logging section from appsettings.json

Open rodion-m opened this issue 2 years ago • 4 comments

What is the correct way to make Serilog read Logging section from appsettings.json? I want Serilog to count this section:

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

rodion-m avatar May 16 '22 00:05 rodion-m

The section you're showing is MEL's configuration section; Serilog has its own (under "Serilog"), there's no way to get Serilog to use MEL's (it's a different logging framework). Hope this helps

nblumhardt avatar May 16 '22 01:05 nblumhardt

The section you're showing is MEL's configuration section; Serilog has its own (under "Serilog"), there's no way to get Serilog to use MEL's (it's a different logging framework). Hope this helps

Hey @nblumhardt , thanks for a fast response! Yes, I know that this section from MEL. Perhaps it costs to add some mapper that will grab Serilog configuration from Logging section by default? It's really not expected behavior when after Serilog adding, Logging section's configs became ignored.

rodion-m avatar May 18 '22 22:05 rodion-m

Thanks for your reply @rodion-m. Unfortunately the systems aren't equivalent; the "Logging" section isn't generic - it's specific to the implementation-side of Microsoft.Extensions.Logging. Serilog only implements the MEL abstractions, and has a completely different internal model of levels, sinks, filters, etc.

nblumhardt avatar May 19 '22 00:05 nblumhardt

Sometimes I had a desire to write such a mapper, but I quickly came to the conclusion that it was not worth it.

sungam3r avatar Jun 06 '22 08:06 sungam3r