I have below settings in my celery configuration file:
I looked at the settings file of the celery and there is no option to specify the log file size limit in the configuration. Even the code looks like its using the StreamHandler instead of the RotationHandler class. Any clues/hints ?
Thanks.
For log rotation on Ubuntu, if you have your celery log in /var/log/celery/ celeryd.log you can use a configuration like the one above to do weekly log rotation with /etc/logrotate.d/.
/var/log/celery/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
copytruncate
}
Try using a [WatchedFileHandler][1]
. It notices that a file has been truncated or changed otherwise and reopens the file. Note you must set CELERY_HIJACK_ROOT_LOGGER = False and then setup this logger yourself, and do logging.getLogger('custom_logger') inside the tasks yourself. See this post about how Celery's builtin logging configuration is not flexible and for fine-grained control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With