From d12b6b3a86d364087bd1a3e0c0df493b907101ac Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 25 Jun 2020 13:01:45 +0100 Subject: [PATCH] Disable LogbackLoggingSystem's XML support when spring.xml.ignore=true Closes gh-22106 --- .../boot/logging/logback/LogbackLoggingSystem.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 95e8a07efd..a9695fbf06 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 @@ -49,6 +49,7 @@ import org.springframework.boot.logging.LoggingInitializationContext; import org.springframework.boot.logging.LoggingSystem; import org.springframework.boot.logging.LoggingSystemProperties; import org.springframework.boot.logging.Slf4JLoggingSystem; +import org.springframework.core.SpringProperties; import org.springframework.core.env.Environment; import org.springframework.util.Assert; import org.springframework.util.ResourceUtils; @@ -65,6 +66,9 @@ import org.springframework.util.StringUtils; */ public class LogbackLoggingSystem extends Slf4JLoggingSystem { + // Static final field to facilitate code removal by Graal + private static final boolean XML_ENABLED = !SpringProperties.getFlag("spring.xml.ignore"); + private static final String CONFIGURATION_FILE_PROPERTY = "logback.configurationFile"; private static final LogLevels LEVELS = new LogLevels<>(); @@ -172,7 +176,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem { private void configureByResourceUrl(LoggingInitializationContext initializationContext, LoggerContext loggerContext, URL url) throws JoranException { - if (url.toString().endsWith("xml")) { + if (XML_ENABLED && url.toString().endsWith("xml")) { JoranConfigurator configurator = new SpringBootJoranConfigurator(initializationContext); configurator.setContext(loggerContext); configurator.doConfigure(url);