log4net one file per run

Posted by Diego Mijelshon on Stack Overflow See other posts from Stack Overflow or by Diego Mijelshon
Published on 2010-06-15T20:39:49Z Indexed on 2010/06/15 20:42 UTC
Read the original article Hit count: 249

Filed under:

I need my application to create a log file each time it runs.

My preferred format would be App.log.yyyy-MM-dd_HH-mm-ss. If that's not possible, I'd settle for App.log.yyyy-MM-dd.counter

This is my current appender configuration:

<appender name="File" type="log4net.Appender.RollingFileAppender">
  <file value="App.log"/>
  <rollingStyle value="Date"/>
  <datePattern value=".yyyy-MM-dd_HH-mm-ss"/>
  <staticLogFileName value="false"/>
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
</appender>

But it creates a random number of files based on the date and time.

© Stack Overflow or respective owner

Related posts about log4net