I am using Kafka producer client and i don't have any log4j configuration in my project.
On running, the program prints a lot of Kafka Debug logs which i really don't want.
So, i tried to add a log4j.properties to set log level to ERROR as below which does not seem to work:
log4j.rootLogger=ERROR
How do i change Kafka Log Level?
Kafka is designed to ingest, process, store, and route logging data, all in real time. Once data is processed, Kafka can turn disorganized logging streams into a more understandable, easy-to-read output for IT staff to monitor.
Kafka uses Simple Logging Facade for Java (SLF4J) for logging.
Use the command line flag -Dlog4j.configuration=file:/path/to/log4j.properties
when running your client.
Example log4j property files:
For mirror maker and other tools that result in a call to kafka-run-class.sh
, you can use the env variable KAFKA_LOG4J_OPTS
(set to something like -Dlog4j.configuration=file:/path/to/log4j.properties
) to change the logging configuration. See: https://github.com/apache/kafka/blob/0.10.2/bin/kafka-run-class.sh#L158
Example of my log4j.properties
file for mirror maker that I use for testing.
# https://github.com/apache/kafka/blob/trunk/config/tools-log4j.properties
log4j.rootLogger=DEBUG, stderr
log4j.appender.stderr=org.apache.log4j.ConsoleAppender
log4j.appender.stderr.layout=org.apache.log4j.PatternLayout
log4j.appender.stderr.layout.ConversionPattern=[%d] %p %m (%c)%n
log4j.appender.stderr.Target=System.err
Try adding logging.level.org.apache.kafka: DEBUG into your clients configuration properties. I am using Springboot and this is the format. Use appropriate format for your clients program.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With