I have implemented Serilog in .net core,I wanted to achieve multiple logging files for each log type. For example Error.log file will only contain error,Trace.log file will only contain Trace log, Warning.log will only contain warning messages and not error messages. I have used Serilog.Sinks.RollingFile and restrictedToMinimumLevel, i am able to generate multiple files but due to restrictedToMinimumLevel, it logs above defined level as well. Is there any option/way to set logOnlyLevel kind of thing. I can use filter but is there any better option.
"Serilog": {
"Using": ["Serilog.Sinks.RollingFile"],
"MinimumLevel": {
"Default": "Verbose",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [{
"Name": "RollingFile",
"Args": {
"pathFormat": "Logs/Information.txt",
"rollingInterval": "Day",
"fileSizeLimitBytes": "2000000",
"retainedFileCountLimit": "10",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}|{EventId}|{Message}|{Scope} {NewLine}",
"restrictedToMinimumLevel": "Information"
}
}, {
"Name": "RollingFile",
"Args": {
"pathFormat": "Logs/Warning.txt",
"rollingInterval": "Day",
"fileSizeLimitBytes": "2000000",
"retainedFileCountLimit": "10",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}|{EventId}|{Message}|{Scope} {NewLine}",
"restrictedToMinimumLevel": "Warning"
}
}
}