title: How to programmatically tell Celery to send all log messages to stdout or stderr?
body: <p><strong>How does one turn on celery logging programmatically?</strong></p>
  
  <p>From the terminal, this works fine: </p>
  
  <pre><code>celery worker -l DEBUG
  </code></pre>
  
  <p>When I call <code>get_task_logger(__name__).debug('hello')</code>, I can see the message come up in the terminal. (stdout and stderr are being displayed)  I can even <code>import logging</code> and call <code>logger.info('hi')</code> and see that too. (both work)</p>
  
  <p>However, while developing a task, I prefer to use a test module and call the task function directly rather than firing up a whole worker. But I can't see the log messages. I understand that Celery is redirecting everything to its internal apparatus, but I want to see the log messages on the stdout too.  </p>
  
  <p><strong>How do I tell Celery to send a copy of the log messages back to stdout?</strong></p>
  
  <p>I've read a bunch of online articles about logging but it seems that a number of logging-related configuration vars from celery have been deprecated and it's unclear to me from the docs what is the supported path today.  </p>
  
  <p><strong>Here is an example module that creates a celery object and attempts to log output.  Nothing shows in the terminal.</strong></p>
  
  <p>example <strong>mymodule.py</strong></p>
  
  <pre><code>from celery import Celery
  import logging
  from celery.utils.log import get_task_logger
  
  app = Celery('test')
  app.config_from_object('myfile', True)
  
  get_task_logger(__name__).warn('hello world')
  logging.getLogger(__name__).warn('hello world 2')
  </code></pre>
  
  <p><strong>EDIT</strong>
  I know that I can add a handler to redirect some of the output back to the terminal by adding a handler</p>
  
  <pre><code>log = get_task_logger(__name__)
  h = logging.StreamHandler(sys.stdout)
  log.addHandler(h)
  </code></pre>
  
  <p>But is there a "Celery way" to do this?  Maybe one that lets me also have the Celery formatted lines of text.</p>
  
  <pre><code>[2014-03-02 15:51:32,949: WARNING] hello world
  </code></pre>