I have a problem with Log4net. Running C# .Net 4.7.2, Log4Net Ver. 2.0.13.
I want to have a new file
for every new day (so I set rollingStyle to 'Date')
if max size is exceeeded (so I set maximumFileSize to '10MB')
if program is started again (so I set appendToFile to 'false')
for every other user (so I use the USERNAME in the filename)
And I want to have the second generated file with a new filename, so first generated logfile wouldn't be renamed (because program could be opened twice, so first filename shouldn't be changed).
So I would expect the following filenames:
first program call: programname_user_301221.0.log
second program call: programname_user_301221.1.log
third program call: programname_user_301221.2.log
I'm using the following RollingFileAppender:
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="programname_${USERNAME}_">
<datepattern value="ddMMyy'.log'">
<staticlogfilename value="false">
<preservelogfilenameextension value="true">
<countdirection value="1">
<appendtofile value="false">
<rollingstyle value="Date">
<maxsizerollbackups value="5">
<maximumfilesize value="10MB">
<layout type="log4net.Layout.PatternLayout">
<conversionpattern value="%date{dd.MM.yyyy HH:mm:ss} %-5level %-5thread %message%newline">
With this configuration, there are two problems: When starting program, I get correctly the file "programname_user_301221.0.log"
1) When closing program and starting it again, there is no new file generated, but existing file is overwritten!
2) When starting program a second time (and first time is still running) I get correctly a second file, but with a wrong filename "programname_user_301221.0301221.log.0.log"
What I have tried:
Different changes in the RollingFileAppender