I am using Serilog's MSSqlServer Sink and all settings are described in the appsettings.json. I read it in as follows:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) {
return WebHost.CreateDefaultBuilder(args)
.UseSerilog((ctx, config) => { config.ReadFrom.Configuration(ctx.Configuration); })
.UseStartup<Startup>();
}
I would then like to amend some of the entries read from the appsettings.json file in code. I am having trouble figuring out how to get to the configuration I just read from the file. And then how do I change MSSqlServer sink specific entries?
Specifically, let's say I want to change disableTriggers
in the columnOptionsSection
to false
from the file below. How would I do that?
For reference, here is abbreviated portion of appsettings.json with relevant parts:
"Serilog": {
"WriteTo": [
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "User ID=zzz;Password=yyy;...",
"tableName": "LogMe",
"autoCreateSqlTable": false,
"batchPostingLimit": 1000,
"period": "0.00:00:05",
"columnOptionsSection": {
"disableTriggers": true,
"clusteredColumnstoreIndex": false,
...
}
}
}
]
}