我正在尝试扩展RollingFileAppender,这样即使没有消息进入日志系统,它也会旋转。通常,在消息到达时调用rollOver方法,并执行时间检查以触发旋转。
我的RollingFileAppender版本将每x秒调用一次rollOver,这样即使没有消息到达,我也可以保证轮换。
现在我的问题是RollingFileAppender rollOver有一个没有修饰符的访问级别修饰符。因此,我不能像我希望的那样每隔x秒调用一次。
/**
Rollover the current file to a new file.
*/
void rollOver() throws IOException {现在看一下代码,我不明白为什么它不需要修改,所以我决定把这个类放到我的包中,并调用rollOver。
现在感觉很脏,如果我想调用rollOver,我还有其他选择吗?
发布于 2009-03-26 14:39:49
当然,您也可以使用反射来完成此操作。
从主干或标签1.2.15中提取的源代码:svn at apache
public // synchronization not necessary since doAppend is alreasy synched
void rollOver() {
File target;
...我们谈论的是同一件事吗: log4j-1.2.15?
https://stackoverflow.com/questions/685619
复制相似问题