问题描述
jmp
这些都不出现在应用程序日志文件中。
我的应用程序是使用C#开发的,具有%3|1602097315.970|FAIL|rdkafka#consumer-2| [thrd:kfkqaapq0002d.ch.me.com:9092/bootstrap]: kfkqaapq0002d.ch.me.com:9092/bootstrap: Failed to resolve 'kfkqaapq0002d.ch.me.com:9092': No such host is kNown. (after 42ms in state CONNECT)
%3|1602097315.970|FAIL|rdkafka#consumer-3| [thrd:kfkqaapq0002d.ch.me.com:9092/bootstrap]: kfkqaapq0002d.ch.me.com:9092/bootstrap: Failed to resolve 'kfkqaapq0002d.ch.me.com:9092': No such host is kNown. (after 41ms in state CONNECT)
%3|1602097315.972|FAIL|rdkafka#producer-1| [thrd:kfkqaapq0003d.ch.me.com:9092/bootstrap]: kfkqaapq0003d.ch.me.com:9092/bootstrap: Failed to resolve 'kfkqaapq0003d.ch.me.com:9092': No such host is kNown. (after 48ms in state CONNECT)
%3|1602097315.973|ERROR|rdkafka#producer-1| [thrd:app]: rdkafka#producer-1: kfkqaapq0003d.ch.me.com:9092/bootstrap: Failed to resolve 'kfkqaapq0003d.ch.me.com:9092': No such host is kNown. (after 48ms in state CONNECT)
%3|1602097316.459|FAIL|rdkafka#producer-1| [thrd:kfkqaapq0001d.ch.me.com:9092/bootstrap]: kfkqaapq0001d.ch.me.com:9092/bootstrap: Failed to resolve 'kfkqaapq0001d.ch.me.com:9092': No such host is kNown. (after 42ms in state CONNECT)
作为依赖项,并且使用Confluent.Kafka
。我认为那是它的来源。我正在研究它们与心跳有关的可能性。
我的appSettings.json具有以下日志记录配置:
librdkafka.redist
这也是写到日志文件的任何地方吗,还是有什么方法可以从应用程序中的.NET Core Healthcheck解析出来?
解决方法
您可以将自己的日志处理程序传递给客户端构建器,请参见 https://docs.confluent.io/current/clients/confluent-kafka-dotnet/api/Confluent.Kafka.ProducerBuilder-2.html#Confluent_Kafka_ProducerBuilder_2_SetLogHandler_System_Action_Confluent_Kafka_IProducer__0__1__Confluent_Kafka_LogMessage_ _
例如:
using (var producer =
new ProducerBuilder<byte[],byte[]>(producerConfig)
.SetLogHandler((_,m) => ..emit m as you wish..)
.Build())