logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: 2 FileAppenders with the same file name
Date Wed, 07 Nov 2007 13:17:30 GMT

On Nov 7, 2007, at 5:30 AM, Begun, Yana wrote:

> Hi,
>
> I am looking to the way to use functionality of the both
> DayRollingFileAppender and RollingFileAppender for the same logger. Is
> it OK to create 2 different appenders with the same file name and  
> to add
> them to the same Logger?
>
> Thanks,
> Yana
>

If the file names refer to the same physical file, then bad things  
are likely to happen but log4j will do nothing to stop or warn you.   
log4j makes no attempt to detect or synchronize access to a single  
file by more than one appender.  The scenario arises most frequently  
when the same configuration file is loaded into multiple JVM's.

Instead of starting from org.apache.log4j.RollingFileAppender, look  
at org.apache.log4j.rolling.RollingFileAppender in the extras  
companion which was designed with pluggable triggering policies (when  
to roll over) and rolling policies (what to name files).  It is  
likely that you can achieve your desired behavior by supplying your  
own policies and not have to extend the appender.  If it isn't  
obvious (or even if it is), ask here and we can give advice.

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


Mime
View raw message