title: Configuring logback TimeBasedRollingPolicy to roll a file in specific way
body: <p>I'm trying to achieve a certain way of rolling files by using <code>TimeBasedRollingPolicy</code> but I can't get it to work as I intended.</p>
  
  <p>My current <code>logback.xml</code> configuration (logback version 1.1.3):</p>
  
  <pre><code>&lt;configuration debug="true"&gt;
      &lt;appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
          &lt;file&gt;${com.sun.aas.instanceRoot}/logs/server.log&lt;/file&gt;
          &lt;append&gt;true&lt;/append&gt;
  
          &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
              &lt;fileNamePattern&gt;${com.sun.aas.instanceRoot}/logs/server.%d{yyyy-MM-dd}.%i.log&lt;/fileNamePattern&gt;
              &lt;timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"&gt;
                  &lt;maxFileSize&gt;5MB&lt;/maxFileSize&gt;
              &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
              &lt;MaxHistory&gt;7&lt;/MaxHistory&gt;
          &lt;/rollingPolicy&gt;
  
          &lt;encoder&gt;
              &lt;Pattern&gt;[%d] [%thread] [%-5level] [%logger{52}]%n %msg%n%n&lt;/Pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;root&gt;
          &lt;level value="TRACE"/&gt;
          &lt;appender-ref ref="FILE"/&gt;
      &lt;/root&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>How I want the logger to behave</strong>:</p>
  
  <ul>
  <li>append log to <code>/logs/server.log</code> file until it achieves 5MB filesize or the date rolls</li>
  <li>when the <code>/logs/server.log</code> file reaches 5MB (or the date rolls)
  
  <ul>
  <li>change its name according to <code>fileNamePattern</code>(e.g. <code>logs/server.2016-09-19T10-58.0.log</code>)</li>
  <li>create new server.log file to append fresh logs to</li>
  </ul></li>
  </ul>
  
  <hr>
  
  <p><strong>How it behaves with mentioned configuration</strong>:</p>
  
  <ul>
  <li>appends log to <code>/logs/server.log</code> file indefinitely, doesn't roll the file at all.</li>
  </ul>
  
  <hr>
  
  <p><strong>What I've tried so far</strong>:</p>
  
  <ul>
  <li><p>removing the main file attribute <code>&lt;file&gt;${com.sun.aas.instanceRoot}/logs/server.log&lt;/file&gt;</code></p></li>
  <li><p>using simply the <code>TimeBasedRollingPolicy</code> <strong>without</strong> <code>SizeAndTimeBasedFNATP</code> and setting the rollover period to one minute (by adding <code>HH-mm</code> to <code>fileNamePattern</code>)</p>
  
  <p>These solutions seem to enable file rolling, but unfortunately cause the <code>/logs/server.log</code> file to be completely omitted from logging.</p></li>
  <li><p>using <code>FixedWindowRollingPolicy</code> with filesize-based only <code>SizeBasedTriggeringPolicy</code> (using the same <code>fileNamePattern</code>)</p>
  
  <p>It causes the logger to append to <code>/logs/server.log</code> file indefinitely.</p></li>
  </ul>