‘file’: {‘level’: ‘DEBUG’,
‘class’: ‘logging.handlers.TimedRotatingFileHandler’,
‘filename’: os.path.join(LOG_PATH, ‘temp.log’),
‘when’: ‘s’,
‘interval’: 10, #rotates/creates new logs every 10 seconds
I have the above piece of code as a handler in my LOGGING configuration. The logging doesn’t work as expected, new log files are created at random timestamps and not every 10 seconds. How to resolve this. My project runs in a docker container and there are many files that use logging.

This is a Python issue and not a Django issue.

See the caveats regarding log rotation at logging.handlers — Logging handlers — Python 3.12.4 documentation. You’re not going to be able to guarantee that you’re going to get new files at exactly 10-second intervals.