<?xml version="1.0" encoding="UTF-8" ?>java
- <configuration>spring
- <!--sql
日誌配置
-->apache
<property name="PROJECT_NAME" value="work_manager_server" />mybatis
<property name="LOG_BASE" value="/home/product/logs" />app
<property name="LOG_BACK_DIR" value="${LOG_BASE}/${PROJECT_NAME}_logs" />ui
- <!--debug
logback 工程的日誌配置
-->日誌
- <appender name="INFO_ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">code
<file>${LOG_BACK_DIR}/info.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!--
rollover daily
-->
<fileNamePattern>${LOG_BACK_DIR}/info_%d{yyyyMMddHH}.%i.log</fileNamePattern>
- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
- <!--
or whenever the file size reaches 100MB
-->
<maxFileSize>256MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>168</maxHistory>
- <!--
保存最大文件數 7天的日誌
-->
</rollingPolicy>
- <encoder>
<charset>UTF-8</charset>
</encoder>
- <layout class="com.fenqile.work.common.layout.SensitiveLayout">
<param name="Pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS}|%X{threadId}|%X{traceId}-%X{rpcId}|%level|%C|%M|%L|uid=%X{uid},requestId=%X{requestId},clientIp=%X{clientIp}|%msg|%X{callChain}%n" />
</layout>
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <!--
只打印錯誤日誌
-->
<level>INFO</level>
</filter>
</appender>
- <appender name="ERROR_ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_BACK_DIR}/error.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!--
rollover daily
-->
<fileNamePattern>${LOG_BACK_DIR}/error_%d{yyyyMMdd}.%i.log</fileNamePattern>
- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
- <!--
or whenever the file size reaches 100MB
-->
<maxFileSize>256MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>168</maxHistory>
- <!--
保存最大文件數
-->
</rollingPolicy>
- <encoder>
<charset>UTF-8</charset>
</encoder>
- <layout class="com.fenqile.work.common.layout.SensitiveLayout">
<param name="Pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS}|%X{threadId}|%X{traceId}-%X{rpcId}|%level|%C|%M|%L|uid=%X{uid},requestId=%X{requestId},clientIp=%X{clientIp}|%.-512msg|%X{callChain}%n" />
</layout>
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <!--
只打印錯誤日誌
-->
<level>WARN</level>
</filter>
</appender>
- <appender name="DEBUG_ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_BACK_DIR}/debug.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!--
rollover daily
-->
<fileNamePattern>${LOG_BACK_DIR}/debug_%d{yyyyMMddHH}.%i.log</fileNamePattern>
- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
- <!--
or whenever the file size reaches 100MB
-->
<maxFileSize>256MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>7</maxHistory>
- <!--
保存最大文件數
-->
</rollingPolicy>
- <encoder>
<charset>UTF-8</charset>
</encoder>
- <layout class="com.fenqile.work.common.layout.SensitiveLayout">
<param name="Pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS}|%X{threadId}|%X{traceId}-%X{rpcId}|%level|%C|%M|%L|uid=%X{uid},requestId=%X{requestId},clientIp=%X{clientIp}|%.-512msg|%X{callChain}%n" />
</layout>
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <!--
只打印錯誤日誌
-->
<level>TRACE</level>
</filter>
</appender>
- <!--
logback 工程的日誌配置 END
-->- <!--
開發環境使用 打印在控制檯
-->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <layout class="ch.qos.logback.classic.PatternLayout">
<param name="Pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS}|%X{threadId}|%X{traceId}-%X{rpcId}|%level|%C|%M|%L|uid=%X{uid},requestId=%X{requestId},clientIp=%X{clientIp}|%.-512msg|%X{callChain}%n" />
</layout>
</appender>
<logger name="org.springframework" level="WARN" />
<logger name="java.sql.Connection" level="INFO" />
<logger name="java.sql.ResultSet" level="INFO" />
<logger name="org.apache.zookeeper.ClientCnxn" level="WARN" />
<logger name="org.mybatis.spring.SqlSessionUtils" level="WARN" />
- <logger name="com.alibaba.dubbo.common.logger.LoggerFactory" level="WARN">
<appender-ref ref="ERROR_ROLLING" />
</logger>
- <!--
開發環境爲DEBUG等級
-->
- <root level="INFO">
<appender-ref ref="INFO_ROLLING" />
<appender-ref ref="DEBUG_ROLLING" />
<appender-ref ref="ERROR_ROLLING" />
<appender-ref ref="STDOUT" />
</root>
</configuration>