10

電話しようとすると、次の例外が発生します

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

タイプ 'Common.Logging.ConfigurationException' の初回例外が Common.Logging.dll で発生しました

タイプ 'Common.Logging.ConfigurationException' の未処理の例外が Common.Logging.dll で発生しました

追加情報: 構成セクション 'common/logging' から Common.Logging の構成を取得できませんでした。

これは、への参照を含む .NET 4 アプリケーションです。

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

私のapp.configには次のものがあります:

<?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>    

私は次のように電話しようとしています:

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

私は何が欠けていますか?

4

1 に答える 1

28

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

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

于 2011-07-21T17:13:47.977 に答える