Polish "Add a config prop to enable/disable SI's default logging"

See gh-28355
This commit is contained in:
Andy Wilkinson 2021-10-19 10:28:57 +01:00
parent c6891c5184
commit 657eb86dad
2 changed files with 12 additions and 3 deletions

View File

@ -395,9 +395,12 @@ public class IntegrationProperties {
public static class Management {
/**
* Logging management in the integration components.
* 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.
*/
boolean defaultLoggingEnabled = true;
private boolean defaultLoggingEnabled = true;
public boolean isDefaultLoggingEnabled() {
return this.defaultLoggingEnabled;

View File

@ -486,7 +486,13 @@ class IntegrationAutoConfigurationTests {
}
@Test
void integrationManagementLoggingDisabled() {
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));