I am writing all logs into one file(s) using rolling. But I want to separate them by Information
, Warning
and Exceptions
rolling files.
my current configuration is like this
"Serilog": {
"WriteTo": [
{
"Name": "RollingFile",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}",
"pathFormat": "logs\\log-{Hour}.log",
"rollOnFileSizeLimit ": true,
"retainedFileCountLimit ": null,
"rollingInterval": "Hour",
"fileSizeLimitBytes": 5000000
}
}
]
},
class
public ILogger GetLogger()
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
_logger =
new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.CreateLogger();
return _logger ;
}