You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by David Delbecq <de...@oma.be> on 2007/04/23 16:49:15 UTC
Howto setup log4j to work properly with maven test ?
Hello,
i have a problem with the test plugin of maven (1.x). When i add log4j
configuration to project, it seems part of output that should go in
test-report/xxx.yyy.TestZzz.txt does in fact go out on the user console.
This is a problem because we get the test report stripped out of most of
it's output.
Example, if my log4j.xml is empty, i get this:
maven test -Dmaven.junit.usefile=true -Dmaven.junit.fork=true
-Dmaven.junit.forkmode=perTest
....
test:test:
[junit] Running be.dissco.slide.SlideFopDriverTest
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 4,799 sec
[junit] 23 Apr 2007 16:46:15 - org.apache.slide.common.Domain -
WARNING - Access denied on /users by user *** Could not determine
principal *** for action /actions/read
[junit] 23 Apr 2007 16:46:15 - org.apache.slide.common.Domain -
WARNING - Access denied on /users by user *** Could not determine
principal *** for action /actions/read
[junit] [ERROR] TEST be.dissco.slide.SlideFopDriverTest FAILED
[junit] Running be.rmi.intranet.db.V4_newsServiceTest
However, if my log4j.xml contains console appenders, i get this:
test:test:
[junit] Running be.dissco.slide.SlideFopDriverTest
[junit] 0 [main] DEBUG be.dissco.slide.SlideFopDriverTest -
remove store dir
[junit] 3 [main] DEBUG be.dissco.slide.SlideFopDriverTest -
remove work dir
[junit] 1223 [main] INFO be.dissco.common.Dissco - Start DISSCO
configuration initialization
[junit] 1226 [main] DEBUG
be.dissco.common.configuration.ConfigurationLoader - properties defined
: configuration.resource=dissco.xml,
[junit] 1227 [main] INFO
be.dissco.common.configuration.ConfigurationLoader - load configuration
from :: systemId =
file:/home/delbd/dev/workspaces/intranet/RMI_intranet/target/test-classes/dissco.xml
publicId = null
Obviously, those log entries should go in test-report not screen!
How to solve thise, is there a specific appender to use?
Thanks for help.
(part of log4j.xml below)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false" threshold="debug">
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-4r [%t] %-5p %c %x
- %m%n"/>
</layout>
</appender>
<!-- Shark loggers -->
<appender name="PERSISTENCE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-4r [%t] %-5p %c %x
- %m%n"/>
</layout>
</appender>
.....
If i type in console:
maven test -Dmaven.junit.usefile=true -Dmaven.junit.fork=true
i get this:
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org