I am trying to upgrade the log4j version in kafka and zookeeper docker image from 1.x.x to 2.x.x
Docker commands
RUN rm /zookeeper-3.5.9/lib/log4j-1.2.17.jar
RUN wget https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core/2.17.0/log4j-core-2.17.0.jar -P /zookeeper-3.5.9/lib/
RUN wget https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api/2.17.0/log4j-api-2.17.0.jar -P /zookeeper-3.5.9/lib/
RUN rm /opt/kafka_2.12-2.2.1/libs/log4j-1.2.17.jar
RUN wget https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core/2.17.0/log4j-core-2.17.0.jar -P /opt/kafka_2.12-2.2.1/libs/
RUN wget https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api/2.17.0/log4j-api-2.17.0.jar -P /opt/kafka_2.12-2.2.1/libs/
This is the error I am getting while initialising the pod
Failed to instantiate SLF4J LoggerFactory Reported exception: java.lang.NoClassDefFoundError: org/apache/log4j/Level
Can someone please guide me on how can I upgrade the log4j version without upgrading the base kafka and zookeeper version?
I assume you are trying to manually patch log4j security issues on your own?
Don't.
Kafka and Zookeeper projects have already done this by moving to
reload4j
, which is still log4j 1.x compatible. (logback
is used in Zookeeper 3.8, actually)Upgrade to the latest version of each Zookeeper and Kafka (using existing Docker images, even), rather than cherry-pick JAR files that will not work with these projects without further source code changes.