Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
1.0.13
-
None
Description
If an appender like
public class FooAppender extends AppenderBase<ILoggingEvent> { protected void append(ILoggingEvent eventObject) { } public void start() { super.start(); System.out.println("############################################################"); System.out.println("############################################################"); System.out.println(""+getName()+" started!"); System.out.println("############################################################"); System.out.println("############################################################"); } public void stop() { super.stop(); System.out.println("############################################################"); System.out.println("############################################################"); System.out.println(""+getName()+" stopped!"); System.out.println("############################################################"); System.out.println("############################################################"); } }
is defined in a logback.xml but never attached to any logger then
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); loggerContext.reset();
will not execute the stop() call. start(), on the other hand, is executed during configuration.
There are two possible solutions to this problem: either Logback should detect that the appender is unused and never call start() (I guess this would make the most sense) or reset should also call stop() on unattached appenders.
While an unattached appender seems like a misconfiguration there are situations where an appender-ref is temporarily removed without even noticing that it was the last use of the appender. An unattached appender should therefore cause a warning but start()/stop() behavior should be consistent even in that case.