diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index 1813521d19..176b48162c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -245,6 +245,8 @@ public class FlywayAutoConfiguration { .to((prefix) -> configuration.scriptPlaceholderPrefix(prefix)); map.from(properties.getScriptPlaceholderSuffix()) .to((suffix) -> configuration.scriptPlaceholderSuffix(suffix)); + map.from(properties.isExecuteInTransaction()).to(configuration::executeInTransaction); + map.from(properties::getLoggers).to(configuration::loggers); // Flyway Teams properties map.from(properties.getBatch()).to(configuration::batch); map.from(properties.getDryRunOutput()).to(configuration::dryRunOutput); @@ -269,7 +271,6 @@ public class FlywayAutoConfiguration { .as((patterns) -> patterns.toArray(new String[0])) .to(configuration::ignoreMigrationPatterns); map.from(properties.getDetectEncoding()).to(configuration::detectEncoding); - map.from(properties.isExecuteInTransaction()).to(configuration::executeInTransaction); } private void configureSqlServerKerberosLoginFile(FluentConfiguration configuration, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java index e6c73a175f..8215c688a9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java @@ -367,6 +367,11 @@ public class FlywayProperties { */ private boolean executeInTransaction = true; + /** + * Loggers Flyway should use. + */ + private String[] loggers = { "slf4j" }; + public boolean isEnabled() { return this.enabled; } @@ -855,4 +860,12 @@ public class FlywayProperties { this.executeInTransaction = executeInTransaction; } + public String[] getLoggers() { + return this.loggers; + } + + public void setLoggers(String[] loggers) { + this.loggers = loggers; + } + } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java index c349882c5c..b2148d973e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java @@ -763,6 +763,21 @@ class FlywayAutoConfigurationTests { .run((context) -> assertThat(context).hasSingleBean(ResourceProviderCustomizer.class)); } + @Test + void loggers() { + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .run((context) -> assertThat(context.getBean(Flyway.class).getConfiguration().getLoggers()) + .containsExactly("slf4j")); + } + + @Test + void overrideLoggers() { + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("spring.flyway.loggers=log4j2") + .run((context) -> assertThat(context.getBean(Flyway.class).getConfiguration().getLoggers()) + .containsExactly("log4j2")); + } + @Test void shouldRegisterResourceHints() { RuntimeHints runtimeHints = new RuntimeHints();