log2j.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="WARN" monitorInterval="30">
<properties>
<property name="LOG_HOME">/output/logs</property>
<!-- 日志备份目录 -->
<property name="SERVER_NAME">${module.name}</property>
</properties>
<appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %level [%C{1}:%L] - %msg%n" />
</Console>
<RollingFile name="RollingFile"
fileName="${LOG_HOME}/dev/${SERVER_NAME}.log"
filePattern="${LOG_HOME}/dev/${SERVER_NAME}.%d{yyyy-MM-dd}.%i.log">
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %level [%C{36}.%M] - %msg%n" />
<Policies>
<SizeBasedTriggeringPolicy size="10MB" />
</Policies>
<Filters>
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY" />
</Filters>
<DefaultRolloverStrategy>
<!-- 删除指定目录下7天之前的日志-->
<Delete basePath="${LOG_HOME}" maxDepth="2">
<IfFileName glob="*/*.log" />
<IfLastModified age="7d" />
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- 产品数据分析日志 -->
<RollingRandomAccessFile name="ProductLog"
fileName="${LOG_HOME}/${SERVER_NAME}.log"
filePattern="${LOG_HOME}/back/${SERVER_NAME}.%d{yyyyMMddHHmmss}.log">
<PatternLayout pattern="%d{yyyy.MM.dd HH:mm:ss.SSS} [%thread] %level [%C{36}.%M:%L] - %msg%xEx%n" />
<Policies>
<SizeBasedTriggeringPolicy size="10MB" />
</Policies>
</RollingRandomAccessFile>
</appenders>
<loggers>
<logger name="org.slf4j" level="info" />
<logger name="org.quartz" level="warn" />
<logger name="org.redisson" level="info" />
<logger name="com.atomikos" level="warn" />
<logger name="com.alibaba.dubbo" level="info" />
<logger name="org.apache.activemq" level="info" />
<logger name="org.springframework" level="info" />
<logger name="com.weibo.api.motan" level="warn" />
<logger name="org.apache.zookeeper" level="warn" />
<logger name="org.springframework.web" level="debug" />
<Logger name="top.ibase4j" level="info">
<AppenderRef ref="ProductLog" />
</Logger>
<Logger name="org.ibase4j" level="debug">
<AppenderRef ref="ProductLog" />
</Logger>
<Root level="debug">
<AppenderRef ref="Console" />
<AppenderRef ref="RollingFile" />
</Root >
</loggers>
</configuration>