Logging help

koranthala koranthala at gmail.com
Mon Jan 19 20:36:05 CET 2009


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.
   Ex: The logging file - log.txt
   Now, rotatingfilehandler goes and updates to log.txt.1, log.txt.2,
log.txt.3 etc.
   Now, I also want to rotate it automatically I start the program -
i.e.
   The second time I start the program - log.txt -> log.txt.1, log.txt.
1 -> log.txt.2 etc.

   I can write up a simple script to move it by 1 digit every time.
   My question is - is it possible automatically via logging
functionality? This is needed because say TimedRotatingFileHandler etc
wont work that well otherwise.

   It does look like  twisted.python.logfile.DailyLogFile seems to be
an Ok option, but I want to use the logging module in the Python
distribution, since it is more powerful.




More information about the Python-list mailing list