How does the loading of the logback.xml file work? specifically, when is it loaded?
I see all over the web this explanation:
- Logback tries to find a file called logback.groovy in the classpath.
- If no such file is found, logback tries to find a file called logback-test.xml in the classpath.
- If no such file is found, it checks for the file logback.xml in the classpath..
- If neither file is found, logback configures itself automatically using the BasicConfigurator which will cause logging output to be directed to the console.
But with no mention on when it is loaded. Is it on the first call to a logging statement?
Logback-clasic initiailization occurs on the first call to the
getILoggerFactory()method inorg.slf4j.LoggerFactory. This method is indirectly invoked by theLoggerFactory.getLogger()method. Thus, in practice, logback-clasic initiailization will occur on the first call toLoggerFactory.getLogger().