我检查了librdkafka文档,并说set_log_cb可用于为librdkafka "Logs are logged through the log_cb which defaults to a stderr writer, there is also a builtin syslog writer you can configure with set_log_cb()."启用syslogging。我找不到确切的方法。
undefined
为什么要记录日志。如果您在上面的配置中看到,我正在使用终止信号来停止kafka线程,但是它有些不起作用,并且我的进程陷入了下面的函数调用中,并最终被杀死。
std::unique_ptr<RdKafka::Conf> conf(RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL));
std::unique_ptr<RdKafka::Conf> tconf(RdKafka::Conf::create(RdKafka::Conf::CONF_TOPIC));
conf->set("metadata.broker.list", brokers, errstr);
conf->set("bootstrap.servers", brokers, errstr);
// Set a termination signal which should make shutdown faster
char tmp[16];
snprintf(tmp, sizeof(tmp), "%i", SIGKILL);
conf->set("internal.termination.signal", tmp, errstr);
conf->set("topic.metadata.refresh.interval.ms","3000", errstr);
conf->set("default_topic_conf", tconf.get(), errstr);
conf->set("debug", "all", errstr);
如果我可以启用syslogging,我可以查看正在发生的情况并对其进行进一步调试。 感谢您的帮助。