现在的位置: 首页 > 综合 > 正文

Config Log4J for Spring in WSAD

2012年11月01日 ⁄ 综合 ⁄ 共 934字 ⁄ 字号 评论关闭

In SpringFramework, for logging by Log4J subsystem,  we can config it with the file named log4j.properties and put it in the folder web-inf/class/ (If using WSAD, you should put it in JavaSource/. It will be deployed to web-inf/class.).
The content of a log4j.properties file like this:


log4j.rootCategory=INFO, stdout, logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n

log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=/home/trisberg/jakarta-tomcat-4.1.24/logs/springapp.log
log4j.appender.logfile.MaxFileSize=512KB
# Keep three backup files
log4j.appender.logfile.MaxBackupIndex=3
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
#Pattern to output : date priority [category] - <message>line_separator
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - <%m>%n

The item “log4j.appender.logfile.file“ is the path.

抱歉!评论已关闭.