再次抑制Logback输出

时间:2012-06-13 22:33:03

标签: logback

如何抑制所有Logback的初始输出?这个问题已经被问到twice before,但我的情况有点不同; Logback不会抛出任何警告或错误。

这是整个日志:

17:29:32,471 |-INFO in ch.qos.logback.access.joran.action.ConfigurationAction - Ignoring debug attribute.
17:29:32,472 |-INFO in ch.qos.logback.core.joran.action.StatusListenerAction - Adding status listener of type [ch.qos.logback.core.status.OnConsoleStatusListener]
17:29:32,473 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
17:29:32,473 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
17:29:32,474 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - No compression will be used
17:29:32,474 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use the pattern C:/dev/diesel/trunk/diesel-test//logs/request/request-%d{yyyy-MM-dd}.log for the active file
17:29:32,475 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern 'C:/dev/diesel/trunk/diesel-test//logs/request/request-%d{yyyy-MM-dd}.log'.
17:29:32,475 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
17:29:32,475 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Wed Jun 13 17:29:32 CDT 2012
17:29:32,475 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.access.PatternLayoutEncoder] for [encoder] property
17:29:32,497 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Active log file name: C:/dev/diesel/trunk/diesel-test//logs/request/request-2012-06-13.log
17:29:32,497 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - File property is set to [null]
17:29:32,498 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to ch.qos.logback.access.jetty.v7.RequestLogImpl@3caa4b
17:29:32,498 |-INFO in ch.qos.logback.access.joran.action.ConfigurationAction - End of configuration.
17:29:32,499 |-INFO in ch.qos.logback.access.jetty.v7.RequestLogImpl@3caa4b - RequestLog added to RequestLogRegistry with name: LogbackRequestLog

这是logback.xml。请注意,我将root level = OFF设置为测试。

<configuration>

    <property name="MAIN_LOG_DIR" value="${app.home}/logs"/>
    <property name="DEFAULT_ENCODER_PATTERN" value="%date{yyyy-MM-dd HH:mm:ss} %logger %-4relative %-5level %msg%n" />
    <property name="DEFAULT_FILENAME_PATTERN" value="-%d{yyyy-MM-dd}.log" />

    <logger name="org.quartz" additivity="false">
        <appender class="ch.qos.logback.core.helpers.NOPAppender"></appender>   
    </logger>

    <root level="OFF">
        <appender class="ch.qos.logback.core.rolling.RollingFileAppender">
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <fileNamePattern>${MAIN_LOG_DIR}/root/root${DEFAULT_FILENAME_PATTERN}</fileNamePattern>
            </rollingPolicy>
            <encoder><pattern>${DEFAULT_ENCODER_PATTERN}</pattern></encoder>
        </appender> 
    </root>

</configuration>

我还有一个单独的logback-access.xml,如果有人想看,我会发布。

1 个答案:

答案 0 :(得分:1)

您看到的状态消息由logback-access而非logback-classic输出。

第一行是赠品(还有其他迹象)

|-INFO in ch.qos.logback.**access**.joran.action.ConfigurationAction - Ignoring debug attribute.

Logback-access在控制台上输出其内部状态,因为显然已经要求它这样做:

|-INFO in ch.qos.logback.core.joran.action.StatusListenerAction - Adding status listener of type [ch.qos.logback.core.status.OnConsoleStatusListener]

对于logback-access,配置文件名为logback-access.xml。您应该发布该文件的内容,而不是logback.xml。