Question

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?

Was it helpful?

Solution 2

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.

OTHER TIPS

Maybe the XML path is wired into log4net, try asking them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top