You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Peter Steele <ps...@maxiscale.com> on 2008/06/05 20:18:09 UTC

Is it safe to has different processes on the same machine log to the same file?

This is what we're doing right now and it appears to be working fine. Is
this safe to do though, as a general rule?

 


Re: Is it safe to has different processes on the same machine log to the same file?

Posted by Curt Arnold <ca...@apache.org>.
On Jun 5, 2008, at 1:23 PM, Stephen Bartnikowski wrote:

> I've been doing that for two years with no issue. It was my  
> understanding that this was one of the major features of log4cxx,  
> but I could be taking that for granted.
>
> - Stephen
>
> From: Peter Steele [mailto:psteele@maxiscale.com]
> Sent: Thursday, June 05, 2008 1:18 PM
> To: log4cxx-user@logging.apache.org
> Subject: Is it safe to has different processes on the same machine  
> log to the same file?
>
> This is what we’re doing right now and it appears to be working  
> fine. Is this safe to do though, as a general rule?
>

Depends on the file IO library under log4cxx for FileAppenders.

RollingFileAppenders are likely very poorly behaved.  The file size is  
determined from the initialize size and the number of bytes written by  
the appender, so file will likely be larger than the specified value  
when rolled.  When they are rolled, either renaming may fail (usually  
on Windows) or one instance of rename the previous file and start a  
new one which other instances continue to write to the old, now  
renamed, file.  When the other instances attempt to roll, bad things  
are likely to happen.

log4cxx mimics log4j and there is no mechanism in Java to coordinate  
access to a shared file between multiple instances.  The standard  
answer to that question for log4j is that database or network  
appenders should be used in that scenario.

RE: Is it safe to has different processes on the same machine log to the same file?

Posted by Stephen Bartnikowski <sb...@barkinglizards.com>.
I've been doing that for two years with no issue. It was my understanding
that this was one of the major features of log4cxx, but I could be taking
that for granted.
 
- Stephen


  _____  

From: Peter Steele [mailto:psteele@maxiscale.com] 
Sent: Thursday, June 05, 2008 1:18 PM
To: log4cxx-user@logging.apache.org
Subject: Is it safe to has different processes on the same machine log to
the same file?



This is what we're doing right now and it appears to be working fine. Is
this safe to do though, as a general rule?