How does the loading of the logback.xml file work? specifically, when is it loaded?
I see all over the web this explanation:
But with no mention on when it is loaded. Is it on the first call to a logging statement?
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.
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.
As mentioned earlier, logback will try to configure itself using the files logback-test. xml or logback. xml if found on the class path.
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()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With