Configuring log filenames in a multi-tenant, identical-WAR scenario

Christopher Dodunski <[email protected]> Tue, 27 Jan 2026 23:01:14 +1300
Newsgroups gmane.comp.jakarta.log4j.user
Message-ID <[email protected]>
Dear Log4J2 community,

I am currently exploring the possibility of deploying multiple (byte 
identical) WARs for servicing multiple tenants, but hosted by a single 
Tomcat installation.

The WARs, although being identical (including web.xml), are to be named 
according to each tenant.  My main goal is having these web applications 
logging to different files.

     tom.war >> /tom (Tomcat context) >> logs to tom.log

     dick.war >> /dick >> logs to dick.log

     harry.war >> /harry >> logs to harry.log

I've created separate log4j2.xml configuration files for each and placed 
these in WEB-INF, as per below:

     WEB-INF/log4j2-tom.xml

     WEB-INF/log4j2-dick.xml

     WEB-INF/log4j2-harry.xml

I'd thought that the log4j-web package would allow Log4J to 
automatically select the correct XML based on Tomcat context, but this 
seems not to be the case.

I'm eager to learn of a method that would allow log filenames to be set 
from outside the WAR, if possible.

Thanking you in advance for any suggestions.

Kind regards,

Chris.