How to implement Serilog in Asp.Net Core 8.0

preview_player
Показать описание

{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Debug"
},
"WriteTo": [
{
"Name": "File",
"Args": {
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss zzz} {CorrelationId} [{Level:u3}] {Username} {Message:lj}{Exception}{NewLine}"
}
}
]
},
"AllowedHosts": "*"
}

var _logger = new LoggerConfiguration()
.ReadFrom.Configuration(builder.Configuration)
.Enrich.FromLogContext().CreateLogger();
builder.Logging.ClearProviders();
builder.Logging.AddSerilog(_logger);
Рекомендации по теме
Комментарии
Автор

Thank you bud. very clear and right to the point. thx.

purplepanther