log4j 工作正常,但是,在服务器启动时,我收到以下警告:
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
这意味着
log4j.properties
找不到。但我不确定如何解决这个问题,因为一切似乎都运行良好。
请您参考如下方法:
将 spring Log4jConfigListener 作为 web.xml 中的第一个监听器。
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
您可以在上下文参数中设置 log4j 属性的位置,但如果将其放置在类路径上,则不需要这样做。
一个例子是..
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/resources/log4j.properties</param-value>
</context-param>