In serilog ,Is there any property to maintain the configured filename is latest log

81 Views Asked by At

Hi i am using serilog to write the log. Log captured perfectly, my problem with the log filename. I have configured log filename as trace.log. once the file limit is reached the latest log captured in trace_001.txt. but i want the latest log always there in trace.log. back up goes to trace_001.log.is there any property?

My configuration:

  "WriteTo": [
      //FILE
      {
        "Name": "File",
        "Args": {
          "path": "%BASEDIR%/trace.log",
          "shared": true,
          "rollingInterval": "Day",
          "rollOnFileSizeLimit": true,
          "fileSizeLimitBytes": 1048576,
          "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [{MachineName}_{Tenant}] [{EnvironmentUserName}] [{ProcessId}] [{Guid}] [{ClassName}.{MethodName}] {Message:lj}{NewLine}{Exception}",
        }
      }
    ]
1

There are 1 best solutions below

0
On

Serilog has opted not to implement such a scheme in the standard Serilog.Sinks.File sink - see that issue for a link to a sink that does implement that naming (but I would recommend against that, as such rolling renames are fundamentally a bad idea IMO)