log4net正在生成两个日志文件 [英] log4net is generating two log files
本文介绍了log4net正在生成两个日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我在web.config中使用下面的代码,我发现有两个日志文件被创建。
由于某种原因,记录器每天都会切换到备用日志文件,文件名(应该是yyyy-mm-dd.log.text)重复两次。所以总有两个日志文件。
如果我遗漏了某些内容或有任何错误,请指导我。
Hello,
I am using below code in my web.config and I found there are two log files getting created .
For some reason every day the logger switches at times to an alternate log file with the filename (which is supposed to be yyyy-mm-dd.log.text) repeated twice. So there are always two log files.
Please guide me if I am missing something or making any mistake.
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\\Logs\\MyProject\\" />
<appendtofile value="true" />
<rollingstyle value="Date" />
<datepattern value="yyyy-MM-dd'.log.txt'" />
<staticlogfilename value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionpattern value="%date %level %type{1}.%method - %message%newline" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
谢谢,
Thanks,
推荐答案
您正在使用Ro lling File Appender顾名思义就是在日期上滚动到一个新文件,尝试使用FileAppender,请看这里: http://logging.apache.org/log4net/release/config-examples.html [ ^ ]
You are using the "Rolling File Appender" which as its name suggests rolls to a new file on dates, try using the FileAppender, see here : http://logging.apache.org/log4net/release/config-examples.html[^]
这篇关于log4net正在生成两个日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文