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.

Posted on 2004-07-26 16:11  Samuel Chen  阅读(1743)  评论(0编辑  收藏  举报