Closed SoftCircuits closed 1 year ago
Thank you for the bug report. This issue has already been brought to our attention in #389. It is already fixed by #391 which is merged in the dev
branch but a new NuGet package has not yet been released.
In the meantime, the recommended workaround is to specify one assembly through the ConfigurationReaderOptions
object.
var options = new ConfigurationReaderOptions(typeof(ConsoleLoggerConfigurationExtensions).Assembly);
string logFormat = "[{Timestamp:yyyy-MM-dd hh:mm:ss tt}][{Level:u3}] {Message:lj}{NewLine}{Exception}";
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(appServices.Configuration, options)
.WriteTo.Console(LogEventLevel.Verbose, logFormat)
.WriteTo.File(LogFile, LogEventLevel.Verbose, logFormat)
.WriteTo.List(LogEvents)
.CreateLogger();
@0xced Thanks for the timely response. I will review your workaround and keep an eye out for the next update. I found my project also runs if I just don't produce a single file.
@0xced I've queued up #395 - think this is ready to merge/release?
Yes, releasing 7.0.1 with these two bug fixes is a good idea in my opinion.
Serilog.Settings.Configuration 7.0.1, which fixes this issue, is now released on NuGet, enjoy! 🚀
@0xced Sorry, but I had another question about this.
Actually, I had not installed Serilog.Settings.Configuration. I thought you were updating the main component. Would installing this package still fix this issue for me?
Serilog.Settings.Configuration is a dependency of the Serilog.AspNetCore package, as you can see on its NuGet page: Serilog.Settings.Configuration (>= 7.0.0)
It means that even though you have not explicitly installed this package, it is already (implicitly) installed as a dependency.
So yes, installing version 7.0.1 explicitly of Serilog.Settings.Configuration
will solve your issue.
@0xced Cool. Thanks again. I guess the NuGet manager in Visual Studio isn't smart enough to see I have that dependency.
I haven't used Visual Studio in years so I can't tell. But JetBrains Rider helps understanding implicitly installed packages, see screenshot. 😉
My console application has been working fine. Recently, I made some changes and redeployed it, and now it's throwing an exception.
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:
I'm using .NET 7.0. And here's my configuration section.