Difficult setup for logging the celery task queues. After many many trials and consultings of professor Google the following setup works for me:
Setting CELERY_REDIRECT_STDOUTS_LEVEL to loglevel (from celery docs) in settings:
CELERY_REDIRECT_STDOUTS_LEVELThe log level output to stdout and stderr is logged as. Can be one of DEBUG, INFO, WARNING, ERROR or CRITICAL.Default is WARNING.
And, secondly, the LOGGING var in settings like so:
'handlers': {
...
'celery': {
'level': LOGLEVEL,
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(BASE_DIR,'celery.log'),
'formatter': 'simple',
'maxBytes': 1024 * 1024 * 100, # 100 mb
},
},
'loggers': {
'py.warnings': {
'handlers': ['console', 'logfile'],
},
...
'celery': { # celery logging to special logfile (handler)
'handlers': ['celery', 'console',],
'level': 'INFO',
},
'tasks.notifications': { # celery logging to special logfile (handler)
'handlers': ['celery', 'console',],
'level': 'DEBUG',
},
}
I had to restart celery_ovgw, and the loglevel is set to “INFO” — seems to work alright, a little bit of tuning could be in order, though.