I have a problem with the log output in a single file by using MPI (Message Passing Interface) into my app (write in C#) and log4net. The log output works fine when my app a little time works but when the app start created log4net sometimes not one log file but two or three log files. Here a example:
Properly (App start and log4net build one log file):
- Log_2014_02_25_[12.39.07]_Build_2014_02_25
Wrong (App start and log4net build three log files):
- Log_2014_02_25_[12.12.03]_Build_2014_02_25
- Log_2014_02_25_[12.12.03]_Build_2014_02_252014_02_25
- Log_2014_02_25_[12.12.03]_Build_2014_02_252014_02_25252014_02_25
I think log4net tries exactly at the same time to write something in the log file. If that coincidentally happens is the log file locked and log4net cannot in the same log file write. In this case created log4net probably created a new log file. In short, I think the problem is the Minimal Lock from log4net but I'm not sure and not know how I can solve the error.
Here my log4net config:
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="Logs\%property{LogFileName}.log"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy_MM_dd" />
<staticLogFileName value="false" />
<preserveLogFileNameExtension value="true"/>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{dd.MM.yyyy HH:mm:ss} - %message%newline" />
</layout>
</appender>
var fileName = string.Format("Log_{0}_[{1}]_Build_",
DateTime.Now.ToString("yyyy_MM_dd"), DateTime.Now.ToString("HH.mm.ss")); //
GlobalContext.Properties["LogFileName"] = fileName;
log4net.Config.XmlConfigurator.Configure();
Thx for all help.... :)