NO IMAGE

1.引入log4j.properties

log4j.rootLogger=Console,File
#定義日誌輸出目的地為控制檯  
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
#可以靈活地指定日誌輸出格式,下面一行是指定具體的格式  
log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n
#檔案大小到達指定尺寸的時候產生一個新的檔案
log4j.appender.File = org.apache.log4j.RollingFileAppender
log4j.appender.File.File = /data/logs/ssm.log
#定義檔案最大大小
log4j.appender.File.MaxFileSize = 100MB
# 輸出所以日誌,如果換成DEBUG表示輸出DEBUG以上級別日誌
log4j.appender.File.Threshold = info
log4j.appender.File.Append = true
log4j.appender.File.MaxBackupIndex = 10
log4j.appender.File.layout = org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%l]%m%n

2.在web.xml中引入

 <!-- logger -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>