Skip to content

Commit b79159e

Browse files
committed
Merge pull request #39957 from wanger26
* pr/39957: Polish "Add standardized property to distinguish a group of applications" Add standardized property to distinguish a group of applications Closes gh-39957
2 parents edafc78 + de001f5 commit b79159e

File tree

21 files changed

+393
-16
lines changed

21 files changed

+393
-16
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpPropertiesConfigAdapter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.boot.actuate.autoconfigure.opentelemetry.OpenTelemetryProperties;
2929
import org.springframework.core.env.Environment;
3030
import org.springframework.util.CollectionUtils;
31+
import org.springframework.util.StringUtils;
3132

3233
/**
3334
* Adapter to convert {@link OtlpProperties} to an {@link OtlpConfig}.
@@ -79,13 +80,19 @@ public Map<String, String> resourceAttributes() {
7980
Map<String, String> result = new HashMap<>((!CollectionUtils.isEmpty(resourceAttributes)) ? resourceAttributes
8081
: get(OtlpProperties::getResourceAttributes, OtlpConfig.super::resourceAttributes));
8182
result.computeIfAbsent("service.name", (key) -> getApplicationName());
83+
result.computeIfAbsent("service.group", (key) -> getApplicationGroup());
8284
return Collections.unmodifiableMap(result);
8385
}
8486

8587
private String getApplicationName() {
8688
return this.environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
8789
}
8890

91+
private String getApplicationGroup() {
92+
String applicationGroup = this.environment.getProperty("spring.application.group");
93+
return (StringUtils.hasLength(applicationGroup)) ? applicationGroup : null;
94+
}
95+
8996
@Override
9097
public Map<String, String> headers() {
9198
return get(OtlpProperties::getHeaders, OtlpConfig.super::headers);

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/OpenTelemetryAutoConfiguration.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3737
import org.springframework.context.annotation.Bean;
3838
import org.springframework.core.env.Environment;
39+
import org.springframework.util.StringUtils;
3940

4041
/**
4142
* {@link EnableAutoConfiguration Auto-configuration} for OpenTelemetry.
@@ -55,6 +56,8 @@ public class OpenTelemetryAutoConfiguration {
5556

5657
private static final AttributeKey<String> ATTRIBUTE_KEY_SERVICE_NAME = AttributeKey.stringKey("service.name");
5758

59+
private static final AttributeKey<String> ATTRIBUTE_KEY_SERVICE_GROUP = AttributeKey.stringKey("service.group");
60+
5861
@Bean
5962
@ConditionalOnMissingBean(OpenTelemetry.class)
6063
OpenTelemetrySdk openTelemetry(ObjectProvider<SdkTracerProvider> tracerProvider,
@@ -72,9 +75,13 @@ OpenTelemetrySdk openTelemetry(ObjectProvider<SdkTracerProvider> tracerProvider,
7275
@ConditionalOnMissingBean
7376
Resource openTelemetryResource(Environment environment, OpenTelemetryProperties properties) {
7477
String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
75-
return Resource.getDefault()
76-
.merge(Resource.create(Attributes.of(ATTRIBUTE_KEY_SERVICE_NAME, applicationName)))
77-
.merge(toResource(properties));
78+
String applicationGroup = environment.getProperty("spring.application.group");
79+
Resource resource = Resource.getDefault()
80+
.merge(Resource.create(Attributes.of(ATTRIBUTE_KEY_SERVICE_NAME, applicationName)));
81+
if (StringUtils.hasLength(applicationGroup)) {
82+
resource = resource.merge(Resource.create(Attributes.of(ATTRIBUTE_KEY_SERVICE_GROUP, applicationGroup)));
83+
}
84+
return resource.merge(toResource(properties));
7885
}
7986

8087
private static Resource toResource(OpenTelemetryProperties properties) {

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpPropertiesConfigAdapterTests.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,32 @@ void shouldUseDefaultApplicationNameIfApplicationNameIsNotSet() {
139139
assertThat(createAdapter().resourceAttributes()).containsEntry("service.name", "unknown_service");
140140
}
141141

142+
@Test
143+
@SuppressWarnings("removal")
144+
void serviceGroupOverridesApplicationGroup() {
145+
this.environment.setProperty("spring.application.group", "alpha");
146+
this.properties.setResourceAttributes(Map.of("service.group", "beta"));
147+
assertThat(createAdapter().resourceAttributes()).containsEntry("service.group", "beta");
148+
}
149+
150+
@Test
151+
void serviceGroupOverridesApplicationGroupWhenUsingOtelProperties() {
152+
this.environment.setProperty("spring.application.group", "alpha");
153+
this.openTelemetryProperties.setResourceAttributes(Map.of("service.group", "beta"));
154+
assertThat(createAdapter().resourceAttributes()).containsEntry("service.group", "beta");
155+
}
156+
157+
@Test
158+
void shouldUseApplicationGroupIfServiceGroupIsNotSet() {
159+
this.environment.setProperty("spring.application.group", "alpha");
160+
assertThat(createAdapter().resourceAttributes()).containsEntry("service.group", "alpha");
161+
}
162+
163+
@Test
164+
void shouldUseDefaultApplicationGroupIfApplicationGroupIsNotSet() {
165+
assertThat(createAdapter().resourceAttributes()).doesNotContainKey("service.group");
166+
}
167+
142168
private OtlpPropertiesConfigAdapter createAdapter() {
143169
return new OtlpPropertiesConfigAdapter(this.properties, this.openTelemetryProperties, this.connectionDetails,
144170
this.environment);

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/OpenTelemetryAutoConfigurationTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,23 @@ void shouldApplySpringApplicationNameToResource() {
9090
});
9191
}
9292

93+
@Test
94+
void shouldApplySpringApplicationGroupToResource() {
95+
this.runner.withPropertyValues("spring.application.group=my-group").run((context) -> {
96+
Resource resource = context.getBean(Resource.class);
97+
assertThat(resource.getAttributes().asMap())
98+
.contains(entry(AttributeKey.stringKey("service.group"), "my-group"));
99+
});
100+
}
101+
102+
@Test
103+
void shouldNotApplySpringApplicationGroupIfNotSet() {
104+
this.runner.run((context) -> {
105+
Resource resource = context.getBean(Resource.class);
106+
assertThat(resource.getAttributes().asMap()).doesNotContainKey(AttributeKey.stringKey("service.group"));
107+
});
108+
}
109+
93110
@Test
94111
void shouldFallbackToDefaultApplicationNameIfSpringApplicationNameIsNotSet() {
95112
this.runner.run((context) -> {

spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/features/logging.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The following items are output:
3434
* Process ID.
3535
* A `---` separator to distinguish the start of actual log messages.
3636
* Application name: Enclosed in square brackets (logged by default only if configprop:spring.application.name[] is set)
37+
* Application group: Enclosed in square brackets (logged by default only if configprop:spring.application.group[] is set)
3738
* Thread name: Enclosed in square brackets (may be truncated for console output).
3839
* Correlation ID: If tracing is enabled (not shown in the sample above)
3940
* Logger name: This is usually the source class name (often abbreviated).
@@ -44,6 +45,8 @@ It is mapped to `ERROR`.
4445

4546
TIP: If you have a configprop:spring.application.name[] property but don't want it logged you can set configprop:logging.include-application-name[] to `false`.
4647

48+
TIP: If you have a configprop:spring.application.group[] property but don't want it logged you can set configprop:logging.include-application-group[] to `false`.
49+
4750

4851

4952
[[features.logging.console-output]]
@@ -544,12 +547,13 @@ The following listing shows three sample profiles:
544547
If you want to refer to properties from your Spring `Environment` within your Log4j2 configuration you can use `spring:` prefixed https://logging.apache.org/log4j/2.x/manual/lookups.html[lookups].
545548
Doing so can be useful if you want to access values from your `application.properties` file in your Log4j2 configuration.
546549

547-
The following example shows how to set a Log4j2 property named `applicationName` that reads `spring.application.name` from the Spring `Environment`:
550+
The following example shows how to set a Log4j2 property named `applicationName` and `applicationGroup` that reads `spring.application.name` and `spring.application.group` from the Spring `Environment`:
548551

549552
[source,xml]
550553
----
551554
<Properties>
552555
<Property name="applicationName">${spring:spring.application.name}</Property>
556+
<Property name="applicationProperty">${spring:spring.application.property}</Property>
553557
</Properties>
554558
----
555559

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ private PropertyResolver getPropertyResolver() {
229229
protected void apply(LogFile logFile, PropertyResolver resolver) {
230230
String defaultCharsetName = getDefaultCharset().name();
231231
setApplicationNameSystemProperty(resolver);
232+
setApplicationGroupSystemProperty(resolver);
232233
setSystemProperty(LoggingSystemProperty.PID, new ApplicationPid().toString());
233234
setSystemProperty(LoggingSystemProperty.CONSOLE_CHARSET, resolver, defaultCharsetName);
234235
setSystemProperty(LoggingSystemProperty.FILE_CHARSET, resolver, defaultCharsetName);
@@ -255,6 +256,16 @@ private void setApplicationNameSystemProperty(PropertyResolver resolver) {
255256
}
256257
}
257258

259+
private void setApplicationGroupSystemProperty(PropertyResolver resolver) {
260+
if (resolver.getProperty("logging.include-application-group", Boolean.class, Boolean.TRUE)) {
261+
String applicationGroup = resolver.getProperty("spring.application.group");
262+
if (StringUtils.hasText(applicationGroup)) {
263+
setSystemProperty(LoggingSystemProperty.LOGGED_APPLICATION_GROUP.getEnvironmentVariableName(),
264+
"[%s] ".formatted(applicationGroup));
265+
}
266+
}
267+
}
268+
258269
private void setSystemProperty(LoggingSystemProperty property, PropertyResolver resolver) {
259270
setSystemProperty(property, resolver, Function.identity());
260271
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public enum LoggingSystemProperty {
3030
*/
3131
APPLICATION_NAME("LOGGED_APPLICATION_NAME"),
3232

33+
/**
34+
* Logging system property for the application group that should be logged.
35+
*/
36+
LOGGED_APPLICATION_GROUP("LOGGED_APPLICATION_GROUP"),
37+
3338
/**
3439
* Logging system property for the process ID.
3540
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2012-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.logging.logback;
18+
19+
import ch.qos.logback.classic.pattern.ClassicConverter;
20+
import ch.qos.logback.classic.pattern.PropertyConverter;
21+
import ch.qos.logback.classic.spi.ILoggingEvent;
22+
23+
import org.springframework.boot.logging.LoggingSystemProperty;
24+
25+
/**
26+
* Logback {@link ClassicConverter} to convert the
27+
* {@link LoggingSystemProperty#LOGGED_APPLICATION_GROUP APPLICATION_GROUP} into a value
28+
* suitable for logging. Similar to Logback's {@link PropertyConverter} but a non-existent
29+
* property is logged as an empty string rather than {@code null}.
30+
*
31+
* @author Jakob Wanger
32+
* @since 3.4.0
33+
*/
34+
public class ApplicationGroupConverter extends ClassicConverter {
35+
36+
@Override
37+
public String convert(ILoggingEvent event) {
38+
String applicationGroup = event.getLoggerContextVO()
39+
.getPropertyMap()
40+
.get(LoggingSystemProperty.LOGGED_APPLICATION_GROUP.getEnvironmentVariableName());
41+
if (applicationGroup == null) {
42+
applicationGroup = System
43+
.getProperty(LoggingSystemProperty.LOGGED_APPLICATION_GROUP.getEnvironmentVariableName());
44+
if (applicationGroup == null) {
45+
applicationGroup = "";
46+
}
47+
}
48+
return applicationGroup;
49+
}
50+
51+
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ void apply(LogbackConfigurator config) {
6868
}
6969

7070
private void defaults(LogbackConfigurator config) {
71+
config.conversionRule("applicationGroup", ApplicationGroupConverter.class);
7172
config.conversionRule("applicationName", ApplicationNameConverter.class);
7273
config.conversionRule("clr", ColorConverter.class);
7374
config.conversionRule("correlationId", CorrelationIdConverter.class);
@@ -76,7 +77,7 @@ private void defaults(LogbackConfigurator config) {
7677
config.getContext()
7778
.putProperty("CONSOLE_LOG_PATTERN", resolve(config, "${CONSOLE_LOG_PATTERN:-"
7879
+ "%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) "
79-
+ "%clr(${PID:- }){magenta} %clr(---){faint} %clr(%applicationName[%15.15t]){faint} "
80+
+ "%clr(${PID:- }){magenta} %clr(---){faint} %clr(%applicationName%applicationGroup[%15.15t]){faint} "
8081
+ "%clr(${LOG_CORRELATION_PATTERN:-}){faint}%clr(%-40.40logger{39}){cyan} "
8182
+ "%clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"));
8283
String defaultCharset = Charset.defaultCharset().name();
@@ -85,7 +86,7 @@ private void defaults(LogbackConfigurator config) {
8586
config.getContext().putProperty("CONSOLE_LOG_THRESHOLD", resolve(config, "${CONSOLE_LOG_THRESHOLD:-TRACE}"));
8687
config.getContext()
8788
.putProperty("FILE_LOG_PATTERN", resolve(config, "${FILE_LOG_PATTERN:-"
88-
+ "%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- %applicationName[%t] "
89+
+ "%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- %applicationName%applicationGroup[%t] "
8990
+ "${LOG_CORRELATION_PATTERN:-}"
9091
+ "%-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"));
9192
config.getContext()

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackRuntimeHints.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ private void registerHintsForBuiltInLogbackConverters(ReflectionHints reflection
5858
}
5959

6060
private void registerHintsForSpringBootConverters(ReflectionHints reflection) {
61-
registerForPublicConstructorInvocation(reflection, ApplicationNameConverter.class, ColorConverter.class,
62-
ExtendedWhitespaceThrowableProxyConverter.class, WhitespaceThrowableProxyConverter.class,
63-
CorrelationIdConverter.class);
61+
registerForPublicConstructorInvocation(reflection, ApplicationNameConverter.class,
62+
ApplicationGroupConverter.class, ColorConverter.class, ExtendedWhitespaceThrowableProxyConverter.class,
63+
WhitespaceThrowableProxyConverter.class, CorrelationIdConverter.class);
6464
}
6565

6666
private void registerForPublicConstructorInvocation(ReflectionHints reflection, Class<?>... classes) {

spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@
103103
"description": "Log groups to quickly change multiple loggers at the same time. For instance, `logging.group.db=org.hibernate,org.springframework.jdbc`.",
104104
"sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener"
105105
},
106+
{
107+
"name": "logging.include-application-group",
108+
"type": "java.lang.Boolean",
109+
"description": "Whether to include the application group in the logs.",
110+
"sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener",
111+
"defaultValue": true
112+
},
106113
{
107114
"name": "logging.include-application-name",
108115
"type": "java.lang.Boolean",
@@ -228,6 +235,11 @@
228235
"description": "Log level threshold for file output.",
229236
"defaultValue": "TRACE"
230237
},
238+
{
239+
"name": "spring.application.group",
240+
"type": "java.lang.String",
241+
"description": "Application group."
242+
},
231243
{
232244
"name": "spring.application.index",
233245
"type": "java.lang.Integer",

spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2-file.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property>
55
<Property name="LOG_LEVEL_PATTERN">%5p</Property>
66
<Property name="LOG_DATEFORMAT_PATTERN">yyyy-MM-dd'T'HH:mm:ss.SSSXXX</Property>
7-
<Property name="CONSOLE_LOG_PATTERN">%clr{%d{${sys:LOG_DATEFORMAT_PATTERN}}}{faint} %clr{${sys:LOG_LEVEL_PATTERN}} %clr{%pid}{magenta} %clr{---}{faint} %clr{${sys:LOGGED_APPLICATION_NAME:-}[%15.15t]}{faint} %clr{${sys:LOG_CORRELATION_PATTERN:-}}{faint}%clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
8-
<Property name="FILE_LOG_PATTERN">%d{${sys:LOG_DATEFORMAT_PATTERN}} ${sys:LOG_LEVEL_PATTERN} %pid --- ${sys:LOGGED_APPLICATION_NAME:-}[%t] ${sys:LOG_CORRELATION_PATTERN:-}%-40.40c{1.} : %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
7+
<Property name="CONSOLE_LOG_PATTERN">%clr{%d{${sys:LOG_DATEFORMAT_PATTERN}}}{faint} %clr{${sys:LOG_LEVEL_PATTERN}} %clr{%pid}{magenta} %clr{---}{faint} %clr{${sys:LOGGED_APPLICATION_NAME:-}${sys:LOGGED_APPLICATION_GROUP:-}[%15.15t]}{faint} %clr{${sys:LOG_CORRELATION_PATTERN:-}}{faint}%clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
8+
<Property name="FILE_LOG_PATTERN">%d{${sys:LOG_DATEFORMAT_PATTERN}} ${sys:LOG_LEVEL_PATTERN} %pid --- ${sys:LOGGED_APPLICATION_NAME:-}${sys:LOGGED_APPLICATION_GROUP:-}[%t] ${sys:LOG_CORRELATION_PATTERN:-}%-40.40c{1.} : %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
99
</Properties>
1010
<Appenders>
1111
<Console name="Console" target="SYSTEM_OUT" follow="true">

spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property>
55
<Property name="LOG_LEVEL_PATTERN">%5p</Property>
66
<Property name="LOG_DATEFORMAT_PATTERN">yyyy-MM-dd'T'HH:mm:ss.SSSXXX</Property>
7-
<Property name="CONSOLE_LOG_PATTERN">%clr{%d{${sys:LOG_DATEFORMAT_PATTERN}}}{faint} %clr{${sys:LOG_LEVEL_PATTERN}} %clr{%pid}{magenta} %clr{---}{faint} %clr{${sys:LOGGED_APPLICATION_NAME:-}[%15.15t]}{faint} %clr{${sys:LOG_CORRELATION_PATTERN:-}}{faint}%clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
8-
<Property name="FILE_LOG_PATTERN">%d{${sys:LOG_DATEFORMAT_PATTERN}} ${sys:LOG_LEVEL_PATTERN} %pid --- ${sys:LOGGED_APPLICATION_NAME:-}[%t] ${sys:LOG_CORRELATION_PATTERN:-}%-40.40c{1.} : %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
7+
<Property name="CONSOLE_LOG_PATTERN">%clr{%d{${sys:LOG_DATEFORMAT_PATTERN}}}{faint} %clr{${sys:LOG_LEVEL_PATTERN}} %clr{%pid}{magenta} %clr{---}{faint} %clr{${sys:LOGGED_APPLICATION_NAME:-}${sys:LOGGED_APPLICATION_GROUP:-}[%15.15t]}{faint} %clr{${sys:LOG_CORRELATION_PATTERN:-}}{faint}%clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
8+
<Property name="FILE_LOG_PATTERN">%d{${sys:LOG_DATEFORMAT_PATTERN}} ${sys:LOG_LEVEL_PATTERN} %pid --- ${sys:LOGGED_APPLICATION_NAME:-}${sys:LOGGED_APPLICATION_GROUP:-}[%t] ${sys:LOG_CORRELATION_PATTERN:-}%-40.40c{1.} : %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
99
</Properties>
1010
<Appenders>
1111
<Console name="Console" target="SYSTEM_OUT" follow="true">

spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/defaults.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ Default logback configuration provided for import
55
-->
66

77
<included>
8+
<conversionRule conversionWord="applicationGroup" converterClass="org.springframework.boot.logging.logback.ApplicationGroupConverter" />
89
<conversionRule conversionWord="applicationName" converterClass="org.springframework.boot.logging.logback.ApplicationNameConverter" />
910
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
1011
<conversionRule conversionWord="correlationId" converterClass="org.springframework.boot.logging.logback.CorrelationIdConverter" />
1112
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
1213
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
1314

14-
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr(%applicationName[%15.15t]){faint} %clr(${LOG_CORRELATION_PATTERN:-}){faint}%clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
15+
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr(%applicationName%applicationGroup[%15.15t]){faint} %clr(${LOG_CORRELATION_PATTERN:-}){faint}%clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
1516
<property name="CONSOLE_LOG_CHARSET" value="${CONSOLE_LOG_CHARSET:-${file.encoding:-UTF-8}}"/>
1617
<property name="CONSOLE_LOG_THRESHOLD" value="${CONSOLE_LOG_THRESHOLD:-TRACE}"/>
17-
<property name="FILE_LOG_PATTERN" value="${FILE_LOG_PATTERN:-%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- %applicationName[%t] ${LOG_CORRELATION_PATTERN:-}%-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
18+
<property name="FILE_LOG_PATTERN" value="${FILE_LOG_PATTERN:-%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- %applicationName%applicationGroup[%t] ${LOG_CORRELATION_PATTERN:-}%-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
1819
<property name="FILE_LOG_CHARSET" value="${FILE_LOG_CHARSET:-${file.encoding:-UTF-8}}"/>
1920
<property name="FILE_LOG_THRESHOLD" value="${FILE_LOG_THRESHOLD:-TRACE}"/>
2021

0 commit comments

Comments
 (0)