title: Django Celery Logging Best Practice
body: <p>I'm trying to get Celery logging working with <code>Django</code>. I have logging set-up in <code>settings.py</code> to go to console (that works fine as I'm hosting on <code>Heroku</code>). At the top of each module, I have:</p>
  
  <pre><code>import logging
  logger = logging.getLogger(__name__)
  </code></pre>
  
  <p>And in my tasks.py, I have:</p>
  
  <pre><code>from celery.utils.log import get_task_logger
  logger = get_task_logger(__name__)
  </code></pre>
  
  <p>That works fine for logging calls from a task and I get output like this:</p>
  
  <pre><code>2012-11-13T18:05:38+00:00 app[worker.1]: [2012-11-13 18:05:38,527: INFO/PoolWorker-2] Syc feed is starting
  </code></pre>
  
  <p>But if that task then calls a method in another module, e.g. a <code>queryset</code> method, I get duplicate log entries, e.g.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I think I could use</p>
  
  <pre><code>CELERY_HIJACK_ROOT_LOGGER = False
  </code></pre>
  
  <p>to just use the <code>Django</code> logging but this didn't work when I tried it and even if I did get it to work, I would lose the <code>"PoolWorker-6"</code> bit which I do want. (Incidentally, I can't figure out how to get the task name to display in the log entry from Celery, as <a href="http://docs.celeryproject.org/en/master/configuration.html?highlight=celeryd_task_log_format#std:setting-CELERYD_TASK_LOG_FORMAT">the docs</a> seems to indicate that it should).</p>
  
  <p>I suspect I'm missing something simple here.</p>