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.confrequire 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
debuglevel 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
| Setting | Description | Example Value |
|---|---|---|
| log.console | Enable console logging | true |
| log.console.level | Console log level | info, warning, error, debug |
| log.file | Log file path | /var/log/rabbitmq/rabbit.log |
| log.file.level | File log level | warning |
| log.file.rotation.size | Max log file size in bytes | 10485760 |
| log.file.rotation.count | Number of rotated files to keep | 5 |
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.