Log4cxx DailyRollingFileAppender 未滚动
我有一个仅在硬件触发时运行的应用程序。我们最近还添加了 log4cxx 的旧版 C++ 应用程序,用于生成日志以帮助调试罕见的生产问题。我们当然想要每日日志文件。
事实证明我们从来没有得到过滚动文件。
为了调试问题,我们将其设置为按分钟而不是按天滚动。我们发现,如果在从一分钟开始的几秒钟内调用该程序,文件就会滚动。如果在该分钟结束后超过 5 秒才调用,则不会发生翻滚。
在测试中,程序运行大约需要 5 秒。
如果需要的话,是否可以在程序启动时对文件进行 log4 翻转?
即,如果我们在第 6 分钟记录,然后直到第 50 分钟才再次运行,我们将在开始记录第 50 分钟之前滚动日志文件,而不是仅仅追加到第 6 分钟。
I have an application that only runs when triggered by hardware. An legacy c++ application that we recently added log4cxx too, to generate logs to help debug rare production issues. We of course wanted daily logfiles.
It turns out that we never got rolling files.
To debug the problem we set it roll over on the minute rather than the day. We found that if the program was called within a few seconds from the top of the minute, the file would roll over. If it was called more than 5 seconds after the top of the minute, roll over did not occur.
In testing the program takes roughly 5 seconds to run.
Is there anyway to have log4 rollover the file when the program starts, if needed?
i.e. If we logged at minute 6 and then don't run again until minute 50, we'll roll over the log file before we starting logging for minute 50, rather than just appending to minute 6.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
DailyRollingFileAppender
在我的情况下也不起作用(在 log4cxx 0.10.0),所以我最终使用RollingFileAppender
加上TimeBasedRollingPolicy
:点是 <强>不要指定
,否则它不会滚动(它也无法识别
StaticLogFileName
参数与原始 log4j 中相同)。DailyRollingFileAppender
didn't work in my case too (at log4cxx 0.10.0), so I ended up usingRollingFileAppender
plusTimeBasedRollingPolicy
:Point is not to specify
<param name="file">
or it won't roll over (also it doesn't recognizeStaticLogFileName
param as in the original log4j).尝试 {
}
Try {
}
结果是 log4cxx 实现中的一个错误。 :(
Turns out a bug in the log4cxx implementation. :(