3👍
✅
For some reason, even if Celery is using then handlers you specify in Django’s logging settings, it still overrides the levels of the loggers. I’m now using this function to get a logger. With the logger set to the appropriate level, things seem to be working as expected.
import logging
from celery.utils.log import get_task_logger
def get_celery_logger(name):
logger = get_task_logger(name)
logger.level = logging.INFO
return logger
👤Josh
1👍
First of all, if you use django-celery
you can try it run as so:
./manage.py celeryd –loglevel=info
Secondly, if you use Celery >= 3.0 you must get logger object as:
from celery.utils.log import get_task_logger logger = get_task_logger(__name__) # and inside your function use # logger instead logging @periodic_task(run_every=crontab()) def test_logging(): print('running test_logging') logger.info("Here's an info message", extra = { 'tell_admins': True, 'email_content': 'Additional content' }) logger.error("Here's an error message")
If it would not work you also can try change LOGGIN object
Source:stackexchange.com