微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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"));

我失踪了什么

解决方法

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

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

原文地址:https://www.jb51.cc/csharp/93446.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐