Authored by liangyi.chen@yoho.cn

日志优化

package com.yoho.datasync.producer.starter;
public class HealthModify {
}
... ... @@ -12,5 +12,4 @@ public class YohoDatasyncProducerApplication {
SpringApplication.run(YohoDatasyncProducerApplication.class, args);
}
}
... ...
... ... @@ -30,15 +30,36 @@
</encoder>
</appender>
<!-- DEBUG、INFO、WARN、ERROR级别日志 appender -->
<appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/Data/logs/yoho-datasync-producer/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>/Data/logs/yoho-datasync-producer/archived/debug.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${maxFileSize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days' worth of history -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
<encoder>
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
<!-- 设置字符集 -->
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- INFO级别日志 appender -->
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/Data/logs/yoho-datasync-producer/info.log</file>
<!-- 过滤器,过滤掉 TRACE 和 DEBUG 级别的日志 -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>/Data/logs/yoho-datasync-producer/%d{yyyy-MM-dd}/info-log.log</fileNamePattern>
<fileNamePattern>/Data/logs/yoho-datasync-producer/archived/info.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- 日志最大的保存天数 -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
... ... @@ -54,13 +75,14 @@
<!-- WARN级别日志 appender -->
<appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/Data/logs/yoho-datasync-producer/warn.log</file>
<!-- 过滤器,过滤掉 TRACE 和 DEBUG 和 INFO 级别的日志 -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>/Data/logs/yoho-datasync-producer/%d{yyyy-MM-dd}/warn-log.log</fileNamePattern>
<fileNamePattern>/Data/logs/yoho-datasync-producer/archived/warn.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- 日志最大的保存天数 -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
... ... @@ -79,7 +101,7 @@
<!-- 控制台输出 -->
<appender-ref ref="STDOUT" />
<!-- 文件输出 -->
<appender-ref ref="INFO" />
<appender-ref ref="DEBUG" />
<appender-ref ref="WARN" />
</root>
... ...