Skip to content

.NET Core 2.0 minimum level handling/roadmap #98

@nblumhardt

Description

@nblumhardt

The current provider works with .NET Core 2.0, but the APIs have shifted since the 1.x version and I'm not confident we've got a decent story here now.

.NET Core 2.0 has its own internal "minimum level" that will be set to Information regardless of what we do in Serilog, unless we play in the JSON configuration system introduced with that version:

datalust/seq-extensions-logging#22

The net effect will be that apps using Serilog today will have to either separately specify ILoggingBuilder.SetMinimumLevel() in addition to the Serilog minimum level, or add a "Serilog.Extensions.Logging.SerilogLoggerProvider" element to the "Logging" configuration section in appsettings.json with level configuration specific to Serilog, even if this duplicates what's already been set through LoggerConfiguration.

(We can improve this experience by adding [ProviderAlias("Serilog")] to SerilogLoggerProvider, but, it just wins us a shorter key under "Logging", no other improvement in level handling.)

The conundrum we're facing is: the Serilog level and level overrides are set via LoggerConfiguration. When we call loggingBuilder.AddSerilog(), we don't communicate to .NET Core that we're handling our own levels. So, the framework will apply an Information filter, regardless.

I'm not sure what ways forward are open to us; it doesn't look like .NET Core 2.0 allows any level configuration to take place via Serilog (MinimumLevel, MinimumLevel.Override()) without the user duplicating all of that configuration now through Microsoft.Extensions.Logging's APIs.

(About all I can come up with is taking the nuclear option and completely replacing the whole logging subsystem with a Serilog one, but that will paint us into a corner of another kind.)

Needing some guidance here - any help appreciated @pakrym @davidfowl & co.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions