Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common.Logging config exception

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?

like image 831
Jahmic Avatar asked Jul 21 '11 16:07

Jahmic


1 Answers

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

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

like image 64
Klinger Avatar answered Oct 14 '22 11:10

Klinger