c# – log4net配置 – 找不到节
发布时间:2020-12-15 06:43:40 所属栏目:百科 来源:网络整理
导读:这是我的错误信息: log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the log4net and configSections elements. The configuration section should look
这是我的错误信息:
log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> 这是我的web.config: <?xml version="1.0"?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> </configSections> <system.serviceModel> ... </system.serviceModel> <connectionStrings> ... </connectionStrings> <log4net> ... </log4net> </configuration> 我的配置有什么问题? 更新: 还有Web.Release.config: <?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> </system.web> <system.serviceModel> ... </system.serviceModel> <connectionStrings> ... </connectionStrings> <log4net> ... <root> <level value="DEBUG" xdt:Transform ="Replace"/> </root> </log4net> </configuration> Web.Test.cofig – 与发行版一样 和Web.Debug.config,这是空的: <?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> </configuration> 解决方法
你在某处调用XmlConfigurator.Configure()
删除这些调用,只添加[assembly:log4net.Config.XmlConfigurator(Watch = true)]属性. 通常在单独的文件中配置log4net是比较容易的.创建一个文件log4net.config并将您的属性更改为: [assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config",Watch = true)] 删除您的web.config中的部分. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- XML 中CDATA段 #PCDATA CDATA类型
- ajax – 反CSRF令牌和Javascript
- 如何告诉oracle按照从java传入的特定排序顺序进行排序?
- 【玩转cocos2d-x之十七】cocos2d-x中文显示
- 避免GLib内存池和Valgrind可能在C中丢失
- The content of elements must consist of well-formed cha
- 解决 com.alibaba.fastjson.JSONException: autoType is no
- c# – 如何等待将要启动的进程?
- ruby-on-rails – 使用Rails.cache.write设置原始值
- C#实现异步发送邮件的方法