Unit tests - log4j

Hi,

I am using log4j and this is a fragment from my log4j.properties file:

log4j.appender.gen.file=${catalina.home}/logs/foo.log

When the container is up, ${catalina.home} is interpreted to the correct path. How about when running unit tests though? Is there any configuration so ${catalina.home} can be recognized as a global variable even if the server is not running?

Thanks

[461 byte] By [ar.kaza] at [2007-11-26 21:55:02]
# 1

> Hi,

>

> I am using log4j and this is a fragment from my

> log4j.properties file:

>

> > log4j.appender.gen.file=${catalina.home}/logs/foo.log

>

>

> When the container is up, ${catalina.home} is

> interpreted to the correct path. How about when

> running unit tests though? Is there any configuration

> so ${catalina.home} can be recognized as a global

> variable even if the server is not running?

>

> Thanks

Well if it is a Unit test can you not hard code the value? this isn't perfect but it is hardly criminal either.

kikemellya at 2007-7-10 3:50:30 > top of Java-index,Java Essentials,New To Java...
# 2
put this System.setProperty("catalina.home", "YOUR_PATH_HERE"); before launching any test.
java_2006a at 2007-7-10 3:50:30 > top of Java-index,Java Essentials,New To Java...
# 3

> Is there any configuration so ${catalina.home}

> can be recognized as a global variable even if

> the server is not running?

>

> Thanks

Is it an environment variable? If it is, you could just add it as a -D argument to the JVM:

java -Dcatalina.home="/usr/blah/..."

kevjavaa at 2007-7-10 3:50:30 > top of Java-index,Java Essentials,New To Java...