You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@apex.apache.org by Claire Yuan <cl...@yahoo-inc.com> on 2017/06/15 20:52:37 UTC

problem regarding multi binding in slf4j

Hi all,  I am currently running the example in apache beam project and got some issue that I could not fix. I used the maven compile and here is what I noticed in building project:SLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding in [jar:file:/home/claireyuan/.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:/home/claireyuan/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.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]  I check online with this problem and did some modification to the pom.xml file. Here is my dependency with SLF4J:    <dependency>      <groupId>org.apache.beam</groupId>      <artifactId>beam-sdks-java-core</artifactId>
      <exclusions>        <exclusion>          <groupId>org.slf4j</groupId>          <artifactId>slf4j-log4j12</artifactId>        </exclusion>        <exclusion>          <groupId>log4j</groupId>          <artifactId>log4j</artifactId>        </exclusion>      </exclusions>Also with something added:    <dependency>      <groupId>ch.qos.logback</groupId>      <artifactId>logback-classic</artifactId>      <version>1.2.3</version>    </dependency>But seems like this problem still not solved. Would any of you provide any suggestion with this?
Claire


Re: problem regarding multi binding in slf4j

Posted by Lukasz Cwik <lc...@google.com>.
SLF4J only supports a single logging backend (e.g. slf4j-log4j12), when
there are multiple on the classpath it uses the first one that is found.

You want to make sure that only one logging backend is on your classpath.
You can ensure that your project only uses one logging backend by using the
Maven dependency plugin (
https://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html) like
so:
mvn dependency:tree -Dverbose

This will give you a tree of dependencies for your project. You'll want to
update your pom.xml and add exclusions for exclude any additional slf4j
logging backends that are found in the dependency tree.

Also, to get logging integration across multiple logging APIs, you'll want
to install bridges that adapt the different types of loggers to become
SLF4J loggers. More details about that on the SLF4J site
https://www.slf4j.org/legacy.html

You can also find lots of similar questions with answers about this on
stackoverflow, such as how to deal with multiple backends, how to exclude a
transitive maven dependency, etc....





On Thu, Jun 15, 2017 at 1:52 PM, Claire Yuan <cl...@yahoo-inc.com>
wrote:

> Hi all,
>   I am currently running the example in apache beam project and got some
> issue that I could not fix. I used the maven compile and here is what I
> noticed in building project:
> SLF4J: Class path contains multiple SLF4J bindings.
> SLF4J: Found binding in [jar:file:/home/claireyuan/.
> 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:/home/claireyuan/.
> m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.
> 7.5.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]
>   I check online with this problem and did some modification to the
> pom.xml file. Here is my dependency with SLF4J:
>     <dependency>
>       <groupId>org.apache.beam</groupId>
>       <artifactId>beam-sdks-java-core</artifactId>
>
>       <exclusions>
>         <exclusion>
>           <groupId>org.slf4j</groupId>
>           <artifactId>slf4j-log4j12</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>log4j</groupId>
>           <artifactId>log4j</artifactId>
>         </exclusion>
>       </exclusions>
> Also with something added:
>     <dependency>
>       <groupId>ch.qos.logback</groupId>
>       <artifactId>logback-classic</artifactId>
>       <version>1.2.3</version>
>     </dependency>
> But seems like this problem still not solved. Would any of you provide any
> suggestion with this?
>
> Claire
>
>
>

Re: problem regarding multi binding in slf4j

Posted by Lukasz Cwik <lc...@google.com>.
SLF4J only supports a single logging backend (e.g. slf4j-log4j12), when
there are multiple on the classpath it uses the first one that is found.

You want to make sure that only one logging backend is on your classpath.
You can ensure that your project only uses one logging backend by using the
Maven dependency plugin (
https://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html) like
so:
mvn dependency:tree -Dverbose

This will give you a tree of dependencies for your project. You'll want to
update your pom.xml and add exclusions for exclude any additional slf4j
logging backends that are found in the dependency tree.

Also, to get logging integration across multiple logging APIs, you'll want
to install bridges that adapt the different types of loggers to become
SLF4J loggers. More details about that on the SLF4J site
https://www.slf4j.org/legacy.html

You can also find lots of similar questions with answers about this on
stackoverflow, such as how to deal with multiple backends, how to exclude a
transitive maven dependency, etc....





On Thu, Jun 15, 2017 at 1:52 PM, Claire Yuan <cl...@yahoo-inc.com>
wrote:

> Hi all,
>   I am currently running the example in apache beam project and got some
> issue that I could not fix. I used the maven compile and here is what I
> noticed in building project:
> SLF4J: Class path contains multiple SLF4J bindings.
> SLF4J: Found binding in [jar:file:/home/claireyuan/.
> 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:/home/claireyuan/.
> m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.
> 7.5.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]
>   I check online with this problem and did some modification to the
> pom.xml file. Here is my dependency with SLF4J:
>     <dependency>
>       <groupId>org.apache.beam</groupId>
>       <artifactId>beam-sdks-java-core</artifactId>
>
>       <exclusions>
>         <exclusion>
>           <groupId>org.slf4j</groupId>
>           <artifactId>slf4j-log4j12</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>log4j</groupId>
>           <artifactId>log4j</artifactId>
>         </exclusion>
>       </exclusions>
> Also with something added:
>     <dependency>
>       <groupId>ch.qos.logback</groupId>
>       <artifactId>logback-classic</artifactId>
>       <version>1.2.3</version>
>     </dependency>
> But seems like this problem still not solved. Would any of you provide any
> suggestion with this?
>
> Claire
>
>
>