Description
My console application has been working fine. Recently, I made some changes and redeployed it, and now it's throwing an exception.
Unhandled exception. System.InvalidOperationException: No Serilog:Using configuration section is defined and no Serilog assemblies were found. This is most likely because the application is published as a single-file.
None of my changes were related to Serilog or logging. However, I did refresh all the NuGet packages with updates, including updating Serilog.AspNetCore from 6.1.0 to 7.0.0.
While it's true I have the Produce single file option checked, this options was working and I'd prefer to keep using it.
Does anyone know what might have changed in Serilog version 7 that could cause this?
Here's my configuration:
// Configure Serilog
string logFormat = "[{Timestamp:yyyy-MM-dd hh:mm:ss tt}][{Level:u3}] {Message:lj}{NewLine}{Exception}";
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(appServices.Configuration)
.WriteTo.Console(LogEventLevel.Verbose, logFormat)
.WriteTo.File(LogFile, LogEventLevel.Verbose, logFormat)
.WriteTo.List(LogEvents)
.CreateLogger();
I'm using .NET 7.0. And here's my configuration section.
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
}
}