Noremac
Noremac

Reputation: 3547

When is the logback config file loaded?

How does the loading of the logback.xml file work? specifically, when is it loaded?

I see all over the web this explanation:

  1. Logback tries to find a file called logback.groovy in the classpath.
  2. If no such file is found, logback tries to find a file called logback-test.xml in the classpath.
  3. If no such file is found, it checks for the file logback.xml in the classpath..
  4. 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?

Upvotes: 7

Views: 1625

Answers (1)

Ceki
Ceki

Reputation: 27490

Logback-clasic initiailization occurs on the first call to the getILoggerFactory() method in org.slf4j.LoggerFactory. This method is indirectly invoked by the LoggerFactory.getLogger() method. Thus, in practice, logback-clasic initiailization will occur on the first call to LoggerFactory.getLogger().

Upvotes: 5

Related Questions