In the Unix world, it usually works for small amounts of data as the file
system will manage the simultaneous access itself. There are no guarantees
though on ordering, whether the full message will be logged (if it is a long
message), or whether it will work at all. On Windows, I'm doubting it will
work due to windows not liking more than one process to write to a file at a
time, but this depends on how the file is actually opened in log4j (and
ultimately in Java), and I'm no expert here.

The same type of problem exists when mail servers must accept large amounts
of mail for a single mailbox. To handle things correctly, locking is used
(whether that be file system locking, creating a lock file, etc), and then
things like race conditions must be handled, deadlocks, etc. as the locking
process might die leaving the lock. A much more complicated problem than it
seems on the surface.

Back to your question, it will probably work on Unix (success depends upon
the Unix variant), and probably not so well on Windows. In any case, if you
want your code to be truly portable and safe, it is probably better to not
do it. Not exactly the type of thing you want to rely upon, especially when
it might change when you upgrade your OS.

- kate

On 3/5/07, James Stauffer <[EMAIL PROTECTED]> wrote:

Generally having more than 1 process write to a file is bad.  You
could have both processes send the logs to a socket appender and have
1 socket server receive them and write them to the 1 file.

On 3/5/07, Cheung, Quinn <[EMAIL PROTECTED]> wrote:
> Is there any danger in having more than 1 process (or more than 1
thread)  use File Appenders that are configured to write to the same
file?  If it can be done safely, are there any performance issues?
>
> Thanks
> Squid
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
James Stauffer        http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Kate Ward <[EMAIL PROTECTED]>

Reply via email to