Skip to content

Commit

Permalink
sl4j-logback模块:LevelFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
guolanren committed Jun 18, 2020
1 parent 4716476 commit 911a651
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions slf4j-logback/src/main/resources/logback/spring-logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@

<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<encoder>
<pattern>%d %red(%contextName) %clr(%5level) --- [%magenta(%15thread)] %cyan((%class{40}\)) : %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>

<!--输出到文件-->
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<appender name="file-error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<file>${log.file}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
Expand All @@ -38,7 +43,7 @@

<!-- 级别依次为【从高到低】:FATAL > ERROR > WARN > INFO > DEBUG > TRACE -->
<root level="WARN">
<appender-ref ref="file"/>
<appender-ref ref="file-error"/>
</root>

<root level="INFO">
Expand Down

0 comments on commit 911a651

Please sign in to comment.