logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Pimlott <and...@pimlott.net>
Subject log4j doesn't trap appender exceptions
Date Fri, 29 Jul 2011 02:18:19 GMT
The FAQ says,

    If for any reason, log4j throws an uncaught exception, please send
    an email to the log4j-user@logging.apache.org mailing list.

Ok.  log4j does not trap exceptions thrown by appenders.  You can
reproduce under apache-log4j-1.2.16 with this simple appender:

    import org.apache.log4j.*;
    import org.apache.log4j.spi.*;

    public static class MyAppender extends AppenderSkeleton {
        public void append(LoggingEvent e) {
            throw new RuntimeException("catch me!");
        }
        public boolean requiresLayout() { return true; }
        public void close() { }
    }

The exception:

    Exception in thread "main" java.lang.RuntimeException: catch me!
            at MyAppender.append(MyAppender.java:6)
            at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
            at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
            at org.apache.log4j.Category.callAppenders(Category.java:206)
            at org.apache.log4j.Category.forcedLog(Category.java:391)
            at org.apache.log4j.Category.warn(Category.java:1043)
            at Log4jTry.main(Log4jTry.java:20)

log4j should catch errors from appenders.  (Or, it should not call
itself fail-stop.  Or, it should not call itself extensible.)

Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message