log4net 在滚动到新日期时未正确记录
Log4Net 在几个月内运行良好,但在第二天推出新文件时开始出现问题。
问题: 每当我在白天签到或直到 23:59 之前,所有内容都会被记录,但一旦滚动,滚动的文件将包含第二天 00:00 - 06:00 的数据。前一天的所有日志都会丢失。
因此,对于滚动文件 Service.log20100702 将包含 03/07/2010 日期的 00:00 - 06:00 小时数据,仅包含其他数据。
问题主要出在生产盒子上,它在我的本地盒子上运行良好。
我的滚动文件附加器看起来像
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\TTLLogs\Refunds\Ttl.Refunds.Web.UI.log"/>
<appendToFile value="true" />
<datePattern value="yyyyMMdd" />
<rollingStyle value="Date" />
<maximumFileSize value="10MB" />
<maxSizeRollBackups value="100" />
<layout type="log4net.Layout.PatternLayout">
<header value="[Header]
"/>
<footer value="[Footer]
"/>
<conversionPattern value="%date %-5level %logger ${COMPUTERNAME} %property{UserHostAddress} [%property{SessionID}] - %message%newline"/>
</layout>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
</appender>
Log4Net worked fine for a few months and then started giving problems when rolling out a new file for the next day.
Problem:
Whenever I check in the daytime or until 23:59 everything is logged but as soon as it rolls over, the rolled file will have the data of 00:00 - 06:00 hrs of the next day. All the logs of the previous day are lost.
So for the rolledfile Service.log20100702 will contain the data 00:00 - 06:00 hrs for 03/07/2010 date and nothing else.
The problem is mainly on the Production boxes, it's working fine on my local box.
My rolling file appender looks like
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\TTLLogs\Refunds\Ttl.Refunds.Web.UI.log"/>
<appendToFile value="true" />
<datePattern value="yyyyMMdd" />
<rollingStyle value="Date" />
<maximumFileSize value="10MB" />
<maxSizeRollBackups value="100" />
<layout type="log4net.Layout.PatternLayout">
<header value="[Header]
"/>
<footer value="[Footer]
"/>
<conversionPattern value="%date %-5level %logger ${COMPUTERNAME} %property{UserHostAddress} [%property{SessionID}] - %message%newline"/>
</layout>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
</appender>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会尝试:
I'd try: