15.9.6. TimedRotatingFileHandler¶
The TimedRotatingFileHandler
class, located in the logging.handlers
module, supports rotation of disk log files at certain timed intervals.
- class
logging.handlers.
TimedRotatingFileHandler
(filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False) -
Returns a new instance of the
TimedRotatingFileHandler
class. The specified file is opened and used as the stream for logging. On rotating it also sets the filename suffix. Rotating happens based on the product of when and interval.You can use the when to specify the type of interval. The list of possible values is below. Note that they are not case sensitive.
Value Type of interval 'S'
Seconds 'M'
Minutes 'H'
Hours 'D'
Days 'W0'-'W6'
Weekday (0=Monday) 'midnight'
Roll over at midnight