<?xml version="1.0" encoding="utf-8"?> <configuration> <properties> <!-- 文件输出格式 --> <property name="PATTERN">%d{yyyy-MM-dd HH:mm:ss.SSS} |-%-5level [%thread][%X{PFTID}] - [%X{requestId}] %c [%L] -| %msg%n</property> <!-- 日志根目录 --> <property name="BASEDIR">/export/Logs</property> <Property name="rollingLogSize">1000 MB</Property> <Property name="rollingLogMaxNum">10</Property> </properties> <appenders> <Console name="CONSOLE" target="system_out"> <PatternLayout pattern="${PATTERN}" /> </Console> <!-- 所有日志 --> <RollingRandomAccessFile fileName="${BASEDIR}/all.log" filePattern="${BASEDIR}/%d{yyyyMMdd}/all.%d{yyyyMMdd}-%i.log" immediateFlush="true" name="ALL_FILE"> <PatternLayout pattern="${PATTERN}"/> <Policies> <TimeBasedTriggeringPolicy interval="1" modulate="true"/> <SizeBasedTriggeringPolicy size="${rollingLogSize}"/> </Policies> <DefaultRolloverStrategy max="${rollingLogMaxNum}"> <Delete basePath="${BASEDIR}" maxDepth="2"> <IfFileName glob="all.*.log"/> <IfLastModified age="5D"/> </Delete> </DefaultRolloverStrategy> </RollingRandomAccessFile> <!-- ERROR级别日志 --> <RollingRandomAccessFile fileName="${BASEDIR}/error.log" filePattern="${BASEDIR}/%d{yyyyMMdd}/error.%d{yyyyMMdd}-%i.log" immediateFlush="true" name="ERROR_FILE"> <Filters> <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/> </Filters> <PatternLayout pattern="${PATTERN}"/> <Policies> <TimeBasedTriggeringPolicy interval="1" modulate="true"/> <SizeBasedTriggeringPolicy size="${rollingLogSize}"/> </Policies> <DefaultRolloverStrategy max="${rollingLogMaxNum}"> <Delete basePath="${BASEDIR}" maxDepth="2"> <IfFileName glob="error.*.log"/> <IfLastModified age="5D"/> </Delete> </DefaultRolloverStrategy> </RollingRandomAccessFile> </appenders> <loggers> <logger name="org.springframework" level="WARN" /> <logger name="org.apache" level="WARN" /> <logger name="io.netty" level="WARN" /> <root level="DEBUG"> <!-- 若不注释该打印,将可能会出现两次打印的情况,调试时使用 --> <!--<appenderref ref="CONSOLE" /> --> <appenderref ref="ALL_FILE" /> <appender-ref ref="ERROR_FILE"/> </root> </loggers> </configuration>
标签:xml,PFTID,5level,-%-,ss,log4j2 From: https://www.cnblogs.com/niun/p/17043583.html