0
0
RabbitmqHow-ToBeginner ยท 3 min read

How to Configure Logging in RabbitMQ: Simple Steps

To configure logging in RabbitMQ, edit the rabbitmq.conf file to set log levels, formats, and destinations using the log configuration options. You can specify log file paths, enable console logging, and adjust verbosity by setting log.console.level or log.file.level.
๐Ÿ“

Syntax

The main logging settings in rabbitmq.conf use the following syntax:

  • log.console = true|false: Enable or disable logging to the console.
  • log.console.level = info|warning|error|debug: Set the minimum log level for console output.
  • log.file = /path/to/logfile.log: Specify the file path for log output.
  • log.file.level = info|warning|error|debug: Set the minimum log level for file output.
  • log.file.rotation.size = size_in_bytes: Set max file size before rotation.
  • log.file.rotation.count = number: Number of rotated log files to keep.

These settings control where logs go and how detailed they are.

conf
log.console = true
log.console.level = info
log.file = /var/log/rabbitmq/rabbit.log
log.file.level = warning
log.file.rotation.size = 10485760
log.file.rotation.count = 5
๐Ÿ’ป

Example

This example configures RabbitMQ to log info and above messages to the console and warnings and above to a log file with rotation.

conf
log.console = true
log.console.level = info
log.file = /var/log/rabbitmq/rabbit.log
log.file.level = warning
log.file.rotation.size = 10485760
log.file.rotation.count = 3
Output
Logs of level info and above appear in the console. Logs of level warning and above are saved to /var/log/rabbitmq/rabbit.log. Log files rotate after 10MB, keeping 3 backups.
โš ๏ธ

Common Pitfalls

  • Not restarting RabbitMQ: Changes to rabbitmq.conf require a service restart to take effect.
  • Incorrect file paths: Ensure the log file directory exists and RabbitMQ has write permissions.
  • Setting too low log level: Using debug level in production can create large logs quickly.
  • Disabling all logging: Setting both console and file logging to false will lose all logs.
conf
## Wrong: disables all logging
log.console = false
log.file = ""

## Right: enable console logging at warning level
log.console = true
log.console.level = warning
๐Ÿ“Š

Quick Reference

SettingDescriptionExample Value
log.consoleEnable console loggingtrue
log.console.levelConsole log levelinfo, warning, error, debug
log.fileLog file path/var/log/rabbitmq/rabbit.log
log.file.levelFile log levelwarning
log.file.rotation.sizeMax log file size in bytes10485760
log.file.rotation.countNumber of rotated files to keep5
โœ…

Key Takeaways

Edit rabbitmq.conf to configure logging settings like log levels and destinations.
Enable console or file logging by setting log.console and log.file options.
Restart RabbitMQ after changing logging configuration to apply changes.
Ensure log file paths exist and have correct permissions.
Avoid debug level logging in production to prevent large log files.