Bogey Jammer
Bogey Jammer

Reputation: 688

How to configure logging handler to produce weekly rotated log files?

TimedRotatingFileHandler(filename, when='W', interval=0, backupCount=0)

Produces:

ValueError: Unable to configure handler 'fichierSemaineStandard': You must specify a day for weekly rollover from 0 to 6 (0 is Monday): W

But the python documentation tells

value: 'W', type of interval: Week day (0=Monday)

So what's wrong?

Upvotes: 2

Views: 1768

Answers (1)

Bogey Jammer
Bogey Jammer

Reputation: 688

It seems that this section of documentation is not clear about this. After having a peek in the code, to make the week rotation work, the 'W' argument is not sufficient. The weekday number must be placed just after the letter W:

TimedRotatingFileHandler(filename, when='W0', backupCount=0)

Note that the "interval" argument is useless.

Upvotes: 5

Related Questions