Logback.xml模板

前端之家收集整理的这篇文章主要介绍了Logback.xml模板前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

   <!-- 时间滚动输出 level为 DEBUG 日志 -->
    <appender name="file-debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>DEBUG</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY </onMismatch>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>/export/data/logs/debug.%d{yyyy-MM-dd}.log</FileNamePattern>
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
 
    <!-- 时间滚动输出 level为 INFO 日志 -->
    <appender name="file-info" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY </onMismatch>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>/export/data/logs/info.%d{yyyy-MM-dd}.log</FileNamePattern>
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
    
    <!-- 时间滚动输出 level为 INFO 日志 -->
    <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>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>/export/data/logs/error.%d{yyyy-MM-dd}.log</FileNamePattern>
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
    
    <!-- 很多人使用Mybatis的时候,控制台不能输出SQL语句,造成调试困难。只需要让DAO层的日志级别调整为DEBUG就可以了 -->
    <logger name="com.example.dao" level="DEBUG" />
<span style="white-space:pre">	</span><!-- 指定项目可输出的最低级别日志 -->
  <!-- 这里最低级别要是DEGUB,不然不会输出debug信息,logback中一共有5种有效级别,
  分别是TRACE、DEBUG、INFO、WARN、ERROR,优先级依次从低到高-->
  <root level="DEGUB">
    <appender-ref ref="console" />
    <appender-ref ref="file-debug" />
    <appender-ref ref="file-info" />
    <appender-ref ref="file-error" />
  </root>
   
</configuration>

猜你在找的XML相关文章