How to rename sections in app.config? Section name does not work
isn't it possible to rename tags within the app.config?
If I use the following
...
<sectionGroup 开发者_开发知识库name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
...
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
...
everything works as expected (logging with Common Logging is done). But if I change the section names the config is ignored, e.g. if I rename the group common to mycommon.
<sectionGroup name="mycommon">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
...
<mycommon>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</mycommon>
...
Anyone knows the trick?
Maybe the XML path is wired into log4net, try asking them.
The solution was found in the code itself...
public static class LogManager
{
/// <summary>
/// The name of the default configuration section to read settings from.
/// </summary>
/// <remarks>
/// You can always change the source of your configuration settings by setting another <see cref="IConfigurationReader"/> instance
/// on <see cref="ConfigurationReader"/>.
/// </remarks>
public static readonly string COMMON_LOGGING_SECTION = "common/logging";
private static IConfigurationReader _configurationReader;
So you can create a new class Implementing the IConfigurationReader interface, extend/replace the LogManager (or replace the string, but this requires recompiling Common.Logging).
Thanks for the well commented code of Common.Logging... I got it after debugging.
精彩评论