I have a small application configured to use SLF4J + Logback. I'm getting JUL output from Flyway which I'd like Logback to handle.
FlywayWrapper.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FlywayWrapper {
private static final Logger logger = LoggerFactory.getLogger(FlywayWrapper.class);
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{ISO8601} [%thread] %-5level %logger{0}: %msg%n</pattern>
</encoder>
</appender>
<logger name="com.foo.test" level="INFO" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration>
And I'm seeing console logging like so:
2014-09-01 12:53:47,405 [main] INFO FlywayWrapper: Operation >> migrate
Sep 01, 2014 12:53:47 PM org.flywaydb.core.internal.dbsupport.DbSupportFactory createDbSupport
INFO: Database: jdbc:postgresql://localhost:5433/test (PostgreSQL 9.2)
Sep 01, 2014 12:53:47 PM org.flywaydb.core.internal.command.DbValidate validate
INFO: Validated 3 migrations (execution time 00:00.055s)
I've noticed this in org.flywaydb.core.internal.util.logging.LogFactory
which is probably why JUL is being used.
public static Log getLog(Class<?> clazz) {
if (logCreator == null) {
FeatureDetector featureDetector = new FeatureDetector(Thread.currentThread().getContextClassLoader());
if (featureDetector.isAndroidAvailable()) {
logCreator = new AndroidLogCreator();
} else if (featureDetector.isApacheCommonsLoggingAvailable()) {
logCreator = new ApacheCommonsLogCreator();
} else {
logCreator = new JavaUtilLogCreator();
}
}
return logCreator.createLogger(clazz);
}
Any ideas on how I can get Flyway to use my logging backend?