Common Logging log4net INLINE WATCH

922 Views Asked by At

I have the following app.config in an application using Common.Logging.Log4net (ommited several parts to simplify the example):

<configuration>
  <configSections>
    <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
    </sectionGroup>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
      ...
      <common>
        <logging>
          <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net1211">
            <arg key="configType" value="INLINE" />
          </factoryAdapter>
        </logging>
      </common>
      <log4net>
        <appender ...
        <root>
          <level value="INFO" />
        </root>
      ...
      </log4net>

The idea is to let Common Logging runtime to configure log4net automatically (without the Assembly Attributes) and to use a unique file to have this configuration, which is the application's app.config.

Although with this INLINE configType I can't change the app.config on-the-fly to update logging configuration during the application run, because this behavior is achieved by FILE-WATCH configType.

So I want to:

  1. Have only one config file (my application's app.Config)
  2. Not have to include the Assembly Attribute into AssemblyInfo in order to configure log4net
  3. Change the app.Config log4net section (e.g. root logging level value) during the application runtime and have the application automatically updating its logging configuration as I change the app.config.

Any idea how could I fill these requirements using Common Logging + Log4net?

0

There are 0 best solutions below