C
C#8mo ago
Brady Kelly

Configure Serilog to only write warnings to Seq sink

I have the following Serilog configuration:
Serilog.Debugging.SelfLog.Enable(Console.Error);
Log.Logger = new LoggerConfiguration()
.Enrich.WithProperty("Application", typeof(Program).Assembly.GetName().Name)
.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Error)
.WriteTo.Console().MinimumLevel.Information()
.WriteTo.Seq("http://localhost:5341", apiKey:"awz1rXJhgYM2xxKKYaZ2")
.WriteTo.EventLog(source:"Application", logName:"Application", restrictedToMinimumLevel:LogEventLevel.Warning)
.CreateLogger();
Serilog.Debugging.SelfLog.Enable(Console.Error);
Log.Logger = new LoggerConfiguration()
.Enrich.WithProperty("Application", typeof(Program).Assembly.GetName().Name)
.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Error)
.WriteTo.Console().MinimumLevel.Information()
.WriteTo.Seq("http://localhost:5341", apiKey:"awz1rXJhgYM2xxKKYaZ2")
.WriteTo.EventLog(source:"Application", logName:"Application", restrictedToMinimumLevel:LogEventLevel.Warning)
.CreateLogger();
In this case I've had to include the minimum level override for Microsoft.EntityFrameworkCore because it was filling up the Windows Event Log sink with warnings I'd rather only see in Seq. Moving on I would like to 'reverse' this to only write EF Core warning level events (or other detailed events) to the Seq sink. How can I go about this?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server