• mybatis WARN No appenders could be found for logger的解决方法


    log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).
    log4j:WARN Please initialize the log4j system properly.

    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

    网上有好多解决办法都不管用,这个提示应该是读入web应用程序的log4j.properties文件之前就报出来了。是在加载org.springframework.web.context.ContextLoader这个listener的时候没找到log4j的配置文件造成的。 

    仔细查看web.xml发现在加载org.springframework.web.context.ContextLoader这个listener之后才加载org.springframework.web.util.Log4jConfigListener,把log4j的配置放到org.springframework.web.context.ContextLoader之前,就可以解决这个问题了

    web.xml中

    <!-- 以下3项参数与log4j的配置相关 -->  
          
        <context-param>  
            <param-name>log4jConfigLocation</param-name>  
            <param-value>/WEB-INF/log4j.properties</param-value>  
        </context-param>  
          
        <context-param>  
            <param-name>log4jRefreshInterval</param-name>  
            <param-value>60000</param-value>  
        </context-param>  
        <listener>  
            <listener-class>  
                org.springframework.web.util.Log4jConfigListener  
            </listener-class>  
        </listener>  
    <!-- end -->  
      
        <listener>  
            <listener-class>  
                org.springframework.web.context.ContextLoaderListener  
            </listener-class>  
        </listener>  
  • 相关阅读:
    JDBC
    Listener监听器
    Filter过滤器
    Jstl标签库
    el表达式
    Ajax技术
    数据交换格式之
    MVC模式
    函数
    二维数组练习
  • 原文地址:https://www.cnblogs.com/shanheyongmu/p/5650499.html
Copyright © 2020-2023  润新知