使用 RollingFileAppender 无限数量的备份文件

发布于 2024-09-11 17:20:26 字数 229 浏览 3 评论 0原文

您是否知道如何使用 RollingFileAppender

当我根本不指定任何 maxBackupIndex 时,我最终只会得到一个备份文件。

Do you know a way to create an infinite number of backup files with the RollingFileAppender?

When I don't specify any maxBackupIndex at all, I end up with only one backup file.

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

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

发布评论

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

评论(3

等数载,海棠开 2024-09-18 17:20:26

这是不可能的。请参阅 Log4J API :

MaxBackupIndex 选项确定在删除最旧的备份文件之前保留多少个备份文件。该选项采用正整数值。如果设置为零,则不会有备份文件,并且日志文件在达到 MaxFileSize 时将被截断。

您能做的最好的事情就是使用非常大的限制(Integer.MAX_VALUE 将是最大值)。

It is not possible. See the Log4J API :

The MaxBackupIndex option determines how many backup files are kept before the oldest is erased. This option takes a positive integer value. If set to zero, then there will be no backup files and the log file will be truncated when it reaches MaxFileSize.

The best you can do is using a very large limit (Integer.MAX_VALUE will be the max).

深海不蓝 2024-09-18 17:20:26

您可以尝试使用 DailyRollingFileAppender。这样你的日志每天只循环一次。

You could try using the DailyRollingFileAppender. That way your log only cycles once a day.

忘年祭陌 2024-09-18 17:20:26

除了无限之外,Integer.MAX_INT 怎么样?

Instead of infinite, how about Integer.MAX_INT?

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