Tomcat Web 应用程序内部和外部的 log4j
我设置了一个 Web 应用程序来通过 slf4j 和 log4j 进行日志记录。 webapp是用Spring配置的。
相关的 web.xml 内容位于底部。我遇到的问题是,我还想在通过嵌入式 API 启动 tomcat 的应用程序内部使用这个 web 应用程序。一切都找到了,直到网络应用程序关闭,然后我就明白了。
log4j:WARN No appenders could be found for logger (org.apache.catalina.loader.WebappClassLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
有没有什么方法可以让“网络应用程序内部”的东西与外部的东西很好地配合?
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring-app-context.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>bt.r4dws.root</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
I have a webapp set up to log over slf4j and log4j. The webapp is configured with Spring.
The relevant web.xml stuff is on the bottom. The problem I've got is that I also want to use this webapp inside of an application that launches tomcat itself via the embedded API. Everything is find until the webapp shuts down, and then I get.
log4j:WARN No appenders could be found for logger (org.apache.catalina.loader.WebappClassLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Is there some way to make the 'inside the webapp' stuff play nicely with the outside stuff?
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring-app-context.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>bt.r4dws.root</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论