-
Notifications
You must be signed in to change notification settings - Fork 148
Closed
Description
I have serilog config in Json. When I'm trying to add/remove columns, nothing happens.
Dependencies
Microsoft.AspNetCore.All (2.1.0)
Serilog.AspNetCore (2.1.1)
Serilog.Settings.Configuration (2.6.1)
Serilog.Sinks.MSSqlServer (5.1.2)
logsettings.json have Copy always (After config change Clean -> Rebuild)
Calling config
IConfiguration config = new ConfigurationBuilder()
.AddJsonFile("logsettings.json", optional: true, reloadOnChange: true)
.Build();
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(config)
.CreateLogger();
Config
{
"Serilog": {
"Using": [ "Serilog.Sinks.MSSqlServer" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning"
}
},
"WriteTo": [
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "Server=localhost; Database=log; MultipleActiveResultSets=true; User ID=sa; Password=Admin1234",
"tableName": "Logs",
"autoCreateSqlTable": true,
"columnOptionsSection": {
"customColumns": [
{
"ColumnName": "Application",
"DataType": "string"
},
{
"ColumnName": "SourceContext",
"DataType": "string"
},
{
"ColumnName": "ActionId",
"DataType": "string"
},
{
"ColumnName": "ActionName",
"DataType": "string"
},
{
"ColumnName": "RequestId",
"DataType": "string"
},
{
"ColumnName": "RequestPath",
"DataType": "string"
},
{
"ColumnName": "ConnectionId",
"DataType": "string"
}
], //Custom columns aren't in database
"addStandardColumns": [ "LogEvent" ], //LogEvent column still isn't in database
"removeStandardColumns": [ "MessageTemplate", "Properties" ], //Properties column is still in database
"logEvent": {
"columnName": "LogEvent",
"excludeAdditionalProperties": true
}
}
}
}
]
}
}
Even config template did not work
{
"Serilog": {
"Using": ["Serilog.Sinks.MSSqlServer"],
"MinimumLevel": "Debug",
"WriteTo": [
{ "Name": "MSSqlServer",
"Args": {
"connectionString": "Server=localhost; Database=log; MultipleActiveResultSets=true; User ID=sa; Password=Admin1234",
"tableName": "Logs",
"autoCreateSqlTable": true,
"columnOptionsSection": {
"customColumns": [
{ "ColumnName": "EventType", "DataType": "int", "AllowNull": false },
{ "ColumnName": "Release", "DataType": "varchar", "DataLength": 32 }
]
}
}
}
]
}
}
In database are always these columns (None is added/removed)
| Id | Message | MessageTemplate | Level | TimeStamp | Exception | Properties |
davidliang2008, kalexx, OculiViridi, Luxuride, skoruba and 2 more
Metadata
Metadata
Assignees
Labels
No labels