gpt4 book ai didi

java - DailyRollingFileAppender,丢失前一天的数据

转载 作者:行者123 更新时间:2023-11-29 09:18:41 26 4
gpt4 key购买 nike

第 1 天 程序开始并运行一整天。日志如期写入

第 2 天 当天的第一个 Activity 发生时午夜过后(一个 cron in我的情况)记录了 Activity ,第一天的所有数据都丢失了。此 Activity 记录为第 1 天 Activity

log4j.rootLogger=DEBUG, R

log4j.appender.R = org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File = ../log/ooo.log
log4j.appender.R.Append = true
log4j.appender.R.DatePattern = '.'yyyy-MM-dd
log4j.appender.R.layout = org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n

示例:

ooo.log.2011-10-20 中,我希望找到 10-20 的 Activity 相反,我看到 10-21 的前几秒

我期望行为,如 specification 所定义的那样

'.'yyyy-MM-dd Rollover at midnight each day. At midnight, on March 8th, 2002, /foo/bar.log will be copied to /foo/bar.log.2002-03-08. Logging for the 9th day of March will be output to /foo/bar.log until it is rolled over the next day.

此外,请查看时间戳。它似乎是随机的,与我的 cron 被调用时的分钟标记一致。不管它做了什么,appender 的行为与其描述不一致。

enter image description here

这是怎么回事?请帮助我理解和纠正。

最佳答案

这也可能是一个程序的多个实例记录到同一个文件的症状;查看更多 here以及其他答案。

Additionally, take a look at the timestamps. It appears to be random is consistent with the minute mark when my cron is called. Regardless of what it does though, appender's behavior is not consistent with its' description.

没错。翻转不会在“整点”发生,而是在翻转时间标记之后的第一个记录语句(因此是您的文件时间戳)。并且不检查翻转部分需要重命名的文件名是否可以免费使用。

关于java - DailyRollingFileAppender,丢失前一天的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7880364/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com