title: Logback: SizeAndTimeBasedRollingPolicy applies totalSizeCap to each day in maxHistory
body: <p>Logback version 1.2.3</p>
  
  <p>I want to use a SizeAndTimeBasedRollingPolicy in our logback configuration file (logback.xml), but at this time the SizeAndTimeBasedRollingPolicy doesn't function as expected. (<a href="https://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy" rel="noreferrer">https://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy</a>)</p>
  
  <p>Ideally I want to keep logs dating back no later than ex. 90 days, each file no larger than 100MB and a total archive size of ex. 10GB in total.</p>
  
  <p>As it currently stands, the totalSizeCap is applied to each entry within the MaxHistory range.
  Ex.</p>
  
  <pre><code>&lt;appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
      &lt;file&gt;mylog.txt&lt;/file&gt;
      &lt;rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"&gt;
        &lt;!-- rollover daily --&gt;
        &lt;fileNamePattern&gt;mylog-%d{yyyy-MM-dd}.%i.txt&lt;/fileNamePattern&gt;
         &lt;!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB --&gt;
         &lt;maxFileSize&gt;100MB&lt;/maxFileSize&gt;    
         &lt;maxHistory&gt;60&lt;/maxHistory&gt;
         &lt;totalSizeCap&gt;1GB&lt;/totalSizeCap&gt;
      &lt;/rollingPolicy&gt;
      &lt;encoder&gt;
        &lt;pattern&gt;%msg%n&lt;/pattern&gt;
      &lt;/encoder&gt;
  &lt;/appender&gt;
  </code></pre>
  
  <p>The above XML configuration will create logs spanning over 60 days, applying a totalSizeCap of 1GB per day. This will lead to a total archive size of 60GB instead of the expected 1GB. If the totalSizeCap is reached during the day the day's logs will start to rollover by deleting the day's oldest files, this will create gaps within the log history, which we don't want. A work-around for this error was to use a yearly rollover, instead of daily or monthly rollover, unfortunately yearly rollover doesn't work when using a SizeAndTimeBasedRollingPolicy.</p>
  
  <p>Does anyone know of this problem, has this been fixed, or am I doing something wrong in my configuration?</p>