开发Spring MVC应用程序(1)的修正

类别:Java 点击:0 评论:0 推荐:
在《开发Spring MVC应用程序(1)》中,由于对log4j的配置有问题,导致log4j无法正常工作。现对log4j做如下修正:

# For JBoss: Avoid to setup log4j outside $JBOSS_HOME/server/default/deploy/log4j.xml!

# For all other servers: Comment out the Log4J listener in web.xml too.

log4j.rootLogger=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=springapp.log

log4j.appender.logfile.MaxFileSize=512KB

# Keep three backup files.

log4j.appender.logfile.MaxBackupIndex=3

# Pattern to output: date priority [category] - message

log4j.appender.logfile.layout=org.apache.log4j.PatternLayout

log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n   去掉第三行的注释,指定log文件名为springapp.log,并在log4j.properties同目录下创建该空文件。log4j.properties内容的具体含义可以参考《Log4j日志管理系统简单使用说明》

本文地址:http://com.8s8s.com/it/it16035.htm