Log4J 能够从磁盘满恢复吗?
我们这里运行着几个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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我没有对此进行测试,但 logback 的网站指出:
我认为上述情况也是如此。
I didn't test this, but the website of logback states:
I assume the same would be true for the above situation.
您认为什么是可接受的结果?我会考虑编写一个新的 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.
限制日志的大小并尝试使用自定义附加程序将日志存档到具有大量磁盘空间的备份计算机。
limit the size of your logs and try using a custom appender to archive logs to a backup machine with lots of disk space.