From bbf0932f0f81c18449f36946a4b0415a8cc66234 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 7 Dec 2018 15:37:24 +0000 Subject: [PATCH] Exclude jcl-over-slf4j in favour of spring-jcl Closes gh-15392 --- .../spring-boot-dependencies/pom.xml | 6 ++++++ .../spring-boot-starter-data-solr/pom.xml | 10 ---------- spring-boot-project/spring-boot-test/pom.xml | 5 ----- .../spring-boot-loader/pom.xml | 5 ----- spring-boot-project/spring-boot/pom.xml | 5 ----- .../LoggingApplicationListenerTests.java | 19 +++++++++++-------- .../logback/LogbackLoggingSystemTests.java | 7 +++---- .../spring-boot-sample-data-cassandra/pom.xml | 6 ++++++ .../spring-boot-launch-script-tests/pom.xml | 6 ++++++ 9 files changed, 32 insertions(+), 37 deletions(-) diff --git a/spring-boot-project/spring-boot-dependencies/pom.xml b/spring-boot-project/spring-boot-dependencies/pom.xml index 13346660ba..53f3f9a8b0 100644 --- a/spring-boot-project/spring-boot-dependencies/pom.xml +++ b/spring-boot-project/spring-boot-dependencies/pom.xml @@ -1696,6 +1696,12 @@ org.apache.solr solr-solrj ${solr.version} + + + org.slf4j + jcl-over-slf4j + + org.apache.solr diff --git a/spring-boot-project/spring-boot-starters/spring-boot-starter-data-solr/pom.xml b/spring-boot-project/spring-boot-starters/spring-boot-starter-data-solr/pom.xml index f5f5f2b1a7..c5ce104c76 100644 --- a/spring-boot-project/spring-boot-starters/spring-boot-starter-data-solr/pom.xml +++ b/spring-boot-project/spring-boot-starters/spring-boot-starter-data-solr/pom.xml @@ -22,16 +22,6 @@ org.apache.solr solr-solrj - - - log4j - log4j - - - org.slf4j - jcl-over-slf4j - - org.springframework.data diff --git a/spring-boot-project/spring-boot-test/pom.xml b/spring-boot-project/spring-boot-test/pom.xml index 57c734f394..0c49019128 100644 --- a/spring-boot-project/spring-boot-test/pom.xml +++ b/spring-boot-project/spring-boot-test/pom.xml @@ -172,11 +172,6 @@ kotlin-runtime test - - org.slf4j - jcl-over-slf4j - test - org.slf4j slf4j-api diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/pom.xml b/spring-boot-project/spring-boot-tools/spring-boot-loader/pom.xml index 4c5d8b7bab..23b840832e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/pom.xml +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/pom.xml @@ -21,11 +21,6 @@ true - - org.slf4j - jcl-over-slf4j - test - ch.qos.logback logback-classic diff --git a/spring-boot-project/spring-boot/pom.xml b/spring-boot-project/spring-boot/pom.xml index 6debcfc737..933cd542d9 100644 --- a/spring-boot-project/spring-boot/pom.xml +++ b/spring-boot-project/spring-boot/pom.xml @@ -373,11 +373,6 @@ postgresql test - - org.slf4j - jcl-over-slf4j - test - org.springframework spring-context-support diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java index d566e8d40c..cd59e5eea7 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java @@ -26,15 +26,16 @@ import java.util.logging.Handler; import java.util.logging.LogManager; import java.util.logging.Logger; +import ch.qos.logback.classic.LoggerContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.commons.logging.impl.SLF4JLogFactory; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.bridge.SLF4JBridgeHandler; +import org.slf4j.impl.StaticLoggerBinder; import org.springframework.boot.SpringApplication; import org.springframework.boot.context.event.ApplicationFailedEvent; @@ -89,9 +90,11 @@ public class LoggingApplicationListenerTests { private final LoggingApplicationListener initializer = new LoggingApplicationListener(); - private final SLF4JLogFactory logFactory = new SLF4JLogFactory(); + private final LoggerContext loggerContext = (LoggerContext) StaticLoggerBinder + .getSingleton().getLoggerFactory(); - private final Log logger = this.logFactory.getInstance(getClass()); + private final ch.qos.logback.classic.Logger logger = this.loggerContext + .getLogger(getClass()); private final SpringApplication springApplication = new SpringApplication(); @@ -404,9 +407,9 @@ public class LoggingApplicationListenerTests { this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); this.logger.debug("testatdebug"); - this.logger.fatal("testatfatal"); + this.logger.error("testaterror"); assertThat(this.outputCapture.toString()).doesNotContain("testatdebug") - .doesNotContain("testatfatal"); + .doesNotContain("testaterror"); } @Test @@ -416,9 +419,9 @@ public class LoggingApplicationListenerTests { this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); this.logger.debug("testatdebug"); - this.logger.fatal("testatfatal"); + this.logger.error("testaterror"); assertThat(this.outputCapture.toString()).doesNotContain("testatdebug") - .doesNotContain("testatfatal"); + .doesNotContain("testaterror"); } @Test @@ -657,7 +660,7 @@ public class LoggingApplicationListenerTests { } private void assertTraceEnabled(String name, boolean expected) { - assertThat(this.logFactory.getInstance(name).isTraceEnabled()) + assertThat(this.loggerContext.getLogger(name).isTraceEnabled()) .isEqualTo(expected); } 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 6b1c37268c..0d0e65ba9a 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 @@ -31,8 +31,6 @@ import ch.qos.logback.core.ConsoleAppender; import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.rolling.RollingFileAppender; import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.impl.SLF4JLogFactory; import org.hamcrest.Matcher; import org.hamcrest.Matchers; import org.junit.After; @@ -87,7 +85,7 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { private final LogbackLoggingSystem loggingSystem = new LogbackLoggingSystem( getClass().getClassLoader()); - private Log logger; + private Logger logger; private LoggingInitializationContext initializationContext; @@ -96,7 +94,8 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { @Before public void setup() { this.loggingSystem.cleanUp(); - this.logger = new SLF4JLogFactory().getInstance(getClass().getName()); + this.logger = ((LoggerContext) StaticLoggerBinder.getSingleton() + .getLoggerFactory()).getLogger(getClass()); this.environment = new MockEnvironment(); this.initializationContext = new LoggingInitializationContext(this.environment); } diff --git a/spring-boot-samples/spring-boot-sample-data-cassandra/pom.xml b/spring-boot-samples/spring-boot-sample-data-cassandra/pom.xml index c362259e17..5da7445405 100644 --- a/spring-boot-samples/spring-boot-sample-data-cassandra/pom.xml +++ b/spring-boot-samples/spring-boot-sample-data-cassandra/pom.xml @@ -35,6 +35,12 @@ cassandra-unit-spring 3.5.0.1 test + + + org.slf4j + jcl-over-slf4j + + diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/pom.xml b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/pom.xml index 0cbf662c00..e95d03aeb5 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/pom.xml +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/pom.xml @@ -34,6 +34,12 @@ docker-java 3.0.14 test + + + org.slf4j + jcl-over-slf4j + + org.springframework.boot