在没有SPRING 的情况下:
web.xml
<param-value>classpath:/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>com.root</param-value>
</context-param>
maven:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
log4j.properties
# Output pattern : date [thread] priority category - message
log4j.rootLogger=DEBUG, C, D, E
#C
log4j.appender.C=org.apache.log4j.ConsoleAppender
log4j.appender.C.layout=org.apache.log4j.PatternLayout
log4j.appender.C.layout.ConversionPattern=%d %t %-5p %l - %m%n
#D
log4j.appender.D=org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.layout=org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern=%d %t %-5p %l - %m%n
log4j.appender.D.datePattern='-'yyyy-MM-dd'.log'
log4j.appender.D.Threshold=DEBUG
log4j.appender.D.append=true
log4j.appender.D.File=${catalina.base}/logs/info
#E
log4j.appender.E=org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.layout=org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern=%d %t %-5p %l - %m%n
log4j.appender.E.datePattern='-'yyyy-MM-dd'.log'
log4j.appender.E.Threshold=ERROR
log4j.appender.E.append=true
log4j.appender.E.File=${catalina.base}/logs/error
新建文件夹: