serilog-settings-configuration
serilog-settings-configuration copied to clipboard
configureLogger doesn't work for published app
I need to specify different filters for each sink and example above is working correctly in debug mode, but after publishing application as self-contained logs failed to write.
{
"Serilog": {
"MinimumLevel": "Debug",
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.File",
"Serilog.Expressions"
],
"WriteTo": [
{
"Name": "Logger",
"Args": {
"configureLogger": {
"Filter": [
{
"Name": "ByExcluding",
"Args": {
"expression": "StartsWith(SourceContext, 'System.Net.Http.HttpClient.HttpMarkingService.LogicalHandler')"
}
}
],
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} {NewLine}"
}
}
]
}
}
},
{
"Name": "Logger",
"Args": {
"configureLogger": {
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "log.txt",
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} <s:{SourceContext}>{NewLine}{Exception}"
}
}
]
}
}
}
]
}
}
Without nested "WriteTo" sections it works fine.