I have very big solution that use ILogger<T> with serilog for each class, all of them write logs to same file with shared : true. the problem is retainedFileCountLimit doesn’t work for me because everyone count for himself, is there any option to make them all write to same file (shared: true) and also retain only 10 files?
this is my configuration:
{
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File"],
"MinimumLevel": "Debug",
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "Logs/PrinterApi.log",
"retainedFileCountLimit": 2,
"shared": true,
"rollOnFileSizeLimit": true,
"fileSizeLimitBytes": 50000,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss}] [{Level:u3}] [{ThreadId}] [{SourceContext:1}] {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Destructure": [
{
"Name": "ToMaximumDepth",
"Args": { "maximumDestructuringDepth": 4 }
},
{
"Name": "ToMaximumStringLength",
"Args": { "maximumStringLength": 100 }
},
{
"Name": "ToMaximumCollectionCount",
"Args": { "maximumCollectionCount": 10 }
}
],
"Properties": {
"Application": "Sample"
}
}
}
tried to have only 10 combined files but serilog create more and more because its 10 per logger