Kind of a puzzle here.
I have an application in WAR. There are web.xml and application context.xml in there, and also there is log4j.properties. This WAR runs in tomcat.
There is a possibility to use some variables in log4j.properties, e.g. log4j.appender.file.File=${catalina.base}/logs/app.log
I want to define a variable in web.xml or context.xml and use it in log4j.properties. For example, somehow set version=1.1
and use log4j.appender.file.File=${catalina.base}/logs/app-${version}.log
. It should not be an environment variable.
Can I do it without recompiling the app?
ADD shouldn't affect anything, but just in case...
Its web.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">
<!-- Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:context.xml</param-value>
</context-param>
<!-- log4j -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>10000</param-value>
</context-param>
<context-param>
<param-name>log4jExposeWebAppRoot</param-name>
<param-value>false</param-value>
</context-param>
...
</web-app>