<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO" monitorInterval="60">
<Properties>
<Property name="logPath">/export/Logs/myapp</Property>
</Properties>
<Appenders>
<Console name="Console">
<PatternLayout pattern="%d [%t] %-5level [%c:%L] %M -【traceId:%X{traceId}】 - %msg%n"/>
</Console>
<!-- FileAll 输出日志有格式 PatternLayout-->
<RollingFile name="FileAll" fileName="${logPath}/oper.log"
filePattern="${logPath}/roll/oper-%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="%d [%t] %-5level [%c:%L] %M -【traceId:%X{traceId}】 - %msg%n"/>
<Policies>
<SizeBasedTriggeringPolicy size="1000MB"/>
</Policies>
<DefaultRolloverStrategy max="20">
<Delete basePath="${logPath}/roll" maxDepth="2">
<IfAny>
<IfAccumulatedFileSize exceeds="10GB" />
<IfAccumulatedFileCount exceeds="20" />
</IfAny>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- SafetyFile 日志无PatternLayout,打印什么就输出什么-->
<RollingFile name="SafetyFile" fileName="${logPath}/safety.log"
filePattern="${logPath}/roll/safety-%d{yyyy-MM-dd}-%i.log">
<Policies>
<SizeBasedTriggeringPolicy size="1000MB"/>
</Policies>
<DefaultRolloverStrategy max="20">
<Delete basePath="${logPath}/roll" maxDepth="2">
<IfAny>
<IfAccumulatedFileSize exceeds="10GB" />
<IfAccumulatedFileCount exceeds="20" />
</IfAny>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
</Appenders>
<Loggers>
<logger name="org.springframework" level="WARN" />
<logger name="org.apache" level="WARN" />
<!-- 指定日志输出路径及过滤级别-->
<logger name="com.xx.controller.XXXController" level="WARN">
<AppenderRef ref="SafetyFile"/>
</logger>
<!-- 定义异步输出-->
<AsyncLogger name="DEFAULT" level="INFO" additivity="false">
<AppenderRef ref="FileAll"/>
<AppenderRef ref="SafetyFile"/>
</AsyncLogger>
<!-- 根,所有的日志都会在这里,可以更改日志级别-->
<Root level="DEBUG">
<AppenderRef ref="Console"/>
<AppenderRef ref="FileAll"/>
</Root>
</Loggers>
</Configuration>
版权声明:本文为CJQ316210原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。