Common.Logging配置异常 [英] Common.Logging config exception

查看:2099
本文介绍了Common.Logging配置异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下异常,当我尝试调用

 变种数= LogManager.GetLogger(this.GetType());
 

  

有一个第一次机会异常类型的Common.Logging.ConfigurationException在Common.Logging.dll发生

     

类型的unhanded异常'Common.Logging.ConfigurationException在Common.Logging.dll发生

     

更多信息:Failed(故障)获得配置从配置节通用/日志Common.Logging

这是一个.NET 4应用程序引用

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

我的app.config有以下几点:

 < XML版本=1.0&GT?;
<结构>
    <启动>
        < supportedRuntime版本=4.0版的SKU =NETFramework,版本= V4.0/>
    < /启动>
    < configSections>
        < sectionGroup名=普通>
            <节名称=记录类型=Common.Logging.ConfigurationSectionHandler,Common.Logging/>
        < / sectionGroup>
    < / configSections>
    <普通>
        <记录>
            < factoryAdapter TYPE =Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter,Common.Logging>
                <精氨酸键=级别值=ALL/>
                <精氨酸键=showLogName值=真/>
                <精氨酸键=showDataTime值=真/>
                <精氨酸键=dateTimeFormat值=YYYY / MM / DD HH:MM:SS:FFF/>
            < / factoryAdapter>
        < /记录>
    < /常见>
< /结构>
 

我试图调用像这样:

 变种数= LogManager.GetLogger(this.GetType());
log.Debug(M => M(测试));
 

我在想什么?

解决方案

它,如果你删除元素运行正常启动从你的配置。

编辑:除删除,只需将configsections后的启动元素

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?

解决方案

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

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

这篇关于Common.Logging配置异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆