CSV Timed RotatingFileHandler not rotating files
We need to fulfil a request for our Python (v3.11.7) Django (v3.2.23) app to log specific security related events on a csv file that will be rotated on an hourly basis and have a filename like audit_logs20250130_0800-0900.csv.
Our Django back-end is running on a docker container with an entrypoint like gunicorn wsgi:application --bind 0.0.0.0:8000 --workers 4 --threads 4
We are trying to implement this by inheriting from logging.handlers.TimedRotatingFileHandler to implement a CSVTimedRotatingFileHandler that looks like this:
The events are logged ok at the csv file but file roll over doesn't take place. If we log in to python manage.py shell inside the django container, logging.handlers.TimedRotatingFileHandler.shouldRollover reutrns correct results and if we manually execute logging.handlers.TimedRotatingFileHandler.doRollover this happens ok as well.
But when log messages are generated, all of them are written on the base file audit_logs.csv for ever and no rotation takes place.
Any ideas why?