commons-logging结合Log4j的问题

来源:互联网 发布:数控车整个圆球的编程 编辑:程序博客网 时间:2024/05/20 18:49

java.lang.NoSuchMethodError: org.apache.log4j.Category.log(Ljava/lang/String;Lorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/Throwable;)V
  at org.apache.commons.logging.impl.Log4JCategoryLog.debug(Log4JCategoryLog.java:94)错误

认为是log4j的问题 ,把log4j升级到1.2.9,还是不行,升级到1.2.11,错误依旧,只好看源码了,Log4JCategoryLog.java中,有这末一句,"deprecated Use {@link Log4JLogger} instead",原来是class目录下commons-logging.properties的问题

原来的commons-logging.properties

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JCategoryLog

更改后的commons-logging.properties

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

class目录下log4j..properties文件配置信息

# 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 to activate Log4J.
#log4j.rootLogger=INFO, stdout, logfile
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=${tatan.root}/log/ebook.log
log4j.appender.logfile.MaxFileSize=512KB
# Keep three backup files.
log4j.appender.logfile.MaxBackupIndex=0
# 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

# If programmed properly the most messages would be at DEBUG
# and the least at FATAL.

log4j.logger.com.tatan.dao.jdbc=DEBUG
log4j.logger.com.tatan.service.impl=DEBUG



注意不要多写stdout,log4j.logger.com.tatan.Myclass=DEBUG, stdout,它会会继承root的appender ,会重复输出了

 
原创粉丝点击