title: How to delete older rolled over log4j2 logs, keeping up to 10 files?
body: <p>What I want is:</p>
  
  <ul>
  <li>Maximum of 10 log files, in <em>total</em></li>
  <li>Each log file, not more than 50MB in size.</li>
  </ul>
  
  <p>Thus the logs folder never grows over (50MB *10 )= 500MB.</p>
  
  <p>But it seems my log4j2 config is not properly done.</p>
  
  <p>What is happening is:</p>
  
  <ul>
  <li>Logs do roll over after 50 MB</li>
  <li>But there are upto 10 logs kept <em>per day</em></li>
  <li>Thus there is no limit of number of log files kept in log folder (since for eg, in 2 days, 20 logs of 50mb each have collected)</li>
  </ul>
  
  <p>Here is the config:</p>
  
  <pre><code>&lt;Configuration status="WARN"&gt;
      &lt;Appenders&gt;
          &lt;RollingFile name="RollingFile" fileName="log/my.log" filePattern="log/my-%d{MM-dd-yyyy}-%i.log"&gt;
            &lt;PatternLayout&gt;
                  &lt;Pattern&gt;%d %p %c{1.} [%t] %m%n&lt;/Pattern&gt;
            &lt;/PatternLayout&gt;
            &lt;Policies&gt;
                  &lt;OnStartupTriggeringPolicy /&gt;
                  &lt;TimeBasedTriggeringPolicy /&gt;
                  &lt;SizeBasedTriggeringPolicy size="50 MB"/&gt;
            &lt;/Policies&gt;
            &lt;DefaultRolloverStrategy max="10"/&gt;
          &lt;/RollingFile&gt;
      &lt;/Appenders&gt;
      &lt;Loggers&gt;
          &lt;Root level="info"&gt;
              &lt;AppenderRef ref="RollingFile"/&gt;
          &lt;/Root&gt;
      &lt;/Loggers&gt;
  &lt;/Configuration&gt;
  </code></pre>
  
  <p>What am I doing wrong?</p>