Связывание Java с несколькими SLF4J - проект также используется ch.qos.logback - PullRequest
0 голосов
/ 12 декабря 2018

Я работаю над двумя проектами: 1. Первый проект:

<groupId>org.abc</groupId>
<artifactId>db-manager</artifactId>
<version>18.11.1</version>
<packaging>jar</packaging>

второй проект:

org.abc data-fetcher 18.11.2 jar

оба имеют следующие зависимости:

<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 - Конец конфигурации.12: 58: 22,509 | -INFO в ch.qos.logback.classic.joran.JoranConfigurator@4520ebad - Регистрация текущей конфигурации в качестве безопасной резервной точки

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

Я добавил исключение, но есть некоторые конфликты, любая идеякак это решить?

...