Change:
-Dlog4j.configuration=c:\tmp\log4j.xml test
To:
-Dlog4j.configuration=file:///c:/tmp/log4j.xml test
Or, just copy log4j.xml to the root directory of your compiled test
classes and let Log4j autoconfigure itself.
Jake
At 04:16 PM 1/23/2007, you wrote:
>I have written some JUnit tests and put them in the standard layout for test
>cases under Maven. The tests use log.debug(msg), log.info(msg) etc.
>
>The tests run OK.
>
>So now I created a simple log4j.xml file with an appender and a logger that
>filters only the logging messages in my test case (by package).
>
>When I run maven (mvn test), how do I tell it where my log4j.xml is
and how to
>use log4j logging?
>
>I have tried everything. I edited the "mvn" script under the
install directory
>to include the following:
>
> exec "$JAVACMD" \
> $MAVEN_OPTS \
> -classpath "${M2_HOME}"/core/boot/classworlds-*.jar \
> "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
> "-Dmaven.home=${M2_HOME}" \
> "-Dmaven.junit.sysproperties=log4j.configuration" \
> "-Dlog4j.configuration=file:C:\tmp\log4j.xml" \
> ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS
>
>
>this does not work (have tried with and without file:.
>
>---
>I have included a something similiar on the mvn command line:
> mvn -Dlog4j.configuration=c:\tmp\log4j.xml test
>
>this does not work (have included =file:c:\tmp... as well
>
>---
>I have also tried setting properties in the pom.xml like so:
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <configuration>
> <skip>false</skip>
> <useFile>false</useFile>
>
> <systemProperties>
> <property>
> <name>maven.junit.sysproperties</name>
> <value>log4j.configuration</value>
> </property>
> <property>
> <name>log4j.configuration</name>
> <value>file=:c:\tmp\log4j.xml</value>
> </property>
> </systemProperties>
> </configuration>
> </plugin>
>
>---
>and
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <configuration>
> <skip>false</skip>
> <useFile>false</useFile>
>
> <systemProperties>
> <property>
> <name>maven.junit.sysproperties</name>
> <value>log4j.configuration</value>
> </property>
> <property>
> <name>log4j.configuration</name>
> <value>c:\tmp\log4j.xml</value>
> </property>
> </systemProperties>
> </configuration>
> </plugin>
>
>--- and (log4j.xml is in same directory as pom.xml) this does not
work either.
>
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <configuration>
> <skip>false</skip>
> <useFile>false</useFile>
>
> <systemProperties>
> <property>
> <name>maven.junit.sysproperties</name>
> <value>log4j.configuration</value>
> </property>
> <property>
> <name>log4j.configuration</name>
> <value>log4j.xml</value>
> </property>
> </systemProperties>
> </configuration>
> </plugin>
>
>
>---
>none of these work. Any ideas on how to integrate Maven2, Log4J and
>Junit would
>be greatly appreciated.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]