title: log4j2 unable to delete old files
body: <p>I have searched everywhere for the answer. I have to delete files after the number of file archived is more than 10. </p>
  
  <p>This is my log4j2.xml</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configuration status="warn" name="MyApp" packages=""&gt;
      &lt;Appenders&gt;
          &lt;RollingFile name="RollingFile" fileName="C:/temp/logs/app.log"
              filePattern="C:/temp/logs/app.log.%i"&gt;
              &lt;PatternLayout&gt;
                  &lt;Pattern&gt;%d %p %c{1.} [%t] %m%n&lt;/Pattern&gt;
              &lt;/PatternLayout&gt;
              &lt;Policies&gt;
                  &lt;SizeBasedTriggeringPolicy size="1000 kb" /&gt;
              &lt;/Policies&gt;
              &lt;DefaultRolloverStrategy max="10"&gt;
                  &lt;Delete basePath="C:/temp/logs/" maxDepth="1"&gt;
                      &lt;IfFileName glob="app*.log*"&gt;
                          &lt;IfLastModified age="2m"&gt;
                              &lt;IfAny&gt;
                                  &lt;IfAccumulatedFileCount exceeds="11" /&gt;
                              &lt;/IfAny&gt;
                          &lt;/IfLastModified&gt;
                      &lt;/IfFileName&gt;
                  &lt;/Delete&gt;
              &lt;/DefaultRolloverStrategy&gt;
          &lt;/RollingFile&gt;
      &lt;/Appenders&gt;
      &lt;Loggers&gt;
          &lt;Root level="trace"&gt;
              &lt;AppenderRef ref="RollingFile" /&gt;
          &lt;/Root&gt;
      &lt;/Loggers&gt;
  &lt;/Configuration&gt;
  </code></pre>
  
  <p>But it does not delete all the files in the folder. For example in the screenshot below, it does not delete the old log file: </p>
  
  <p><a href="https://i.stack.imgur.com/mCtBz.jpg" rel="nofollow noreferrer">logs</a></p>
  
  <p>I have gone through all the documentation and lots of discussions but I couldn't solve this. Any help would be appreciated.</p>