Log4J able to recover from disk full?

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?


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.


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.


限制日志的大小,并尝试使用自定义appender将日志归档到具有大量磁盘空间的备份计算机。

链接地址: http://www.djcxy.com/p/43120.html

上一篇: Web服务获取GPS坐标

下一篇: Log4J能够从磁盘恢复完整?