You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Andreas Hartmann <an...@apache.org> on 2009/11/23 16:41:14 UTC
[2.2] Configure logging for tests
Hi everyone,
I'm using Cocoon 2.2.
How do I configure the logging output for my unit tests?
This tutorial helped me a lot for the web application, but it doesn't
seem to work for the tests …
http://happygiraffe.net/blog/2008/08/27/logging-in-cocoon-22/
Thanks a lot for any hints!
Best regards,
Andreas
--
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [2.2] Configure logging for tests
Posted by Andreas Hartmann <an...@apache.org>.
Hi Dominic,
thanks a lot for your reply!
Dominic Mitchell schrieb:
> On Mon, Nov 23, 2009 at 3:41 PM, Andreas Hartmann <andreas@apache.org
> <ma...@apache.org>> wrote:
> I'm using Cocoon 2.2.
> How do I configure the logging output for my unit tests?
[…]
> * Set up maven to invoke the tests in a forked JVM, and pass in the
> log4j.configuration system property. Look at the docs for the
> surefire plugin
> <http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html>.
I chose this option. Here's what works for me:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>log4j.configuration</name>
<value>file://${project.basedir}/etc/log4j.xml</value>
</property>
</systemProperties>
</configuration>
</plugin>
Thanks again and best regards,
-- Andreas
--
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [2.2] Configure logging for tests
Posted by Dominic Mitchell <do...@happygiraffe.net>.
On Mon, Nov 23, 2009 at 3:41 PM, Andreas Hartmann <an...@apache.org>wrote:
> Hi everyone,
>
> I'm using Cocoon 2.2.
> How do I configure the logging output for my unit tests?
>
> This tutorial helped me a lot for the web application, but it doesn't seem
> to work for the tests …
> http://happygiraffe.net/blog/2008/08/27/logging-in-cocoon-22/
>
> Thanks a lot for any hints!
>
>
That's because the tests aren't run inside a jetty container. They're just
run inside JUnit.
The easiest way that I've found in the past is to create a file
src/main/resources/log4j.properties with the desired test logging setup.
When the tests fire up, log4j auto-detects it because it'll be at the root
of the classpath.
If that fails, there are other options:
- Set up a base class for all your tests, which has a setUp() which
invokes PropertyConfigurator.configure(…)<http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PropertyConfigurator.html#configure(java.lang.String)>
.
- Set up maven to invoke the tests in a forked JVM, and pass in the
log4j.configuration system property. Look at the docs for the surefire
plugin<http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html>
.
-Dom