不要打印 kafka-console-consumer 警告 [英] Don't print the kafka-console-consumer warnings

查看:43
本文介绍了不要打印 kafka-console-consumer 警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将加密消息调试到 Kafka 集群上.显然,这些消息充满了不可打印的字符,无法在控制台上使用,所以我想将输出保存在这样的文件中:

I am trying to debug encrypted messages onto a Kafka cluster. Obviously these messages are full of non printable characters and are not usable on a console, so I wanted to save the output in a file like this:

kafka-console-consumer \
    --zookeeper 0.zookeeper.local,1.zookeeper.local \
    --max-messages 1 \
    --topic MYTOPIC > /tmp/message

我无法解密生成的消息,因为输出中包含与密文一起的警告消息,例如:

I am unable to decrypt the resulting message, because the output contains, along with the ciphertext, warning messages such as:

[2016-02-24 11:52:47,488] WARN Reconnect due to socket error: null (kafka.consumer.SimpleConsumer)

有没有办法在文件中获取一条消息,并且将警告嵌入到该文件中?

Is there a way to get one single message in a file and NOT embed the warnings in that file?

推荐答案

有一个用于入站控制台工具的特殊记录器配置文件.请在 [kafka_home]/config/tools-log4j.properties 文件中将记录器级别从 WARN 更改为 OFF.该文件应如下所示:

There is a special logger config file for inbound console tools. Please, change the logger level from WARN to OFF in [kafka_home]/config/tools-log4j.properties file. The file should look like:

tools-log4j.properties

log4j.rootLogger=OFF, stdout 

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c)%n

之后,您将只在控制台中收到消息.

After it you will get only messages in console.

这篇关于不要打印 kafka-console-consumer 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆