Hello Tapestry team,
I'm searching for a method to set Log4J2's output log filename from
outside the WAR, in time for Tapestry starting to log during startup.
Hard-coding the log filename inside the WAR in log4j2.xml works fine,
but this approach ill-suits a multi-tenant, multi-WAR scenario (single
Tomcat). I'm looking to deploy byte-for-byte identical Tapestry
applications whereby the WARs have different names/contexts, connect to
different DBs, and write to different log files.
Externalising database connectivity was straightforward, by means of
external context XML placed in
/usr/local/tomcat/conf/Catalina/localhost/ (example below).
To date, I've tried:
1) SYS, CTX and WEB look-ups from log4j2.xml inside the WAR (the
latter utilising the log4j-web package and associated listener in
web.xml).
2) Creating a full copy of log4j2.xml for each WAR, with log filenames
hard-coded.
On the face of it, it seems that Tapestry starts logging before Tomcat
initialises the below, which was unexpected.
I'm eager to hear your ideas on how to satisfy the above Tapestry use
case. 😊
<Context>
<!-- Database -->
<Resource name="jdbc/HarbourDS"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.cj.jdbc.Driver"
url="jdbc:mysql://localhost:3306/demo?useSSL=false"
username="demo"
password="???"
maxTotal="100"
maxIdle="20"
minIdle="10"
maxWaitMillis="10000"
validationQuery="SELECT 1"
testOnBorrow="true"
testWhileIdle="true"
timeBetweenEvictionRunsMillis="300000"/>
<!-- Parameter unfortunately ignored as Tapestry logs before the
servlet context is fully initialised. -->
<Parameter name="log4jContextName"
value="demo"
override="false"/>
<!-- Parameter log4jConfigurationFile is supposedly honoured at
Log4j2 bootstrap time, not application time. Unfortunately, this too
wasn't successful. -->
<Parameter name="log4jConfigurationFile"
value="file:/usr/local/tomcat/conf/Catalina/localhost/demo-log4j2.xml"
override="false"/>
</Context>
Kind regards,
Chris.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]