miércoles, 13 de mayo de 2020

Shutting up ASP.NET debug logs using Serilog

Log example:

{
"@t": "2020-05-13T23:39:04.3578970Z",
"@mt": "Executed action method {ActionName}, returned result {ActionResult} in {ElapsedMilliseconds}ms.",
// ...
"SourceContext": "Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker",
//...
}

Serilog configuration:

"Serilog": {
"WriteTo": [
{
"Name": "Console",
"Args": {
"formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact",
"restrictedToMinimumLevel": "Information"
}
}
],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft.AspNetCore": "Warning",
"System": "Warning"
}
}
},

No hay comentarios: