<?xml version="1.0" encoding="UTF-8" ?>
<configuration status="WARN">
<!--全局参数-->
<Properties>
<Property name="pattern">%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n</Property>
<Property name="filePath">BhisLog</Property>
</Properties>
<Loggers>
<Root level="INFO">
<AppenderRef ref="CONSOLE"></AppenderRef>
<AppenderRef ref="AsyncLog"></AppenderRef>
<AppenderRef ref="ERROR_ROLLING_FILE"></AppenderRef>
</Root>
</Loggers>
<Appenders>
<!-- 控制台 -->
<Console name="CONSOLE" target="SYSTEM_OUT" follow="true">
<ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout>
<Pattern>${pattern}</Pattern>
</PatternLayout>
</Console>
<!-- 业务日志 -->
<RollingRandomAccessFile name="BUSSINESS_ROLLING_FILE"
fileName="${filePath}/bussiness/bussiness.log"
filePattern="${filePath}/bussiness/$${date:yyyy-MM}/bussiness-%d{yyyy-MM-dd}-%i.log.gz"
immediateFlush="false">
<!-- 过滤 业务日志只记录info级别的 error级别的记录到error日志里面 -->
<ThresholdFilter level="WARN"
onMatch="DENY"
onMismatch="NEUTRAL"/><!-- 此处要设置中立,否则下面的 ThresholdFilter将接收不到日志-->
<ThresholdFilter level="INFO"
onMatch="ACCEPT"
onMismatch="DENY"/>
<PatternLayout>
<Pattern>${pattern}</Pattern>
</PatternLayout>
<Policies>
<!-- 按天分类 -->
<TimeBasedTriggeringPolicy />
<!-- 每个文件的大小 -->
<SizeBasedTriggeringPolicy size="100M"/>
</Policies>
<!-- 最多多少个文件 -->
<DefaultRolloverStrategy max="30"/>
</RollingRandomAccessFile>
<!-- 错误日志 -->
<RollingRandomAccessFile name="ERROR_ROLLING_FILE"
fileName="${filePath}/error/error.log"
filePattern="${filePath}/error/$${date:yyyy-MM}/error-%d{yyyy-MM-dd}-%i.log.gz">
<ThresholdFilter level="WARN"
onMatch="ACCEPT"
onMismatch="DENY"/>
<PatternLayout>
<Pattern>${pattern}</Pattern>
</PatternLayout>
<Policies>
<!-- 按天分类 -->
<TimeBasedTriggeringPolicy />
<!-- 每个文件的大小 -->
<SizeBasedTriggeringPolicy size="50M"/>
</Policies>
<!-- 最多多少个文件 -->
<DefaultRolloverStrategy max="30"/>
</RollingRandomAccessFile>
<!-- 异步 -->
<Async name="AsyncLog">
<AppenderRef ref="BUSSINESS_ROLLING_FILE"/>
</Async>
</Appenders>
</configuration>
来源:oschina
链接:https://my.oschina.net/u/2708082/blog/3025475