Kafka Consumer 向控制台输出过多的 DEBUG 语句(ecilpse) [英] Kafka Consumer outputs excessive DEBUG statements to console (ecilpse)
问题描述
我正在运行 http://www.javaworld.com/article/3060078/big-data/big-data-messaging-with-kafka-part-1.html?page=2,并且 kafkaconsumer 正在根据需要从主题中消费,但每次轮询都会导致打印(到标准输出)许多调试日志,这是我不想要的.
I'm running some sample code from http://www.javaworld.com/article/3060078/big-data/big-data-messaging-with-kafka-part-1.html?page=2, and the kafkaconsumer is consuming from topic as desired, but every poll results in print (to std out) of many debug logs, which I don't want.
我尝试将 /config/log4j.properties
中的所有 INFO 和 DEBUG 更改为 ERROR(甚至做了 grep 以确保),特别是设置 log4j.logger.kafka=ERROR
,kafkaAppender,但问题依旧.我参考了如何为Kafka生产者配置日志记录?,并采用那里的解决方案,但也许消费者的情况不同?
I have tried changing all INFO and DEBUG to ERROR (even did a grep to make sure) in /config/log4j.properties
, in particular setting log4j.logger.kafka=ERROR
, kafkaAppender, but the problem persists. I referred to How to configure logging for Kafka producers?, and adopted the solution there, but perhaps the situation is different for consumers?
DEBUG 消息都具有类似的格式:
The DEBUG messages all have a similar format:
[Thread-0] DEBUG org.apache.kafka.clients.consumer.internals.Fetcher - Sending fetch for partitions... to broker... (id: 0 rack: null)
并且以每秒 10 次左右的速度出现(将 poll 参数更改为 1000 甚至 10000 没有帮助,我试过了)
and are appearing at rate of 10 every second or so (changing poll argument to 1000 or even 10000 doesn't help, I tried)
非常感谢任何专家的帮助.提前致谢!
Would really appreciate any help from any expert. Thanks in advance!
不确定它是否重要,但我将 BasicConfigurator.configure();
添加到我的主要方法中,以解决之前发生的一些其他错误,这些错误甚至阻止了消费者的启动.
Not sure if it matters, but I added BasicConfigurator.configure();
to my main method, to resolve some other error occurring previously that stopped the Consumer from even starting.
推荐答案
只需修改聊天类的日志记录级别(聊天交互).由于在您的日志中您会看到源自 org.apache.kafka.clients.consumer.internals.Fetcher
的日志条目,您可以通过将以下行添加到 log4j 来简单地调整该记录器的日志记录级别.属性
:
Just modify the logging level of the chatty class (chatty interaction).
Since in your logs you see log entries originating from org.apache.kafka.clients.consumer.internals.Fetcher
you can simply adjust the logging level for that logger by adding following line to log4j.properties
:
log4j.logger.org.apache.kafka.clients.consumer.internals.Fetcher=WARN
... 或任何更广泛的捕获记录器,因为它们是名称间隔的:
... or any wider catching logger since these are name spaced:
# adjusting logging for entire Kafka
log4j.logger.org.apache.kafka=WARN
希望能帮到你
这篇关于Kafka Consumer 向控制台输出过多的 DEBUG 语句(ecilpse)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!