Log4net不会写入日志文件 [英] Log4net does not writes to log file
本文介绍了Log4net不会写入日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法找到log4net没有向日志文件写入任何内容的原因。以下是我使用的配置。
I am unable to find the reason why log4net is not writing anything to log file. the below is the configuration I have used.
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Log/TestLog.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="2KB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
但是当我给出这样的路径时,工作正常。
But the same is working fine when i gives the path like this ..
<file value="C:\\TestProj\\TestLog.txt" />
任何人都可以帮我这个吗?
Can anyone help me on this?
推荐答案
检查你的应用程序对日志文件的目标文件夹具有写权限。
Check if your application has write permissions on destination folder for log file.
<pre lang="text">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
log4net.Config.XmlConfigurator.Configure();
}
</pre>
initialization the connfig file
这篇关于Log4net不会写入日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文