Thank you all.
We created SortByFolderFileAppender, which inherit from RollingFileAppender
Example of final result:
somewhere\Logs\20100305\Client-104615.0
namespace CustomLogging
{
public class SortByFolderFileAppender : log4net.Appender.RollingFileAppender
{
protected override void OpenFile(string fileName, bool append)
{
//Inject folder [yyyyMMdd] before the file name
string baseDirectory = Path.GetDirectoryName(fileName);
string fileNameOnly = Path.GetFileName(fileName);
string newDirectory = Path.Combine(baseDirectory, DateTime.Now.ToString("yyyyMMdd"));
string newFileName = Path.Combine(newDirectory, fileNameOnly);
base.OpenFile(newFileName, append);
}
}
}
<appender name="SortByFolderFileAppender" type="CustomLogging.SortByFolderFileAppender">
<file type="log4net.Util.PatternString" value="Logs\Client"/>
<appendToFile value="true"/>
<rollingStyle value="Composite"/>
<datePattern value="-HHmmss"/>
<maxSizeRollBackups value="40"/>
<maximumFileSize value="1MB"/>
<countDirection value="1"/>
<encoding value="utf-8"/>
<staticLogFileName value="false"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{HH:mm:ss.fff}|%-5level|%message%newline"/>
</layout>
</appender>