I have a ASP.NET core web API where I’m using Serilog to do the logging.
I want to log Info from Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware
in the log-file, but in the database I only want to log Warning from Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware
.
Any easy way to this?
My current Serilog config looks more or less like this, but it logs Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware
to the database.
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File", "Serilog.Sinks.MSSqlServer" ],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft.AspNetCore": "Warning",
"Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware": "Information"
}
},
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "Logs/log.txt",
"rollingInterval": "Day"
}
},
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "....",
"restrictedToMinimumLevel": "Information"
// More configuration options
}
}
]
}