Logback 1.3 and SLF4J 2.0

pull/31033/head
Andy Wilkinson 3 years ago
parent 4cb9d95b49
commit f39a080a0e

@ -813,7 +813,7 @@ bom {
] ]
} }
} }
library("Logback", "1.2.11") { library("Logback", "1.3.0-alpha15") {
group("ch.qos.logback") { group("ch.qos.logback") {
modules = [ modules = [
"logback-access", "logback-access",
@ -1289,7 +1289,7 @@ bom {
] ]
} }
} }
library("SLF4J", "1.7.36") { library("SLF4J", "2.0.0-alpha7") {
group("org.slf4j") { group("org.slf4j") {
modules = [ modules = [
"jcl-over-slf4j", "jcl-over-slf4j",

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,7 @@ package org.springframework.boot.loader.tools;
import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Level;
import org.slf4j.ILoggerFactory; import org.slf4j.ILoggerFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.impl.StaticLoggerBinder; import org.slf4j.LoggerFactory;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -32,7 +32,7 @@ import org.springframework.util.ClassUtils;
public abstract class LogbackInitializer { public abstract class LogbackInitializer {
public static void initialize() { public static void initialize() {
if (ClassUtils.isPresent("org.slf4j.impl.StaticLoggerBinder", null) if (ClassUtils.isPresent("org.slf4j.LoggerFactory", null)
&& ClassUtils.isPresent("ch.qos.logback.classic.Logger", null)) { && ClassUtils.isPresent("ch.qos.logback.classic.Logger", null)) {
new Initializer().setRootLogLevel(); new Initializer().setRootLogLevel();
} }
@ -41,7 +41,7 @@ public abstract class LogbackInitializer {
private static class Initializer { private static class Initializer {
void setRootLogLevel() { void setRootLogLevel() {
ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory(); ILoggerFactory factory = LoggerFactory.getILoggerFactory();
Logger logger = factory.getLogger(Logger.ROOT_LOGGER_NAME); Logger logger = factory.getLogger(Logger.ROOT_LOGGER_NAME);
((ch.qos.logback.classic.Logger) logger).setLevel(Level.INFO); ((ch.qos.logback.classic.Logger) logger).setLevel(Level.INFO);
} }

@ -39,9 +39,9 @@ import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.util.StatusListenerConfigHelper; import ch.qos.logback.core.util.StatusListenerConfigHelper;
import org.slf4j.ILoggerFactory; import org.slf4j.ILoggerFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker; import org.slf4j.Marker;
import org.slf4j.bridge.SLF4JBridgeHandler; import org.slf4j.bridge.SLF4JBridgeHandler;
import org.slf4j.impl.StaticLoggerBinder;
import org.springframework.boot.logging.AbstractLoggingSystem; import org.springframework.boot.logging.AbstractLoggingSystem;
import org.springframework.boot.logging.LogFile; import org.springframework.boot.logging.LogFile;
@ -348,7 +348,7 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem {
} }
private LoggerContext getLoggerContext() { private LoggerContext getLoggerContext() {
ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory(); ILoggerFactory factory = LoggerFactory.getILoggerFactory();
Assert.isInstanceOf(LoggerContext.class, factory, Assert.isInstanceOf(LoggerContext.class, factory,
() -> String.format( () -> String.format(
"LoggerFactory is not a Logback LoggerContext but Logback is on " "LoggerFactory is not a Logback LoggerContext but Logback is on "

Loading…
Cancel
Save