配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="other" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{HH:mm:ss} %5p %c{1} %m%n"/>
</layout>
</appender>
<appender name="wapmail-hihadmin-stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %5p [%-20c{1}] %m%n"/>
</layout>
</appender>
<appender name="wapmail-hihadmin-log" class="org.apache.log4j.RollingFileAppender">
<param name="MaxFileSize" value="1024KB"/>
<param name="MaxBackupIndex" value="4"/>
<param name="File" value="wapmail.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} %-5p [%c{1}] - %m%n"/>
</layout>
</appender>
<!-- 如下包名改成自己项目的-->
<category name="com.cjdropshipping.procurement.controllers">
<priority value="debug"/>
<appender-ref ref="wapmail-hihadmin-stdout"/>
<appender-ref ref="wapmail-hihadmin-log"/>
</category>
<category name="com.cucheng.dao.procurement">
<priority value="debug"/>
<appender-ref ref="wapmail-hihadmin-stdout"/>
<appender-ref ref="wapmail-hihadmin-log"/>
</category>
<category name="com.cucheng.dao.*">
<priority value="debug"/>
<appender-ref ref="wapmail-hihadmin-stdout"/>
<appender-ref ref="wapmail-hihadmin-log"/>
</category>
</log4j:configuration>