Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Celery - Worker ignoring loglevel INFO

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.

like image 482
RadiantHex Avatar asked Dec 10 '13 14:12

RadiantHex


2 Answers

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".

like image 60
Artem Mezhenin Avatar answered Sep 21 '22 15:09

Artem Mezhenin


Try using the CELERYD_HIJACK_ROOT_LOGGER setting:

celery_instance = Celery('django_app')
celery_instance.add_defaults({
    'CELERYD_HIJACK_ROOT_LOGGER': False,
})
like image 32
Armando Pérez Marqués Avatar answered Sep 20 '22 15:09

Armando Pérez Marqués