How to set CATALINA_HOME in log4j.xml?

java, log4j, tomcat

Solution

You can do the following:

- send the `CATALINA_HOME` as an environment variable using `-D` option. You just have to run

`set JAVA_OPTS=%JAVA_OPTS% -DCATALINA_HOME=%CATALINA_HOME%` if you are on windows or `export JAVA_OPTS=${JAVA_OPTS} -DCATALINA_HOME=$CATALINA_HOME` for unix.

Now just use ${CATALINA_HOME} into your log4j configuration file and this should work.

Problem

I need something like this: "param name="File" value="${CATALINA_HOME}/logs/log4j.log" I saw a lot of similar questions, but there is no working solutions.

Original source

Related problems