Java Multiple SLF4J绑定-项目也请使用ch.qos.logback

时间:2018-12-12 11:28:16

标签: dependencies pom.xml logback slf4j logback-classic

我从事两个项目: 1.第一个项目:

<groupId>org.abc</groupId>
<artifactId>db-manager</artifactId>
<version>18.11.1</version>
<packaging>jar</packaging>
  1. 第二个项目:

    org.abc     数据获取器     18.11.2     罐子

都具有以下依赖性:

<dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.2.3</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

第二个项目将第一个作为依赖项:

<dependency>
            <groupId>org.abc</groupId>
            <artifactId>db-manager</artifactId>
            <version>18.11.1</version>
            <exclusions>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

但是当我运行代码时,我收到以下消息:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/<myPath>/.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:/C:/Users/<myPath>/.m2/repository/org/abc/db-manager/18.11.1/db-manager-18.11.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
12:58:22,338 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
12:58:22,339 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
12:58:22,339 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/C:/Users/<my_path>/.m2/repository/org/abc/db-manager/18.11.1/db-manager-18.11.1.jar!/logback.xml]
12:58:22,340 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath.
12:58:22,340 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/C:/Users/<my_path>/.m2/repository/org/abc/data-model/18.11.2/data-model-18.11.2.jar!/logback.xml]
12:58:22,340 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/C:/Users/<my_path>/.m2/repository/org/abc/db-manager/18.11.1/db-manager-18.11.1.jar!/logback.xml]
12:58:22,365 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@735b5592 - URL [jar:file:/C:/Users/<my_path>/.m2/repository/org/abc/db-manager/18.11.1/db-manager-18.11.1.jar!/logback.xml] is not of type file
12:58:22,435 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
12:58:22,437 |-INFO in ch.qos.logback.classic.joran.action.LoggerContextListenerAction - Adding LoggerContextListener of type [ch.qos.logback.classic.jul.LevelChangePropagator] to the object stack
12:58:22,449 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@58651fd0 - Propagating DEBUG level on Logger[ROOT] onto the JUL framework
12:58:22,449 |-INFO in ch.qos.logback.classic.joran.action.LoggerContextListenerAction - Starting LoggerContextListener
12:58:22,449 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
12:58:22,452 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [console]
12:58:22,454 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:58:22,506 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.abc] to DEBUG
12:58:22,506 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@58651fd0 - Propagating DEBUG level on Logger[com.abc] onto the JUL framework
12:58:22,506 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.maven] to DEBUG
12:58:22,506 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@58651fd0 - Propagating DEBUG level on Logger[org.apache.maven] onto the JUL framework
12:58:22,506 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.github.dockerjava] to INFO
12:58:22,506 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@58651fd0 - Propagating INFO level on Logger[com.github.dockerjava] onto the JUL framework
12:58:22,506 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [httpclient] to ERROR
12:58:22,506 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@58651fd0 - Propagating ERROR level on Logger[httpclient] onto the JUL framework
12:58:22,506 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [java] to ERROR
12:58:22,506 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@58651fd0 - Propagating ERROR level on Logger[java] onto the JUL framework
12:58:22,506 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache] to ERROR
12:58:22,506 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@58651fd0 - Propagating ERROR level on Logger[org.apache] onto the JUL framework
12:58:22,506 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.aragost.javahg.log.JULLogger] to ERROR
12:58:22,506 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@58651fd0 - Propagating ERROR level on Logger[com.aragost.javahg.log.JULLogger] onto the JUL framework
12:58:22,507 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [console] to Logger[ROOT]
12:58:22,507 |-INFO in 

ch.qos.logback.classic.joran.action.ConfigurationAction-配置结束。     ch.qos.logback.classic.joran.JoranConfigurator@4520ebad中的12:58:22,509 | -INFO-将当前配置注册为安全的后备点

SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

我添加了排除功能,但仍然存在一些冲突,您知道如何解决吗?

0 个答案:

没有答案