Logging help
koranthala
koranthala at gmail.com
Tue Jan 20 05:11:52 EST 2009
On Jan 20, 5:45 am, Chris Rebert <c... at rebertia.com> wrote:
> On Mon, Jan 19, 2009 at 11:36 AM, koranthala <koranth... at gmail.com> wrote:
> > Hi,
> > Is it possible somehow to have the logging module rotate the files
> > every time I start it.
> > Basically, I can automatically rotate using RotatingFileHandler;
> > Now I want it rotated every time I start the program too.
>
> Just call the .doRollover() method of the RotatingFileHandler at the
> start of the program.
> Reading The Fine Documentation for the module is helpful.
>
> Cheers,
> Chris
>
> --
> Follow the path of the Iguana...http://rebertia.com
My question was poorly framed. I will try to explain the issue a
little more.
Current doRollover method is not very helpful to rolling over every
day if the process starts and stops many times.
For example:
TimedRotatingFileHandler - when='D' Interval=1. I call
handler.doRollover everytime process starts.
First run - the output files are
log.txt
----------
Second run - files are
log.txt, log.txt.2009-01-20
----------
Till now, fine.
Third run - files are
log.txt, log.txt.2009-01-20 ***But the earlier file is overwritten***
The doRollover method does not append to the earlier file. Rather, it
creates a new file with the same name.
Due to this the earlier logs are all gone.
More information about the Python-list
mailing list