Question

I have a many DB integration tests that are using the following annotations for transactional rollback:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:ApplicationContext-DAOs.xml"})
@Transactional

The tests pass, but when I run them Spring deems it necessary to log at INFO level to standard error! It logs things like:

19/11/2010 16:49:11 org.springframework.test.context.TestContextManager
  retrieveTestExecutionListeners
INFO: @TestExecutionListeners is not present for class [class my.SomeDAOTest]:
  using defaults.
etc for many, many lines ...

Where do I turn this off?

Was it helpful?

Solution

You can hide it using log4j. In your log4j.xml, set a logger for spring to warn (or error).

<logger name="org.springframework">
    <level value="warn"/>
</logger>

OTHER TIPS

Spring core is using apache commons logging. In order to configure away from default behavior (writing to stderr) I had to use the bridge component for my particular framework.

I'm using Log4j2, so once I added the bridge from apache commons to log4j2, then spring core respected my settings.

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-jcl</artifactId>
    <version>2.11.2</version>
</dependency>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top