I was trying to add the date to my log file name and I was able to make it work by following the few suggestions I've found in stackoverflow. Everything works fine but for some reason, the first file always has the date appended twice.
For example, instead of log.2009-02-23.log, I get log.2009-02-23.log.2009-02-23.log.
I found it so weird and fyi, this is a very simple code. It's not like I have it running in a multi-threaded environment.
My log4net config:
<log4net>
<appender name="MyLog" type="log4net.Appender.RollingFileAppender">
<file value="../../Logs/Mylog"/>
<staticLogFileName value="false" />
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value=".yyyy-MM-dd.lo\g" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{DATE} [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="MyLog"/>
</root>
</log4net>
Any ideas why?
Edit: I want to add the information about the environment I'm testing this in.
- asp.net
- .net framework 2.0
- windows server 2003 64-bit service pack 2
- log4net 1.2.10