'Log4j2 delete old log using age attribute not working

Hi I'm trying to delete the old log files based on age attribute of log4j2, but it seems it is not working. The testing that I'm doing is changing my System's date to check if the old files will be deleted when the application is running. Below is my log4j2 configuration.

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
    <Property name="logBaseDir">/app/proj/logs/java_jar</Property>
    <Property name="fileName">app_name</Property>
</Properties>
<Appenders>
    <RollingRandomAccessFile name="LogToRollingRandomAccessFile" fileName="${logBaseDir}/${fileName}.log"
            filePattern="${logBaseDir}/${fileName}.log.%d{yyyy-MM-dd}-%i.gz" append="true" immediateFlush="true">
        <PatternLayout>
            <Pattern>%-5p &#60;%d{yyyy-MM-dd HH:mm:ss.SSS} %C{1}(%L)&#62; %m%n</Pattern>
        </PatternLayout>
        <Policies>
            <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
        </Policies>
        <DefaultRolloverStrategy max="2" compressionLevel="0">
          <Delete basePath="${logBaseDir}" maxDepth="2">
            <IfLastModified age="1d" />
            <IfFileName glob="/${fileName}.log.*.gz" />
          </Delete>
        </DefaultRolloverStrategy>
    </RollingRandomAccessFile> 
</Appenders>
<Loggers>
    <Logger name="com.ibm.msp.webservice_util" level="debug" additivity="false">
        <AppenderRef ref="LogToRollingRandomAccessFile"/>
    </Logger>
    <Root level="error">
        <AppenderRef ref="LogToRollingRandomAccessFile"/>
    </Root>
</Loggers>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source