diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java index 6b6e585151..10ee727e13 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java @@ -209,7 +209,8 @@ public class IntegrationAutoConfiguration { protected static class IntegrationManagementConfiguration { @Configuration(proxyBeanMethods = false) - @EnableIntegrationManagement + @EnableIntegrationManagement( + defaultLoggingEnabled = "${spring.integration.management.default-logging-enabled:true}") protected static class EnableIntegrationManagementConfiguration { } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationProperties.java index 24349d0b7a..54111bf46f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationProperties.java @@ -47,6 +47,8 @@ public class IntegrationProperties { private final Poller poller = new Poller(); + private final Management management = new Management(); + public Channel getChannel() { return this.channel; } @@ -71,6 +73,10 @@ public class IntegrationProperties { return this.poller; } + public Management getManagement() { + return this.management; + } + public static class Channel { /** @@ -386,4 +392,24 @@ public class IntegrationProperties { } + public static class Management { + + /** + * Whether Spring Integration components should perform logging in the main + * message flow. When disabled, such logging will be skipped without checking the + * logging level. When enabled, such logging is controlled as normal by the + * logging system's log level configuration. + */ + private boolean defaultLoggingEnabled = true; + + public boolean isDefaultLoggingEnabled() { + return this.defaultLoggingEnabled; + } + + public void setDefaultLoggingEnabled(boolean defaultLoggingEnabled) { + this.defaultLoggingEnabled = defaultLoggingEnabled; + } + + } + } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java index d90a1cb29c..4f66bd1645 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java @@ -54,6 +54,7 @@ import org.springframework.core.io.ResourceLoader; import org.springframework.integration.annotation.IntegrationComponentScan; import org.springframework.integration.annotation.MessagingGateway; import org.springframework.integration.annotation.ServiceActivator; +import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.IntegrationManagementConfigurer; import org.springframework.integration.context.IntegrationContextUtils; @@ -484,6 +485,20 @@ class IntegrationAutoConfigurationTests { }); } + @Test + void integrationManagementLoggingIsEnabledByDefault() { + this.contextRunner.withBean(DirectChannel.class, DirectChannel::new).run((context) -> assertThat(context) + .getBean(DirectChannel.class).extracting(DirectChannel::isLoggingEnabled).isEqualTo(true)); + } + + @Test + void integrationManagementLoggingCanBeDisabled() { + this.contextRunner.withPropertyValues("spring.integration.management.defaultLoggingEnabled=false") + .withBean(DirectChannel.class, DirectChannel::new).run((context) -> assertThat(context) + .getBean(DirectChannel.class).extracting(DirectChannel::isLoggingEnabled).isEqualTo(false)); + + } + @Configuration(proxyBeanMethods = false) static class CustomMBeanExporter {