serilog-sinks-async
serilog-sinks-async copied to clipboard
What is correct configuration in appsettings.json?
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}"
}
}
]
}
}
]
}
}
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 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?)