confluent-kafka-python
confluent-kafka-python copied to clipboard
AdminClient does not work with logger
Description
Log messages are not logged via logger.
How to reproduce
import logging
import sys
from confluent_kafka.admin import AdminClient
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
logger=logging.getLogger("AdminClient")
logger.info("Running...")
client = AdminClient({
"bootstrap.servers": "localhost:9999",
"logger": logger
})
client.list_topics(timeout=1)
I would expect to see a log record such as:
%3|1713881891.083|FAIL|rdkafka#producer-1| [thrd:localhost:9999/bootstrap]: localhost:9999/bootstrap: Connect to ipv4#127.0.0.1:9999 failed: Connection refused (after 0ms in state CONNECT)
Python: 3.12.1 Confluent-Kafka version: ('2.3.0', 33751040)
Yes there is some issue in logger with AdminClient. Its similar to https://github.com/confluentinc/confluent-kafka-python/issues/1699. Marking it as bug to investigate it further. Hopefully, we will be able to take this up later this quarter.
You can use admin_client.poll to serve the logs through the custom logger.
I have updated the other thread where more discussion will continue. Closing this ticket so that all the discussion can happen at one place.