我当前的网络应用程序使用的是 Servlet 4.0 版本,我正在尝试禁用 log4j2 的自动初始化,下面是我遵循的 web.xml官方文档
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>CentricityPracticeWS</display-name>
<listener>
<listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
</listener>
<filter>
<filter-name>CentricityPracticeWS</filter-name>
<filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CentricityPracticeWS</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<context-param>
<param-name>isLog4jContextSelectorNamed</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>file://C://jboss//standalone//deployments//CentricityPracticeEAR.ear//init//log4j2.xml</param-value>
</context-param>
<context-param>
<param-name>log4jContextName</param-name>
<param-value>CentricityPracticeWS</param-value>
</context-param>
<context-param>
<param-name>isLog4jAutoInitializationDisabled</param-name>
<param-value>true</param-value>
</context-param>
<!-- init properties shared by entire application -->
<context-param>
<param-name>earDeploymentDescriptorPath</param-name>
<param-value>application.xml</param-value>
</context-param>
<listener>
<listener-class>com.CustomListener</listener-class>
</listener>
<!-- bootstrap Log4j -->
<!-- Log4j refresh interval -->
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<context-param>
<param-name>log4jExposeWebAppRoot</param-name>
<param-value>false</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- bootstrap Spring -->
<context-param>
<param-name>parentContextKey</param-name>
<param-value>centricity.practice</param-value>
</context-param>
<context-param>
<param-name>locatorFactorySelector</param-name>
<param-value>/beanRefFactory.xml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/context-web.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- welcome file list-->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
禁用自动初始化不适用于上面的 web.xml
我也试过只保持在下面但没有运气
<context-param>
<param-name>isLog4jAutoInitializationDisabled</param-name>
<param-value>true</param-value>
</context-param>
如果上面的 web.xml 配置有任何问题,请纠正我,您的帮助很重要!