All Products
Search
Document Center

Enterprise Distributed Application Service:What do I do if Log4j logs cannot be generated as expected due to overwriting issues when I use EDAS?

Last Updated:May 25, 2023

Problem description

When I use Enterprise Distributed Application Service (EDAS), Log4j logs cannot be generated as expected.

Causes

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

Solutions

  1. Change the default name of the Log4j configuration file.

    Note

    If you use the default name, the Log4j configuration file is automatically masked.

  2. Configure Log4jConfigListener of Spring and add the following configurations to web.xml to modify the path of the Log4j configuration file:

     <listener>
         <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
     </listener>
     <context-param>
         <param-name>log4jConfigLocation</param-name>
         <param-value>WEB-INF/log4j-[$App_Name].xml</param-value>
     </context-param>     

    [$App_Name]: the name of the application.

  3. Start the application.

    Note
    1. Pandora loads the built-in Log4j.jar file and then the built-in Log4j configuration file. In this case, the configurations of the application are not loaded.

    2. After Pandora loads the preceding files, Log4jConfigListener is executed to load the custom Log4j configurations of the application when the web.xml file of the application is loaded. This ensures that the Log4j configurations of the application take effect.