Skip to content

Commit de001f5

Browse files
committed
Polish "Add standardized property to distinguish a group of applications"
See gh-39957
1 parent 8ddb77f commit de001f5

File tree

20 files changed

+73
-44
lines changed

20 files changed

+73
-44
lines changed

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

Lines changed: 3 additions & 6 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}.
@@ -43,11 +44,6 @@ class OtlpPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter<Ot
4344
*/
4445
private static final String DEFAULT_APPLICATION_NAME = "unknown_service";
4546

46-
/**
47-
* Default value for application group if {@code spring.application.group} is not set.
48-
*/
49-
private static final String DEFAULT_APPLICATION_GROUP = "unknown_group";
50-
5147
private final OpenTelemetryProperties openTelemetryProperties;
5248

5349
private final OtlpMetricsConnectionDetails connectionDetails;
@@ -93,7 +89,8 @@ private String getApplicationName() {
9389
}
9490

9591
private String getApplicationGroup() {
96-
return this.environment.getProperty("spring.application.group", DEFAULT_APPLICATION_GROUP);
92+
String applicationGroup = this.environment.getProperty("spring.application.group");
93+
return (StringUtils.hasLength(applicationGroup)) ? applicationGroup : null;
9794
}
9895

9996
@Override

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

Lines changed: 8 additions & 10 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.
@@ -53,11 +54,6 @@ public class OpenTelemetryAutoConfiguration {
5354
*/
5455
private static final String DEFAULT_APPLICATION_NAME = "unknown_service";
5556

56-
/**
57-
* Default value for application group if {@code spring.application.group} is not set.
58-
*/
59-
private static final String DEFAULT_APPLICATION_GROUP = "unknown_group";
60-
6157
private static final AttributeKey<String> ATTRIBUTE_KEY_SERVICE_NAME = AttributeKey.stringKey("service.name");
6258

6359
private static final AttributeKey<String> ATTRIBUTE_KEY_SERVICE_GROUP = AttributeKey.stringKey("service.group");
@@ -79,11 +75,13 @@ OpenTelemetrySdk openTelemetry(ObjectProvider<SdkTracerProvider> tracerProvider,
7975
@ConditionalOnMissingBean
8076
Resource openTelemetryResource(Environment environment, OpenTelemetryProperties properties) {
8177
String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
82-
String applicationGroup = environment.getProperty("spring.application.group", DEFAULT_APPLICATION_GROUP);
83-
return Resource.getDefault()
84-
.merge(Resource.create(Attributes.of(ATTRIBUTE_KEY_SERVICE_NAME, applicationName)))
85-
.merge(Resource.create(Attributes.of(ATTRIBUTE_KEY_SERVICE_GROUP, applicationGroup)))
86-
.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));
8785
}
8886

8987
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void shouldUseApplicationGroupIfServiceGroupIsNotSet() {
162162

163163
@Test
164164
void shouldUseDefaultApplicationGroupIfApplicationGroupIsNotSet() {
165-
assertThat(createAdapter().resourceAttributes()).containsEntry("service.group", "unknown_group");
165+
assertThat(createAdapter().resourceAttributes()).doesNotContainKey("service.group");
166166
}
167167

168168
private OtlpPropertiesConfigAdapter createAdapter() {

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/how-to/pages/properties-and-configuration.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ The preceding example YAML corresponds to the following `application.properties`
204204
[source,properties,subs="verbatim",configprops]
205205
----
206206
spring.application.name=cruncher
207-
spring.application.group=crunchGroup
208207
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
209208
spring.datasource.url=jdbc:mysql://localhost/test
210209
server.port=9000

spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/tracing.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ logging:
8888
pattern:
8989
correlation: "[${spring.application.name:},%X{traceId:-},%X{spanId:-}] "
9090
include-application-name: false
91-
include-application-group: false
9291
----
9392

94-
NOTE: In the example above, configprop:logging.include-application-name[] and configprop:logging.include-application-group[] is set to `false` to avoid the application name being duplicated in the log messages (configprop:logging.pattern.correlation[] already contains it).
93+
NOTE: In the example above, configprop:logging.include-application-name[] is set to `false` to avoid the application name being duplicated in the log messages (configprop:logging.pattern.correlation[] already contains it).
9594
It's also worth mentioning that configprop:logging.pattern.correlation[] contains a trailing space so that it is separated from the logger name that comes right after it by default.
9695

9796

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ NOTE: Logback does not have a `FATAL` level.
4444
It is mapped to `ERROR`.
4545

4646
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`.
47+
4748
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`.
4849

4950

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ private void setApplicationGroupSystemProperty(PropertyResolver resolver) {
260260
if (resolver.getProperty("logging.include-application-group", Boolean.class, Boolean.TRUE)) {
261261
String applicationGroup = resolver.getProperty("spring.application.group");
262262
if (StringUtils.hasText(applicationGroup)) {
263-
setSystemProperty(LoggingSystemProperty.APPLICATION_GROUP.getEnvironmentVariableName(),
263+
setSystemProperty(LoggingSystemProperty.LOGGED_APPLICATION_GROUP.getEnvironmentVariableName(),
264264
"[%s] ".formatted(applicationGroup));
265265
}
266266
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public enum LoggingSystemProperty {
3333
/**
3434
* Logging system property for the application group that should be logged.
3535
*/
36-
APPLICATION_GROUP("LOGGED_APPLICATION_GROUP"),
36+
LOGGED_APPLICATION_GROUP("LOGGED_APPLICATION_GROUP"),
3737

3838
/**
3939
* Logging system property for the process ID.

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
/**
2626
* Logback {@link ClassicConverter} to convert the
27-
* {@link LoggingSystemProperty#APPLICATION_GROUP APPLICATION_GROUP} into a value suitable
28-
* for logging. Similar to Logback's {@link PropertyConverter} but a non-existent property
29-
* is logged as an empty string rather than {@code null}.
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}.
3030
*
3131
* @author Jakob Wanger
3232
* @since 3.4.0
@@ -37,9 +37,10 @@ public class ApplicationGroupConverter extends ClassicConverter {
3737
public String convert(ILoggingEvent event) {
3838
String applicationGroup = event.getLoggerContextVO()
3939
.getPropertyMap()
40-
.get(LoggingSystemProperty.APPLICATION_GROUP.getEnvironmentVariableName());
40+
.get(LoggingSystemProperty.LOGGED_APPLICATION_GROUP.getEnvironmentVariableName());
4141
if (applicationGroup == null) {
42-
applicationGroup = System.getProperty(LoggingSystemProperty.APPLICATION_GROUP.getEnvironmentVariableName());
42+
applicationGroup = System
43+
.getProperty(LoggingSystemProperty.LOGGED_APPLICATION_GROUP.getEnvironmentVariableName());
4344
if (applicationGroup == null) {
4445
applicationGroup = "";
4546
}

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

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

7070
private void defaults(LogbackConfigurator config) {
71-
config.conversionRule("applicationName", ApplicationNameConverter.class);
7271
config.conversionRule("applicationGroup", ApplicationGroupConverter.class);
72+
config.conversionRule("applicationName", ApplicationNameConverter.class);
7373
config.conversionRule("clr", ColorConverter.class);
7474
config.conversionRule("correlationId", CorrelationIdConverter.class);
7575
config.conversionRule("wex", WhitespaceThrowableProxyConverter.class);
7676
config.conversionRule("wEx", ExtendedWhitespaceThrowableProxyConverter.class);
7777
config.getContext()
7878
.putProperty("CONSOLE_LOG_PATTERN", resolve(config, "${CONSOLE_LOG_PATTERN:-"
7979
+ "%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) "
80-
+ "%clr(${PID:- }){magenta} %clr(---){faint} %clr(%applicationName[%15.15t]){faint} %clr(---){faint} %clr(%applicationGroup[%15.15t]){faint} "
80+
+ "%clr(${PID:- }){magenta} %clr(---){faint} %clr(%applicationName%applicationGroup[%15.15t]){faint} "
8181
+ "%clr(${LOG_CORRELATION_PATTERN:-}){faint}%clr(%-40.40logger{39}){cyan} "
8282
+ "%clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"));
8383
String defaultCharset = Charset.defaultCharset().name();
@@ -86,7 +86,7 @@ private void defaults(LogbackConfigurator config) {
8686
config.getContext().putProperty("CONSOLE_LOG_THRESHOLD", resolve(config, "${CONSOLE_LOG_THRESHOLD:-TRACE}"));
8787
config.getContext()
8888
.putProperty("FILE_LOG_PATTERN", resolve(config, "${FILE_LOG_PATTERN:-"
89-
+ "%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- %applicationName[%t] --- %applicationGroup[%t] "
89+
+ "%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- %applicationName%applicationGroup[%t] "
9090
+ "${LOG_CORRELATION_PATTERN:-}"
9191
+ "%-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"));
9292
config.getContext()

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{---}{faint} %clr{${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>
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{---}{faint} %clr{${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>
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ Default logback configuration provided for import
55
-->
66

77
<included>
8-
<conversionRule conversionWord="applicationName" converterClass="org.springframework.boot.logging.logback.ApplicationNameConverter" />
98
<conversionRule conversionWord="applicationGroup" converterClass="org.springframework.boot.logging.logback.ApplicationGroupConverter" />
9+
<conversionRule conversionWord="applicationName" converterClass="org.springframework.boot.logging.logback.ApplicationNameConverter" />
1010
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
1111
<conversionRule conversionWord="correlationId" converterClass="org.springframework.boot.logging.logback.CorrelationIdConverter" />
1212
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
1313
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
1414

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[%15.15t]){faint} %clr(---){faint} %clr(%applicationGroup[%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}}"/>
1616
<property name="CONSOLE_LOG_CHARSET" value="${CONSOLE_LOG_CHARSET:-${file.encoding:-UTF-8}}"/>
1717
<property name="CONSOLE_LOG_THRESHOLD" value="${CONSOLE_LOG_THRESHOLD:-TRACE}"/>
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[%t] --- %applicationGroup[%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}}"/>
1919
<property name="FILE_LOG_CHARSET" value="${FILE_LOG_CHARSET:-${file.encoding:-UTF-8}}"/>
2020
<property name="FILE_LOG_THRESHOLD" value="${FILE_LOG_THRESHOLD:-TRACE}"/>
2121

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,20 @@ void loggedApplicationNameWhenApplicationNameLoggingDisabled() {
159159
@Test
160160
void loggedApplicationGroupWhenHasApplicationGroup() {
161161
new LoggingSystemProperties(new MockEnvironment().withProperty("spring.application.group", "test")).apply(null);
162-
assertThat(getSystemProperty(LoggingSystemProperty.APPLICATION_GROUP)).isEqualTo("[test] ");
162+
assertThat(getSystemProperty(LoggingSystemProperty.LOGGED_APPLICATION_GROUP)).isEqualTo("[test] ");
163163
}
164164

165165
@Test
166166
void loggedApplicationGroupWhenHasNoApplicationGroup() {
167167
new LoggingSystemProperties(new MockEnvironment()).apply(null);
168-
assertThat(getSystemProperty(LoggingSystemProperty.APPLICATION_GROUP)).isNull();
168+
assertThat(getSystemProperty(LoggingSystemProperty.LOGGED_APPLICATION_GROUP)).isNull();
169169
}
170170

171171
@Test
172172
void loggedApplicationGroupWhenApplicationGroupLoggingDisabled() {
173173
new LoggingSystemProperties(new MockEnvironment().withProperty("spring.application.group", "test")
174174
.withProperty("logging.include-application-group", "false")).apply(null);
175-
assertThat(getSystemProperty(LoggingSystemProperty.APPLICATION_GROUP)).isNull();
175+
assertThat(getSystemProperty(LoggingSystemProperty.LOGGED_APPLICATION_GROUP)).isNull();
176176
}
177177

178178
@Test

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/ApplicationGroupConverterTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ void whenLoggedApplicationGroupConvertReturnsIt() {
6565

6666
private void withLoggedApplicationGroup(String group, Runnable action) {
6767
if (group == null) {
68-
System.clearProperty(LoggingSystemProperty.APPLICATION_GROUP.getEnvironmentVariableName());
68+
System.clearProperty(LoggingSystemProperty.LOGGED_APPLICATION_GROUP.getEnvironmentVariableName());
6969
}
7070
else {
71-
System.setProperty(LoggingSystemProperty.APPLICATION_GROUP.getEnvironmentVariableName(), group);
71+
System.setProperty(LoggingSystemProperty.LOGGED_APPLICATION_GROUP.getEnvironmentVariableName(), group);
7272
}
7373
try {
7474
action.run();
7575
}
7676
finally {
77-
System.clearProperty(LoggingSystemProperty.APPLICATION_GROUP.getEnvironmentVariableName());
77+
System.clearProperty(LoggingSystemProperty.LOGGED_APPLICATION_GROUP.getEnvironmentVariableName());
7878
}
7979
}
8080

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-log4j2/src/main/resources/application.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
spring.application.name=sample
2+
spring.application.group=sample-group
3+
#logging.include-application-name=false
4+
#logging.include-application-group=false
25
spring.security.user.name=user
36
spring.security.user.password=password
47
management.endpoint.shutdown.enabled=true

0 commit comments

Comments
 (0)