You are developing a Java application using a Kafka consumer.
You need to integrate Kafka’s client logs with your own application’s logs using log4j2.
Which Java library dependency must you include in your project?
SLF4J implementation for Log4j 1.2 (org.slf4j:slf4j-log4j12)
SLF4J implementation for Log4j2 (org.apache.logging.log4j:log4j-slf4j-impl)
None, the right dependency will be added by the Kafka client dependency by transitivity.
Just the log4j2 dependency of the application
Kafka clients useSLF4Jas a logging facade. To redirect Kafka logs tolog4j2, you must include theSLF4J binding for log4j2in your classpath:
“org.apache.logging.log4j:log4j-slf4j-impl bridges SLF4J to Log4j2 so that Kafka's logs integrate into your application's Log4j2 configuration.”
Option A is forLog4j 1.x, which is outdated.
Option C is incorrect; Kafka clients don't include logging bindings.
Option D is insufficient without the SLF4J bridge.
Submit