Ivan Marton <git...@martonivan.hu> added the comment:
The assumed behaviour of TimedRotatingFileHandler is to rotate log files older than configured. Even when the script is executed multiple times. self.rolloverAt (the variable that defines when the rollover should be performed) is set after each rollover and right after initializing the file handler instance. If the instance is initialized once (like in your script) and a rollover is performed without having the object destroyed, the logger works fine, the rollover is done and the next round is scheduled properly. The case is not so lucky if the script runs multiple time or the logger itself is initialized multiple times during one execution. In this case, since the MTIME is read each time when the TimedRotatingFileHandler's init is called, and the file is modified (by having a new line added to the end of the file). The next execution will read the new MTIME and will never perform any rollover. I've slightly modified your example script to demonstrate these use-cases. Example 1: Log a single line with the script, but execute it multiple times with delays between the execution! In bash: for i in {1..101}; do python log_40469_single.py $i; sleep 30; done Example 2: Log multiple lines, but reinitiate the logger object between the events! See log_40469_new_instance.py ---------- Added file: https://bugs.python.org/file50208/log_40469_new_instance.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40469> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com