I am trying to get Celery magazine to work with Django . I have a registration in settings.py to go to the console (this works fine since I host on Heroku ). At the top of each module I have:
import logging logger = logging.getLogger(__name__)
And in my .py tasks I have:
from celery.utils.log import get_task_logger logger = get_task_logger(__name__)
This works great for registering calls from a task, and I get the output as follows:
2012-11-13T18:05:38+00:00 app[worker.1]: [2012-11-13 18:05:38,527: INFO/PoolWorker-2] Syc feed is starting
But if this task then calls the method in another module, for example. a queryset , I get duplicate log entries, for example.
2012-11-13T18:00:51+00:00 app[worker.1]: [INFO] utils.generic_importers.ftp_processor process(): File xxx.csv already imported. Not downloaded 2012-11-13T18:00:51+00:00 app[worker.1]: [2012-11-13 18:00:51,736: INFO/PoolWorker-6] File xxx.csv already imported. Not downloaded
I think I could use
CELERY_HIJACK_ROOT_LOGGER = False
just use the Django log, but it didn’t work when I tried it, and even if I earned it, I would lose the "PoolWorker-6" bit that I really want. (By the way, I can't figure out how to get the name of the task to display in the log entry from Celery, since the docs seem to indicate what it should be).
I suspect I'm missing something simple here.
python django logging celery django-celery
alan Nov 13 '12 at 18:14 2012-11-13 18:14
source share