Details
-
Bug
-
Resolution: Fixed
-
Major
-
1.1.3
-
None
Description
ch.qos.logback.classic.LoggerContext implements ch.qos.logback.core.spi.LifeCycle and as such implements a method public void start(). Is seems to be never called.
To reproduce, a modified first example from the Logback Docs (http://logback.qos.ch/manual/introduction.html):
import ch.qos.logback.classic.LoggerContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class HelloWorld1 { public static void main(String[] args) { Logger logger = LoggerFactory.getLogger("chapters.introduction.HelloWorld1"); logger.debug("Hello world."); LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); boolean started = context.isStarted(); System.out.println("started = " + started); } }
It will print:
12:26:19.528 [main] DEBUG chapters.introduction.HelloWorld1 - Hello world.
started = false
It seems to be a bug and the context should be started at some point.
Of course it might be intended to never start the context. This however would make the interface ch.qos.logback.classic.spi.LoggerContextListener a bit weird, since its LoggerContextListener#onStart is also never called.
I have tried to use the onStart method of a LoggerContextListener to add some packages to the context via LoggerContext#getFrameworkPackages. This doesn't work since onStart is never called. Is there some other way to execute code on application start in Logback?
Attachments
Issue Links
- links to