当我尝试调用时出现以下异常
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"));
我错过了什么?
最佳答案
如果您从配置中删除元素 startup
,它运行正常。
编辑:不是删除,而是将启动元素移到配置部分之后。
关于c# - Common.Logging 配置异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6779711/