Why can't you use the default, ExclusiveLock? log4net automatically manages 
writing messages from different threads in the same process. InterProcessLock 
is for a specific use case where more than one process is trying to write to 
the same file. In that case writing to multiple files and combining then in a 
log aggregator seems like a better idea.
    On Tuesday, January 21, 2020, 06:40:03 AM EST, Denis Levushkin 
<denis.levush...@visma.com> wrote:  
 
   Hi,
I have discovered a problem with "interprocesslock" locking model used in our 
project for File appender. I will appreciate if you could investigate the issue 
and let me  know what is wrong. Maybe it is a bug within log4net dll.

ISSUE:If file appender is configured with
"<lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />"
and 
"<maximumFileSize value="5MB" />"
Then splitting file for each new day works fine while splitting file during a 
day on limit "5MB" reached crashes the whole application. If I set  
maximumFileSize value to another value, let us say, to "50KB"  then the app 
crashes when log file reaches these 50KB. Previous file gets footer at the end, 
new file is creating and even first attempt to write to new file is always ok. 
However, any next attempt to write into new log file by log4net dll fails.
The issue fixes only by changing locking model from "InterProcessLock"  to 
"MinimalLock". However, we would like to use "InterProcessLock" because it 
works faster and we do logging only from one single process.  It is a windows 
service written in C# .net with multi-threading approach used. Therefore, one 
process with a lot of separate threads starting and stopping inside. And 
logging works fine every day until log file reaches the limit by value. As I 
said, splitting of log file on each new day does not produce any issues.
I turned on diagnostic and debug mode for log4net library. All files are 
attached. Configuration file is also attached.
The code line that fails:
if (Log.IsInfoEnabled) Log.Info("New schedule configuration is saved 
successfully on server.");

if I have two such lines of code written within the same function and after the 
first one file reaches the limit then call of the second will crash the app.

Best regards 







| Denis LevushkinSoftware Architect - H&L LønnMobile +47 45 83 80 69 | 
Switchboard +47 46 40 40 00 Visma Software ASKarenslyst Allé 56, 0277 Oslo | 
http://www.visma.no |

 
|  | Stay ahead with leading cloud software |

This communication is intended for the person(s) named above only. It contains 
information that is confidential and legally privileged. If received in error, 
please delete this e-mail and notify the sender.  

Reply via email to