what's the difference between "when='D' " and "when='midnight'" for TimedRotatingFileHandler?
There are two relevant parameters to TimedRotatingFileHandler
: when
, and interval
. Most of the possible values for when
, such as D
for days, or H
for hours, work in conjunction with interval
—for example, if when='D', interval=7
were specified, then the log would be rotated every seven days. Similarly, if when='H', interval=12
were specified, then the log would be rotated every twelve hours, starting when the script is launched. when='midnight'
is a special case, in that the interval
parameter is not used, and the log is rolled over on a daily basis at midnight, regardless of the time when the script is launched (see the source here).