logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "K Sunil" <ksu...@novell.com>
Subject Re: TimeBasedRollingPolicy behaviour
Date Thu, 01 Sep 2005 10:31:16 GMT
Thanks for responding to my clarification. 
 I tried as you suggested. 
 I removed setActiveFileName. 
It worked by appending the date with the fileName. 
 I have one more clarification: 
 Is it possible to have a activeFileName with just name and no date
 and the rolled up files must have date appended. 
 What I mean is whenever log are printed, it should print to fileName
without date appended 
 and once the rollup happens then rolled up fileName should have date
 It is possible to get the functionality with log4j 1.3 alpha build. 
Thanks and Regards, 

>>> carnold@apache.org 8/31/2005 9:37 PM >>>

On Aug 31, 2005, at 7:35 AM, K Sunil wrote:
> Hi All,
>           I am using Log4j 1.3 alpha build for the development.
>           In this build, I tried to use TimeBasedRollingPolicy,  
> set  below properties
>           TimeBasedRollingPolicy f = new TimeBasedRollingPolicy();
>           f.setActiveFileName("rolling.txt");
>           f.setFileNamePattern("rolling.%d.zip");
>           f.activateOptions();
>           then setRollingPolicy to RollingFileAppender object.
>          r = new RollingFileAppender();
>          r.setRollingPolicy(f);
>          r.setLayout(s);
>           r.activateOptions();
>          I am observing different behaviour i.e
>          I am run the program it logs to rolling.txt file
>          Now I change the system time to one day more and rerun the 

> same program.
>          Behaviour observed:  It is not rolling the file, instead  
> it is appended to the same rolling.txt file
>          Expected behaviour: Should roll up the file with the date  
> appended to file Name.
>          Please let me know if I have missed any setting or Is the  
> behaviour as I am observing?
> Thanks and Regards,
> Sunil.K

The RollingFileAppender only renames files when a triggering event  
occurs while the application is running.  It does not attempt to  
determine if a triggering event would have occurred during the time  
that the application was inactive.

What you have specified currently says:   Always log to  
"rolling.txt"  If the evaluation of the file name pattern changes  
between logging events, attempt rename the old rolling.txt to the  
previous evaluation of the file name pattern.

If you are running the CVS HEAD, you can remove the setActiveFileName 
() call which will allow the active log file to be generated from the 

file name pattern.  It still would not attempt to imply transitions  
that occurred in the past, but it would likely have the behavior that 

you desired.  It is also more robust since it eliminates the close  
and rename actions.

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

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

View raw message