Bug 1244292 - (6.4.z) maxBackupIndex is not working in PeriodicSizeRotatingFileHandler, when log is rotated on the basis of periodic configuration
Summary: (6.4.z) maxBackupIndex is not working in PeriodicSizeRotatingFileHandler, whe...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Logging
Version: 6.4.0
Hardware: All
OS: All
high
high
Target Milestone: ---
: ---
Assignee: jboss-set
QA Contact: Nikoleta Hlavickova
URL:
Whiteboard:
Depends On:
Blocks: 1260036
TreeView+ depends on / blocked
 
Reported: 2015-07-17 16:48 UTC by Jyoti Wankhede
Modified: 2020-07-16 08:34 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-06-28 20:44:21 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1260036 0 unspecified CLOSED PeriodicSizeRotatingFileHandler's maxBackupIndex is not working as expected 2021-02-22 00:41:40 UTC
Red Hat Issue Tracker PRODMGT-1418 0 Major Resolved maxBackupIndex is not working in PeriodicSizeRotatingFileHandler, when log is rotated on the basis of periodic configura... 2020-01-23 13:08:18 UTC

Internal Links: 1260036

Description Jyoti Wankhede 2015-07-17 16:48:51 UTC
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.

Comment 1 James Perkins 2015-07-17 17:13:16 UTC
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.

Comment 3 Lucas Costi 2015-09-10 04:36:03 UTC
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.

Comment 4 James Perkins 2015-09-10 15:41:39 UTC
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 :)

Comment 5 Lucas Costi 2015-09-21 06:03:57 UTC
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

Comment 9 Brad Maxwell 2016-06-28 20:44:21 UTC
Closing as not a but, this is a feature request => PRODMGT-1418

Comment 10 Brad Maxwell 2017-06-06 17:19:55 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.