我有一个使用log4j的应用程序,我将logback starter添加到了同一应用程序以获取其他功能。
由于slf4j只能绑定到一个日志记录框架,因此出现logback-classic-1.2.4.jar和log4j-slf4j-impl-2.11.2.jar错误。
是否有一种方法可以告诉slf4j忽略log4j,而又不会从maven依赖项中排除log4j-slf4j-impl?
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/.m2/repository/ch/qos/logback/logback-
classic/1.2.3/logback-classic-
1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/.m2/repository/org/apache/logging/log4j/log4j-slf4j-
impl/2.11.2/log4j-slf4j-impl-
2.11.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
explanation.
SLF4J: Actual binding is of type
[ch.qos.logback.classic.util.ContextSelectorStaticBinder]
[ERR] Caused by: java.lang.IllegalArgumentException: LoggerFactory is not
a Logback LoggerContext but Logback is on the classpath. Either remove
Logback or the competing implementation (class
org.apache.logging.slf4j.Log4jLoggerFactory loaded from
jar:file:/home/app/BOOT-INF/lib/log4j-slf4j-impl-2.10.0.jar!/). If you are
using WebLogic you will need to add 'org.slf4j' to prefer-application-
packages in WEB-INF/weblogic.xml:
org.apache.logging.slf4j.Log4jLoggerFactory