Log config doesn't work for spring

I have logback.xml file

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
    </encoder>
</appender>

<logger name="my.package">
    <level value="TRACE"/>
</logger>

<logger name="org.springframework.web">
    <level value="DEBUG"/>
</logger>

<root>
    <priority value="debug"/>
    <appender-ref ref="STDOUT"/>
</root>

      

When I run the application, I see messages in the console that were being called like this:

LOGGER.error("error ");

      

from classes inside my.package


I can't see messages from spring.

How am I wrong?

+3


source to share


2 answers


By default, Spring writes to the Apache log. To switch it to log, exclude writing to Commons

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.1.3.RELEASE</version>
        <exclusions>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

      



and add the bridge to the log

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>1.7.12</version>
    </dependency>

      

+3


source


Spring is using commons-logging

so you need to use bridge jcl-over-slf4j

for spring to think about it with jcl.

You need to exclude commons-logging

from spring dependencies in your folder and include jcl-over-slf4j

.



More information: Overcoming deprecated APIs

+1


source