Skip to content

Debug mode is not logging web and sql related loggers #16018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -320,12 +321,11 @@ private void initializeFinalLoggingLevels(ConfigurableEnvironment environment,
}

protected void initializeLogLevel(LoggingSystem system, LogLevel level) {
List<String> loggers = LOG_LEVEL_LOGGERS.get(level);
if (loggers != null) {
for (String logger : loggers) {
system.setLogLevel(logger, level);
}
}
Optional.ofNullable(LOG_LEVEL_LOGGERS.get(level)).orElse(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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -315,6 +315,21 @@ public void parseDebugArg() {
assertThat(this.outputCapture.toString()).doesNotContain("testattrace");
}

@Test
public void parseDebugArgExpandGroups() {
addPropertiesToEnvironment(this.context, "debug");
this.initializer.initialize(this.context.getEnvironment(),
this.context.getClassLoader());
ch.qos.logback.classic.Logger sqlGroup = this.loggerContext
.getLogger("org.hibernate.SQL");
ch.qos.logback.classic.Logger webGroup = this.loggerContext
.getLogger("org.springframework.boot.actuate.endpoint.web");
webGroup.debug("testdebugwebgroup");
sqlGroup.debug("testdebugsqlgroup");
assertThat(this.outputCapture.toString()).contains("testdebugwebgroup");
assertThat(this.outputCapture.toString()).contains("testdebugsqlgroup");
}

@Test
public void parseTraceArg() {
addPropertiesToEnvironment(this.context, "trace");
Expand Down