sschutten / serilog-sinks-contextrollingfile

The rolling file sink for Serilog, with support for token replacement in the path template.
3 stars 4 forks source link

Custom property in configuration doesn't work #1

Open john-luke-laue opened 5 years ago

john-luke-laue commented 5 years ago

If I use a custom property in the file name, and then try to ReadFrom a configuration section, the property is disregarded in the file name.

config.json:

"Serilog": {
      "MinimumLevel": {
        "Default": "Debug"
      },
      "WriteTo": [
        {
          "Name": "ContextRollingFile",
          "Args": { "pathFormat": "C:\\temp\\log-{LongDate:1}-{Date}.txt" }
        }
      ]
    }

code:

var logger = new LoggerConfiguration()
                .ReadFrom.ConfigurationSection(config.GetSection("IntacctInvoiceSyncCron:Serilog"))
                .Enrich.WithProperty("LongDate", DateTime.Now.ToString("yyyyMMddHHmmssfff"))
                .CreateLogger();

produces a file, but the property is missing: log-20181121.txt

I am expecting: log-2018112111441142123-20181121.txt