To build from the answer above using the SortByFolderFileAppender.
This is how we resolved the issue using rolling date for log filenames. I changed the staticLogFileName to true so the entire filename is passed into the OpenFile method.
If the filename ends in ".log" then nothing needs to be appended. I'm guessing some kind of locking has occurred and I want log4net to try using the same filename again, hoping the previous lock has been released.
Although, I'm not sure if this could end up causing an infinite call to OpenFile if the file is locked and won't let go of it. We did create a web service using the producer consumer pattern to log everything in one location from all applications in the system, which is currently ten and growing.
We don't need to include log4net into any of the other applications but we needed to create a web client class that is accessible by all applications to use for logging to the web service.
The result for the filename is "Logs\Client\2017\11\08.log" and obviously changes everyday.
protected override void OpenFile( string fileName, bool append )
{
// append "\yyyy\mm\dd.log" to create the correct filename.
if ( !fileName.EndsWith( ".log") )
fileName = $@"{fileName}\{DateTime.Now:yyyy\\MM\\dd}.log";
base.OpenFile( fileName, 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>