严重:异常org.springframework.web.util.Log4jConfigListener

Sea*_*ane 6 java spring spring-mvc

尝试在Spring Tool Suite中运行tomcat时获得以下严重异常:

SEVERE: Exception sending context initialized event to listener instance of class    org.springframework.web.util.Log4jConfigListener
java.lang.IllegalStateException: Cannot set web app root system property when WAR file is not expanded
at    org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:143)
at    org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:117)
at    org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)

Art*_*lan 6

不要Log4jConfigListener在未扩展的WAR中使用; 我们可能需要让它更清晰.

只有两个好处Log4jWebConfigurer: - Log4J配置文件更改时刷新Log4J配置; - 允许使用相对于Web应用程序根目录的日志文件路径.

当WAR未扩展时,两者都不适用,因此Log4jWebConfigurer在这种情况下使用没有意义.只需从log4j.properties类路径根目录中的文件中依赖Log4J的默认初始化.

顺便说一下,您可能已经注意到,Log4jConfigListener在Petclinic和States' 中已经注释掉了,原因相反web.xml:能够部署未扩展的WAR,并且在JBoss中没有麻烦地工作(它有自己特殊的Log4J用法) .

克林斯曼