我收到以下异常,当我尝试调用
变种数= 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.dllmy 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.