码迷,mamicode.com
首页 > 编程语言 > 详细

Spring boot:logback文件配置

时间:2018-08-26 11:58:36      阅读:274      评论:0      收藏:0      [点我收藏+]

标签:config   文件   res   pre   OLE   log   blank   tar   elf   

resources文件夹下:新建logback-spring.xml文件。

文件内容like:

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

<appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} : %msg%n
</pattern>
</layout>

</appender>

<appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>DENY</onMatch>
<onMismatch>ACCEPT</onMismatch>
</filter>
<encoder>
<pattern>
${FILE_LOG_PATTERN:-%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } -- %-40.40logger{39} : %m%n}}
</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>D:/log/info.%d.log</fileNamePattern>
</rollingPolicy>
</appender>

<appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<encoder>
<pattern>
%msg%n
</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>D:/log/error.%d.log</fileNamePattern>
</rollingPolicy>
</appender>

<root level="info">
<appender-ref ref="consoleLog"/>
<appender-ref ref="fileInfoLog"/>
<appender-ref ref="fileErrorLog"/>
</root>

</configuration>

详情文档参考:https://wenku.baidu.com/view/71a056eb0975f46527d3e138.html



Spring boot:logback文件配置

标签:config   文件   res   pre   OLE   log   blank   tar   elf   

原文地址:https://www.cnblogs.com/fqfanqi/p/9536534.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!