Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 476
Noremac Avatar asked Jul 10 '12 19:07

Noremac


People also ask

How does spring boot Logback work?

Spring Boot has a LoggingSystem abstraction that attempts to configure logging based on the content of the classpath. If Logback is available, it is the first choice. You can also set the location of a file to which to write the log (in addition to the console) by using "logging.

Where do I put the Logback file?

In a Spring Boot application, you can put the Logback. xml file in the resources folder. If your Logback. xml file is outside the classpath, you need to point to its location using the Logback.

Which of the following is the configuration file for Logback?

As mentioned earlier, logback will try to configure itself using the files logback-test. xml or logback. xml if found on the class path.


1 Answers

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().

like image 125
Ceki Avatar answered Sep 22 '22 02:09

Ceki