Configure log rotation based on log size with AMQ Broker

Solution Unverified - Updated -

Environment

  • Red Hat AMQ Broker (AMQ Broker)
    • 7.10.0

Issue

  • Need to configure log rotation using log size on AMQ Broker

Resolution

It is possible to archive log rotation based on the size of the logs by changing the default class to PeriodicSizeRotatingFileHandler and setting rotateSize as below :

# File handler configuration
handler.FILE=org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler
#handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.FILE.level=DEBUG
handler.FILE.properties=suffix,append,autoFlush,fileName,maxBackupIndex,rotateSize,rotateOnBoot
handler.FILE.suffix=.yyyy-MM-dd
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.fileName=${artemis.instance}/log/artemis.log
handler.FILE.formatter=PATTERN
handler.FILE.maxBackupIndex=10
handler.FILE.rotateSize=1048576
handler.FILE.rotateOnBoot=true

As a result the logs files will be rotated as shown below :

$ du -h log/*
960K    log/artemis.log
1.1M    log/artemis.log.2022-10-20.1
1.1M    log/artemis.log.2022-10-20.10
1.1M    log/artemis.log.2022-10-20.2
1.1M    log/artemis.log.2022-10-20.3
1.1M    log/artemis.log.2022-10-20.4
1.1M    log/artemis.log.2022-10-20.5
1.1M    log/artemis.log.2022-10-20.6
1.1M    log/artemis.log.2022-10-20.7
1.1M    log/artemis.log.2022-10-20.8
1.1M    log/artemis.log.2022-10-20.9
0   log/audit.log

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments