Logging from servlet context destroyed event

夙愿已清 提交于 2019-12-02 01:24:06

We clashed against a similar issue with Logback. You have to write your own web.xml to fix that, because there's no alternatives to define listeners order.

We disabled the LogbackServletContextListener with:

<context-param>
    <param-name>logbackDisableServletContainerInitializer</param-name>
    <param-value>true</param-value>
</context-param>

then add the LogbackServletContextListener by hand as the first listener:

<listener>
    <listener-class>ch.qos.logback.classic.servlet.LogbackServletContextListener</listener-class>
</listener>

and then all the other listeners.

No idea about log4j, but I think there's something similar...

edit: yes, there is:

<context-param>
    <param-name>isLog4jAutoInitializationDisabled</param-name>
    <param-value>true</param-value>
</context-param>

source: https://logging.apache.org/log4j/2.x/manual/webapp.html

If you configured Log4j's ServletContextListener before yours in web.xml then Log4j should be initialized before your ServletContextListener and be shutdown after yours is.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!