Logrotate - Set logging to use `RotatingFileHandler`
Switch the logging file handler in the Django configuration to RotatingFileHandler
, to avoid letting log files grow too large.
Two new configuration variables:
-
LOGGING_ROTATE_MAX_KBYTES
: The max size of each log file (in KB) -
LOGGING_ROTATE_MAX_FILES
: The max number of log files to keep
How to test:
- Set
LOGGING_ROTATE_MAX_KBYTES=1
in your local OpenCraft IM.env
file - this is to trigger log rotation without needing to generate huge logs - Generate some logs, for example by provisioning a new instance
- Check
log/main.*
- you should see lots of small log files, a few KB each (it seem to still log a full message even if it exceeds slightly the max size, which is a desired behavior).
Note: No unit test since this is only a configuration change, but if you see a meaningful way to test this I'm happy to add it.