0

We are using asp.net Core 1.1 and are using SeriLog to create log file within the application.

Now to control size of log file, I added attribute fileSizeLimitBytes

"Serilog": {
  "MinimumLevel": "Debug",
  "WriteTo": [
    {
      "Name": "RollingFile",
      "Args": {
        "pathFormat": "Logs/LogFileConf-{Date}-test.Log",
        "fileSizeLimitBytes": 500000
      }
    }
  ],
  "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
  "Properties": {
    "Application": "Sample",
    "Environment": "Test"
  }
},

In this case, writing to log file stopped and when I removed above attributes, writing to log file again started working

So I have added as follows "pathFormat": "Logs/LogFileConf-{Date}-test.Log", "fileSizeLimitBytes": 500000

I am not sure what I am missing here.

Project.json contains following reference.
"Serilog.Extensions.Logging": "1.2.0",
"Serilog.Sinks.RollingFile": "3.0.1",
"Serilog.Settings.Configuration": "2.1.0"

Can anybody help here to solve this issue?

Nicholas Blumhardt
  • 30,271
  • 4
  • 90
  • 101
Manish Joisar
  • 1,256
  • 3
  • 23
  • 47

1 Answers1

0

Is your log file already > 500,000 bytes? That's not a high limit, so chances are the logging stops because the file is already above it.

See Serilog.Sinks.File 4.0+ if you are looking for roll-on-file-size.

Nicholas Blumhardt
  • 30,271
  • 4
  • 90
  • 101
  • We added Seilog.Sinks.File in appsettings.json file, and included rolling file attribute as mentioned in question, but now it does not write anything in log file, can you please share example for the same? It seems i am missing something here – Manish Joisar Nov 24 '17 at 10:57