Skip to content

Commit 978f801

Browse files
committed
Polish "Debug mode is not logging web and sql related loggers"
Closes gh-16018
1 parent c3430d5 commit 978f801

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.List;
2222
import java.util.Locale;
2323
import java.util.Map;
24-
import java.util.Optional;
2524
import java.util.concurrent.atomic.AtomicBoolean;
2625

2726
import org.apache.commons.logging.Log;
@@ -321,8 +320,7 @@ private void initializeFinalLoggingLevels(ConfigurableEnvironment environment,
321320
}
322321

323322
protected void initializeLogLevel(LoggingSystem system, LogLevel level) {
324-
Optional.ofNullable(LOG_LEVEL_LOGGERS.get(level)).orElse(Collections.emptyList())
325-
.stream()
323+
LOG_LEVEL_LOGGERS.getOrDefault(level, Collections.emptyList()).stream()
326324
.flatMap((logger) -> DEFAULT_GROUP_LOGGERS
327325
.getOrDefault(logger, Collections.singletonList(logger)).stream())
328326
.forEach((logger) -> system.setLogLevel(logger, level));

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,12 @@ public void parseDebugArg() {
264264

265265
@Test
266266
public void parseDebugArgExpandGroups() {
267-
addPropertiesToEnvironment(this.context, "debug");
267+
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "debug");
268268
this.initializer.initialize(this.context.getEnvironment(),
269269
this.context.getClassLoader());
270-
ch.qos.logback.classic.Logger sqlGroup = this.loggerContext
271-
.getLogger("org.hibernate.SQL");
272-
ch.qos.logback.classic.Logger webGroup = this.loggerContext
273-
.getLogger("org.springframework.boot.actuate.endpoint.web");
274-
webGroup.debug("testdebugwebgroup");
275-
sqlGroup.debug("testdebugsqlgroup");
270+
this.logFactory.getInstance("org.springframework.boot.actuate.endpoint.web")
271+
.debug("testdebugwebgroup");
272+
this.logFactory.getInstance("org.hibernate.SQL").debug("testdebugsqlgroup");
276273
assertThat(this.outputCapture.toString()).contains("testdebugwebgroup");
277274
assertThat(this.outputCapture.toString()).contains("testdebugsqlgroup");
278275
}

0 commit comments

Comments
 (0)