Web.Config 中的 Log4Net 部分生成错误 [英] Log4Net section in Web.Config generates Error

查看:25
本文介绍了Web.Config 中的 Log4Net 部分生成错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图在我的 Web .NET 4.0 应用程序中设置 Log4Net.我已将正确的 .dll 添加到我的项目中,并将以下内容作为启动项附加到我的 Web.Config 文件中:

So I am trying to set up Log4Net in my Web .NET 4.0 application. I have added the correct .dll to my project and have appended the following to my Web.Config file as starters:

<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<root>
  <level value="DEBUG" />
  <appender-ref ref="RollingLogFileAppender" />
</root>
</configSections>
 <log4net debug="true">
 <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
  <file value="C:\TestProj\TestLog.txt" />
  <appendToFile value="true" />
  <rollingStyle value="Size" />
  <maxSizeRollBackups value="10" />
  <maximumFileSize value="10MB" />
  <staticLogFileName value="true" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n" />
  </layout>
 </appender>

但是,如果我将log4net"部分附加到 Web.Config,我将收到错误消息

However, if I append the "log4net" section to Web.Config, I will receive the error message

无法在 Web 服务器上开始调试.常见问题见帮助配置问题.....

Unable to start debugging on the web server. See help for common configuration problems.....

确保服务器正常运行.验证没有语法web.config 中的错误........

Make sure the server is running correctly. Verify there are no syntax errors in the web.config........

注意我可以删除本节的所有内部结构,只留下声明:

NOTE I can remove all the internals of this section and leave only the declaration:

<log4net></log4net>

我仍然会得到同样的错误.

and I will still get the same error.

有人能给我一些关于如何追踪这个错误的提示吗?

Can someone give me some pointers on how to track down this error?

推荐答案

查看位于 log4net 文档 主页.
您可能放错了必需的标签.

Take a look at a sample configurations at log4net documentation homepage.
Chances are you've misplaced required tags.

这篇关于Web.Config 中的 Log4Net 部分生成错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆