Common.Logging配置异常
当我尝试调用时出现以下异常
var log = LogManager.GetLogger(this.GetType());
Common.Logging.dll 中发生了“Common.Logging.ConfigurationException”类型的第一次机会异常
Common.Logging.dll 中发生“Common.Logging.ConfigurationException”类型的未处理异常
其他信息:无法从配置节“common/logging”获取 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"));
我缺少什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您从配置中删除元素
startup
,它就可以正常运行。编辑:不要删除,只需将启动元素移动到配置节之后。
It runs ok if you remove element
startup
from your config.EDIT: Instead of removing, just move the startup element after configsections.