log4net的配置 - 没能找到部分 [英] log4net configuration - failed to find section
问题描述
这是我的错误信息:
log4net的:错误XmlConfigurator:无法找到配置节log4net的在应用程序的config文件。检查你的config文件的< log4net的>和< configSections>元素。配置节应该是这样:<节名称=log4net的TYPE =log4net.Config.Log4NetConfigurationSectionHandler,log4net的/>
这是我的web.config:
< XML版本=1.0&GT?;
<结构>
< configSections>
<节名称=log4net的TYPE =log4net.Config.Log4NetConfigurationSectionHandler,log4net的/>
< / configSections>
< system.serviceModel>
...
< /system.serviceModel>
<的ConnectionStrings>
...
< /的ConnectionStrings>
< log4net的>
...
< / log4net的>
< /结构>
什么是错我的配置?
更新:的
曾经也Web.Release.config:
< XML版本=1.0&GT?;
<结构的xmlns:XDT =http://schemas.microsoft.com/XML-Document-Transform>
<的System.Web>
<编译XDT:转换=RemoveAttributes(调试)/>
< /system.web>
< system.serviceModel>
...
< /system.serviceModel>
<的ConnectionStrings>
...
< /的ConnectionStrings>
< log4net的>
...
<根>
<电平值=DEBUGXDT:转换=替换/>
< /根>
< / log4net的>
< /结构>
Web.Test.cofig - 一样,一个发布
和Web.Debug.config,那就是空的:
< XML版本=1.0&GT?;
<结构的xmlns:XDT =http://schemas.microsoft.com/XML-Document-Transform>
< /结构>
你叫 XmlConfigurator.Configure()
地方?
删除那些来电,但是仅添加 [总成:log4net.Config.XmlConfigurator(表= TRUE)]
属性。
通常更容易配置log4net的在一个单独的文件,创建一个文件log4net.config和改变你的属性为:
[总成:log4net.Config.XmlConfigurator(ConfigFile实现=Log4Net.config,观看=真)
在你删除的部分的web.config
。
This is my error message:
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" />
this is my 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>
What is wrong with my config?
Update:
Have also 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 - the same as Release one
and Web.Debug.config, that is empty:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
</configuration>
Are you calling XmlConfigurator.Configure()
somewhere?
Remove those calls and only add the [assembly: log4net.Config.XmlConfigurator(Watch = true)]
attribute.
Normally it is easier to configure log4net in a seperate file, create a file log4net.config and change your attribute to:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]
Remove the section in you web.config
.
这篇关于log4net的配置 - 没能找到部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!