diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 3190484914..d661da2b3e 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -776,7 +776,7 @@ bom { ] } } - library("Log4j2", "2.19.0") { + library("Log4j2", "2.20.0") { group("org.apache.logging.log4j") { imports = [ "log4j-bom" diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java index 5f28a16b16..7d80489779 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java @@ -159,7 +159,7 @@ class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { assertThat(output).contains("Hello world").contains(tmpDir() + "/tmp.log"); assertThat(new File(tmpDir() + "/tmp.log")).doesNotExist(); assertThat(configuration.getConfigurationSource().getFile().getAbsolutePath()) - .contains("log4j2-nondefault.xml"); + .contains("log4j2-nondefault.xml"); assertThat(configuration.getWatchManager().getIntervalSeconds()).isEqualTo(30); } @@ -236,7 +236,7 @@ class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { this.loggingSystem.setLogLevel(getClass().getName(), LogLevel.DEBUG); LoggerConfiguration configuration = this.loggingSystem.getLoggerConfiguration(getClass().getName()); assertThat(configuration) - .isEqualTo(new LoggerConfiguration(getClass().getName(), LogLevel.DEBUG, LogLevel.DEBUG)); + .isEqualTo(new LoggerConfiguration(getClass().getName(), LogLevel.DEBUG, LogLevel.DEBUG)); } @Test @@ -391,7 +391,7 @@ class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { this.loggingSystem.setLogLevel("com.example.test", LogLevel.DEBUG); LoggerConfiguration configuration = this.loggingSystem.getLoggerConfiguration("com.example.test"); assertThat(configuration) - .isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.DEBUG, LogLevel.DEBUG)); + .isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.DEBUG, LogLevel.DEBUG)); this.loggingSystem.setLogLevel("com.example.test", null); LoggerConfiguration updatedConfiguration = this.loggingSystem.getLoggerConfiguration("com.example.test"); assertThat(updatedConfiguration).isNull(); @@ -402,18 +402,17 @@ class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false); this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(this.initializationContext, null, null); - loggerContext.getConfiguration() - .addLogger("com.example.test", - new LoggerConfig("com.example.test", org.apache.logging.log4j.Level.INFO, false)); + loggerContext.getConfiguration().addLogger("com.example.test", + new LoggerConfig("com.example.test", org.apache.logging.log4j.Level.INFO, false)); this.loggingSystem.setLogLevel("com.example", LogLevel.WARN); this.loggingSystem.setLogLevel("com.example.test", LogLevel.DEBUG); LoggerConfiguration configuration = this.loggingSystem.getLoggerConfiguration("com.example.test"); assertThat(configuration) - .isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.DEBUG, LogLevel.DEBUG)); + .isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.DEBUG, LogLevel.DEBUG)); this.loggingSystem.setLogLevel("com.example.test", null); LoggerConfiguration updatedConfiguration = this.loggingSystem.getLoggerConfiguration("com.example.test"); assertThat(updatedConfiguration) - .isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.WARN, LogLevel.WARN)); + .isEqualTo(new LoggerConfiguration("com.example.test", LogLevel.WARN, LogLevel.WARN)); } @Test @@ -427,6 +426,7 @@ class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { this.loggingSystem.initialize(this.initializationContext, null, null); java.util.logging.Logger logger = java.util.logging.Logger.getLogger(Log4J2LoggingSystemTests.class.getName()); + logger.info("Log to trigger level propagation"); assertThat(logger.getLevel()).isNull(); this.loggingSystem.setLogLevel(Log4J2LoggingSystemTests.class.getName(), LogLevel.DEBUG); assertThat(logger.getLevel()).isEqualTo(Level.FINE); @@ -436,7 +436,7 @@ class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { void shutdownHookIsDisabled() { assertThat( PropertiesUtil.getProperties().getBooleanProperty(ShutdownCallbackRegistry.SHUTDOWN_HOOK_ENABLED, true)) - .isFalse(); + .isFalse(); } @Test @@ -475,11 +475,9 @@ class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { void nonFileUrlsAreResolvedUsingLog4J2UrlConnectionFactory() { this.loggingSystem.beforeInitialize(); assertThatIllegalStateException() - .isThrownBy(() -> this.loggingSystem.initialize(this.initializationContext, - "http://localhost:8080/shouldnotwork", null)) - .havingCause() - .isInstanceOf(ProtocolException.class) - .withMessageContaining("http has not been enabled"); + .isThrownBy(() -> this.loggingSystem.initialize(this.initializationContext, + "http://localhost:8080/shouldnotwork", null)) + .havingCause().isInstanceOf(ProtocolException.class).withMessageContaining("http has not been enabled"); } private String getRelativeClasspathLocation(String fileName) {