On 2011-09-13, Dominik Psenner wrote:

>> LOG4NET-164 introduced a new locking strategy for FileAppender which
>> technically uses a System.Threading.Mutex with a name built from the log
>> file's name.  This should allow separate processes to share a log file
>> without repeatedly opening and closing it.

>> The main remaining issue is its name (apart from docs which will follow
>> once the name is settled).  Right now it is called MutexLock but that
>> may not convey to users what this actually does - they'd need to know
>> what a Mutex is in the first place.

>> I'm notoriously bad at names so I'm asking here now.  Names suggested in
>> the JIRA ticket are "InterProcessLock", "SystemWideLock" and
>> "GlobalLock".

> Are we talking about the variable name? In that case I would prefer a name
> that makes it obvious what it is behind:

> MutexLock

Not only, it would also appear inside the config file in order to set
the locking model of FileAppender like in the third example of
http://logging.apache.org/log4net/release/config-examples.html#fileappender
Right now it would be 

<lockingModel type="log4net.Appender.FileAppender+MutexLock" />


> Did you actually do performance tests too? A mutex is rather expensive and
> it should be avoided to acquire/release it multiple times unless really
> necessary.

It would be aquired and released for each single logging event.  The
alternatives are (1) don't share the same log file between different
processes or (2) repeatedly open and close the file (which is the
MinimalLocking model).  Whether the mutex performs better or worse than
MinimalLocking depends on the concrete circumstances, I guess, but I'd
expect the overhead of opening a file to be significant as well.

Stefan

Reply via email to