-
Notifications
You must be signed in to change notification settings - Fork 831
Closed
Labels
Description
Serilog version 2.4.0. Simple demo:
namespace SerilogOverrideErrorDemo {
class Program {
static void Main(string[] args) {
var logBuilder = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.Logger(l => l.MinimumLevel.Information().MinimumLevel.Override("SerilogOverrideErrorDemo.Class2", LogEventLevel.Error).WriteTo.LiterateConsole()
);
Log.Logger = logBuilder.CreateLogger();
var l1 = Log.ForContext<Class1>();
var l2 = Log.ForContext<Class2>();
l1.Information("Info 1");
l2.Information("Info 2");
l1.Error("Error 1");
l2.Error("Error 2");
Console.ReadLine();
}
}
class Class1 {
}
class Class2 {
}
}
Output:
[14:06:12 INF] Info 1 - expected
[14:06:13 INF] Info 2 - unexpected
[14:06:13 ERR] Error 1 - expected
[14:06:13 ERR] Error 2 - expected
It works fine if "Override" is placed in rootLoggerConfiguration:
var logBuilder = new LoggerConfiguration()
.MinimumLevel.Information()
.MinimumLevel.Override("SerilogOverrideErrorDemo.Class2", LogEventLevel.Error)
.WriteTo.LiterateConsole();