We have a big solution composed of several application. One of the application is ran very regularly( every 10minutes), and sometimes if the computer is busy, two executions may ran in parallel. (The question is not about if it's a good idea or not).
The only issue we currently have is that sometimes, the two overlapping process are both having a ILogger
for the same file, we have an error from log4net, indicating that it cannot access to the file(file already used by another process or something like that).
Here is how we have the log configured:
RollingFileAppender appender = new RollingFileAppender
{
Name = appenderName,
File = fileName,
AppendToFile = true,
MaxSizeRollBackups = 10,
MaximumFileSize = "10MB",
RollingStyle = RollingFileAppender.RollingMode.Size,
StaticLogFileName = false,
LockingModel = new FileAppender.MinimalLock(),
ImmediateFlush = true
};
What would be the best way to handle this issue? We cannot have one file per execution.
EDIT
Here is the error I get:
log4net:ERROR [RollingFileAppender] Unable to acquire lock on file XXXX. The process cannot acces the file because it is being used by another process.