Is Log4J able to fully recover a drive?

We have several java application servers working here with several applications. All of them are registered with Log4J in the same file system that we created only for this reason. From time to time it happens that the file system runs out of space, and the application receives

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

Unfortunately, Log4J is not recovering from this error, so even after freeing up space in the file system from this application, no more logs are written. Are there any programming or tuning options to start Log4J again, besides restarting the application?

+7
java log4j
source share
3 answers

What do you see is an acceptable result? I would consider writing a new Appender that wraps the one that appender gets to disk, and tries to do something sensible when it detects IOExceptions. Perhaps try wrapping the main methods for writing Appenders in a try-catch block and sending you or sysadmin an email.

+1
source share

I have not tested this, but the logback website says:

Graceful recovery from I / O failures

Logback FileAppender and all its subclasses, including RollingFileAppender, can gracefully recover from I / O crashes. Thus, if the file server is temporarily down, you no longer need to restart the application just to resume the log. As soon as the server file is returned, the corresponding log attachment will be transparently and quickly restored from the previous error condition.

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

+3
source share

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

0
source share

All Articles