Search code examples
c#serilogserilog-sinks-file

Maintaining a (single) stable filename using Serilog File sink


I am logging the data like below :

.WriteTo.File("log.txt", rollOnFileSizeLimit: true,retainedFileCountLimit: 1,
                                             fileSizeLimitBytes: 10)

This creates a file set like this:

log.txt => log_001.txt => log_002.txt

Since I set retainedFileCountLimit = 1 once the log.text was deleted then log_001.txt

Is there any way to maintain only the log.log file instant of keeping int values in an increased format ?


Solution

  • There is a forked sink, Serilog.Sinks.PersistentFile that does this.

    But it's a very debatable ask which is why it's not supported by the standard Serilog.Sinks.File for the foreseeable future.