You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by K Sunil <ks...@novell.com> on 2005/08/31 14:35:21 UTC

TImeBasedRollingPolicy behaviour



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 
  
               
  
              


Re: TimeBasedRollingPolicy behaviour

Posted by Jacob Kjome <ho...@visi.com>.
Quoting K Sunil <ks...@novell.com>:

> 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
> appended
>  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
> appended.
>
>  It is possible to get the functionality with log4j 1.3 alpha build.
>

If you provide a patch, it will make it much more likely to get into 1.3.

Jake

>
> Thanks and Regards,
> Sunil.K
>
>
> >>> 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
>




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


Re: TimeBasedRollingPolicy behaviour

Posted by K Sunil <ks...@novell.com>.
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
appended 
 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
appended. 
     
 It is possible to get the functionality with log4j 1.3 alpha build. 
 
 
Thanks and Regards, 
Sunil.K 


>>> 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


Re: TImeBasedRollingPolicy behaviour

Posted by Curt Arnold <ca...@apache.org>.
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