XRAY: Configuring RabbitMQ Log Rotation For JFrog Xray
Over time, Xray’s RabbitMQ log can become quite large, consuming unnecessary disk space. RabbitMQ does not have its log rotation configured by default, however, this functionality can be added with a few simple updates.
Configuring RabbitMQ Log RotationLocate the rabbitmq.conf file which defaults to /opt/jfrog/xray/app/bin/rabbitmq/rabbitmq.conf. For file size based rotation, add the following lines to the configuration file
# rotate when the file reaches 50 MiB (file size in bytes)
log.file.rotation.size =52428800
# keep up to 5 archived log files
log.file.rotation.count = 5
This configuration will rotate the log file upon reaching 50MiB, and keep 5 log files in the archive, which will be sufficient for debugging problematic RabbitMQ behavior.
Restarting RabbitMQThis configuration will not be applied automatically, and RabbitMQ will need to restart to apply the change.
As the Xray linux user, navigate to /opt/jfrog/xray/app/third-party/rabbitmq/sbin and execute the following commands:
./rabbitmqctl stop_app ./rabbitmqctl start_app
We can confirm that the rotation took effect by listing the log directory:
ls -lh /opt/jfrog/xray/var/log/rabbitmq/
The existence of a log.0 file will confirm the log was rotated:
total 1.8G -rw-rw-r-- 1 xray xray 115K Jul 10 16:27 rabbit@node.log -rw-r--r-- 1 xray xray 1.8G Jul 10 16:14 rabbit@node.log.0