diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/StructuredLoggingLayout.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/StructuredLoggingLayout.java index a198cbc9abd3..e0e45944f6c8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/StructuredLoggingLayout.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/StructuredLoggingLayout.java @@ -240,7 +240,7 @@ static final class Builder implements org.apache.logging.log4j.core.util.Builder private String serviceEnvironment; @PluginBuilderAttribute - private boolean logMdc = true; + private boolean logMdc; @Override public StructuredLoggingLayout build() { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java index c0592f3e5bfa..17026916195b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java @@ -161,6 +161,7 @@ private StructuredLoggingEncoder createStructuredLoggingEncoder(LogbackConfigura encoder.setFormat(format); encoder.setCharset(charset); encoder.setPid(resolveLong(config, "${PID:--1}")); + encoder.setLogMdc(true); String applicationName = resolve(config, "${APPLICATION_NAME:-}"); if (StringUtils.hasLength(applicationName)) { encoder.setServiceName(applicationName); diff --git a/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2-file.xml b/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2-file.xml index 1c3ab463ff13..83ce0d8ce4da 100644 --- a/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2-file.xml +++ b/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2-file.xml @@ -11,10 +11,10 @@ diff --git a/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2.xml b/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2.xml index 973fee731517..ec5e474d1479 100644 --- a/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2.xml +++ b/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2.xml @@ -11,7 +11,7 @@