title: How to control log file with daily rolling and max file size by log4j?
body: <p>I would like to create log file that can be rolled at the beginning of the next day or if it's reached to specified file size and log file must be contained inside date folder.
  Format of folder is <code>YYYYMMDD</code> (<code>/20111103/mylogfile.log</code>)</p>
  
  <p>Is it possible to do this by Log4j without implementing custom class? </p>
  
  <p>Now I am using log4j and log4j-extra, 
  I set FileNamePattern attribute as defined in log4j API to rolling my file everyday 
  and set max file size to 50 MB.</p>
  
  <p>My <code>log4j.xml</code> is:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;appender name="MYAPPENDER" class="org.apache.log4j.rolling.RollingFileAppender"&gt;
      &lt;param name="encoding" value="UTF-8" /&gt;
      &lt;param name="append" value="true" /&gt;
      &lt;rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"&gt;
          &lt;param name="FileNamePattern" value="${catalina.home}/logs/MY-APP/%d{yyyyMMdd}/MY-APP_%d{yyyyMMddHHmmss}.log" /&gt;
      &lt;/rollingPolicy&gt;
      &lt;triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy"&gt;
          &lt;param name="maxFileSize" value="50000000" /&gt;
      &lt;/triggeringPolicy&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="[%d{dd/MM/yyyy HH\:mm\:ss}] %-5p [%c.%M(),%4L] - %m%n" /&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  </code></pre>
  
  <p>Result of above setting is that log file is not rolled at the beginning of next days but if file's size reached to 50 MB, log file will be rolled.</p>
  
  <p>Please help to advise me. m(_ _)m</p>