When the jar package introduced in the project contains Log4j.xml or Log4j.properties, the configured log4j is overwritten, which invalidates the log4j of the configuration. To confirm whether it is overwritten, first check the path of the log4j profile read at the start of the project, you can find the service you configured under MyEclipse Server, and add the virtual machine parameter in the JDK startup key parameter:-dlog4j.debug
When you start, you can see the load path of the log4j configuration file. When the discovery is actually overwritten, the problem can be resolved by specifying the read path to the log4j in Web. XML, configured as follows:
<!--log4j avoid being overwritten-
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>WEB-INF/classes/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.log4jconfiglistener</listener-class >
</listener>