Reputation: 6487
I am using latest Serilog.File 4.1.0
and Serilog.Sinks.Async
. Async logging works but I want the files to be rolled.
How can I enable rolling of files?
I have the following:
Log.Logger = new LoggerConfiguration()
.WriteTo.Async(a =>
{
a.File("logs/logs.log");
})
.MinimumLevel.Verbose()
.CreateLogger();
Upvotes: 3
Views: 11525
Reputation: 27878
The File
Sink has support for Rolling files. Just define your rolling policies.
Log.Logger = new LoggerConfiguration()
.WriteTo.Async(a =>
{
a.File("logs/logs.log", rollingInterval: RollingInterval.Hour); // <<<<<
})
.MinimumLevel.Verbose()
.CreateLogger();
Upvotes: 8