You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Rohit Sonalkar <ro...@ipunity.com> on 2005/05/24 05:31:31 UTC

RollingFileAppender

Hi,

The RollingFileAppender rolls over files when they reach a certain size.
What is the technique it uses to do the roll over if for e.g. the
maxBackupIndex is 10 and there are currently 10 files? Does it simply
delete logs.out.10 and rename logs.out.9 as logs.out.10, logs.out.8 as
logs.out.9 and so on, or does it do file copying? I guess what I am
asking is what is penalty on the JVM while the rollover is in progress,
will all threads doing logging at that time get suspended till the
rollover is complete? If so, what is the approximate relation between
this suspension period and the maxBackupIndex?

Thanks
Rohit



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: RollingFileAppender

Posted by Curt Arnold <ca...@apache.org>.
On May 23, 2005, at 10:31 PM, Rohit Sonalkar wrote:

>
> Hi,
>
> The RollingFileAppender rolls over files when they reach a certain  
> size.
> What is the technique it uses to do the roll over if for e.g. the
> maxBackupIndex is 10 and there are currently 10 files? Does it simply
> delete logs.out.10 and rename logs.out.9 as logs.out.10, logs.out.8 as
> logs.out.9 and so on, or does it do file copying?

The log4j 1.2.x code checks if each possible filename using  
File.exists() and if so, uses File.renameTo() to rename.

The log4j CVS HEAD until a few hours ago would attempt a similar  
approach but if the file was locked and could not be renamed, it  
would attempt to copy it.  The very fresh CVS HEAD code will defer  
rolling over until a successful rename sequence can be completed.


> I guess what I am
> asking is what is penalty on the JVM while the rollover is in  
> progress,
> will all threads doing logging at that time get suspended till the
> rollover is complete? If so, what is the approximate relation between
> this suspension period and the maxBackupIndex?

All threads logging to a particular rolling appender will be blocked  
until the file rename operation is complete.  The rename pass is  
linear with the (maxBackupIndex - minBackupIndex).  If the operation  
was done by retrieving a list of matching files by calling File.list 
(), then the operation could be linear with the number of matching  
files and I might give that a shot in the CVS HEAD.



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org