1

I have a class: MyClass

private static final Log LOG = LogFactory.getLog(MyClass.class);

Somewhere in my code I do a LOG.trace() only LOG.isTraceEnabled()

And a test for that MyClass which uses Junit4

the test is ran by maven (2.2.1) just fine and logs the other logs (I've set the log4j.xml to level=INFO)

But if I switch to maven 3.0.3, the log4j.xml gets overridden or it not pointing where is should be and all the levels of debug are enabled (debug, trace, etc.)

I want to disable, if possible trace logging as it works in maven 2.2.1. There are hacky ways that I can do, I know, but I want to understand why is this happening?

Some of the key dependencies from the pom.xml

<dependency>
   <groupId>commons-logging</groupId>
   <artifactId>commons-logging</artifactId>
   <version>1.1.1</version>
</dependency>
 <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.8.2</version>
   <scope>test</scope>
</dependency>
<dependency>
   <groupId>log4j</groupId>
   <artifactId>log4j</artifactId>
   <version>1.2.16</version>
</dependency>

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.4.3</version>
</plugin>

the test is ran with other test classes. (multi-module project) if I do mvn clean test -Dtest=MyClassTest, the logging don't get messed up, but if I do mvn clean test (for all the tests) the logging will not work okay anymore (this is still just in case for maven 3)

4

0 回答 0