Closed kalyaniravi14 closed 1 year ago
UPdating the config file with columnOption section also did not work "Serilog": { "Using": [ "Serilog.Sinks.MSSqlServer" ], "Minimumlevel": { "Default": "Information" }, "Enrich": [ "FromLogContext", "WithProperty" ], "WriteTo": [ { "Name": "MSSqlServer", "Args": { "ConnectionString": "Data Source=....", "tableName": "Logs" }, "columnOptionsSection": { "additionalColumns": [ { "ColumnName": "APPName", "DataType": "nvarchar", "AllowNull": 50 } ] } }
Can you try adding this to your Serilog DB connection string ;TrustServerCertificate=true
Hi @kalyaniravi14!
Can you please provide a simple but full program which demonstrates your problem. The code above is incomplete.
You need to place columnOptionsSection inside Args. Also tableName should be inside a sinkOptionsSection which should also be in Args. The following WriteTo section works on current latest 6.3.0, it will create the table with the default columns + a new one called SomeIntPropertyName of type int, nullable, and will be filled with property values from the log lines that match "SomeIntPropertyName"
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "...",
"restrictedToMinimumLevel": "Information",
"sinkOptionsSection": {
"tableName": "Logs",
"schemaName": "logs",
"autoCreateSqlTable": true
},
"columnOptionsSection": {
"additionalColumns": [
{ "ColumnName": "SomeIntPropertyName", "DataType": "int", "AllowNull": true }
]
}
}
}
UPdating the config file with columnOption section also did not work "Serilog": { "Using": [ "Serilog.Sinks.MSSqlServer" ], "Minimumlevel": { "Default": "Information" }, "Enrich": [ "FromLogContext", "WithProperty" ], "WriteTo": [ { "Name": "MSSqlServer", "Args": { "ConnectionString": "Data Source=....", "tableName": "Logs" }, "columnOptionsSection": { "additionalColumns": [ { "ColumnName": "APPName", "DataType": "nvarchar", "AllowNull": 50 } ] } }
Thank you @ciuly for the answer!
@kalyaniravi14 does this solution solve your problem?
Bug Report / Support Request Template
If you are opening a feature request, you can ignore this template. Bug reports and requests for assistance usually require the same basic information described below. This will help us more quickly reproduce and investigate the problem you're reporting. (If you are using Serilog.Sinks.MSSqlServerCore, that package is deprecated, please switch to Serilog.Sinks.MSSqlServer before reporting an issue.)
OS: Windows