Skip to content

Commit 2c0c894

Browse files
committed
Upgrade to Log4j2 2.20.0
Closes gh-34349
1 parent a6bca29 commit 2c0c894

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

spring-boot-project/spring-boot-dependencies/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ bom {
776776
]
777777
}
778778
}
779-
library("Log4j2", "2.19.0") {
779+
library("Log4j2", "2.20.0") {
780780
group("org.apache.logging.log4j") {
781781
imports = [
782782
"log4j-bom"

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void testNonDefaultConfigLocation(CapturedOutput output) {
159159
assertThat(output).contains("Hello world").contains(tmpDir() + "/tmp.log");
160160
assertThat(new File(tmpDir() + "/tmp.log")).doesNotExist();
161161
assertThat(configuration.getConfigurationSource().getFile().getAbsolutePath())
162-
.contains("log4j2-nondefault.xml");
162+
.contains("log4j2-nondefault.xml");
163163
assertThat(configuration.getWatchManager().getIntervalSeconds()).isEqualTo(30);
164164
}
165165

@@ -236,7 +236,7 @@ void getLoggingConfiguration() {
236236
this.loggingSystem.setLogLevel(getClass().getName(), LogLevel.DEBUG);
237237
LoggerConfiguration configuration = this.loggingSystem.getLoggerConfiguration(getClass().getName());
238238
assertThat(configuration)
239-
.isEqualTo(new LoggerConfiguration(getClass().getName(), LogLevel.DEBUG, LogLevel.DEBUG));
239+
.isEqualTo(new LoggerConfiguration(getClass().getName(), LogLevel.DEBUG, LogLevel.DEBUG));
240240
}
241241

242242
@Test
@@ -391,7 +391,7 @@ void getLoggingConfigurationWithResetLevelReturnsNull() {
391391
this.loggingSystem.setLogLevel("com.example.test", LogLevel.DEBUG);
392392
LoggerConfiguration configuration = this.loggingSystem.getLoggerConfiguration("com.example.test");
393393
assertThat(configuration)
394-
.isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.DEBUG, LogLevel.DEBUG));
394+
.isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.DEBUG, LogLevel.DEBUG));
395395
this.loggingSystem.setLogLevel("com.example.test", null);
396396
LoggerConfiguration updatedConfiguration = this.loggingSystem.getLoggerConfiguration("com.example.test");
397397
assertThat(updatedConfiguration).isNull();
@@ -402,18 +402,17 @@ void getLoggingConfigurationWithResetLevelWhenAlreadyConfiguredReturnsParentConf
402402
LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false);
403403
this.loggingSystem.beforeInitialize();
404404
this.loggingSystem.initialize(this.initializationContext, null, null);
405-
loggerContext.getConfiguration()
406-
.addLogger("com.example.test",
407-
new LoggerConfig("com.example.test", org.apache.logging.log4j.Level.INFO, false));
405+
loggerContext.getConfiguration().addLogger("com.example.test",
406+
new LoggerConfig("com.example.test", org.apache.logging.log4j.Level.INFO, false));
408407
this.loggingSystem.setLogLevel("com.example", LogLevel.WARN);
409408
this.loggingSystem.setLogLevel("com.example.test", LogLevel.DEBUG);
410409
LoggerConfiguration configuration = this.loggingSystem.getLoggerConfiguration("com.example.test");
411410
assertThat(configuration)
412-
.isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.DEBUG, LogLevel.DEBUG));
411+
.isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.DEBUG, LogLevel.DEBUG));
413412
this.loggingSystem.setLogLevel("com.example.test", null);
414413
LoggerConfiguration updatedConfiguration = this.loggingSystem.getLoggerConfiguration("com.example.test");
415414
assertThat(updatedConfiguration)
416-
.isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.WARN, LogLevel.WARN));
415+
.isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.WARN, LogLevel.WARN));
417416
}
418417

419418
@Test
@@ -427,6 +426,7 @@ void log4jLevelsArePropagatedToJul() {
427426

428427
this.loggingSystem.initialize(this.initializationContext, null, null);
429428
java.util.logging.Logger logger = java.util.logging.Logger.getLogger(Log4J2LoggingSystemTests.class.getName());
429+
logger.info("Log to trigger level propagation");
430430
assertThat(logger.getLevel()).isNull();
431431
this.loggingSystem.setLogLevel(Log4J2LoggingSystemTests.class.getName(), LogLevel.DEBUG);
432432
assertThat(logger.getLevel()).isEqualTo(Level.FINE);
@@ -436,7 +436,7 @@ void log4jLevelsArePropagatedToJul() {
436436
void shutdownHookIsDisabled() {
437437
assertThat(
438438
PropertiesUtil.getProperties().getBooleanProperty(ShutdownCallbackRegistry.SHUTDOWN_HOOK_ENABLED, true))
439-
.isFalse();
439+
.isFalse();
440440
}
441441

442442
@Test
@@ -475,11 +475,9 @@ void initializeAddsSpringEnvironmentPropertySource() {
475475
void nonFileUrlsAreResolvedUsingLog4J2UrlConnectionFactory() {
476476
this.loggingSystem.beforeInitialize();
477477
assertThatIllegalStateException()
478-
.isThrownBy(() -> this.loggingSystem.initialize(this.initializationContext,
479-
"http://localhost:8080/shouldnotwork", null))
480-
.havingCause()
481-
.isInstanceOf(ProtocolException.class)
482-
.withMessageContaining("http has not been enabled");
478+
.isThrownBy(() -> this.loggingSystem.initialize(this.initializationContext,
479+
"http://localhost:8080/shouldnotwork", null))
480+
.havingCause().isInstanceOf(ProtocolException.class).withMessageContaining("http has not been enabled");
483481
}
484482

485483
private String getRelativeClasspathLocation(String fileName) {

0 commit comments

Comments
 (0)