serilog-sinks-async icon indicating copy to clipboard operation
serilog-sinks-async copied to clipboard

What is correct configuration in appsettings.json?

Open ziga34 opened this issue 5 years ago • 3 comments

Hello,

It's tough for me to figure it out, so please let me know what is the correct config:

{
  "Serilog": {
    "Using": [ "Serilog.Sinks.Async" ], <--- Is it ok, or should be Serilog.Sinks.RollingFileAlternate?
    "WriteTo": [
      {
        "Name": "Async",
        "Args": {
          "bufferSize": 100000, <-- does this belongs here? Or elsewhere?
          "blockWhenFull": true, <-- does this belongs here? Or elsewhere?
          "configure": [
            {
              "Name": "RollingFileAlternate",
              "Args": {
                "logDirectory": "D:\\log",
                "fileSizeLimitBytes": 1048576,
                "outputTemplate": "[{Timestamp:o} {Level:u3}] {Message:lj} {Properties:j}{NewLine}{Exception}"
              }
            }
          ]
        }
      }
    ]
  }
}

ziga34 avatar Aug 06 '19 09:08 ziga34

ensure you install the nuget Serilog.Sinks.Async

example: async sink that wraps file sink:

{
  "Name": "Async",
  "Args": {
    "configure": [
      {
        "Name": "File",
        "Args": {
          "path": "logs/app.log",
          "rollingInterval": "Day",
          "formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact"
        }
      }
    ]
  }
}

The docs for this are unclear, they should be updated with a proper example like above.

lonix1 avatar Mar 01 '21 08:03 lonix1

@lonix1 Your suggestion looks good - Async over a console log is also debatable so, if you can make the time to do a PR based on the above it'd be great.

(Also your other issue pretty much duplicates the questions asked within this, no?)

bartelink avatar Mar 01 '21 08:03 bartelink