logback - 调试级别不起作用

时间:2017-12-13 10:34:28

标签: java logging logback

我有一个使用logback的JAVA EE应用程序(用作流行的log4j项目的后续版本)

此处为logback.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <!-- trace, debug, info, warn, error, fatal -->
    <timestamp key="myTimestamp" datePattern="yyyy-MM-dd'_'HH-mm-ss.SSS"/>  


    <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
        <resetJUL>true</resetJUL>
    </contextListener>

    <!-- To enable JMX Management -->
    <jmxConfigurator/>

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{"yyyy-MM-dd HH:mm"}  [%thread] %-5level %logger{35} - %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>telefonica.log</file> 

        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>telefonica.%i.log.zip</fileNamePattern>             
            <minIndex>1</minIndex>
            <maxIndex>3</maxIndex>
        </rollingPolicy>

        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>5MB</maxFileSize>
        </triggeringPolicy>
        <encoder>
            <pattern>%d{"yyyy-MM-dd HH:mm"} [%thread] %-5level %logger{35} - %msg%n</pattern>
        </encoder>
    </appender>



    <logger name="com.telefonica”                      level="debug" />
    <logger name="org.springframework"             level="debug" />
    <logger name="org.springframework.web"         level="debug" />
    <logger name="org.springframework.security"    level="debug" />

    <root level="debug">
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="FILE" />
    </root>
</configuration>

在包com.telefonica内的一个类中,我有这个代码

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public static final Logger log = LoggerFactory.getLogger(TS.class);

log.debug ("logging to WS " + WS_VERSION);

我在控制台中没有看到任何内容,但是当我放置log.info ("logging to WS " + WS_VERSION);

时我就看到了

2 个答案:

答案 0 :(得分:0)

将记录器级别从ORA-00907

更改为level="DEBUG"
INFO

答案 1 :(得分:0)

尝试在您的记录器中添加appender,如下所示

<logger name="org.springframework" additivity="false">
<level value="DEBUG" />
<appender-ref ref="STDOUT" />
</logger>

请参阅此问题和解决方案

Spring : Logging not working with log4j or logback