W
W
wawa2018-07-13 19:04:03
Python
wawa, 2018-07-13 19:04:03

Why doesn't celery write logs from tasks?

jang settings:

LOGGING = {
...
    'loggers': {
            'celery': {
                'level': 'INFO',
                'handlers': ['file'],
            },
    }
}

The logs of the celery itself are written according to the settings above. But there are no logs from the code below:
from celery.utils.log import get_task_logger

from config.celery import app

from smtplib import SMTPException


logger = get_task_logger(__name__)
print(logger.name)


@app.task(autoretry_for=(SMTPException,), default_retry_delay=10, max_retries=2)
def send_mail(subject, message, from_email, recipient_list, **kwargs):
    logger.info('a message "{}" to {}'.format(subject, ', '.join(recipient_list)))
    ...

Although all the logs are displayed in the stdout of the worker.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-07-14
@dimonchik2013

setup_task_loggers is set correctly?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question