For the Flyway Maven plugin, I need to call a number of libraries that log using commons-logging (Flyway, Spring, ...)
In Maven2, I could use maven-plugin-log4j to accomplish this. This is what the output looks like:
[INFO] [flyway:history {execution: default-cli}]
[INFO] Hsql does not support locking. No concurrent migration supported.
In Maven3 however, this doesn't work so well:
[INFO] --- flyway-maven-plugin:1.3.2-SNAPSHOT:history (default-cli) @ flyway-sample ---
15.04.2011 09:49:10 com.googlecode.flyway.core.dbsupport.hsql.HsqlDbSupport <init>
INFO: Hsql does not support locking. No concurrent migration supported.
How can I get clean logging output in Maven3?
Ok, I found out what the issue was.
In order to support Maven 2, the plugin depends on maven-core version 2.2.1.
This version of maven-core pulls in an slf4j-jdk14 dependency.
This doesn't do anything under Maven 2, but in Maven 3 it gets used and redirects all logging output to JDK 1.4 logging (which is an absolute pain to configure).
In order to get the commons-logging output redirected to the Maven log in both Maven 2 and Maven 3, I now have the following setup working:
<!-- Stop redirecting to JDK 1.4 logging -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.2.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Log4J to Maven Log -->
<dependency>
<groupId>com.pyx4j</groupId>
<artifactId>maven-plugin-log4j</artifactId>
<version>1.0.1</version>
</dependency>
<!-- Slf4j to Log4J -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>