0

I'm using serilog with this configuration:

{
    "Serilog": {
        "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
        "MinimumLevel": "Debug",
        "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
        "WriteTo": [
            { "Name": "Console" },
            {
                "Name": "File",
                "Args": {
                    "path": "./logs/performance-{Date}.log",
                    "rollingInterval": "Day",
                    "fileSizeLimitBytes": 1000,
                    "rollOnFileSizeLimit": true,
                    "retainedFileCountLimit": null,
                    "shared": true
                }
            }
        ]
    }
}

Output file should look like 20210613-performance.log But output file looks like {Date}-performance20210613.log.

What i'm doing wrong?

Maxim Kitsenko
  • 2,042
  • 1
  • 20
  • 43

1 Answers1

0

The {Date} placeholder is not a feature of the Serilog.Sinks.File sink that you're using. You're probably confusing with the (deprecated) Serilog.Sinks.RollingFile sink which has this feature.

With Serilog.Sinks.File, at this time, you cannot define where the date will appear. It's always appended to the end of the file name you choose (and before the sequence number if you also are rolling by file size).

There have been attempts to implement this feature, but as of this writing it's not yet there.

C. Augusto Proiete
  • 24,684
  • 2
  • 63
  • 91