Regarding max no of days to keep log file

Latest response

Hi All,

I am using standalone jboss EAP 6.2 server for application logging. Is there any property in PeriodicSizeRotatingFileHandler class which can tell after how many days after creation the log file should be removed automatically for example in logback.xml we have
element which tells the same days.

I have written following lines in standalone.xml in jboss-home/standalone/configuration path:

<custom-handler name="BNETLOGHANDLER" class="org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler" module="org.jboss.logmanager">
            <formatter>
                <pattern-formatter pattern="[%d][Thread:%t][Level:%-5p][Logger Class:%X{LoggerClass}][Error Code:%X{ErrorCode}][Error Message:%X{ErrMsg}] [Priority:%p][CorrelationId:%X{IPCorrelationId}][ServerFullName:%X{IPServerFullName}][Helper Text Id:%X{helpTextId}][Helper Message:%X{helpTextMsg}] %n
                    - %m%n"/>
            </formatter>
            <properties>
                <property name="autoFlush" value="true"/>
                <property name="append" value="true"/>
                <property name="rotateSize" value="10000"/>
                <!--<property name="maxBackupIndex" value="3"/>-->
                <property name="suffix" value=".yyyy-MM-dd"/>
                <property name="fileName" value="${jboss.server.log.dir}/bnetApplicationLog.log"/>
            </properties>
        </custom-handler>

Responses

The only solution I can think of is a workaround. There isn't anything that says after so many days the files should be removed as far as I know; but you can use the maxBackupIndex to do the same thing. If you have a rotateSize that's fairly large, which means a new log is created at midnight by default I believe. Creating a new log every day means you can treat your maxBackupIndex like number of days as opposed to number of logs. I hope that helps.