0

What is the correct process for having logrotate manage files written to by the python logging module? Usually I would use a WatchedFileHandler but I need to target 2.4, which does not have this class. Is there a function in the logging module which i can attach to a HUP handler, perhaps, to have it reopen the logfile?

2 Answers2

0

I would advise that you copy the source of WatchedFileHandler from a later version and adapt it, if needed, so that it works on 2.4.

Vinay Sajip
  • 95,872
  • 14
  • 179
  • 191
  • For those of you who want to do thi, it is in Lib/logging/handlers.py. I ended up just using TimedRoatingFieHandler and having python do the rotation for me. – James Bennet Aug 14 '13 at 09:31
0

The logrotate utility needs to be told which files to rotate, and with what options. You might want to override the standard WatchedFileHandler class to make entries required in /etc/logrotate.d as part of your module load sequence before logging begins.

Chris Johnson
  • 20,650
  • 6
  • 81
  • 80