Log4J 能够从磁盘满恢复吗?

发布于 2024-08-02 14:06:54 字数 328 浏览 1 评论 0原文

我们这里运行着几个java应用程序服务器,其中有几个应用程序。它们都使用 Log4J 记录到同一个文件系统中,我们只是为此原因创建了该文件系统。 有时,文件系统会耗尽空间,并且应用程序会

log4j:ERROR Failed to flush writer,                                             
java.io.IOException

不幸地 Log4J 无法从此错误中恢复,因此即使在文件系统中释放空间后,也不会从该应用程序写入更多日志。除了重新启动应用程序之外,是否有任何编程或设置选项可以让 Log4J 再次运行?

We have several java application server running here, with several apps. They all log with Log4J into the same file system, which we created only for that reason.
From time to time it happens that the file system runs out of space and the app gets

log4j:ERROR Failed to flush writer,                                             
java.io.IOException

Unfortunately Log4J does not recover from this error, so that even after space is freed in the file system, no more logs are written from that app. Are there any options, programming-wise or setting-wise, to get Log4J going again, besides restarting the app?

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

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

发布评论

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

评论(3

葬花如无物 2024-08-09 14:06:54

我没有对此进行测试,但 logback 的网站指出:

从 I/O 故障中正常恢复

Logback 的 FileAppender 及其所有子类,包括
RollingFileAppender,可以从 I/O 故障中优雅地恢复。因此,
如果文件服务器暂时出现故障,您不再需要重新启动您的文件服务器
应用程序只是为了让日志记录再次工作。一旦文件
服务器恢复,相关的 logback 附加程序将透明地
并快速从之前的错误状态中恢复。

我认为上述情况也是如此。

I didn't test this, but the website of logback states:

Graceful recovery from I/O failures

Logback's FileAppender and all its sub-classes, including
RollingFileAppender, can gracefully recover from I/O failures. Thus,
if a file server fails temporarily, you no longer need to restart your
application just to get logging working again. As soon as the file
server comes back up, the relevant logback appender will transparently
and quickly recover from the previous error condition.

I assume the same would be true for the above situation.

你爱我像她 2024-08-09 14:06:54

您认为什么是可接受的结果?我会考虑编写一个新的 Appender 来包装正在访问磁盘的任何 Appender,并在检测到 IOException 时尝试执行一些明智的操作。也许让它将底层 Appender 写入方法包装在 try-catch 块中,并向您或系统管理员发送一封电子邮件。

What do you see is an acceptable outcome here? I'd consider writing a new Appender that wraps whichever appender is accessing the disk, and tries to do something sensible when it detects IOExceptions. Maybe get it to wrap the underlying Appenders write methods in a try-catch block, and send you or a sysadmin an email.

狠疯拽 2024-08-09 14:06:54

限制日志的大小并尝试使用自定义附加程序将日志存档到具有大量磁盘空间的备份计算机。

limit the size of your logs and try using a custom appender to archive logs to a backup machine with lots of disk space.

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