user20929302
user20929302

Reputation: 403

Python Timed Rotating Logs

Asking for some clarification on this article in the section labeled "TimedRotatingLogs": https://www.blog.pythonlibrary.org/2014/02/11/python-how-to-create-rotating-logs/

    handler = TimedRotatingFileHandler(path,
                                       when="m",
                                       interval=1,
                                       backupCount=5)

I am curious about this part in particular. When looking at the article it says for "WeekDay" do "w0-w6". Would that look like this? :

        handler = TimedRotatingFileHandler(path,
                                       when="w",
                                       interval=0,
                                       backupCount=5)

Or would it look like:

 handler = TimedRotatingFileHandler(path,
                                       when="w0",
                                       interval=1,
                                       backupCount=5)

And explain why one over the other

Upvotes: 2

Views: 148

Answers (1)

Travis
Travis

Reputation: 687

According to the article on Kite Docs. It states that

When using weekday-based rotation, specify ‘W0’ for Monday, ‘W1’ for Tuesday, and so on up to ‘W6’ for Sunday. In this case, the value passed for interval isn’t used.

So going from there The code in your case would be

handler = TimedRotatingFileHandler(path, when="w0", backupCount=5)

Upvotes: 1

Related Questions