1

I get below error when I run a sample code like wordcount in Kafka Streams:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

I visited the link: https://www.slf4j.org/codes.html#StaticLoggerBinder and tried adding one of the slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar as mentioned in that link. but it didn't help.

I read that issue is with embedded maven version in eclipse but I tried creating project from console but still I ran into same issue.

  • Kafka Streams version - 0.11.0.0
  • Maven version - 3.3.9

is anyone aware of this issue? My next steps would be installing different maven version and try it.

miguno
  • 14,498
  • 3
  • 47
  • 63
  • This is a common maven/slf4j issue. Have you looked at existing SO threads such as https://stackoverflow.com/questions/12458469/slf4j-failed-to-load-class-org-slf4j-impl-staticloggerbinder-in-a-maven-proj? – miguno Sep 22 '17 at 07:20

1 Answers1

4

I had the same problem running any of the Kafka streams examples from the maven produced jar. It appears to me to be a simple compile/test dependency issue. Running:

mvn dependency:tree

the results show:

[INFO] +- org.apache.kafka:kafka-clients:jar:1.0.0-cp1:compile
[INFO] |  +- org.lz4:lz4-java:jar:1.4:compile
[INFO] |  +- org.xerial.snappy:snappy-java:jar:1.1.4:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
...
[INFO] +- io.confluent:common-utils:jar:4.0.0:compile
[INFO] \- org.slf4j:slf4j-log4j12:jar:1.7.25:test
[INFO]    \- log4j:log4j:jar:1.2.17:test

So the slf4j-log4j12 jar is only included in the test environment. I added the following to the pom.xml

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.25</version>
</dependency>
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>

Rebuilding the jar and running with the appropriate log4j command line argument, the examples all now use logging. eg:

java -cp kafka-streams-examples-4.0.0-standalone.jar -Dlog4j.configuration=file:log4j.properties io.confluent.examples.streams.GlobalKTablesExample broker:9092 http://schema_registry:8081