Closed atliuhui closed 1 year ago
to save us some time, can u push up the full solution to a github repository
please pull this repo: https://github.com/atliuhui/debug-serilog
Me too 👀
This seems very similar to an issue that I ran into with LogContext not working correctly when PublishSingleFile=true
:
https://github.com/serilog/serilog/issues/1558
TL;DR - Automatic discovery of configuration assemblies is not supported in bundled mode. You may need to explicitly list the Serilog assembly names being referenced in the "Using" array of the Serilog settings section. Something like this:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Serilog": {
"Using": [ <------ This section!
"Serilog",
"Serilog.Sinks.File",
"Serilog.Settings.Configuration",
... etc
],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "logs/.log",
"rollingInterval": "Day",
"rollOnFileSizeLimit": true,
"fileSizeLimitBytes": 10485760
}
}
]
}
}
net7.0
dotnet new web
dotnet add package Serilog.AspNetCore --version 6.1.0
appsettings.json
Program.cs
FolderProfile.pubxml
run
test.exe
don't generate log files. but whenPublishSingleFile=false
, generate log files is OK.