Spring引导以不同的顺序加载日志类

Spring引导以不同的顺序加载日志类,spring,spring-boot,slf4j,logback-classic,Spring,Spring Boot,Slf4j,Logback Classic,我不知道你们中有多少人熟悉这一点,但在两个不同的环境中运行同一个应用程序会导致我的spring boot应用程序以不同的顺序加载其日志依赖项。Im使用logback-classic-1.1.7以及slfj4j-log4j12-1.7.13运行 现在,我知道logback已经嵌入了slfj(至少,现在我知道了),它通常会显示一个多绑定警告,然后它会继续。应用程序将启动 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found

我不知道你们中有多少人熟悉这一点,但在两个不同的环境中运行同一个应用程序会导致我的spring boot应用程序以不同的顺序加载其日志依赖项。Im使用logback-classic-1.1.7以及slfj4j-log4j12-1.7.13运行

现在,我知道logback已经嵌入了slfj(至少,现在我知道了),它通常会显示一个多绑定警告,然后它会继续。应用程序将启动

SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/root/dev2/target/lib/logback-classic-
1.1.7.jar! /org/slf4j/impl/StaticLoggerBinder.class]
SLF4J:  Found binding in [jar:file:/root/dev2/target/lib/
slf4j/slf4j-jdk14/1.5.3/slf4j-jdk14 1.5.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Actual binding is of type
[ch.qos.logback.classic.util.ContextSelectorStaticBinder]
//Spring then starts the app successfully here. 
我读到过,有时候当slf4j发现多个绑定时,它会随机选择一个。我已经消除了另一个不必要的依赖,这解决了我的问题。我更感兴趣的是,为什么同一个应用程序在同一个linux版本的不同服务器上运行时会加载错误的记录器。在另一个环境中运行时,尝试启动时的结果是:

SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J:  Found binding in [jar:file:/root/dev3/target/lib/
slf4j/slf4j-jdk14/1.5.3/slf4j-jdk14 1.5.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/dev3/target/lib/logback-classic-
1.1.7.jar! /org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: Actual binding is of type
[org.slf4j.impl.Log4jLoggerFactory]
Exception is in thread "main" java.lang.IllegalArgumentException: LoggerFactory
is not a Logback LoggerContext but Logback is on the classpath. 
Either remove Logback or the competing 
implemenataion (class org.slf4j.iml.Log4jLoggerFactory...
//app then fails to start 
在这种环境中,它以相反的顺序加载两个相互竞争的记录器,然后应用程序无法启动。有人知道更多关于Spring加载依赖项的行为,以及为什么它会在不同的环境中以不同的顺序加载依赖项吗?这导致此错误在一段时间内未被注意到。这两个环境具有相同的linux版本


提前感谢

您运行的是同一个罐子吗?是的,是同一个罐子,所以它是外部的。。?