Kafka Avro Consumer (kafka-avro-console-consumer) 日志级别

Kafka Avro Consumer (kafka-avro-console-consumer) Logging Level

有什么方法可以关闭 /usr/bin/kafka-avro-console-consumer 中的“INFO”日志记录级别吗?

或者,是否有其他方法可以查看 avro 架构中的数据?

现在我使用该程序(通过 Docker),在它发出关于我想要的主题的数据之前,输出包含大量日志消息(我不想要):

[2022-05-10 14:08:33,090] INFO Registered kafka:type=kafka.Log4jController MBean (kafka.utils.Log4jControllerRegistration$)
[2022-05-10 14:08:33,643] INFO ConsumerConfig values:
    allow.auto.create.topics = true
    auto.commit.interval.ms = 5000
    auto.offset.reset = earliest
    bootstrap.servers = [kafka:9092]
    check.crcs = true
    client.dns.lookup = use_all_dns_ips
    client.id = consumer-console-consumer-25832-1
    client.rack =
    connections.max.idle.ms = 540000
    default.api.timeout.ms = 60000
    enable.auto.commit = false
    exclude.internal.topics = true
    fetch.max.bytes = 52428800
    fetch.max.wait.ms = 500
    fetch.min.bytes = 1
    group.id = console-consumer-25832
    group.instance.id = null
    heartbeat.interval.ms = 3000
    interceptor.classes = []
    internal.leave.group.on.close = true
    internal.throw.on.fetch.stable.offset.unsupported = false
    isolation.level = read_uncommitted
    key.deserializer = class org.apache.kafka.common.serialization.ByteArrayDeserializer
    max.partition.fetch.bytes = 1048576
    max.poll.interval.ms = 300000
    max.poll.records = 500
    metadata.max.age.ms = 300000
    metric.reporters = []
    metrics.num.samples = 2
    metrics.recording.level = INFO
    metrics.sample.window.ms = 30000
    partition.assignment.strategy = [class org.apache.kafka.clients.consumer.RangeAssignor]
    receive.buffer.bytes = 65536
    reconnect.backoff.max.ms = 1000
    reconnect.backoff.ms = 50
    request.timeout.ms = 30000
    retry.backoff.ms = 100
    sasl.client.callback.handler.class = null
    sasl.jaas.config = null
    sasl.kerberos.kinit.cmd = /usr/bin/kinit
    sasl.kerberos.min.time.before.relogin = 60000
    sasl.kerberos.service.name = null
    sasl.kerberos.ticket.renew.jitter = 0.05
    sasl.kerberos.ticket.renew.window.factor = 0.8
    sasl.login.callback.handler.class = null
    sasl.login.class = null
    sasl.login.refresh.buffer.seconds = 300
    sasl.login.refresh.min.period.seconds = 60
    sasl.login.refresh.window.factor = 0.8
    sasl.login.refresh.window.jitter = 0.05
    sasl.mechanism = GSSAPI
    security.protocol = PLAINTEXT
    security.providers = null
    send.buffer.bytes = 131072
    session.timeout.ms = 10000
    socket.connection.setup.timeout.max.ms = 30000
    socket.connection.setup.timeout.ms = 10000
    ssl.cipher.suites = null
    ssl.enabled.protocols = [TLSv1.2, TLSv1.3]
    ssl.endpoint.identification.algorithm = https
    ssl.engine.factory.class = null
    ssl.key.password = null
    ssl.keymanager.algorithm = SunX509
    ssl.keystore.certificate.chain = null
    ssl.keystore.key = null
    ssl.keystore.location = null
    ssl.keystore.password = null
    ssl.keystore.type = JKS
    ssl.protocol = TLSv1.3
    ssl.provider = null
    ssl.secure.random.implementation = null
    ssl.trustmanager.algorithm = PKIX
    ssl.truststore.certificates = null
    ssl.truststore.location = null
    ssl.truststore.password = null
    ssl.truststore.type = JKS
    value.deserializer = class org.apache.kafka.common.serialization.ByteArrayDeserializer
 (org.apache.kafka.clients.consumer.ConsumerConfig)
[2022-05-10 14:08:33,809] INFO Kafka version: 6.2.0-ce (org.apache.kafka.common.utils.AppInfoParser)
[2022-05-10 14:08:33,809] INFO Kafka commitId: 5c753752ae1445a1 (org.apache.kafka.common.utils.AppInfoParser)
[2022-05-10 14:08:33,809] INFO Kafka startTimeMs: 1652191713801 (org.apache.kafka.common.utils.AppInfoParser)
[2022-05-10 14:08:33,814] INFO [Consumer clientId=consumer-console-consumer-25832-1, groupId=console-consumer-25832] Subscribed to topic(s): dbserver1.public.x_account (org.apache.kafka.clients.consumer.KafkaConsumer)
[2022-05-10 14:08:34,471] INFO [Consumer clientId=consumer-console-consumer-25832-1, groupId=console-consumer-25832] Cluster ID: 9-BvG22VQrimBsWAceE02Q (org.apache.kafka.clients.Metadata)
[2022-05-10 14:08:34,473] INFO [Consumer clientId=consumer-console-consumer-25832-1, groupId=console-consumer-25832] Discovered group coordinator kafka:9092 (id: 2147483646 rack: null) (org.apache.kafka.clients.consumer.internals.AbstractCoordinator)
[2022-05-10 14:08:34,477] INFO [Consumer clientId=consumer-console-consumer-25832-1, groupId=console-consumer-25832] (Re-)joining group (org.apache.kafka.clients.consumer.internals.AbstractCoordinator)
[2022-05-10 14:08:34,501] INFO [Consumer clientId=consumer-console-consumer-25832-1, groupId=console-consumer-25832] (Re-)joining group (org.apache.kafka.clients.consumer.internals.AbstractCoordinator)
[2022-05-10 14:08:34,507] INFO [Consumer clientId=consumer-console-consumer-25832-1, groupId=console-consumer-25832] Successfully joined group with generation Generation{generationId=1, memberId='consumer-console-consumer-25832-1-d482e04b-8ed0-4d68-b533-a010dde3c99a', protocol='range'} (org.apache.kafka.clients.consumer.internals.AbstractCoordinator)
[2022-05-10 14:08:34,511] INFO [Consumer clientId=consumer-console-consumer-25832-1, groupId=console-consumer-25832] Finished assignment for group at generation 1: {consumer-console-consumer-25832-1-d482e04b-8ed0-4d68-b533-a010dde3c99a=Assignment(partitions=[dbserver1.public.x_account-0])} (org.apache.kafka.clients.consumer.internals.ConsumerCoordinator)
[2022-05-10 14:08:34,524] INFO [Consumer clientId=consumer-console-consumer-25832-1, groupId=console-consumer-25832] Successfully synced group in generation Generation{generationId=1, memberId='consumer-console-consumer-25832-1-d482e04b-8ed0-4d68-b533-a010dde3c99a', protocol='range'} (org.apache.kafka.clients.consumer.internals.AbstractCoordinator)
[2022-05-10 14:08:34,525] INFO [Consumer clientId=consumer-console-consumer-25832-1, groupId=console-consumer-25832] Notifying assignor about the new Assignment(partitions=[dbserver1.public.x_account-0]) (org.apache.kafka.clients.consumer.internals.ConsumerCoordinator)
[2022-05-10 14:08:34,529] INFO [Consumer clientId=consumer-console-consumer-25832-1, groupId=console-consumer-25832] Adding newly assigned partitions: dbserver1.public.x_account-0 (org.apache.kafka.clients.consumer.internals.ConsumerCoordinator)
[2022-05-10 14:08:34,540] INFO [Consumer clientId=consumer-console-consumer-25832-1, groupId=console-consumer-25832] Found no committed offset for partition dbserver1.public.x_account-0 (org.apache.kafka.clients.consumer.internals.ConsumerCoordinator)

生成上述输出的命令如下:

docker exec -i [schema-registry-container] /usr/bin/kafka-avro-console-consumer \
  --bootstrap-server kafka:9092 \
  --topic [some-topic] \
  --from-beginning \
  --property schema.registry.url="http://schema-registry:8081"

对于 Confluent Schema Registry 映像,您可以添加此 env-var 以完全禁用任何消费者包日志

SCHEMA_REGISTRY_LOG4J_LOGGERS="org.apache.kafka.clients.consumer=OFF"

Comma-separate 更多包进一步配置 log4j

alternate way to view data that is in an avro schema

kcat 或 AKHQ、Conduktor 等工具