c# – Common.Logging配置异常

前端之家收集整理的这篇文章主要介绍了c# – Common.Logging配置异常前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我尝试调用时,我收到以下异常
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’.

这是一个.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"));

我失踪了什么

解决方法

如果您从配置中删除元素启动,则运行正常.

编辑:而不是删除,只需移动启动元素后配置.

猜你在找的C#相关文章