1.先说业务日志
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<jmxConfigurator/>
<property name="log.path" value="/home/noahfund/dx/logs" />
<property name="PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %level [kdsale,%X{traceId},%X{spanId},true] [%thread] [%c.%M:%L] - %message%n" />
<!-- 控制台输出 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<encoder>
<pattern>${PATTERN}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!--错误日志-->
<appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</FileNamePattern>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${PATTERN}</pattern>
<charset>UTF-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!--输入输出报文-->
<appender name="FILE_BUSINESS" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 按天滚动文件,如果一天内达到256M也会滚动文件, 滚动文件将会压缩成zip格式 -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/business.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>300MB</maxFileSize>
<maxHistory>999</maxHistory>
<totalSizeCap>50GB</totalSizeCap>
</rollingPolicy>
<!-- 独立的pattern -->
<encoder>
<pattern>${PATTERN}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<logger name="org.springframework" level="INFO" additivity="false">
<appender-ref ref="FILE_BUSINESS" />
</logger>
<logger name="com.szkingdom.jros.core.web.controller" level="INFO" additivity="false">
<appender-ref ref="FILE_BUSINESS" />
</logger>
<!--系统框架 -->
<logger name="com.szkingdom.jros" level="INFO" additivity="false">
<appender-ref ref="FILE_BUSINESS" />
</logger>
<logger name="com.szkingdom.jros.core.engine.unmarshaller" level="WARN" additivity="false">
<appender-ref ref="FILE_BUSINESS" />
</logger>
<logger name="com.szkingdom" level="INFO" additivity="false">
<appender-ref ref="FILE_BUSINESS" />
</logger>
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE_ERROR" />
<appender-ref ref="FILE_BUSINESS" />
</root>
</configuration>
2.如果是tomcat的日志需要安装插件cronolog或者利用系统本身的定时任务做切割。