c# – log4net配置 – 找不到节

c# – log4net配置 – 找不到节,第1张

概述这是我的错误信息: 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 这是我的错误信息:
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中的部分.

总结

以上是内存溢出为你收集整理的c# – log4net配置 – 找不到节全部内容,希望文章能够帮你解决c# – log4net配置 – 找不到节所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1259455.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-07
下一篇2022-06-07

发表评论

登录后才能评论

评论列表(0条)

    保存