diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 0b6f198ccc..8965eef0f0 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1080,10 +1080,9 @@ bom { releaseNotes("https://github.com/apache/logging-log4j2/releases/tag/rel%2F{version}") } } - library("Logback", "1.4.14") { + library("Logback", "1.5.4") { group("ch.qos.logback") { modules = [ - "logback-access", "logback-classic", "logback-core" ] 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 e5bddb3ab5..a4b9fca767 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 @@ -16,6 +16,7 @@ package org.springframework.boot.logging.logback; +import java.io.PrintStream; import java.net.URL; import java.security.CodeSource; import java.security.ProtectionDomain; @@ -38,7 +39,7 @@ import ch.qos.logback.core.status.OnConsoleStatusListener; import ch.qos.logback.core.status.Status; import ch.qos.logback.core.status.StatusUtil; import ch.qos.logback.core.util.StatusListenerConfigHelper; -import ch.qos.logback.core.util.StatusPrinter; +import ch.qos.logback.core.util.StatusPrinter2; import org.slf4j.ILoggerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -106,6 +107,8 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF }; + private final StatusPrinter2 statusPrinter = new StatusPrinter2(); + public LogbackLoggingSystem(ClassLoader classLoader) { super(classLoader); } @@ -271,7 +274,7 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF } if (errors.isEmpty()) { if (!StatusUtil.contextHasStatusListener(loggerContext)) { - StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); + this.statusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); } return; } @@ -473,6 +476,10 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF } } + void setStatusPrinterStream(PrintStream stream) { + this.statusPrinter.setPrintStream(stream); + } + /** * {@link LoggingSystemFactory} that returns {@link LogbackLoggingSystem} if possible. */ diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringPropertyModelHandler.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringPropertyModelHandler.java index ee69317e8e..1d0612b941 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringPropertyModelHandler.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringPropertyModelHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +20,10 @@ import ch.qos.logback.core.Context; import ch.qos.logback.core.joran.action.ActionUtil; import ch.qos.logback.core.joran.action.ActionUtil.Scope; import ch.qos.logback.core.model.Model; -import ch.qos.logback.core.model.ModelUtil; import ch.qos.logback.core.model.processor.ModelHandlerBase; import ch.qos.logback.core.model.processor.ModelHandlerException; import ch.qos.logback.core.model.processor.ModelInterpretationContext; +import ch.qos.logback.core.model.util.PropertyModelHandlerHelper; import ch.qos.logback.core.util.OptionHelper; import org.springframework.core.env.Environment; @@ -57,7 +57,8 @@ class SpringPropertyModelHandler extends ModelHandlerBase { if (OptionHelper.isNullOrEmpty(propertyModel.getName()) || OptionHelper.isNullOrEmpty(source)) { addError("The \"name\" and \"source\" attributes of must be set"); } - ModelUtil.setProperty(intercon, propertyModel.getName(), getValue(source, defaultValue), scope); + PropertyModelHandlerHelper.setProperty(intercon, propertyModel.getName(), getValue(source, defaultValue), + scope); } private String getValue(String source, String defaultValue) { 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 b381da5b24..c115d302c3 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 @@ -40,7 +40,6 @@ import ch.qos.logback.core.encoder.LayoutWrappingEncoder; import ch.qos.logback.core.rolling.RollingFileAppender; import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy; import ch.qos.logback.core.util.DynamicClassLoadingException; -import ch.qos.logback.core.util.StatusPrinter; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -121,7 +120,7 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { ConversionService conversionService = ApplicationConversionService.getSharedInstance(); this.environment.setConversionService((ConfigurableConversionService) conversionService); this.initializationContext = new LoggingInitializationContext(this.environment); - StatusPrinter.setPrintStream(System.out); + this.loggingSystem.setStatusPrinterStream(System.out); } @AfterEach