Serilog RollingFile
Try below:
var log = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.File(@"f:\log\log.txt", rollingInterval: RollingInterval.Day)
.CreateLogger();
The log file name will be automatically log-20150819.txt etc. You do not need to specify the date.Old files will be cleaned up as per retainedFileCountLimit - default is 31.
WriteTo.RollingFile Deprecated
Since the posted answer, the method RollingFile
is no longer viable and replaced with File
and options to roll the logs.
Now one must use the standard Serilog.Sinks.File
NuGet package which supports rolling:
.WriteTo.File(path: @"e:\logs\skilliam.log",
rollingInterval: RollingInterval.Day,
rollOnFileSizeLimit: true,
fileSizeLimitBytes: 123456);