Controlling RabbitMQ log levels

by Feike Wierda

RabbitMQ is a solid and and fast message queue, at Copernica we use it for queueing all kinds of messages throughout the application. Fast and flexible as it may be, it does come with a few quirks we've had to overcome. Over recent months, we've been moving more parts of our software to RabbitMQ, thereby increasing the load we place on RabbitMQ servers. In doing so, RabbitMQ started eating up far more diskspace than any sysadmin would be comfortable with (figures in excess of 20Gb overnight were no exception). Some research revealed that RabbitMQ would log every single connection attempt. When using persistent connections, this would, of course, not be a big problem. However, when you mostly employ short running PHP scripts that send tens of thousands of messages to RabbitMQ, you will find yourself wasting a lot of diskspace on what is essentially useless information.

Luckily RabbitMQ has recently introduced some level of control over logging. Info level logs can be disabled by adding the following line to your /etc/rabbitmq/rabbitmq.config:

[
{rabbit, [ {log_levels, [{connection, error}]} ] }
].

The above tells RabbitMQ to only log connection events if they are errors. As 'connection' is currently the only defined category, events in any other category will always be logged. In the future, more categories will be defined for even finer grained control over logging.

Related articles