Harry <harry.l...@gmail.com> added the comment:
The issue appears when the TimedRotatingHandler rolls over to a filename that already exists. Running your bash script, the handler correctly rolls over so you end up with the expected behaviour. This issue arises in the case that there is already a file with the target name, that file will be overwritten when the handler rolls over. This can be seen clearly if you modify test.sh to contain python3 log_44186.py foo python3 log_44186.py bar python3 log_44186.py baz results are below: $ python3 --version Python 3.9.5 $ bash ./test.sh 10 14 51 TEST > [INFO] [2021-08-01 10:14:51] : foo 2021-08-01T10:14:51.521266 10 14 51 TEST > [INFO] [2021-08-01 10:14:51] : bar 2021-08-01T10:14:51.577802 10 14 51 TEST > [INFO] [2021-08-01 10:14:51] : baz 2021-08-01T10:14:51.634795 $ ls | grep .log test.log test.log.2021-07-31 $ cat test.log baz 2021-08-01T10:14:51.634795 $ cat test.log.2021-07-31 bar 2021-08-01T10:14:51.577802 as you can see, the logs from foo have been overwritten. A very similar result can be seen if you manually create a file and then run the test script. $ python3 --version Python 3.9.5 $ echo "logging test" > test.log.2021-07-31 $ python3 log_44186.py foo 10 33 25 TEST > [INFO] [2021-08-01 10:33:25] : foo 2021-08-01T10:33:25.003750 $ cat test.log foo 2021-08-01T10:33:25.003750 $ cat test.log.2021-07-31 $ once again, you can see that the handler overwrote the target file (this time leaving it blank as there were no logs to write). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44186> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com