My scheduled task will be 5 o'clock in the morning every day to adjust a transaction, trading logs with the logging module, today found that log has a problem, the following troubleshooting.
When viewing the log, I found that I should have logged 5, and the log time was displayed as
2016-09-12 21:00:02,379-info-novel.py[line:82]-Select day
Checked the code, did not find the problem, and then found 21 points and 5 spreads 8 hours, that is, the log hit UTC time
To search the relevant information on the Internet, a post said he used logging, the use of Timedrotatingfilehandler will put today's log into yesterday's log file, feeling and my problem is very similar, To see the Timedrotatingfilehandler module
View Timedrotatingfilehandler no obvious problem, so simplify the code, want to debug to see where the time has changed
The first run results come out, fuck, the result is correct
Later thought I was in the Windows test, this problem will not only appear in Linux, and then copy the code to Linux, execute, there is a problem.
Compared to the logging module code under Windows and Linux, there are some differences, but no time-related differences
Next, make a Linux environment, install an IDE, go to debug, see where the problem is
Troubleshooting Python Logging Timedrotatingfilehandler module