tomcat filewatchdog but has failed to stop it原因以及解决方法

停止tomcat,有些时候会报The web application [/XXX] appears to have started a thread named [FileWatchdog] but has failed to stop it. 

导致这个错误的原因是在web.xml配置了

    <context-param>
        <param-name>log4jRefreshInterval</param-name>
        <param-value>60000</param-value>
    </context-param>

所以,启动了一个检测log4j.properties变化的线程,只不过在1.2.x的log4j实现中,这个线程无法被interupt,所以会出现这个错误。

事实上,这个错误在2002年的时候就出现了,只不过log4j官方一直都没有修复。

原先计划在1.3中修复,后来,就没有后来的1.3版本了,到了2.x版本。

1.2和2.x不兼容性太多,以至于无法平滑升级。

所以要解决这个异常,有三个解决方法:1、升级到2.x;2、去掉自动检测这个配置(事实上95%以上的场景都没有必要);3、自己写个servletcontextlistener强行中止该线程。

详细可参考:https://bz.apache.org/bugzilla/show_bug.cgi?id=4913

原文地址:https://www.cnblogs.com/zhjh256/p/6005444.html