类似的问题好像都是围绕着使用自定义日志记录器展开的,但我很乐意只使用默认/根本不使用。我的pika python应用程序运行并接收消息,但几秒钟后就会崩溃,并显示No handlers could be found for logger "pika.adapters.blocking_connection"
,有什么想法吗?
import pika
credentials = pika.PlainCredentials('xxx_apphb.com', 'xxx')
parameters = pika.ConnectionParameters('bunny.cloudamqp.com', 5672, 'xxx_apphb.com', credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare('messages')
def message_received(channel, method, properties, body):
print "[x] Received %r" % (body)
channel.basic_consume(message_received, queue='messages', no_ack=True)
channel.start_consuming()
通过添加修复:
import logging
logging.basicConfig()