There is no license information available for the latest version (1.0.0) of this package.

Log error and exceptions int rabbitmq exchange.

1.0.0 2017-06-13 09:32 UTC


Log error and exceptions int rabbitmq exchange.

Latest stable

Rabbitmq Logger provides two extensions for Nette Framework.

  • RabbitMqLoggerExtension for logging errors/exceptions into rabbitmq exange. You should use this extension on all projects where you want to log error messages to rabbitmq.
  • ConsumerExtension for getting messages from queue and optionally save them into database using doctrine 2. It also provide grid to show the saved messages. You should use this extension with an internal application to manage saved messages.



sallyx/rabbitmq-logger requires PHP 5.4 or higher.


If you want to use ConsumerExtension to save logs into database:

If you want to use ConsumerExtension to provide Grid to show saved messages:


The best way to install sallyx/rabbitmq-logger is using Composer:

composer require sallyx/rabbitmq-logger
composer require kdyby/console
composer require kdyby/doctrine
composer require ublaboo/datagrid


First you need to configure Kdyby/RabbitMq. A least the connection:

    rabbitmq: Kdyby\RabbitMq\DI\RabbitMqExtension

        host: localhost
        port: 5672
        user: 'guest'
        password: 'guest'
        #vhost: '/'

If you want to use RabbitMqLoggerExtension to log error messages, add and configure it like this:

    rabbitmqLoggerExt: Sallyx\RabbitMqLogger\DI\RabbitMqLoggerExtension

This is the default configuration for RabbitMqLoggerExtension:

    rabbitmqExtensionName: rabbitmq
    guid: rabbitmq-logger
        connection: default # Kdyby/RabbitMq default connection
            name: nette-log-exchange
            type: fanout

If you use direct exchange, the routing key is in form priority, where priority is error or exception. If you use topic exchange, the routing key is in form priority.guid

If you want to use ConsumerExtension, you have to add Kdyby/Console and/or Kdyby/Doctrine extensions and configure it (please have a look at the documentation for this extensions):

    rabbitmqLoggerConsumer: Sallyx\RabbitMqLogger\DI\ConsumerExtension # must be first!
    console: Kdyby\Console\DI\ConsoleExtension
    events: Kdyby\Events\DI\EventsExtension
    annotations: Kdyby\Annotations\DI\AnnotationsExtension
    doctrine: Kdyby\Doctrine\DI\OrmExtension
    rabbitmqLoggerExt: Sallyx\RabbitMqLogger\DI\RabbitMqLoggerExtension # if you want to use it either
    url: http://localhost/~petr/example-url/

    user: petr
    password: xxx
    dbname: databasename
    driver: pdo_pgsql # pdo_mysql

This is the default configuration for ConsumerExtension:

    consumerName: rabbitLogger
        connection: default               # Kdyby/RabbitMq default connection
            name: nette-log-queue
            name: my-fancy-nette-log-exchange # the same as for RabbitMqLoggerExtension
            type: fanout                      # the same as for RabbitMqLoggerExtension
    manager: Sallyx\RabbitMqLogger\Model\Doctrine\Manager

If you want to get an easy acces to your logged exceptions, you can add this to RabbitMqLoggerExtension configuration:

        route: get-tracy-exception-file               
        secret: xxx

This create route in your web application, which provides access to your error messages saved in log in form

To use this in the grid, add this to ConsumerExtension configuration:

        route: get-tracy-exception-file
        secret: xxx


You have to create exchange for RabbitMqLoggerExtension and queue for ConsumerExtension. If you want to use ConsumerExtension to save messages to database, you also have to create the schema and table.

If you have installed Kdyby/Console, you can use rabbitmq:setup-fabric command from Kdyby/RabbitMq extension to setup exchange and queue:

php www/index.php  rabbitmq:setup-fabric

To create the database table, you can use structure-psql.sql for Postgresql and structure-mysql.sql for Mysql/MariaDB.

Using RabbitMqLoggerExtension

No futher action needed. Your project should log messages into rabbitmq exhange as configured.

Using ConsumerExtension

Using Console

If you installed Kdyby/Console extension, you can use this commands:

  • rabbitmqLoggerConsumer:queue to add or delete other queues to exchange.
  • rabbitmqLoggerConsumer:list to list and remove messages from queue.
  • rabbitmqLoggerConsumer:save to list, save messages to database and remove from queue (Kdyby/Doctine extension needed).

While rabbitmqLoggerConsumer:save takes messages from queue described in configuration, rabbitmqLoggerConsumer:list require queue name as argument to avoid accidentally removing message from queue. You can use rabbitmqLoggerConsumer:queue to create new queue.

php www/index.php rabbitmqLoggerConsumer:queue spy-whats-going-on exception  # create queue for 'exception' routing key
php www/index.php rabbitmqLoggerConsumer:list spy-whats-going-on        # print message on console and remove if from queue
php www/index.php rabbitmqLoggerConsumer:queue spy-whats-going-on -d    # delete queue

Using Grid

In a presenter:

use Sallyx\RabbitMqLogger\Controls\Doctrine\GridFactory;

   public function __construct(GridFactory $factory) {
        $this->gridFactory = $factory;

    public function createComponentGrid($name) {
        return $this->gridFactory->create();

In latte:

{control grid}

You need to add assets as described on page.


Ublaboo datagrid