加入 commons-logging.jar,l og4j.jar到lib
加入log4j.properties到src
log4j.properties内容:
log4j.rootLogger=debug,A1,R
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%n%d [%5p] %l%n%m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=megoods_log.txt
log4j.appender.R.MaxFileSize=500KB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%n%d [%5p] %l%n%m%n
上面R配置为最多产生10个500K的日志。
使用:
private static Log log = LogFactory.getLog(xxx.class);
log.debug("xxx");
log.info("xxx");
log.warn("xxx");
log.error("xxx");
log.fatal("xxx");
posted on 2006-12-02 23:17
你是目标 阅读(487)
评论(0) 编辑 收藏 所属分类:
JAVA