9

I'm using the following command:

celery worker -l info -A django_app --concurrency=10 --autoreload

But DEBUG logs are still pouring out, same goes for when using -l warning and --logfile

enter image description here


Any idea why Celery would ignore the log setting?


Further details:

the logs come from the Python library suds which outputs to the logger using DEBUG.

RadiantHex
  • 24,907
  • 47
  • 148
  • 244
  • Possible duplicate of [Django Celery Logging Best Practice](http://stackoverflow.com/questions/13366312/django-celery-logging-best-practice) – Hans Westerbeek Dec 05 '16 at 13:15

2 Answers2

7

I had the same problem and I decide to to adjust loglevel inside settings.py:

LOGGING['loggers']['celery'] = {
                               'handlers': ['console', <etc>],
                               'level': <LEVEL_YOU_WANT>,
                               'propagate': True,
                              }

Also I decide to disable some "not interesting" logs:

LOGGING['loggers']['celery.redirected'] = {
                                           'handlers': ['console', <etc>],
                                           'level': <LEVEL_YOU_WANT>,
                                           'propagate': False,
                                          }
for i in ['worker', 'concurrency', 'beat']:
    LOGGING['loggers']['celery.' + i] = {
                               'handlers': [],
                               'level': 'WARNING',
                               'propagate': True,
                              }
for i in ['job', 'consumer', 'mediator', 'control', 'bootsteps']:
    LOGGING['loggers']['celery.worker.' + i] = {
                               'handlers': [],
                               'level': 'WARNING',
                               'propagate': True,
                              }

Doing so will let you see only logs from you tasks, and not Celery's "machinery".

Artem Mezhenin
  • 5,539
  • 6
  • 32
  • 51
1

Try using the CELERYD_HIJACK_ROOT_LOGGER setting:

celery_instance = Celery('django_app')
celery_instance.add_defaults({
    'CELERYD_HIJACK_ROOT_LOGGER': False,
})
Armando Pérez Marqués
  • 5,661
  • 4
  • 28
  • 45