title: What determines when a log4j TimeBasedRollingPolicy rolls over?
body: <p>I'm setting up a <code>TimeBasedRollingPolicy</code> from <em>Log4J Extras</em> and I am not clear what tells the policy when to roll over.  <a href="http://logging.apache.org/log4j/companions/extras/apidocs/org/apache/log4j/rolling/TimeBasedRollingPolicy.html" rel="nofollow noreferrer">The API</a> is not explicit so I'm just making inferences.  It sounds like it's the last element in the <code>FileNamePattern</code> that determines the frequency.</p>
  
  <p>Take this example from the <a href="http://wiki.apache.org/logging-log4j/Log4jXmlFormat" rel="nofollow noreferrer">log4j Wiki</a>:</p>
  
  <pre><code>&lt;appender name="ROLL" class="org.apache.log4j.rolling.RollingFileAppender"&gt;
      &lt;!-- The active file to log to --&gt;
      &lt;param name="file" value="/applogs/myportal/portal.log" /&gt;
      &lt;param name="append" value="true" /&gt;
      &lt;param name="encoding" value="UTF-8" /&gt;
  
      &lt;rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"&gt;
      &lt;!-- The file to roll to, this is a fairly intelligent parameter, if the file
           ends in .gz, it gzips it, based on the date stamp it rolls at that time, 
           default is yyyy-MM-dd, (rolls at midnight)
      --&gt;
          &lt;param name="FileNamePattern" value="/applogs/myportal/portal.%d.log.gz" /&gt;
      &lt;/rollingPolicy&gt;
  
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%5p %d{ISO8601} [%t][%x] %c - %m%n" /&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  </code></pre>
  
  <p>Am I to assume that because the pattern ends in <code>dd</code>, the policy is to roll when that changes?  Same with an example in the API, a pattern of <code>yyyy-MM</code> means the file should roll when <code>MM</code> changes?</p>
  
  <p>Thanks!</p>
  
  <p>Paul</p>