Symptoms

After Enterprise Distributed Application Service (EDAS) is used, the Log4j logs cannot be generated.

Causes

The Log4j logs are overwritten. As a result, the logs cannot be generated.

Solutions

  1. Do not use the default name of the Log4j configuration file, which may be automatically masked. Instead, rename the configuration file. For example, place it in WEB-INF/log4j-myAppName.xml.
  2. Configure Log4jListener of Spring and add the following configuration to web.xml:
     <listener>
         <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
     </listener>
     <context-param>
         <param-name>log4jConfigLocation</param-name>
         <param-value>WEB-INF/log4j-myAppName.xml</param-value>  # myAppName specifies the application name, which can be defined as needed.
     </context-param>                       
  3. Start the application.
    Note Pandora first loads the built-in Log4j.jar file and the Log4j configuration file configured inside Pandora. In this case, the configuration of the application is not loaded.
    After Pandora is loaded, Log4jConfigListener is executed to load the custom Log4j configuration of the application when the web.xml file of the application is loaded. This ensures that the Log4j configuration of the application takes effect.