From 73ee97b0952f7698c5414a889ed96863b5b64b3f Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 21 Mar 2023 10:41:34 +0000 Subject: [PATCH] Upgrade to Logback 1.4.6 This commit includes a change to stop using an API in Logback that has been deprecated without replacement. As Logback now only supports .xml configuration files, it would only ever have thrown an exception. The call to the API has been replaced with thrown an exception directly. Closes gh-34686 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- .../boot/logging/logback/LogbackLoggingSystem.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 41a6a2ce06..8f1d2ac610 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -783,7 +783,7 @@ bom { ] } } - library("Logback", "1.4.5") { + library("Logback", "1.4.6") { group("ch.qos.logback") { modules = [ "logback-access", 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 b5f7030311..acbab04259 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 @@ -33,7 +33,6 @@ import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.joran.JoranConfigurator; import ch.qos.logback.classic.jul.LevelChangePropagator; import ch.qos.logback.classic.turbo.TurboFilter; -import ch.qos.logback.classic.util.ContextInitializer; import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.spi.FilterReply; import ch.qos.logback.core.status.OnConsoleStatusListener; @@ -272,13 +271,13 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF private void configureByResourceUrl(LoggingInitializationContext initializationContext, LoggerContext loggerContext, URL url) throws JoranException { - if (url.toString().endsWith("xml")) { + if (url.toString().endsWith(".xml")) { JoranConfigurator configurator = new SpringBootJoranConfigurator(initializationContext, this.configurators); configurator.setContext(loggerContext); configurator.doConfigure(url); } else { - new ContextInitializer(loggerContext).configureByResource(url); + throw new IllegalArgumentException("Unsupported file extension in '" + url + "'. Only .xml is supported"); } }