RabbitMQ : Managing access log files in RHEL 7
search cancel

RabbitMQ : Managing access log files in RHEL 7

book

Article ID: 437090

calendar_today

Updated On:

Products

VMware Tanzu Data Services

Issue/Introduction

What settings or configuration do we have to maintain(rotate or delete) the access log files in RabbitMQ?

 

For example, access log files get created in the access.log.yyyy_mm_dd format and you want to delete access log files older than 2 days.

[root@xxxLOWER] rabbitmq # ls -lrt
total 960
-rw-r-----. 1 rabbitmq rabbitmq      0 Apr 14 05:59 rabbitmq_connections.log
-rw-r-----. 1 rabbitmq rabbitmq      0 Apr 14 05:59 rabbitmq_channels.log
-rw-r-----. 1 rabbitmq rabbitmq      0 Apr 14 05:59 rabbitmq_federation.log
-rw-r-----. 1 rabbitmq rabbitmq      0 Apr 14 05:59 rabbitmq_mirroring.log
-rw-r-----. 1 rabbitmq rabbitmq      0 Apr 14 05:59 rabbitmq_queues.log
-rw-r-----. 1 rabbitmq rabbitmq      0 Apr 14 05:59 rabbitmq_upgrade.log
-rw-r-----. 1 rabbitmq rabbitmq      0 Apr 14 08:22 access.log.2026_04_14_08
-rw-r-----. 1 rabbitmq rabbitmq 785585 Apr 14 08:22 rabbitmq.log
[root@sxxx LOWER] rabbitmq #

 

Environment

All supported RabbitMQ versions upto 4.2.x

Cause

Access files are enabled via the management_plugin and are designed to be "user-managed" in RabbitMQ versions upto 4.2.x. RabbitMQ has always appended to log files without rotating them by default. For standard broker logs, there are built-in settings (log.file.rotation.size, etc.), but HTTP access logs (from the Management plugin) were specifically excluded from this internal mechanism.

Because these logs are designed to be user-managed, the official recommendation has been to use external utilities like logrotate on Linux or scheduled scripts on Windows to prevent disk exhaustion.

As of 4.2, the only configuration available to manage these files are listed below. 

#
# Management
#

## Log all requests to the management HTTP API to a file.
## Superseded by http_dispatch.access_log_dir.
##
# management.http_log_dir = /path/to/access.log

## Limits maximum accepted HTTP request body size to 500 KiB.
## The default is 20 MiB.
# management.http.max_body_size = 500000

Resolution

If you are managing these files in a Linux environment, a standard logrotate entry for the HTTP access logs and steps to execute it usually looks like this:

1. Create a test.conf file with the content below

/Users/XXX/log-test/test.state {
    daily
    rotate 1
    # We use 'test.state' as a dummy just to trigger the script
    postrotate
        echo "Pruning files older than 48 hours..."
        /usr/bin/find /Users/XXX/log-test/ -name "access.log.*" -mtime +1 -delete
    endscript
}

2. 

logrotate -f -s /Users/XXX/log-test/test.state /Users/XXX/log-test/test.conf