log4j2.xml 文件配置
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<properties>
<property name="LOG_HOME">./logs/@artifactId@/</property>
<property name="FILE_NAME">@artifactId@</property>
</properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p - %m %l%n"/>
</Console>
<RollingRandomAccessFile name="sysFile" fileName="{FILE_NAME}-system.log"
filePattern="{FILE_NAME}-system-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p - %m %l%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="20MB"/>
<DefaultRolloverStrategy max="20"/>
</Policies>
</RollingRandomAccessFile>
<RollingRandomAccessFile name="controllerLogFile" fileName="{FILE_NAME}-controller.log"
filePattern="{FILE_NAME}-controller-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p - %m %l%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="20MB"/>
<DefaultRolloverStrategy max="20"/>
</Policies>
</RollingRandomAccessFile>
<RollingRandomAccessFile name="serviceLogFile" fileName="{FILE_NAME}-service.log"
filePattern="{FILE_NAME}-service-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p - %m %l%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="20MB"/>
<DefaultRolloverStrategy max="20"/>
</Policies>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
<AppenderRef ref="sysFile"/>
</Root>
<Logger name="com.trjcn.common.base.interceptor.ControllerLogAspect" level="info" additivity="false">
<AppenderRef ref="controllerLogFile"/>
<AppenderRef ref="Console"/>
</Logger>
<Logger name="com.trjcn.common.base.exception.CommonExceptionHandler" level="info" additivity="false">
<AppenderRef ref="controllerLogFile"/>
<AppenderRef ref="serviceLogFile"/>
<AppenderRef ref="Console"/>
</Logger>
<Logger name="com.trjcn..controller" level="info" additivity="false">
<AppenderRef ref="controllerLogFile"/>
<AppenderRef ref="Console"/>
</Logger>
<Logger name="com.trjcn..service.impl" level="info" additivity="false">
<AppenderRef ref="serviceLogFile"/>
<AppenderRef ref="Console"/>
</Logger>
</Loggers>
</Configuration>
网友评论