Read part of configuration from appConfiguration.
Sorry If I misunderstand documentation, but in my humble opinion It says that we can through appConfiguration overwrite some sink or column configuration, but in LoggerConfigurationMSSqlServerExtensions.cs on line 312 I can see that this parameter uses only for the connection string. So my question is that possible to use this parameter for overwriting code configuration with external configuration (in my case IConfiguration).
Also my task: I want to use the configuration in my serilog.json, but replace the connection string with a code approach, because it stores in key vault storage.
My code example which doesn't work:
.UseSerilog((hostContext, loggerConfig) => { loggerConfig .ReadFrom.Configuration(hostContext.Configuration) .WriteTo.MSSqlServer( hostContext.Configuration["identity-db-connection-string"], appConfiguration: hostContext.Configuration) .Enrich.WithProperty("ApplicationName", hostContext.HostingEnvironment.ApplicationName); });
My serilog.json file:
{ "Serilog": { "Using": ["Serilog.Sinks.MSSqlServer"], "MinimumLevel": { "Default": "Error", "Override": { "Skoruba": "Information" } }, "WriteTo": [ { "Name": "Console" }, { "Name": "File", "Args": { "path": "Log/skoruba_admin.txt", "rollingInterval": "Day" } }, { "Name": "MSSqlServer", "Args": { "sinkOptionsSection": { "tableName": "Logs", "autoCreateSqlTable": true }, "columnOptionsSection": { "addStandardColumns": [ "LogEvent" ], "removeStandardColumns": [ "Properties" ] } } } ] } }
Hi @Diponchik!
Can you provide us a full sample program demonstrating the error, so we could investigate it?
Best regrards, Christian