ConfigurationSection() adds sub-section in version 3.0.0; configurable default section name
See original GitHub issueI’ve been using the ReadFrom.ConfigurationSection()
extension method solely for reading the logger configuration from a configuration section with a name that differs from the hard-coded default (e.g. “Logging” instead of “Serilog”).
Version 3.0.0 no longer uses the provided configuration section directly, but instead calls GetSection(DefaultSectionName)
, adding a hard-coded sub-section. This change was seemingly introduced with commit 80b2ec98c56394b9f6901a33c7db64af62f4c652 or one thereafter. I am not sure whether this is on purpose, but using the provided configuration section directly as in version 2.6.1 and earlier seems more logical and also fits the documented behaviour of the extension method.
After having a quick look at the code path in the debugger, it seems that probably just the wrong constructor overload for ConfigurationReader
is called in the 3.0.0 NuGet package assembly.
Regardless of the descrived issue, it would be great if the default section name could be configured (or provided as an optional parameter). If that were possible, the recommended ReadFrom.Configuration()
extension method could be used instead if the only difference is just a different section name.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
@tsimbalar I upgraded to the 3.0.1 pre-relase in a project that previously used version 2.6.1 and all logs seem to have retained their configuration. A quick look with the IDE into the decompiled code also shows that the section overload is now used.
Thanks a lot for the quick fix!
A fix should be available in the pre-release nuget package for v3.0.1:
https://www.nuget.org/packages/Serilog.Settings.Configuration/3.0.1-dev-00160
It would be great if you could give it a try !