Create a folder for each day and a new file when max size is reached
<p>I need to create a logs directory outside the location of my application and a folder for each date. I also need to create a new file when the max size is reached.</p>

<p>I'm using this code:</p>

<pre><code>&lt;log4net&gt;
    &lt;appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender,log4net"&gt;
      &lt;file type="log4net.Util.PatternString" value="D:/Logs/EmailService/"/&gt;
      &lt;appendToFile value="true"/&gt;
      &lt;rollingStyle value="Size"/&gt;
      &lt;datePattern value=".yyyyMMdd\\\\'service.log"/&gt;
      &lt;staticLogFileName value="true"/&gt;
      &lt;maximumFileSize value="5MB"/&gt;
      &lt;maxSizeRollBackups value="20"/&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;conversionPattern value="%date [%thread] %-5level %logger [%ndc] – %message%newline"/&gt;
      &lt;/layout&gt;
      &lt;lockingModel type="log4net.Appender.FileAppender+MutexLock" /&gt;
    &lt;/appender&gt;

    &lt;!-- Setup the root category, add the appenders and set the default level --&gt;
    &lt;root&gt;
      &lt;level value="DEBUG" /&gt;
      &lt;appender-ref ref="LogFileAppender" /&gt;
    &lt;/root&gt;
  &lt;/log4net&gt;
</code></pre>

<p>However, the files are not being created. What is wrong with it?</p>

<h2>UPDATE</h2>

<p>Here's the complete code, that along with @stuartd's answer were able to create the directory per date:</p>

<pre><code>&lt;log4net&gt;
    &lt;appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender,log4net"&gt;
      &lt;file type="log4net.Util.PatternString" value="D:/Logs/emailservice/%date{yyyyMMdd}/logfile.log"/&gt;
      &lt;appendToFile value="true"/&gt;
      &lt;rollingStyle value="Composite"/&gt;
      &lt;maximumFileSize value="5MB"/&gt;
      &lt;maxSizeRollBackups value="20"/&gt;
      &lt;datePattern value="yyyyMMdd"/&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;conversionPattern value="%date [%thread] %-5level %logger [%ndc] – %message%newline"/&gt;
      &lt;/layout&gt;
    &lt;/appender&gt;

    &lt;!-- Setup the root category, add the appenders and set the default level --&gt;
    &lt;root&gt;
      &lt;level value="WARN" /&gt;
      &lt;appender-ref ref="LogFileAppender" /&gt;
    &lt;/root&gt;
  &lt;/log4net&gt;
</code></pre>