I have a batch process that I want to log to MyProcess.YYYYMMDD.log. Usually it runs daily, but sometimes due to failures or testing, it gets run multiple times per day. Based on looking at other log4net questions, I am using the RollingLogFileAppender to create the date-based files. However, if multiple runs happen in the same day, I end up with those multiple runs being logged to the same file.
Ideally, I would like the first run of the batch process to log to MyProcess.YYYYMMDD.log, but the second run in the same day to log to MyProcess.YYYYMMDD.2.log, etc.
What is the easiest way to accomplish this with log4net?
If it is important, my current appender config looks like this:
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="MyProcess.log" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value=".yyyyMMdd" />
<staticLogFileName value="false"/>
<PreserveLogFileNameExtension value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>