C3P0 log4j:WARN No appenders could be found for logger (com.mchange.v2.log.MLog)
程序员文章站
2022-06-10 09:14:04
...
<script type="text/javascript">document.domain = "iteye.com";</script>
学习SSH的过程中,配置日志,使用SLF4J和LOG4J搭配,数据库连接池使c3p0,启动服务器,会出现如下警告信息:
log4j:WARN No appenders could be found for logger
(com.mchange.v2.log.MLog).
log4j:WARN Please initialize the log4j system
properly.
出现原因是,Spring配置监听器先于Log4j配置监听器执行了,解决很简单,把Log4j配置放在Spring配置前就ok了。
下面是我的web.xml配置文件:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>SSHDemo</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <!-- Struts2 configuration --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Log4j configuration --> <context-param> <param-name>webAppRootKey</param-name> <param-value>sshdemo.root</param-value> </context-param> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> </web-app>
推荐阅读
-
关于运行ssm环境maven插件tomcat时出现的log4j:WARN No appenders could be found for logger
-
C3P0 log4j:WARN No appenders could be found for logger (com.mchange.v2.log.MLog)
-
C3P0 log4j:WARN No appenders could be found for logger (com.mchange.v2.log.MLog)
-
java API操作HDFS出现log4j:WARN No appenders could be found.............
-
log4j:WARN No appenders could be found for logger
-
log4j:WARN No appenders could be found for logger
-
关于运行ssm环境maven插件tomcat时出现的log4j:WARN No appenders could be found for logger
-
WARN No appenders could be found for logger的解决方法
-
WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).