0

如何抑制 Logback 的所有初始输出?这个问题之前已经问过两次 了,但我的情况有点不同;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,如果有人想看,我会发布。

4

1 回答 1

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。

于 2012-06-14T08:46:33.470 回答