I have a gradle project and the structure looks like this
>
> main (one project)
> shared (another project)
> api
>> shared2 (another project)
main project depends on both shared and shared2 projects. Both shared and shared2 projects have a logback-test.xml in their src/test
/resources folder and the main project has a logback.xml in its src/main
/resources folder.
When I run the main project in eclipse using its main Application class I am expecting that only logback.xml is loaded in classpath. Instead I see warnings that multiple slf4j bindings are found and more importantly the logging settings are being applied from the logback-test.xml instead of logback.xml. Here is the folder structure for further clarification
>
> main
> > src/main/resources
> > > logback.xml
> shared
> > src/test/resources
> > > logback-test.xml
> api/shared2
> > src/test/resources
> > > logback-test.xml
In both logback-test.xml files I have enabled org.springframework debugging at DEBUG level and in logback.xml its set at INFO level. When I start the application I see the spring DEBUG logs.
Here is the sample github project https://github.com/adeelmahmood/logback-test-conf-issue
Following is the order in which logback library looks up for the configuration xml file: (from documentation)
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.
Hence in your case, logback finds logback-test.xml
in the classpath and logs accordingly.
You can specify your own configuration file location by setting the system property named logback.configurationFile
.
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