Skip to content

Commit c6891c5

Browse files
artembilanwilkinsona
authored andcommitted
Add a config prop to enable/disable SI's default logging
See gh-28355
1 parent 14fb9c4 commit c6891c5

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ public IntegrationMBeanExporter integrationMbeanExporter(BeanFactory beanFactory
209209
protected static class IntegrationManagementConfiguration {
210210

211211
@Configuration(proxyBeanMethods = false)
212-
@EnableIntegrationManagement
212+
@EnableIntegrationManagement(
213+
defaultLoggingEnabled = "${spring.integration.management.default-logging-enabled:true}")
213214
protected static class EnableIntegrationManagementConfiguration {
214215

215216
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationProperties.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class IntegrationProperties {
4747

4848
private final Poller poller = new Poller();
4949

50+
private final Management management = new Management();
51+
5052
public Channel getChannel() {
5153
return this.channel;
5254
}
@@ -71,6 +73,10 @@ public Poller getPoller() {
7173
return this.poller;
7274
}
7375

76+
public Management getManagement() {
77+
return this.management;
78+
}
79+
7480
public static class Channel {
7581

7682
/**
@@ -386,4 +392,21 @@ public void setCron(String cron) {
386392

387393
}
388394

395+
public static class Management {
396+
397+
/**
398+
* Logging management in the integration components.
399+
*/
400+
boolean defaultLoggingEnabled = true;
401+
402+
public boolean isDefaultLoggingEnabled() {
403+
return this.defaultLoggingEnabled;
404+
}
405+
406+
public void setDefaultLoggingEnabled(boolean defaultLoggingEnabled) {
407+
this.defaultLoggingEnabled = defaultLoggingEnabled;
408+
}
409+
410+
}
411+
389412
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.springframework.integration.annotation.IntegrationComponentScan;
5555
import org.springframework.integration.annotation.MessagingGateway;
5656
import org.springframework.integration.annotation.ServiceActivator;
57+
import org.springframework.integration.channel.DirectChannel;
5758
import org.springframework.integration.channel.QueueChannel;
5859
import org.springframework.integration.config.IntegrationManagementConfigurer;
5960
import org.springframework.integration.context.IntegrationContextUtils;
@@ -484,6 +485,14 @@ void whenFixedRatePollerPropertyIsSetThenItIsReflectedAsFixedRatePropertyOfPerio
484485
});
485486
}
486487

488+
@Test
489+
void integrationManagementLoggingDisabled() {
490+
this.contextRunner.withPropertyValues("spring.integration.management.defaultLoggingEnabled=false")
491+
.withBean(DirectChannel.class, DirectChannel::new).run((context) -> assertThat(context)
492+
.getBean(DirectChannel.class).extracting(DirectChannel::isLoggingEnabled).isEqualTo(false));
493+
494+
}
495+
487496
@Configuration(proxyBeanMethods = false)
488497
static class CustomMBeanExporter {
489498

0 commit comments

Comments
 (0)