logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Is it safe to has different processes on the same machine log to the same file?
Date Fri, 06 Jun 2008 02:26:47 GMT

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.
View raw message