As the title says, I'm struggling with Serilog's subloggers configuration (from appsettings.json).
I am trying to have two subloggers: the first one is going to log only information level logs that I sent from services, and the second one must log everything (likely to ASP.NET Core default logging) to a console.
Now I will post two appsettings.json snippets that I tried and explain what they are doing
With this one both subloggers are logging only logs sent from services (probably due global Microsoft error namespace overriding):
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Error"
}
},
"WriteTo": [
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "Server=localhost\\SQLEXPRESS01;Database=AuctionDb;Trusted_Connection=TRUE;Encrypt=False",
"tableName": "ActivityLogs",
"autoCreateSqlTable": false,
"autoCreateSqlDatabase": false,
"columnOptionsSection": {
"customColumns": [
{
"ColumnName": "UserId",
"DataType": "nvarchar"
},
{
"ColumnName": "ItemId",
"DataType": "int"
}
]
}
}
},
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
},
"MinimumLevel": "Verbose"
}
]
}
This one causes console log everything as needed, but the database sublogger doesn't log anything:
"Serilog": {
"MinimumLevel": {
"Default": "Information"
},
"WriteTo": [
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "Server=localhost01\\SQLEXPRESS01;Database=AuctionDb;Trusted_Connection=TRUE;Encrypt=False",
"tableName": "ActivityLogs",
"autoCreateSqlTable": false,
"autoCreateSqlDatabase": false,
"columnOptionsSection": {
"customColumns": [
{
"ColumnName": "UserId",
"DataType": "nvarchar"
},
{
"ColumnName": "ItemId",
"DataType": "int"
}
]
}
}
},
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
},
"MinimumLevel": "Verbose"
}
]
}
I understand where the problem can be, but still can't fix that after many attempts