question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ConfigurationSection() adds sub-section in version 3.0.0; configurable default section name

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
takerukoushiroucommented, Oct 15, 2018

@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!

1reaction
tsimbalarcommented, Oct 15, 2018

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 !

Read more comments on GitHub >

github_iconTop Results From Across the Web

ConfigurationSection Class (System.Configuration)
Represents a section within a configuration file. public ref class ConfigurationSection abstract : System::Configuration::ConfigurationElement. C# Copy.
Read more >
ConfigurationSection Class (Microsoft.Extensions. ...
Represents a section of application configuration values. ... instance to the configuration section specified by the key by matching property names against ...
Read more >
ConfigurationManager.GetSection doesn't return custom ...
I created a ConsoleApplication. Namespace: TryConfigManagement; Add reference: System.Configuration. Changed App.Config (copy always) as follows ...
Read more >
c# - How to use ConfigurationManager.AppSettings with a ...
I think you need to get the config section, and access that: var section = ConfigurationManager.GetSection("server") as NameValueCollection; ...
Read more >
4 Easy Steps to Custom Sections in web.config - Perficient Blogs
Create the handler to read the custom xml. using System.Configuration; namespace MyConfig { //This class reads the defined config section (if ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found