【问题标题】:SLF4J Defaulting to Log4j over logback even when binding doesn't existSLF4J 在 logback 上默认为 Log4j,即使绑定不存在
【发布时间】:2014-10-27 15:34:28
【问题描述】:

我正在尝试让 SLF4J 绑定到 logback,但它默认为 Log4j。

我已经为 logback 配置了所有默认配置文件,以及绑定。

我的类路径有以下相关的 jar:

logback-经典 commons-logging (99.0-does-not-exist) //空 jar 以排除 commons-logging logback 核心 logback-ext-spring

注意:不存在 log4j 依赖项。

这是一个 spring mvc 应用程序。

在启动时 SLF4J 有以下输出:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/masierp/Documents/springsource/vfabric-tc-server-developer-2.8.2.RELEASE/blablahbkla/wtpwebapps/ilm-engine/WEB-INF/lib/activemq-all-5.7.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/masierp/Documents/springsource/vfabric-tc-server-developer-2.8.2.RELEASE/blablahbkla/wtpwebapps/ilm-engine/WEB-INF/lib/logback-classic-1.1.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 [org.slf4j.impl.Log4jLoggerFactory]

请注意,找到的绑定都不是 log4j 绑定。

我弄乱了 spring-ext(试图将它用作 spring 监听器),但无论有没有这个 jar,问题仍然存在。

任何帮助表示赞赏,谢谢。

【问题讨论】:

    标签: java logging log4j slf4j logback


    【解决方案1】:

    可能您的依赖项之一具有 log4j 依赖项。你需要排除它。 尝试查看父 pom。

    【讨论】:

    • mvn 依赖:树 | grep "log4j" 什么也不返回。我已经删除了所有 log4j 依赖项。
    • 你确定项目中没有 JAR 可能意外地被 Log4j 包装了吗?
    猜你喜欢
    • 2014-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-23
    相关资源
    最近更新 更多