Skip to content

Commit 94e8c5d

Browse files
izeyesnicoll
authored andcommitted
Polish gh-39957 and gh-41444
See gh-42359
1 parent e3aac5d commit 94e8c5d

File tree

8 files changed

+21
-24
lines changed

8 files changed

+21
-24
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,13 +712,13 @@ The following listing shows three sample profiles:
712712
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].
713713
Doing so can be useful if you want to access values from your `application.properties` file in your Log4j2 configuration.
714714

715-
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`:
715+
The following example shows how to set Log4j2 properties named `applicationName` and `applicationGroup` that read `spring.application.name` and `spring.application.group` from the Spring `Environment`:
716716

717717
[source,xml]
718718
----
719719
<Properties>
720720
<Property name="applicationName">${spring:spring.application.name}</Property>
721-
<Property name="applicationProperty">${spring:spring.application.property}</Property>
721+
<Property name="applicationGroup">${spring:spring.application.group}</Property>
722722
</Properties>
723723
----
724724

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public enum LoggingSystemProperty {
3232

3333
/**
3434
* Logging system property for the application group that should be logged.
35+
* @since 3.4.0
3536
*/
3637
APPLICATION_GROUP("APPLICATION_GROUP", "spring.application.group", "logging.include-application-group"),
3738

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import org.apache.logging.log4j.core.pattern.PatternParser;
3030

3131
/**
32-
* Log4j2 {@link LogEventPatternConverter} used help format optional values that should be
33-
* shown enclosed in square brackets.
32+
* Log4j2 {@link LogEventPatternConverter} used to help format optional values that should
33+
* be shown enclosed in square brackets.
3434
*
3535
* @author Phillip Webb
3636
* @since 3.4.0

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.springframework.util.StringUtils;
2323

2424
/**
25-
* Logback {@link CompositeConverter} used help format optional values that should be
25+
* Logback {@link CompositeConverter} used to help format optional values that should be
2626
* shown enclosed in square brackets.
2727
*
2828
* @author Phillip Webb

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
@@ -164,19 +164,19 @@ void legacyLoggedApplicationNameWhenHasApplicationName() {
164164
}
165165

166166
@Test
167-
void loggedApplicationGroupWhenHasApplicationGroup() {
167+
void applicationGroupWhenHasApplicationGroup() {
168168
new LoggingSystemProperties(new MockEnvironment().withProperty("spring.application.group", "test")).apply(null);
169169
assertThat(getSystemProperty(LoggingSystemProperty.APPLICATION_GROUP)).isEqualTo("test");
170170
}
171171

172172
@Test
173-
void loggedApplicationGroupWhenHasNoApplicationGroup() {
173+
void applicationGroupWhenHasNoApplicationGroup() {
174174
new LoggingSystemProperties(new MockEnvironment()).apply(null);
175175
assertThat(getSystemProperty(LoggingSystemProperty.APPLICATION_GROUP)).isNull();
176176
}
177177

178178
@Test
179-
void loggedApplicationGroupWhenApplicationGroupLoggingDisabled() {
179+
void applicationGroupWhenApplicationGroupLoggingDisabled() {
180180
new LoggingSystemProperties(new MockEnvironment().withProperty("spring.application.group", "test")
181181
.withProperty("logging.include-application-group", "false")).apply(null);
182182
assertThat(getSystemProperty(LoggingSystemProperty.APPLICATION_GROUP)).isNull();

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ void applicationNameLoggingToConsoleWhenHasApplicationNameWithParenthesis(Captur
586586

587587
@Test
588588
void applicationNameLoggingToConsoleWhenDisabled(CapturedOutput output) {
589-
this.environment.setProperty("spring.application.name", "application-name");
589+
this.environment.setProperty("spring.application.name", "myapp");
590590
this.environment.setProperty("logging.include-application-name", "false");
591591
this.loggingSystem.setStandardConfigLocations(false);
592592
this.loggingSystem.beforeInitialize();
@@ -625,7 +625,7 @@ void applicationNameLoggingToFileWhenHasApplicationNameWithParenthesis() {
625625

626626
@Test
627627
void applicationNameLoggingToFileWhenDisabled() {
628-
this.environment.setProperty("spring.application.name", "application-name");
628+
this.environment.setProperty("spring.application.name", "myapp");
629629
this.environment.setProperty("logging.include-application-name", "false");
630630
new LoggingSystemProperties(this.environment).apply();
631631
File file = new File(tmpDir(), "log4j2-test.log");
@@ -661,15 +661,14 @@ void applicationGroupLoggingToConsoleWhenHasApplicationGroupWithParenthesis(Capt
661661

662662
@Test
663663
void applicationGroupLoggingToConsoleWhenDisabled(CapturedOutput output) {
664-
this.environment.setProperty("spring.application.group", "application-group");
664+
this.environment.setProperty("spring.application.group", "mygroup");
665665
this.environment.setProperty("logging.include-application-group", "false");
666666
this.loggingSystem.setStandardConfigLocations(false);
667667
this.loggingSystem.beforeInitialize();
668668
this.loggingSystem.initialize(this.initializationContext, null, null);
669669
this.logger.info("Hello world");
670-
assertThat(getLineWithText(output, "Hello world")).doesNotContain("${sys:LOGGED_APPLICATION_GROUP}")
671-
.doesNotContain("${sys:APPLICATION_GROUP}")
672-
.doesNotContain("myapp");
670+
assertThat(getLineWithText(output, "Hello world")).doesNotContain("${sys:APPLICATION_GROUP}")
671+
.doesNotContain("mygroup");
673672
}
674673

675674
@Test
@@ -700,7 +699,7 @@ void applicationGroupLoggingToFileWhenHasApplicationGroupWithParenthesis() {
700699

701700
@Test
702701
void applicationGroupLoggingToFileWhenDisabled() {
703-
this.environment.setProperty("spring.application.group", "application-group");
702+
this.environment.setProperty("spring.application.group", "mygroup");
704703
this.environment.setProperty("logging.include-application-group", "false");
705704
new LoggingSystemProperties(this.environment).apply();
706705
File file = new File(tmpDir(), "log4j2-test.log");
@@ -709,9 +708,8 @@ void applicationGroupLoggingToFileWhenDisabled() {
709708
this.loggingSystem.beforeInitialize();
710709
this.loggingSystem.initialize(this.initializationContext, null, logFile);
711710
this.logger.info("Hello world");
712-
assertThat(getLineWithText(file, "Hello world")).doesNotContain("${sys:LOGGED_APPLICATION_GROUP}")
713-
.doesNotContain("${sys:APPLICATION_GROUP}")
714-
.doesNotContain("myapp");
711+
assertThat(getLineWithText(file, "Hello world")).doesNotContain("${sys:APPLICATION_GROUP}")
712+
.doesNotContain("mygroup");
715713
}
716714

717715
@Test

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.nio.charset.Charset;
2121
import java.nio.charset.StandardCharsets;
2222
import java.nio.file.Path;
23-
import java.util.Arrays;
2423
import java.util.EnumSet;
2524
import java.util.HashSet;
2625
import java.util.List;
@@ -571,8 +570,7 @@ void initializeShouldApplyLogbackSystemPropertiesToTheContext() {
571570
Stream.of(LoggingSystemProperty.values())
572571
.map(LoggingSystemProperty::getEnvironmentVariableName)
573572
.forEach(expectedProperties::add);
574-
expectedProperties
575-
.removeAll(Arrays.asList("LOG_FILE", "LOG_PATH", "LOGGED_APPLICATION_NAME", "LOGGED_APPLICATION_GROUP"));
573+
expectedProperties.removeAll(List.of("LOG_FILE", "LOG_PATH"));
576574
expectedProperties.add("org.jboss.logging.provider");
577575
expectedProperties.add("LOG_CORRELATION_PATTERN");
578576
expectedProperties.add("CONSOLE_LOG_STRUCTURED_FORMAT");
@@ -822,7 +820,7 @@ void applicationNameLoggingToFileWhenHasApplicationNameWithParenthesis() {
822820
}
823821

824822
@Test
825-
void applicationNameLoggingToFileWhenDisabled(CapturedOutput output) {
823+
void applicationNameLoggingToFileWhenDisabled() {
826824
this.environment.setProperty("spring.application.name", "myapp");
827825
this.environment.setProperty("logging.include-application-name", "false");
828826
File file = new File(tmpDir(), "logback-test.log");
@@ -939,7 +937,7 @@ void applicationGroupLoggingToFileWhenHasApplicationGroupWithParenthesis() {
939937
}
940938

941939
@Test
942-
void applicationGroupLoggingToFileWhenDisabled(CapturedOutput output) {
940+
void applicationGroupLoggingToFileWhenDisabled() {
943941
this.environment.setProperty("spring.application.group", "myGroup");
944942
this.environment.setProperty("logging.include-application-group", "false");
945943
File file = new File(tmpDir(), "logback-test.log");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Configuration status="WARN" monitorInterval="30">
33
<Properties>
44
<Property name="PID">????</Property>
5-
<Property name="LOG_PATTERN">%clr{%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{${sys:LOGGED_APPLICATION_NAME:-}${sys:LOGGED_APPLICATION_GROUP:-}[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n%xwEx</Property>
5+
<Property name="LOG_PATTERN">%clr{%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{${sys:APPLICATION_NAME:-}${sys:APPLICATION_GROUP:-}[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n%xwEx</Property>
66
</Properties>
77
<Appenders>
88
<Console name="Console" target="SYSTEM_OUT" follow="true">

0 commit comments

Comments
 (0)