扩展 jog4j RollingFileAppender rollOver() 访问级别时出现问题

发布于 2024-07-15 18:18:41 字数 490 浏览 4 评论 0原文

我正在尝试扩展 RollingFileAppender,以便即使没有消息进入日志系统,它也会轮换。 通常,当消息到达并且完成时间检查以触发轮换时,会调用 rollOver 方法。

我的 RollingFileAppender 版本将每 x 秒调用 rollOver 一次,这样即使没有消息到达,我也能保证轮换。

现在我的问题是 RollingFileAppender rollOver 的访问级别修饰符为 no 修饰符。 因此我不能像我希望的那样每隔 x 秒调用它一次。

  /**
     Rollover the current file to a new file.
  */
  void rollOver() throws IOException {

现在查看代码,我不明白为什么它不需要修饰符,我决定将该类放入我的包中并调用 rollOver。

现在这感觉很脏,如果我想调用 rollOver,我还有其他选择吗?

I am trying to extend RollingFileAppender so that it will rotate even when no messages are coming into the logging system. Normally the rollOver method is called when a message arrives and a time check is done to trigger the rotate.

My Version of RollingFileAppender will call rollOver every x seconds so that I am guaranteed a rotate even when no messages arrive.

Now my problem is that RollingFileAppender rollOver has an Access level modifier of no modifier. Thus I can't call it every x seconds like I wish to.

  /**
     Rollover the current file to a new file.
  */
  void rollOver() throws IOException {

Now looking at the code I can't figure out why it requires no modifer and I have decided to bring the class into my packages and call rollOver.

Now this feels dirty do I have any other alternatives if I want to call rollOver?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆那么伤 2024-07-22 18:18:41

您当然可以使用反射来做到这一点。

从主干或标签 1.2.15 提取的源代码: svn at apache

public // synchronization not necessary since doAppend is alreasy synched
void rollOver() {
  File target;
  ...

我们谈论同一件事吗:log4j-1.2.15?

You can of course do it using reflection.

Source code extracted from the trunk or from tag 1.2.15 : svn at apache

public // synchronization not necessary since doAppend is alreasy synched
void rollOver() {
  File target;
  ...

Do we speak about the same thing : log4j-1.2.15 ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文