1

Currently using:

  • Serilog 2.11.0
  • Serilog.Sinks.File 5.0.0
  • Serilog.Sinks.RollingFile 3.3.0

With the following logger configuration:

        _logger = new LoggerConfiguration()
            .MinimumLevel.Verbose()
            .WriteTo.File(
                HttpContext.Current.Server.MapPath("~/MyApp/App_Data/logs/app.log"),
                rollOnFileSizeLimit: true,
                fileSizeLimitBytes: 10000000,
                shared: true)
            .CreateLogger();

I am trying to figure out if it is possible to maintain the current log file name to name specified in logger configuration and have custom named archived file names. For example:

  • app.log (always current log file)
  • app_20220913.log (archived log file that rolled on size on 2022/09/13)
  • app_20220912.log (archived log file that rolled on size on 2022/09/12)
  • app_20220911.log (archived log file that rolled on size on 2022/09/11)

Compared to current behavior:

  • import_001.log (current log file)
  • import.log (archived log file that rolled on size)

Thanks in advance!

seanrco
  • 935
  • 5
  • 16
  • 32
  • Are you trying to use both size and day rolling, did you tried using `rollingInterval: RollingInterval.Day` also along with current configuration ? or try using [this](https://github.com/serilog/serilog-sinks-rollingfile) package. – CodingMytra Sep 26 '22 at 07:17
  • @CodingMytra I want to use rollOnFileSizeLimit, but was wondering if you can configure the format of the file naming as outlined in post. I am guessing it is not possible and would have to write a custom sink. – seanrco Sep 26 '22 at 22:21

0 Answers0