依赖关系添加到pom.xml导致多个SLF4J绑定

时间:2017-06-08 07:47:49

标签: java maven log4j slf4j

我向我的pom.xml添加了一个新的依赖项(browsermob-proxy),显然它包含一些slf4j绑定。因此,当我执行我的代码时,会打印出以下警告消息:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/PATH/.m2/repository/net/lightbody/bmp/browsermob-proxy/2.1.4/browsermob-proxy-2.1.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/PATH/.m2/repository/org/slf4j/slf4j-jcl/1.7.6/slf4j-jcl-1.7.6.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.apache.logging.slf4j.Log4jLoggerFactory]
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

我尝试排除所有与slf4j有关的依赖项或从新依赖项(browsermob-proxy)中记录,如下所示:

<dependency>
        <groupId>net.lightbody.bmp</groupId>
        <artifactId>browsermob-proxy</artifactId>
        <version>2.1.4</version>

        <exclusions>

            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>

            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl-over-slf4j</artifactId>
            </exclusion>

            <exclusion>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
            </exclusion>

            <exclusion>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
            </exclusion>

            <exclusion>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-slf4j-impl</artifactId>
            </exclusion>

        </exclusions>
</dependency>

要发现所有这些依赖项,我只是查看了browsermob-proxy pom.xml

然而,做所有这些没有帮助,我仍然得到完全相同的警告。我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

我认为警告意味着browsermob-proxy-2.1.4.jar中有一个StaticLoggerBinder.class,而不是它的依赖项。但我无法在maven中央回购中找到这个罐子,所以目前无法验证。

您最好检查一下jar,看看是否存在org / slf4j / impl / StaticLoggerBinder

相关问题