微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何从C#应用程序访问librdkafka.redist日志,并将其用作依赖项?

如何解决如何从C#应用程序访问librdkafka.redist日志,并将其用作依赖项?

我的应用程序控制台日志显示很多以下内容

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())

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。