title: How to properly configure Celery logging functionality with Django?
body: <p>I use Django and Celery to schedule a task but I have an issue with the logger because it doesn't propagate properly. As you can see in the code below I have configured the Python <code>logging</code> module and the <code>get_task_logger</code> Celery module.</p>
  
  <pre><code>import logging
  from celery import Celery
  from celery.utils.log import get_task_logger
  
  # Configure logging
  logging.basicConfig(filename='example.log',level=logging.DEBUG)
  
  # Create Celery application and Celery logger
  app = Celery('capital')
  logger = get_task_logger(__name__)
  
  
  @app.task()
  def candle_updated(d, f):
  
      logging.warning('This is a log')
      logger.info('This is another log')
      return d+f
  </code></pre>
  
  <p>I use <code>django-celery-beat</code> extension to setup periodic task from the Django admin. This module stores the schedule in the Django database, and presents a convenient admin interface to manage periodic tasks at runtime. </p>
  
  <p>As recommended <a href="http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html" rel="nofollow noreferrer">in the documentation</a> I start the worker and the scheduler that way:</p>
  
  <pre><code>$ celery -A capital beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
  celery beat v4.4.0 (cliffs) is starting.
  __    -    ... __   -        _
  LocalTime -&gt; 2020-04-02 22:33:32
  Configuration -&gt;
      . broker -&gt; redis://localhost:6379//
      . loader -&gt; celery.loaders.app.AppLoader
      . scheduler -&gt; django_celery_beat.schedulers.DatabaseScheduler
  
      . logfile -&gt; [stderr]@%INFO
      . maxinterval -&gt; 5.00 seconds (5s)
  [2020-04-02 22:33:32,630: INFO/MainProcess] beat: Starting...
  [2020-04-02 22:33:32,631: INFO/MainProcess] Writing entries...
  [2020-04-02 22:33:32,710: INFO/MainProcess] Scheduler: Sending due task Candles update (marketsdata.tasks.candle_updated)
  [2020-04-02 22:33:32,729: INFO/MainProcess] Writing entries...
  [2020-04-02 22:33:38,726: INFO/MainProcess] Scheduler: Sending due task Candles update (marketsdata.tasks.candle_updated)
  [2020-04-02 22:33:44,751: INFO/MainProcess] Scheduler: Sending due task Candles update (marketsdata.tasks.candle_updated)
  </code></pre>
  
  <p>Everything seems to run fine. There is output in the console every 6 seconds (frequency of the periodic task) so it seems the task is executed in the background but I can't check it. And the problem I have is that the file example.log is empty, what could be the reason?</p>