使用log4j2列印日誌
阿新 • • 發佈:2019-01-27
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="60">
<Appenders>
<File name="log" fileName="log/test.log" append="false">
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
</File>
<RollingFile name="RollingFile" fileName="logs/app.log" append="false"
filePattern="log/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout pattern="%d{yyyy-MM-dd 'at' HH:mm:ss z} %-5level %class{36} %L %M - %msg%xEx%n"/>
<SizeBasedTriggeringPolicy size="50MB"/>
</RollingFile>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%X{UUID} %d{yyyy-MM-dd HH:mm:ss} %-5p %c:%L - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="com.lj.test2" level="trace" additivity="false">
<AppenderRef ref="Console"/>
<AppenderRef ref="RollingFile"/>
</Logger>
<Root level="trace">
<AppenderRef ref="Console"/>
<AppenderRef ref="log"/>
<AppenderRef ref="RollingFile"/>
</Root>
</Loggers>
</Configuration>