Common.Logging config exception

萝らか妹 提交于 2019-12-10 12:46:00

问题


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?


回答1:


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

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



来源:https://stackoverflow.com/questions/6779711/common-logging-config-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!