1
votes

I'm deploying multiple WAR files in an apache tomcat server. each WAR file is containing their respective Log4j.properties file (Log4j located in WEB-INF/Log4j.properties).

If I'm deploying app1.WAR, having WEB-INF/classes/Log4j.properties to generate logs in CATALINA-HOME/logs/app1.log and another app2.WAR, having WEB-INF/classes/Log4j.properties to generate logs in CATALINA-HOME/logs/app2.log, but every logs from my both webapps are written into CATALINA-HOME/logs/app1.log.

how can I configure Log4j to create dedicated log file for each webapp loaded in apache ?

1
I found a potential solution by using Log4j2 but the explanation is quite poor.....logging.apache.org/log4j/2.0/manual/logsep.html anybody had the same need ?tiamat

1 Answers

3
votes

I finally found a solution.

we just need to copy Log4j and commons lib jar files in the WEB-INF/lib folder of each WAR file to get an independent instance of Log4j per webapp. Then, Log4J will get the Log4j.properties file of the webapp to create its own Logging instance.

Hope it will help.