Details
Description
I have the following requirement in my ASP.Net web project:
- log4net should be used to create a log file for each day
- in my web application root dir there should be a folder "logs"
- in the folder "logs" there should be a folder "YYYY-MM-DD" for each day
- Inside each day folder there is a logfile called "logfile.txt"
I have the following log4net configuration in web.config:
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<threshold value="INFO" />
<file value="logs/" />
<datePattern type="log4net.Util.PatternString" value="yyyy-MM-dd
'logfile.txt'" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<staticLogFileName value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level (%logger:%line) - %message%newline" />
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="RollingFileAppender" />
</root>
{{ </log4net>}}
This configuration worked very good a long time, BUT since 3 months, we observed a strange behaviour: Each day log4net jumps between 2 files and logs the lines sometimes in the first file and then for some seconds/minutes in the other file and then back to the first file and so on. For example:
../logs/2021-07-03/logfile.txt <-- this day was okay, all logs are in 1 file
../logs/2021-07-04/logfile.txt <-- this file starts at 00:00:00
../logs/2021-07-04/logfile.txt2021-07-04/logfile.txt <-- this was created additionally on the same day, and then log4net jumps between these 2 files
You see that log4net creates a folder in between named "logfile.txt2021-07-04". This is the pattern every day now. But it only creates 2 files, not more per day. Sometimes the logs jump within 1 second between these 2 files if there is lots of traffic on our webapplication.
We use a very old stable log4net version 1.2.11, but it works before without any problems. Nothing was changed to the log4net configuration, the only change could be that perhaps more users access the web application than before.
What could be the reason for this? Is there any workaround I can do?