Serilog is better when the settings are via config sources
See original GitHub issue👋🏻 G’day @davidfowl
So now that Serilog has been merged (ref: #49) I was hoping you might consider another Serilog PR which now removes any hardcoding of serilog settings and instead replacing them with the settings being defined via configuration sources.
Serilog has it’s own special Serilog Configuration nuget which it then knows how to define some serilog settings via .NET configuration (file/env vars/etc):
The obvious example here is via the appsettings.json
, given a specific “section”. This extends to env vars so it works really nicely with Azure App Services or Docker Containers.
Can even use “Secrets” if you really need to -> think, API/License keys fr for the logging sink which is in the cloud.
Why do this?
This means anyone can easily change/setup their “sinks” and/or their logging “levels” at any time, without requiring any new build/deploys. For example, something weird is going on, you could just edit the azure app settings “env vars”/configuration settings and mod the logging level for a specific class or just in general (i.e. all logging is now Debug, not Info) … etc.
Would you be interested in this?
Issue Analytics
- State:
- Created 9 months ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
That seems logical to me. Add the nuget package, choose to configure it in code or via config. Adding sinks dynamically isn’t something that makes sense IMO.
I think it makes sense to move some things to config but not all of them. For example, I need to be able to detect when a URL is configured so that I can dynamically enable one of those sinks (elastic search for e.g.). Does the configuration model support branches (if statements etc)?
Today I can pass in the application name from the hosting environment but when using config, I need to duplicate that name. There are tradeoffs. Also, I can set breakpoints in code 😄.
That said, send me a PR and we can go back and forth until we meet somewhere in the middle.
okay - i have more to learn, it seems! looking forward to seeing what/why/etc 😃 kewl!