log4j properties doesn't apply after upgrading zookeeper from 3.6.3 to 3.9.1

94 Views Asked by At

In my Java project I have log4j2.xml file under recources which defines the logs format and logs level for each service of camel, kafka, zookeeper, springframework.
I set a timestamp before each log and set level="ERROR" for all the services above.
I had apache zookeeper version 3.6.3 as part of kafka and not a direct dependency in my pom.xml.
Because of a vulnerability found in this version I decided to upgrade this version to 3.9.1 by adding a new dependency of zookeeper to my pom.xml.
Before upgrading zookeeper, when I ran docker logs [myservice], this would be one of the logs:
[30/01/24 10:14:15:015 UTC] [qtp2593515078-66] INFO BusinessLogic: createReport - Started
After upgrading, this is a log example:
[pool-3-thread-1] INFO org.apache.camel.impl.engine.DefaultShutdownStrategy - Graceful shutdown of 1 routes completed in 0 seconds
Two things changed, one is that the logs aren't according to the format anymore (no timestamp before each log) and the log level seems to be changed from error to info for the services, which means that the log4j2.xml properties isn't applied anymore.
What I tried to do:

  1. Changed the zookeeper version to 3.7.2, 3.8.3
  2. Excluding ch.qos.logback and io.netty:netty-tcnative-boringssl-static
1

There are 1 best solutions below

2
Don Ha On

zookeeper could bring in another logging implementation as a transient dependency that overwrites log4j, look for that and exclude any logging dependencies you find.