关闭

logback实用配置示例

616人阅读 评论(0) 收藏 举报
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">   
<property name="pattern" value="%d{HH:mm:ss.SSS} %-5level [%X{traceNo}] %logger{10}%line %msg%n" />

<property name="baseDir" value="/datum/data/logs/stulog" />
<property name="level" value="info" />
<property name="charset" value="UTF-8" />
<property name="immediateFlush" value="true"/>


<!-- 控制台输出 -->
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>${charset}</charset>
<pattern>${pattern}</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>D:/logs/INFO.%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder>
<charset>${charset}</charset>
<pattern>${pattern}</pattern>
</encoder>
</appender>


<!-- 时间滚动输出 level为 ERROR 日志 -->
<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>D:/logs/error.%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder>
<charset>${charset}</charset>
<pattern>${pattern}</pattern>
</encoder>
</appender>




<logger name="org.springframework" level="error" >
</logger>
<logger name="org.springframework.core.env.StandardEnvironment" level="error">
</logger>

<logger name="java.sql.Connection">
<level value="error" />
</logger>
<logger name="java.sql.Statement">
<level value="error" />
</logger>
<logger name="com.ibatis">
<level value="error" />
</logger>


<root level="INFO">
<appender-ref ref="stdout" />
<appender-ref ref="file—INFO" />
<appender-ref ref="file—error" />
<appender-ref ref="file-str" />
<appender-ref ref="db" />
</root>


</configuration> 
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:45372次
    • 积分:892
    • 等级:
    • 排名:千里之外
    • 原创:14篇
    • 转载:44篇
    • 译文:0篇
    • 评论:0条
    文章分类