From fadd05412e0c16493430978a72ca2f44b232d68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Mon, 14 Oct 2024 17:03:20 +0200 Subject: [PATCH] Upgrade to Logback 1.5.10 Closes gh-42658 --- .../spring-boot-dependencies/build.gradle | 2 +- .../logging/logback/LogbackLoggingSystem.java | 25 +++++++++++-------- .../logback/LogbackLoggingSystemTests.java | 1 + 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 5fc8404a6e1..166a4713707 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1146,7 +1146,7 @@ bom { releaseNotes("https://github.com/apache/logging-log4j2/releases/tag/rel%2F{version}") } } - library("Logback", "1.5.8") { + library("Logback", "1.5.10") { group("ch.qos.logback") { modules = [ "logback-classic", diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index feac2947972..79dfff0370e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -84,17 +84,20 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF private static final String CONFIGURATION_FILE_PROPERTY = "logback.configurationFile"; - private static final LogLevels LEVELS = new LogLevels<>(); - - static { - LEVELS.map(LogLevel.TRACE, Level.TRACE); - LEVELS.map(LogLevel.TRACE, Level.ALL); - LEVELS.map(LogLevel.DEBUG, Level.DEBUG); - LEVELS.map(LogLevel.INFO, Level.INFO); - LEVELS.map(LogLevel.WARN, Level.WARN); - LEVELS.map(LogLevel.ERROR, Level.ERROR); - LEVELS.map(LogLevel.FATAL, Level.ERROR); - LEVELS.map(LogLevel.OFF, Level.OFF); + private static final LogLevels LEVELS = createLogLevels(); + + @SuppressWarnings("deprecation") + private static LogLevels createLogLevels() { + LogLevels levels = new LogLevels<>(); + levels.map(LogLevel.TRACE, Level.TRACE); + levels.map(LogLevel.TRACE, Level.ALL); + levels.map(LogLevel.DEBUG, Level.DEBUG); + levels.map(LogLevel.INFO, Level.INFO); + levels.map(LogLevel.WARN, Level.WARN); + levels.map(LogLevel.ERROR, Level.ERROR); + levels.map(LogLevel.FATAL, Level.ERROR); + levels.map(LogLevel.OFF, Level.OFF); + return levels; } private static final TurboFilter SUPPRESS_ALL_FILTER = new TurboFilter() { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java index 239ae546bb8..63a32cce5d6 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java @@ -286,6 +286,7 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { } @Test + @Deprecated(since = "3.3.5", forRemoval = true) void getLoggerConfigurationForALL() { this.loggingSystem.beforeInitialize(); initialize(this.initializationContext, null, null);