log4j.xml 1.65 KB
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE log4j:configuration PUBLIC
        "-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%5p] [%d{yyyy-MM-dd HH:mm:ss SSS}] [%t] (%F:%L) %m%n" />
		</layout>
        <filter class="org.apache.log4j.varia.LevelRangeFilter">
            <param name="LevelMin" value="${dili_titan.log.level}" />
        </filter>
	</appender>

    <!-- 输出日志到文件  每天一个文件 -->
    <appender name="dailyRollingFile"
              class="org.apache.log4j.DailyRollingFileAppender">
        <param name="Threshold" value="${dili_titan.log.level}"/>
        <param name="ImmediateFlush" value="true"/>
        <param name="File" value="${dili_titan.log.path}/titan.1n4j.com/titan_worker.log"/>
        <param name="DatePattern" value="'.'yyyy-MM-dd'.log'"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="[%5p] [%d{yyyy-MM-dd HH:mm:ss SSS}] [%t] (%F:%L) %m%n"/>
        </layout>
    </appender>

    <root>
        <priority value="${dili_titan.log.level}"/>
        <!-- 根据实际情况修改日志级别,一般线上是INFO以上 -->
        <appender-ref ref="${dili_titan.log.root.appender}"/>
        <!-- 该appender需要在上线时删除,以免输出重复的日志到catalina.out文件 -->
        <appender-ref ref="dailyRollingFile"/>
    </root>
</log4j:configuration>