Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log4J able to recover from disk full?

Tags:

java

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?

like image 697
dertoni Avatar asked Aug 27 '09 05:08

dertoni


People also ask

Can log4j be disabled?

By default, log4j logging is used for all components for which logging information is generated. To disable log4j logging, set the logging level for the component to OFF in both log4j. conf and log4j.

How does log4j work?

Log4j allows logged messages to contain format strings that reference external information through the Java Naming and Directory Interface (JNDI). This allows information to be remotely retrieved across a variety of protocols, including the Lightweight Directory Access Protocol (LDAP).

What are the three most important components of log4j?

log4j has three main components: loggers: Responsible for capturing logging information. appenders: Responsible for publishing logging information to various preferred destinations. layouts: Responsible for formatting logging information in different styles.

What is log level in log4j?

Logging levels are used to categorize the entries in your log file. But they categorize in a very specific way, i.e., by urgency. The level allows you to separate the following kinds of information: You can filter your log files during the search.


2 Answers

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.

like image 103
dertoni Avatar answered Sep 28 '22 07:09

dertoni


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.

like image 44
GaryF Avatar answered Sep 28 '22 07:09

GaryF