抑制Spring logback中的信息状态日志

时间:2016-12-10 18:30:31

标签: xml spring logging logback

正在将状态日志写入FileAppender。 我试过`debug =“false” 我也试过

<statusListener class="ch.qos.logback.core.status.NopStatusListener" />

您知道如何将INFO状态日志抑制为FileAppender吗?

这是我的logback.xml:

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

    

<appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <outputPatternAsHeader>true</outputPatternAsHeader>
        <pattern>[%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
</appender>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>logs/ANALYTICS.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <!-- daily rollover. Make sure the path matches the one in the file element or else
         the rollover logs are placed in the working directory. -->
        <fileNamePattern>logs/ANALYTICS_%d{yyyy-MM-dd}.%i.log</fileNamePattern>

        <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>100MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
        <!-- keep 30 days' worth of history -->
        <maxHistory>30</maxHistory>
    </rollingPolicy>

    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <outputPatternAsHeader>true</outputPatternAsHeader>
        <pattern>[%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>

</appender>

<root level="DEBUG">
    <appender-ref ref="consoleAppender" />
    </root>
<root level="INFO">
    <appender-ref ref="FILE"/>
</root>

0 个答案:

没有答案