Skip to content

Support restrictedToMinimumLevel when configuring Serilog in code #4957

@jamescrosswell

Description

@jamescrosswell

Description

Serilog supports per sink minimum levels for logs.

We have a extension method that we encourage people to use, which configures a Sentry sink for Serilog, but it does not let SDK users specify this argument (which would need to be passed on here):

return loggerConfiguration.Sink(new SentrySink(options, sdkDisposable));

The only way to configure that currently is by using configuration bindings (e.g. appsettings.json)... probably OK for ASP.NET Core users... bit of a pain for MAUI users though.

NOTE

It is still possible to configure a "global" minimum level for structured logs in code... just not per sink levels. For example:

var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog((_, c) =>
c.Enrich.FromLogContext()
.MinimumLevel.Debug()

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .net code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions