公司项目分为design,runtime两个模块。design使用的logback. runtime 使用log4j.
<dependency>
<groupId>log4jgroupId>
<artifactId>apache-log4j-extrasartifactId>
<version>1.2.17version>
dependency>
xml version="1.0" encoding="UTF-8"?>
DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="runtime" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="Append" value="true" />
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern" value="${user.home}/symphony/%d{yyyy-MM-dd}/runtime-log.log" />
rollingPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c(%L) - %m%n" />
layout>
appender>
<appender name="message" class="org.apache.log4j.rolling.RollingFileAppender">
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern" value="${user.home}/symphony/%d{yyyy-MM-dd}/runtime-message-log.log" />
rollingPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c(%L) - %m%n" />
layout>
appender>
<category name="com.maveriq" additivity="false">
<priority value="WARN"/>
<appender-ref ref="runtime"/>
category>
<category name="com.maveriq.communicate.core.CommunicateLog" additivity="false">
<priority value="INFO"/>
<appender-ref ref="message"/>
category>
<logger name="org">
<level value="error" />
logger>
<logger name="runtime">
<level value="WARN">level>
<appender-ref ref="runtime" />
logger>
<logger name="message">
<level value="INFO">level>
<appender-ref ref="message"/>
logger>
<root level="WARN">
<appender-ref ref="ERROR" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="runtime" />
<appender-ref ref="message" />
root>
log4j:configuration>