File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -402,7 +402,8 @@ timed intervals.
402402 rollover interval.
403403
404404 When computing the next rollover time for the first time (when the handler
405- is created), the last modification time of an existing log file, or else
405+ is created), the creation time (if supported by the OS and file system)
406+ or the last modification of an existing log file, or else
406407 the current time, is used to compute when the next rotation will occur.
407408
408409 If the *utc * argument is true, times in UTC will be used; otherwise
@@ -449,6 +450,10 @@ timed intervals.
449450 .. versionchanged :: 3.9
450451 The *errors * parameter was added.
451452
453+ .. versionchanged :: next
454+ Use the creation time instead of the last modification time, if supported by the OS and file system.
455+
456+
452457 .. method :: doRollover()
453458
454459 Does a rollover, as described above.
Original file line number Diff line number Diff line change @@ -102,6 +102,17 @@ lzma
102102 requires ``lzma `` 5.4.0 or newer while RISC-V requires 5.6.0 or newer.
103103 (Contributed by Chien Wong in :gh: `115988 `.)
104104
105+ logging
106+ -------
107+
108+ * :class: `~logging.handlers.TimedRotatingFileHandler ` now uses the creation
109+ time instead of the last modification time of an existing log file as
110+ the basis for the first rotation after handler creation, if supported by
111+ the OS and file system.
112+ This allows it to be used in short-running programs that start and end
113+ before the rotation interval expires.
114+ (Contributed by Iván Márton and Serhiy Storchaka in :gh: `84649 `.)
115+
105116os
106117--
107118
Original file line number Diff line number Diff line change 1- A bug has been fixed that made the ``TimedRotatingFileHandler `` use the
2- MTIME attribute of the configured log file to to detect whether it has to be
3- rotated yet or not. In cases when the file was changed within the rotation
4- period the value of the MTIME was also updated to the current time and as a
5- result the rotation never happened. The file creation time (CTIME) is used
6- instead that makes the rotation file modification independent.
1+ :class: `~logging.handlers.TimedRotatingFileHandler ` now uses the creation time
2+ instead of the last modification time of an existing log file as the basis
3+ for the first rotation after handler creation, if supported by the OS and file system.
4+ This allows it to be used in short-running programs that start and end before
5+ the rotation interval expires.
You can’t perform that action at this time.
0 commit comments