Upgrade to Logback 1.5.4

Closes gh-40267
This commit is contained in:
Andy Wilkinson 2024-04-09 13:03:44 +01:00
parent 09b3cd260a
commit daf0088e56
4 changed files with 15 additions and 9 deletions

View File

@ -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"
]

View File

@ -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.
*/

View File

@ -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 <springProperty> 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) {

View File

@ -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