How to compress rotated access log in JBoss EAP 7
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.3
- 7.4
Issue
- I need to compress a rotated access log file to save disk space.
Resolution
A customer can compress the rotated access_log.log with specify the suffix attribute ends with .gz or .zip from JBoss EAP 7.3 onward. This is the same with [1] which describes server.log.
CLI:
/subsystem=logging/periodic-size-rotating-file-handler=ACCESS_LOG:write-attribute(name=suffix,value=".yy-MM-dd.gz")
Note: Rightly, it needs configuration for enabling access_log.log and rotating the access_log.log. See [2] and [3] for detail.
standalone.xml:
<periodic-size-rotating-file-handler name="ACCESS_LOG" autoflush="true">
<formatter>
<named-formatter name="ACCESS_LOG_FORMATTER"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="access_log.log"/>
<rotate-size value="500m"/>
<max-backup-index value="3"/>
<suffix value=".yy-MM-dd.gz"/> <<== here
<append value="true"/>
</periodic-size-rotating-file-handler>
[1]How to compress JBoss logs
[2]How to enable access logging for JBoss EAP 7?
[3]Rotating Access Logs in JBoss EAP 7.x
Root Cause
This function has been implemented by LOGMGR-30.
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.