i am using following log4j.properties
log4j.rootLogger=DEBUG, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
I wanted to disable log messages for kafka only. where as display my log messages being logged.
Kafka Connect and other Confluent Platform components use the Java-based logging utility Apache Log4j to collect runtime data and record component events.
Alter EXTRA_ARGS for the Kafka service variable to disable GC Logging. Alter EXTRA_ARGS for the ZooKeeper service variable to disable GC Logging. It's as simple as that.
Kafka can serve as a kind of external commit-log for a distributed system. The log helps replicate data between nodes and acts as a re-syncing mechanism for failed nodes to restore their data. The log compaction feature in Kafka helps support this usage. In this usage Kafka is similar to Apache BookKeeper project.
you need to disable logger for both log4j and slf4j to disable kafka logging completely:
Add a logback.xml file in your resources dir:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<logger name="org.springframework" level="OFF"/>
<logger name="org.apache" level="OFF"/>
<logger name="kafka" level="OFF"/>
</configuration>
Add below to your application.yaml / properties:
logging:
level:
root: OFF
org.springframework: OFF
org.apache: OFF
kafka: OFF
You need to set the log level to OFF
by adding this line:
log4j.logger.org.apache.kafka=OFF
Compare: How to disable loggers of a class or of whole package?
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