Common.Logging config exception

Jahmic picture Jahmic · Jul 21, 2011 · Viewed 14.2k times · Source

I'm getting the following exception when I try to call

var log = LogManager.GetLogger(this.GetType());

A first chance exception of type 'Common.Logging.ConfigurationException' occurred in Common.Logging.dll

An unhanded exception of type 'Common.Logging.ConfigurationException' occurred in Common.Logging.dll

Additional information: Failed obtaining configuration for Common.Logging from configuration section 'common/logging'.

This is a .NET 4 application with references to

  • log4net.dll
  • Common.Logging.dll
  • Common.Logging.log4net.dll

my app.config has the following:

<?xml version="1.0"?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
    <configSections>
        <sectionGroup name="common">
            <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
        </sectionGroup>
    </configSections>
    <common>
        <logging>
            <factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
                <arg key="level" value="ALL" />
                <arg key="showLogName" value="true" />
                <arg key="showDataTime" value="true" />
                <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
            </factoryAdapter>
        </logging>
    </common>
</configuration>    

I'm trying to call like so:

var log = LogManager.GetLogger(this.GetType());
log.Debug(m => m("testing"));

What am I missing?

Answer

Klinger picture Klinger · Jul 21, 2011

It runs ok if you remove element startup from your config.

EDIT: Instead of removing, just move the startup element after configsections.