Description of problem: ======================= Periodic rotating File Handler doesn't support maxBackupIndex value. However, According to this article "https://access.redhat.com/solutions/384393", if you use Periodic "Size" Rotating File Handler (Note that this is different from Periodic Rotating File Handler), you can set the maxBackupIndex. "maxBackupIndex" is not working in "PeriodicSizeRotatingFileHandler", when log is rotated on the basis of periodic configuration. This feature is very important if we want to keep the number of the past log files under control, so that it doesn't keep increasing the disk usage and blow up later on. How reproducible: ================= Add the following "PeriodicSizeRotatingFileHandler" in the standalone.xml. ---------------------------- <custom-handler name="psrf" class="org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler" module="org.jboss.logmanager"> <properties> <property name="append" value="true"/> <property name="fileName" value="${jboss.server.log.dir}/psrf_server.log"/> <property name="rotateSize" value="200000"/> <property name="maxBackupIndex" value="1"/> <property name="suffix" value=".yyyy-MM-dd"/> <property name="autoFlush" value="true"/> </properties> </custom-handler> ---------------------------- Steps to Reproduce: =================== 1. Add the above "PeriodicSizeRotatingFileHandler" in the standalone.xml. 2. Then incremented the system date by 1 day and then incremented 1 more day 3. Now check the number of log files present in the log directory. Actual results: =============== Here more than one backup log file is present. Expected results: ================= As per above configuration there must be only one backup log file.
In EAP 6.4 there is a subsystem=logging/periodic-size-rotating-file-handler=* resource. In the resource description it indicates "Any backups rotated by the suffix will not be purged during a size rotation.". Maybe that's a bit ambiguous but essentially if a file is rotated with a suffix, a date format, it will never be purged. There's too much guess work that would have to be involved in order to guess which files to delete. I don't think the container should make that decision.
Hey James, is this something that should be mentioned in the documentation? GSS has opened BZ#1260036 for a docs mention, but if this is something that's might be be fixed, it's more of a release note thing. If it's not a bug, I can make a not in the Admin & Config Guide noting this behaviour.
I'd say it's not a bug. We don't make an attempt to purge files with a date suffix. I won't say it's something I'll never relook at, but it's not in the near future :)
Thanks, James. I have added a note for the max-backup-index option in the "Periodic Size Rotating Log Handler Properties" list: https://bugzilla.redhat.com/show_bug.cgi?id=1260036#c3
Closing as not a but, this is a feature request => PRODMGT-1418
The maxBackupIndex applies to the log file name ${fileName}${suffix} , in the case below, it is using the year-month-date, so it would keep a max of 1 backup if it rolled over for the given ${fileName}${suffix} when the date changes (after 24 hours), the suffix is now different which is why you would see 2 files from the previous day. <property name="maxBackupIndex" value="1"/> <property name="suffix" value=".yyyy-MM-dd"/> If you only want to have the active log and 1 previous, then change the suffix to not include the date. The date the file was created could be checked by the OS or looking in the log file.