question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cp-kafka-connect fails inconsistently due to multiple loggers in classpath

See original GitHub issue

Hi!

This refers to cp-kafka-connect:7.0.1.

When running cp-kafka-connect docker image we stumble upon inconsistent behavior of SLF4J. The default CUB_CLASSPATH is set to /usr/share/java/cp-base-new/ where multiple loggers exists:

  • slf4j-simple-1.7.30.jar
  • slf4j-log4j12-1.7.30.jar

On one machine we consistently get the error:

===> Check if Kafka is healthy ...
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-simple-1.7.30.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]
log4j:WARN No appenders could be found for logger (io.confluent.admin.utils.cli.KafkaReadyCommand).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

So it finds multiple loggers (which are included in the image cp-kafka-connect), chooses Log4jLoggerFactory and proceeds to crash. The documentation provided (http://www.slf4j.org/codes.html#multiple_bindings) states that there should only be one logger defined in the class path.

However, on another machine we consistently get the output:

===> Check if Kafka is healthy ...
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-simple-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-log4j12-1.7.30.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.SimpleLoggerFactory]

In this case it happens to choose SimpleLoggerFactory instead of Log4jLoggerFactory, and proceeds happily.

Workaround Delete /usr/share/java/cp-base-new/slf4j-log4j12-1.7.30.jar

It seems like /usr/share/java/cp-base-new/slf4j-log4j12-1.7.30.jar should not exist in the classpath

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:7

github_iconTop GitHub Comments

1reaction
oscarjohansson94commented, Feb 16, 2022

@stondini If you want to use 7.0.1 you can add this to your docker file to remove one of the loggers.

FROM confluentinc/cp-kafka-connect:7.0.1
RUN rm /usr/share/java/cp-base-new/slf4j-log4j12-*.jar
1reaction
stondinicommented, Feb 15, 2022

@oscarjohansson94 I get the same logs as you. I downgraded Connect to confluentinc/cp-kafka-connect:6.1.4 which works well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kafka Connect Logging | Confluent Documentation
When Connect starts, it writes the settings that it's using and any WARN and ERROR (or FATAL ) messages along the way. This...
Read more >
java - log4j 2 - configuration issue - Stack Overflow
It exists in the classpath of the project and I tried putting it in many other directories.. I created a logger in the...
Read more >
SLF4J Error Codes
Multiple bindings were found on the class path. SLF4J API is designed to bind with one and only one underlying logging framework at...
Read more >
kafka-images - bytemeta
JMS Connector source task failing if it stays idle for longer, ... cp-kafka-connect fails inconsistently due to multiple loggers in classpath.
Read more >
Log4j – Frequently Asked Questions - Apache Logging Services
Next, check the name of your configuration file. By default, log4j2 will look for a configuration file named log4j2.xml on the classpath. Note ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found