Using Serilog.Settings.Configuration (and presumably Serilog.Expressions) is it possible to reference another appsettings value? I'm trying to dynamically set endpointUrl below without duplicating the BaseUrl value or specifying the value outside of appsettings.
Serilog.Settings.Configuration has includes a section on their ReadMe around IConfiguration parameter, but it doesn't show an example assuming it's talking about what I'm referring to.
I tried the following solutions and none of them correctly set the value, except for the hard coded-duplicate approach.
"App": {
"BaseUrl": "https://localhost:1234"
},
"Serilog": {
"Using": [ "Serilog.Sinks.BrowserConsole", "Serilog.Sinks.BrowserHttp", "Serilog.Expressions" ],
"WriteTo": [
{
"Name": "BrowserHttp",
"Args": {
// This works
//"endpointUrl": "https://localhost:1234/ingest"
// These do not work:
//"endpointUrl": "{Concat(App.BaseUrl, '/ingest')}"
//"endpointUrl": "{App.BaseUrl}/ingest"
//"endpointUrl": "{App:BaseUrl}/ingest"
//"endpointUrl": "{BaseUrl}/ingest"
//"endpointUrl": "{AppSettings:App:BaseUrl}/ingest"
//"endpointUrl": "App.BaseUrl/ingest"
}
}
]
}
You can use
IServiceCollection.PostConfigure<TOptions>()
to edit your options after being bound from configuration provider.Options sample:
Config sample:
Configuring:
Usage:
This works, as you can see: