diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java index ac2854b9dd7..e9415ac11ae 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -320,12 +320,10 @@ public class LoggingApplicationListener implements GenericApplicationListener { } protected void initializeLogLevel(LoggingSystem system, LogLevel level) { - List loggers = LOG_LEVEL_LOGGERS.get(level); - if (loggers != null) { - for (String logger : loggers) { - system.setLogLevel(logger, level); - } - } + LOG_LEVEL_LOGGERS.getOrDefault(level, Collections.emptyList()).stream() + .flatMap((logger) -> DEFAULT_GROUP_LOGGERS + .getOrDefault(logger, Collections.singletonList(logger)).stream()) + .forEach((logger) -> system.setLogLevel(logger, level)); } protected void setLogLevels(LoggingSystem system, Environment environment) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java index 8f5cafa3ac4..b0a4d711679 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -262,6 +262,18 @@ public class LoggingApplicationListenerTests { assertThat(this.outputCapture.toString()).doesNotContain("testattrace"); } + @Test + public void parseDebugArgExpandGroups() { + TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "debug"); + this.initializer.initialize(this.context.getEnvironment(), + this.context.getClassLoader()); + this.logFactory.getInstance("org.springframework.boot.actuate.endpoint.web") + .debug("testdebugwebgroup"); + this.logFactory.getInstance("org.hibernate.SQL").debug("testdebugsqlgroup"); + assertThat(this.outputCapture.toString()).contains("testdebugwebgroup"); + assertThat(this.outputCapture.toString()).contains("testdebugsqlgroup"); + } + @Test public void parseTraceArg() { TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "trace");