Typo in include resource path of logback configuration file for Setting the Log Level in Spring Boot When Testing
mejo1024 opened this issue · comments
Dear Baeldung
I have tried to configure logback as described in Setting the Log Level in Spring Boot When Testing - 4. Configuring Logback
Referring to files
- https://github.com/eugenp/tutorials/blob/b069824c41e565485e89a8daed1a4e0970f2f510/spring-boot-modules/spring-boot-testing-2/src/test/resources/logback-test.xml#L2C24-L2C25
- https://github.com/eugenp/tutorials/blob/b069824c41e565485e89a8daed1a4e0970f2f510/spring-boot-modules/spring-boot-testing-2/src/test/resources/logback-multiprofile.xml#L2C24-L2C25
Wenn I use the logback-test.xml file without the appender and root configuration, like this:
<configuration>
<include resource="/org/springframework/boot/logging/logback/base.xml"/>
<logger name="com.baeldung.testloglevel" level="debug"/>
</configuration>
Then I find the warning: WARN in ch.qos.logback.core.joran.action.IncludeAction - Could not find resource corresponding to [/org/springframework/boot/logging/logback/base.xml]
And the logging configuration does not work, because it does not include the resource file from spring-boot-project and because removal the appender and root configuration is missing.
I tested this with logback-classic version 1.4.14 on windows.
For me it worked to remove the trailing / of the resource path:
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="com.baeldung.testloglevel" level="debug"/>
</configuration>
With this I can change the log level for the package com.baeldung.testloglevel and have the appender and root configuration defaults imported from spring boot.
I would suggest to fix the include resource path or remove it.
Anyway thanks for your article, it helped me to have debug messages for unit test, without needing the @SpringBootTest annotation or an application properties file.