views:

581

answers:

2

Forget for a second the question of why on earth would you do such a thing - if, for whatever reason, two FileAppenders are configured with the same file - will this setup work?

A: 

It doesn't directly answer your question, but log4*net*'s FileAppender has a LockingModel attribute that you can set to only lock when the file is actually in use. So if you had two FileAppenders working in the same thread with MinimalLock set, it would probably work perfectly fine. On different threads, you might hit deadlock once in a while.

The FileAppender supports pluggable file locking models via the LockingModel property. The default behavior, implemented by FileAppender.ExclusiveLock is to obtain an exclusive write lock on the file until this appender is closed. The alternative model, FileAppender.MinimalLock, only holds a write lock while the appender is writing a logging event.

A cursory web search didn't turn up any useful results about implementing MinimalLock in log4j.

Mark Rushakoff
log4net has nothing in common with log4j
skaffman
Not true - it's rather similar in most concepts (error levels, appenders to name two).
ripper234
A: 

Log4j's FileAppender do not allow for two JVM's writing to the same file. If you try, you'll get corrupt log files. However, logback, log4j's successor, in prudent mode allows two appenders even in different JVMs to write to the same file.

Ceki