php-amqplib / RabbitMqBundle

RabbitMQ Bundle for the Symfony web framework
MIT License
1.22k stars 470 forks source link

Can I use this library with monolog to send logs to rabbitmq? #399

Closed ihorsamusenko closed 7 years ago

ihorsamusenko commented 8 years ago

I am trying to do that, there is my conf:

  amqp.log_channel:
    class:  PhpAmqpLib\Channel\AMQPChannel
    factory: ['@old_sound_rabbit_mq.log_producer', getChannel]
monolog:
    handlers:
        queue:
            type: amqp
            exchange: app.newsletter_manager

But I am getting CircularRefernceException

[Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException] Circular reference detected for service "monolog.handler.queue", path: "cache_warmer -> router -> monolog.logger.router -> monolog.handler.queue -> app.newsletter_manager -> old_sound_rabbit_mq. log_producer -> debug.event_dispatcher -> monolog.logger.event".

If I define my connection separately that would mean the application will do two connections all the time which is not acceptable.

tolean commented 6 years ago

@samusenkoiv I have the same situation as you solved this problem?

ihorsamusenko commented 6 years ago

@tolean I just added lazy: true to amqp.log_channel definition

tolean commented 6 years ago

@samusenkoiv cau you explain me what is app.newsletter_manager in you case. in my case after add lazy: true I have this exception: Circular reference detected for service "debug.event_dispatcher", path: "http_kernel -> debug.event_dispatcher -> monolog.logger.event -> monolog.handler.queue -> old_sound_rabbit_mq.log_producer".

Can you show yous rabbit configuration for this producer?