log4net日志文件的修改日期早于日志输入日期.时光机器? [英] log4net log file modification date older than log entry date. Time machine?

查看:168
本文介绍了log4net日志文件的修改日期早于日志输入日期.时光机器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们从客户那里收到了一个奇怪的错误报告:日志文件的最后修改日期早于其中的日志输入时间戳."

We have this strange bug report from a customer: "Log file last modification date is older than log entry time stamp in it".

差异以天为单位(〜2天).这不是一成不变的事情-到目前为止只是一个已知的情况.

The difference is in days (~2 days). It is not a constant thing - just one known case so far.

我不是log4net实施的专家-仅将其用作第三者.如果提供了以下记录器配置,是否有可能由于log4net RollingFileAppender概念中的某些错误配置或误解而发生了这种情况?

I am not a guru in log4net implementation - only using it as a 3rd party. Given the loggers configuration is provided bellow are there any possibilities that this has happened cause of some wrong configuration or misunderstanding in log4net RollingFileAppender concept?

仅对log4net作为问题的可能根源感兴趣(即,我确实知道,有外部方法可以实现此目的……也许是一些糟糕的日志文件管理工具,错误地修改了日期)

Only interested in log4net as a possible source of an issue (i.e. I do understand, that there are external ways to make this happen ... perhaps some crappy log files management tool, that modified the date by mistake)

<appender name="CustomAppender" type="log4net.Appender.RollingFileAppender">
  <param name="File" value="log.txt" />
  <param name="AppendToFile" value="true" />
  <param name="MaxSizeRollBackups" value="2" />
  <param name="RollingStyle" value="Size" />
  <param name="StaticLogFileName" value="true" />
  <param name="MaximumFileSize" value="100MB" />
  <layout type="log4net.Layout.PatternLayout,log4net">
    <conversionPattern value="%date %-5level %message%newline" />
  </layout>
</appender>
<logger name="CustomLogger" additivity="false">
  <level value="ALL" />
  <appender-ref ref="CustomAppender" />
</logger>

直接从代码中使用(简化):

the usage from code is straight forward (simplified):

LogManager.GetLogger("CustomLogger").Info("Message");

log4net版本:1.2.10.0 该应用程序是Windows服务.语言-C#3.0,但我想这没关系.

log4net version: 1.2.10.0 The application is a windows service. Language - C# 3.0, but I guess this does not matter.

推荐答案

我也经常通过log4net看到这一点.报告的日期时间可能只是日志文件最后一次打开以供log4net写入的日期时间.

I see this as well from time to time with log4net. The datetime reported is probably just the datetime at which the log file was last opened for writing by log4net.

在再次关闭文件之前,它可能不会更新文件日期时间.

It may not update the file datetime until the file is closed again.

["我刚刚在机器上本地抨击了一个简单的示例,并且看到了您所描述的行为,但是我之前已经看过-可能在Windows 2003服务器上(而不是我目前使用的XP).看看是否至少可以消除这种可能性]

[ I've just lashed up a simple example locally on my machine and don't see the behaviour you are describing, but I have seen it before - probably on a Windows 2003 server (as opposed to XP that I am using at the moment). See if you can at least eliminate this as a possibility]

这篇关于log4net日志文件的修改日期早于日志输入日期.时光机器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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