To build from the answer above using SortByFolderFileAppender.
Here's how we solved the problem using the calendar date for log file names. I changed staticLogFileName to true, so the whole file name is passed to the OpenFile method.
If the file name ends with ".log", then nothing needs to be added. I assume that some kind of lock occurred, and I want log4net to try to use the same file name again, hoping that the previous lock will be released.
Although, I'm not sure if this can lead to an endless call to OpenFile if the file is locked and does not release it. We created a web service using a consumer-manufacturer template to register everything in one place from all applications in the system, which currently numbers ten and is growing.
We do not need to include log4net in any of the other applications, but we need to create a web client class that is accessible to all applications that will be used to log into the web service.
The result for the file name is "Logs \ Client \ 2017 \ 11 \ 08.log" and, obviously, changes every day.
protected override void OpenFile( string fileName, bool append ) {
Modification of the configuration from above.
<appender name="xxxRollingFileAppender" type="namespace.xxxRollingFileAppender"> <file value="Logs\Client"/> <staticLogFileName value="true"/> <appendToFile value="true"/> <maxSizeRollBackups value="40"/> <maximumFileSize value="1MB"/> <encoding value="utf-8"/> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date{HH:mm:ss.fff}|%-5level|%message%newline"/> </layout> </appender>
kdahl Nov 08 '17 at 2:44 on 2017-11-08 14:44
source share