cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominic Mitchell <...@happygiraffe.net>
Subject Re: [2.2] Configure logging for tests
Date Mon, 23 Nov 2009 16:01:05 GMT
On Mon, Nov 23, 2009 at 3:41 PM, Andreas Hartmann <andreas@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

Mime
View raw message