Skip to content

Commit 2236e95

Browse files
committed
Merge pull request #16018 from nosan
* pr/16018: Polish "Debug mode is not logging web and sql related loggers" Debug mode is not logging web and sql related loggers
2 parents 130ef10 + 978f801 commit 2236e95

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -320,12 +320,10 @@ private void initializeFinalLoggingLevels(ConfigurableEnvironment environment,
320320
}
321321

322322
protected void initializeLogLevel(LoggingSystem system, LogLevel level) {
323-
List<String> loggers = LOG_LEVEL_LOGGERS.get(level);
324-
if (loggers != null) {
325-
for (String logger : loggers) {
326-
system.setLogLevel(logger, level);
327-
}
328-
}
323+
LOG_LEVEL_LOGGERS.getOrDefault(level, Collections.emptyList()).stream()
324+
.flatMap((logger) -> DEFAULT_GROUP_LOGGERS
325+
.getOrDefault(logger, Collections.singletonList(logger)).stream())
326+
.forEach((logger) -> system.setLogLevel(logger, level));
329327
}
330328

331329
protected void setLogLevels(LoggingSystem system, Environment environment) {

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -262,6 +262,18 @@ public void parseDebugArg() {
262262
assertThat(this.outputCapture.toString()).doesNotContain("testattrace");
263263
}
264264

265+
@Test
266+
public void parseDebugArgExpandGroups() {
267+
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "debug");
268+
this.initializer.initialize(this.context.getEnvironment(),
269+
this.context.getClassLoader());
270+
this.logFactory.getInstance("org.springframework.boot.actuate.endpoint.web")
271+
.debug("testdebugwebgroup");
272+
this.logFactory.getInstance("org.hibernate.SQL").debug("testdebugsqlgroup");
273+
assertThat(this.outputCapture.toString()).contains("testdebugwebgroup");
274+
assertThat(this.outputCapture.toString()).contains("testdebugsqlgroup");
275+
}
276+
265277
@Test
266278
public void parseTraceArg() {
267279
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "trace");

0 commit comments

Comments
 (0)