Configuration 节点上非常重要的一个属性 monitorinterval="10"表示每10秒检测1次配置文件的变化
配置文件的思想是将依赖jar包的关键日志信息输出到日志文件frame-output.log.%i
本工程下的日志输出到日志文件proj-output.log.%i
log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="TRACE" monitorinterval="10">
<Properties>
<Property name="var.log.level">${mvn.log.level}</Property>
<Property name="var.log.path.dir">${mvn.log.path}/f.alioo.online</Property>
<Property name="var.output.pattern">[%-5p %d{yyyy-MM-dd HH:mm:ss.SSS}] [%t] [%l] %m%n</Property>
</Properties>
<Appenders>
<Console name="stdout" target="SYSTEM_OUT">
<PatternLayout pattern="${var.output.pattern}"/>
</Console>
<RollingRandomAccessFile bufferSize="1024" name="frame-output" fileName="${var.log.path.dir}/frame-output.log" filePattern="${var.log.path.dir}/frame-output.log.%i">
<PatternLayout>
<Pattern>${var.output.pattern}</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="100MB"/>
</Policies>
<DefaultRolloverStrategy max="5"/>
</RollingRandomAccessFile>
<RollingRandomAccessFile bufferSize="1024" name="o2o-api-monitor" fileName="${var.log.path.dir}/o2o-api-monitor.log" filePattern="${var.log.path.dir}/o2o-api-monitor.log.%i">
<PatternLayout>
<Pattern>[%-5p %d{yyyy-MM-dd HH:mm:ss.SSS}] %m%n</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="100MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingRandomAccessFile>
<RollingRandomAccessFile bufferSize="1024" name="proj-output" fileName="${var.log.path.dir}/proj-output.log" filePattern="${var.log.path.dir}/proj-output.log.%i">
<PatternLayout>
<Pattern>${var.output.pattern}</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="100MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<AsyncRoot level="TRACE" includeLocation="true">
<AppenderRef ref="stdout"/>
</AsyncRoot>
<!-- additivity为true时日志将会追加到控制台 -->
<AsyncLogger name="org.springframework" level="DEBUG" includeLocation="true" additivity="false">
<AppenderRef ref="frame-output"/>
</AsyncLogger>
<!-- log4jdbc -->
<AsyncLogger name="jdbc.sqltiming" level="INFO" includeLocation="true" additivity="false">
<AppenderRef ref="frame-output"/>
</AsyncLogger>
<!-- log4HibernateValidator -->
<AsyncLogger name="org.apache.commons.validator.ValidatorResources" level="ERROR" includeLocation="true" additivity="false">
<AppenderRef ref="frame-output"/>
</AsyncLogger>
<!-- zookeeper -->
<AsyncLogger name="org.apache.zookeeper" level="WARN" includeLocation="true" additivity="false">
<AppenderRef ref="frame-output"/>
</AsyncLogger>
<AsyncLogger name="org.apache.commons.beanutils" level="WARN" includeLocation="true" additivity="false">
<AppenderRef ref="frame-output"/>
</AsyncLogger>
<AsyncLogger name="org.apache.commons.digester" level="WARN" includeLocation="true" additivity="false">
<AppenderRef ref="frame-output"/>
</AsyncLogger>
<AsyncLogger name="org.apache.ibatis.logging.slf4j.Slf4jImpl" level="WARN" includeLocation="true" additivity="false">
<AppenderRef ref="frame-output"/>
</AsyncLogger>
<AsyncLogger name="org.springframework.ui.velocity" level="WARN" includeLocation="true" additivity="false">
<AppenderRef ref="frame-output"/>
</AsyncLogger>
<!-- apache activemq -->
<AsyncLogger name="org.apache.activemq" level="WARN" includeLocation="true" additivity="false">
</AsyncLogger>
<!-- project loggers begin -->
<AsyncLogger name="com.alioo" level="${var.log.level}" includeLocation="true" additivity="true">
<AppenderRef ref="proj-output"/>
</AsyncLogger>
<!-- project loggers end -->
</Loggers>
</Configuration>