没有处理程序可以为记录器“pika.adapters.blocking_connection”中找到

2019-07-04 01:26发布

类似的问题似乎都根据各地使用自定义记录器,我很高兴能只使用默认的/没有。 我的鼠兔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()

Answer 1:

通过添加修正:

import logging
logging.basicConfig()


Answer 2:

应该有交流的名字提供,它不应该离开的默认。

channel.exchange_declare(exchange='anyname')  


文章来源: No handlers could be found for logger “pika.adapters.blocking_connection”
标签: python amqp pika