1

I am getting this error while I am using kafka producer API:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/haifa/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.29.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/haifa/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-0.9.28.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]

In my build.sbt I have the following dependencies:

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka-clients</artifactId>
    <version>2.0.0</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
     </exclusions>
</dependency>

I found this solution to exclude SFL4J from Kafka dependency using maven . But I can't find the equivalent solution while using sbt.

Anyone to help. Thanks.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
scalacode
  • 1,096
  • 1
  • 16
  • 38

1 Answers1

0

Logback depends on slf4j-api. You should be excluding slf4j-log4j12, which pulls the log4j bridge that kafka uses.

You would just add exclude to the end of the the sbt dependency

How to exclude commons-logging from a scala/sbt/slf4j project?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245