Search code examples
serilog

Serilog MinimumLevel.Override


My question is how granular do I need to be with Serilog MinimumLevel.Override when it comes to the source?

For example I want to have all messages from Microsoft be logged at the Warning Level.

Will the source "Microsoft" be adequate?

.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)

Or do I need to do something like this:

.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
....

Solution

  • .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
    

    will cause all events from Microsoft, Microsoft.AspNetCore, Microsoft.AspNetCore.Hosting, etc., to be logged at the Warning level and above. It's not necessary to list every child namespace.