Reputation: 4359
I have a .Net C# WPF application. I'm trying to add rolling logs to the app. In Asp.Net applications, we've previously used the package Serilog.
Does Serilog work .Net desktop (non-asp.net) applications? I googled around and saw there were some issues regarding it, but it wasn't clear to that they were actually resolved.
Here is what the initialization of my Serilog Logger looks like:
string logsDirectory = Path.Combine(Environment.CurrentDirectory, "logs");
// Configure Serilog pipeline
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.RollingFile(Path.Combine(logsDirectory, "log-{Date}.txt"))
.CreateLogger();
I get the followint compilation error for "RollingLog()".
Error CS1061 'LoggerSinkConfiguration' does not contain a definition for 'RollingFile' and no extension method 'RollingFile' accepting a first argument of type 'LoggerSinkConfiguration' could be found (are you missing a using directive or an assembly reference?)
How can one git it to work with WPF?
Upvotes: 1
Views: 7293
Reputation: 2764
You are missing the Serilog RollingFile NuGetPackage if you would like to use rolling logs:
Install-Package Serilog.Sinks.RollingFile
For more details on using this package, see here
As I commented on your question - Serilog is not ASP.Net specific, it is a generic C# logging library.
Upvotes: 6