Tuesday, 2 January 2018

How to rotate the proccess-controller.log, host-controller.log log files in EAP 6?

In this blog post, I am going to explain the log rotation of host-controller.log and process-controller.log

Issue: Every time the host controller starts is overwritten the logs:  host-controller.log, process-controller.log.

Resolution:
Define the PeriodicRotatingFileHandler in $JBOSS_HOME/domain/configuration/logging.properties as following:

# File handler configuration
handler.BOOT_FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.BOOT_FILE.level=DEBUG
handler.BOOT_FILE.properties=autoFlush,append,fileName,suffix
handler.BOOT_FILE.autoFlush=true
handler.BOOT_FILE.append=true
handler.BOOT_FILE.suffix=.yyyy-MM-dd
handler.BOOT_FILE.fileName=${org.jboss.boot.log.file:boot.log}
handler.BOOT_FILE.formatter=PATTERN



The suffix property is responsible for rotating the log files based on a time interval that is determined by the content of the string which is passed in to this property:

handler.BOOT_FILE.suffix=.yyyy-MM-dd

Also note that you need to add append and suffix to handler.BOOT_FILE.properties. (handler.BOOT_FILE.properties=autoFlush,fileName by default.)

Validation:

After a day, verify the $JBOSS_HOME/domain/log path and the logs should be rotated with suffix of date.

[jboss@middleware log]$ ls -ltr  $JBOSS_HOME/domain/log
-rw-rw-r--. 1 jboss jboss   7542 Dec 27 23:50 process-controller.log.2017-12-23
-rw-rw-r--. 1 jboss jboss  14329 Dec 27 23:50 host-controller.log.2017-12-23
-rw-rw-r--. 1 jboss jboss   7572 Dec 28 21:11 process-controller.log
-rw-rw-r--. 1 jboss jboss  19940 Dec 28 21:14 host-controller.log
[jboss@middleware log]$ ls -ltr


No comments: