本文介绍了无法识别的配置节log4net的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在web.config中这个code:
I have this code in web.config:
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="LogFileAppender" />
</root>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="D:\logFileFaculty.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
和我已经下载 log4net.dll
并把它放在斌
文件夹。
And I have downloaded log4net.dll
and placed it in Bin
Folder.
在我的 aspx.cs
网页一个我已经加入此code:
In one of My aspx.cs
pages I have added this code:
using log4net;
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
但它给误差无法识别的配置节log4net的
。
推荐答案
您需要声明 log4net的
部分:
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
以在<$c$c>documentation这也解释了必要的事情要做。
Take a closer look at the documentation
which explains the necessary things to do.
这篇关于无法识别的配置节log4net的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!