i have a problem with logging SLF4J at Apache Kafka. I want to use Tomcats Servlet Container Catalina in connection with Apache Kafka. My Java application has to be integrated into a BPM process from Camunda. The integration of Java coding worked so far also - without the integration of an Apache Kafka Producer. If I integrate this into a Camunda process I get this error:
java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/apache/catalina/loader/ParallelWebappClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of java/net/URLClassLoader) for the method's defining class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:418)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
at org.apache.kafka.clients.CommonClientConfigs.<clinit>(CommonClientConfigs.java:32)
at org.apache.kafka.clients.producer.ProducerConfig.<clinit>(ProducerConfig.java:305)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:304)
As far as I understand the error, Camunda and Apache Kafka are trying to call the SLF4J logger, aren't they? But in my case I need the Camunda logger. So I would like to disable Apache Kafka logging to work around the problem. So far my simple Kafka Producer looks like this:
String topicName = "camunda";
String test = "test123";
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092,localhost:9093");
props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer","org.apache.kafka.common.serialization.StringSerializer");
Producer<String, String> producer = new KafkaProducer <>(props);
ProducerRecord<String, String> record = new ProducerRecord<>(topicName,test);
producer.send(record);
producer.close();
is there a way to solve this problem? Unfortunately, I couldn't find any entries on how to disable the Kafka Logger, or is the problem somewhere else?
Many thanks in advance