可能存在的情况:
(1)在tomcat\common\lib下多放了一个log4j,将其删除
That error is coming from commons-logging finding Log4j and using it in preference to j2sdk1.4.x
logging, but if Log4j doesn't, then, find its configuration, you will get that error.
(2) 将log4j.properties所在的目录加到CLASSPATH中
(3)从WEB-INF\lib下复制log4j.jar到tomcat\common\lib
I just tested having log4j.jar in my WEB-INF/lib and not in common/lib and commons-logging in common/lib couldn't see it (and, therefore, didn't get the Log4j error), so it is most likely that you have log4j.jar in common/lib (or shared/lib) or some other place where commons-logging in Tomcat can see log4j.jar. Remove Log4j.jar and you won't see that error....or, I suppose, you could add log4j.xml or log4j.properties to common/classes and all would be well.
(4)确认log4j.properties在tomcat\webapps\~\WEB-INF\classes下,~\src下,~\WebRoot\WEB-INF\classes下
(5)一个多线程的程序,在子线程中会用到两个Logger,一个绑定到公共的日志输出,另一个则使用独立的日志文件,后者会在线程结束时关闭日志文件。开始我使用了Logger.shutdown(),正是这一方法导致了问题,原因在于shutdown会关闭所有在程序中使用到的Logger,甚至是RootLogger,同时释放Logger占用的所有资源,如Appender。这样一来自然其他的线程再向公共日志中输出时会报Appender不存在的错误。
结论:如果希望显式地关闭日志,应该使用Appender.close()方法;对于FileAppender,可以使用CloseFile()方法。也可以直接使用Logger.removeAppender()方法强行移除Appender,但对于SocketAppender或AsyncAppender可能会导致pending logging。
(6)在 log4j.properties 中加入一个名为 org.springframework 的 Logger。例如:
log4j.logger.org.springframework=DEBUG, org.springframework, stdout
log4j.appender.org.springframework=org.apache.log4j.FileAppender
log4j.appender.org.springframework.File=/opt/adstat/log/spring.log
log4j.appender.org.springframework.Encoding=utf8
log4j.appender.org.springframework.layout=org.apache.log4j.PatternLayout
log4j.appender.org.springframework.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n
分享到:
相关推荐
NULL 博文链接:https://wait7758521.iteye.com/blog/1933964
log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory). log4j:WARN Please initialize the log4j system properly. 将这个文件放到resources目录下,消除警告。
log4j:WARN No appenders could be found for logger org apache commons beanutils ConvertUtils 出现这个错误 在web inf classes路径下加了log4j properties文件还是这个错误log4j:WARN Please initialize the ...
首先,错误信息"log4j:WARN No appenders could be found for logger"表明Log4j找不到任何日志输出的目标,也就是没有设置日志appender。日志appender是Log4j用来定义日志输出目的地的组件,比如控制台、文件、邮件...
《构建企业级应用:MyEclipse中整合Struts、Hibernate、Spring及FreeMarker详解》 在企业级Web应用开发中,Struts、Hibernate、Spring和FreeMarker这四大框架的集成使用已经成为主流。本资料旨在图解如何在...
在Java开发领域,日志记录是一项至关重要的任务,它能够帮助开发者追踪程序运行状态,定位错误与异常,优化性能。Log4j作为Java中广泛使用的日志框架,提供了丰富的功能和自定义配置。在dotcms这个内容管理系统中,...
log4j:WARN No appenders could be found for logger (com.mchange.v2.log.MLog). log4j:WARN Please initialize the log4j system properly.
报错WARN No appenders could be found for logger 或 WARN Please initialize the log4j system properly时需要引入的包。用法可以参考https://blog.csdn.net/u010912188/article/details/79761894
模式爬虫配置单元 不幸的是,到目前为止, 似乎是不切实际的。 从hive-1.1.0(CDH5.4)开始,...log4j:WARN No appenders could be found for logger (org.apache.hive.jdbc.Utils). log4j:WARN Please initialize the
clj-hbase 这是一个用于 hbase 0.98.3 的小型且仍然不完整的 clojure 包装器 用法 假设我们有一个带有列族“byte-data...log4j:WARN No appenders could be found for logger ( org.apache.hadoop.metrics2.lib.Mutabl
玩具应用程序可证明参加动物园管理员领导者选举食谱的多个客户可以随时认为自己是领导者。 建造 建立: $ ../gradlew jar 这将在build / libs中创建...log4j:WARN No appenders could be found for logger (org
log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory). log4j:WARN Please initialize the log4j system properly. log4j:WARN See ...
当出现"log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader)"这样的警告时,这意味着log4j没有找到任何日志输出目标。这通常是因为日志配置文件未被正确加载。解决...
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. 2009-8-29 14:02:12 org.apache.catalina.core....
log4j:WARN No appenders could be found for logger (org.apache.mons.digester.Digester). log4j:WARN Please initialize the log4j system properly. 2009-11-06 21:39:17 org.apache.catalina.core....
例如,在Spring框架的应用中,如果没有正确配置log4j,就可能出现“log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext)”这类警告信息。...