Java Kafka客户端记录每个线程的所有配置。

huangapple go评论79阅读模式
英文:

Java kafka client logging all the config for each thread

问题

我有一个Java客户端(使用kafka客户端版本2.4.1),连接到一个具有5个主题和每个主题有5个分区的Kafka(版本2.4.1)。我为每个分区创建了1个线程。我的问题是,对于每个线程,所有的消费者配置都被记录下来:

Java Kafka客户端记录每个线程的所有配置。

首先,我想知道这是否是正常行为(因为我有25个线程,我看到了25次这些日志)?也许我做错了什么。目前,我每个消费者线程都订阅了它的主题。所以我调用了25次订阅方法,每次调用似乎都会生成这些日志。

然后,我能做些什么来禁止它们出现吗?

英文:

I have a java client (using kafka client version 2.4.1) that is connected to a kafka (version 2.4.1) which have 5 topic with 5 partitions each. I am creating 1 thread per partition. My problem is that for each thread all the consumer configuration is logged :

Java Kafka客户端记录每个线程的所有配置。

First I would like to know if this is normal behavior (as I have 25 threads I am seeing 25 times theses logs) ? Maybe I am doing something wrong. At the moment each of my consumer thread is subscribing to it topic. So I am calling 25 times the method subscribe and each of the call seems to generate theses logs.

Then is there something I can do to disable them ?

答案1

得分: 2

以下是翻译好的部分:

这是正常行为,它只是在每次在每个线程中创建新的KafkaConsumer时记录所有消费者配置(这是在多线程应用中使用多个消费者的正确方法,每个消费者只能在单个线程中使用)。

如果你正在使用log4j,你可以禁用Kafka日志,方法是添加一个日志记录器来过滤掉Kafka的调试消息:

<loggers>
    <logger name="org.apache.kafka" level="ERROR"/>
</loggers>
英文:

It's normal behavior, it just log all consumer config each time you created a new KafkaConsumer in each thread (this is right way to use multiple Consumer in a multi-threads application, each Consumer must only be used in a single thread).

You can disable Kafka log if you're using log4j, by adding a logger to filter out Kafka debug messages:

&lt;loggers&gt;
    &lt;logger name=&quot;org.apache.kafka&quot; level=&quot;ERROR&quot;/&gt;
&lt;/loggers&gt;

huangapple
  • 本文由 发表于 2020年4月7日 21:25:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/61081090.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定