XRAY: Configuring Log Rotation for RabbitMQ

XRAY: Configuring Log Rotation for RabbitMQ

AuthorFullName__c
Shashwath Rai
articleNumber
000006279
ft:sourceType
Salesforce
FirstPublishedDate
2024-12-24T11:59:11Z
lastModifiedDate
2024-12-24
VersionNumber
1
Overview

Managing RabbitMQ logs is essential to prevent log files from growing excessively large, which can lead to disk space issues and challenges in managing the log data. RabbitMQ provides built-in methods for efficient log rotation. This article explains how to configure log rotation for RabbitMQ.

RabbitMQ Log Rotation Methods


RabbitMQ supports two types of built-in log rotation:


1. Periodic Rotation (Time-based)


You can configure periodic log rotation by adding the following settings to the rabbitmq.conf file located at /opt/jfrog/xray/app/bin/rabbitmq directory:
# Rotate logs nightly at midnight  
log.file.rotation.date = $D0  

# Retain up to 5 archived log files  
log.file.rotation.count = 5  

# Compress archived log files  
log.file.rotation.compress = true  

Alternative Periodic Rotation Example:
# Rotate logs daily at 11:00 PM  
log.file.rotation.date = $D23  

# Retain up to 5 archived log files  
log.file.rotation.count = 5  

# Compress archived log files  
log.file.rotation.compress = true

 

Note:

  • log.file.rotation.date specifies the rotation schedule using $D<time> format, where <time> is in a 24-hour clock format.
  • This option cannot be combined with size-based rotation (log.file.rotation.size).

 

2. File Size-based Rotation

To rotate log files based on size, update the rabbitmq.conf file as follows:
# Rotate logs when the file reaches 10 MiB  
log.file.rotation.size = 10485760  

# Retain up to 5 archived log files  
log.file.rotation.count = 5  

# Compress archived log files  
log.file.rotation.compress = true  

 

Note:
  • log.file.rotation.size defines the maximum log file size (in bytes) before rotation occurs.
  • This option cannot be combined with time-based rotation (log.file.rotation.date).

 

Applying the Configuration


After making the changes to the rabbitmq.conf file, reboot the server(this will restart both Rabbitmq and Xray) to apply the updated log rotation settings.