title: prevent duplicate celery logging
body: <p>How do I prevent duplicate celery logs in an application like this?</p>
  
  <pre><code># test.py
  from celery import Celery
  
  import logging
  
  app = Celery('tasks', broker='redis://localhost:6379/0')
  app.logger = logging.getLogger("new_logger")
  file_handler = logging.handlers.RotatingFileHandler("app.log", maxBytes=1024*1024, backupCount=1)
  file_handler.setFormatter(logging.Formatter('custom_format %(message)s'))
  app.logger.addHandler(file_handler)
  
  @app.task
  def foo(x, y):
      app.logger.info("log info from foo")
  </code></pre>
  
  <p>I start the application with: <code>celery -A test worker --loglevel=info --logfile celery.log</code></p>
  
  <p>Then I cause foo to be run with <code>python -c "from test import foo; print foo.delay(4, 4)"</code></p>
  
  <p>This results in the "log info from foo" being displayed in both <code>celery.log</code> and <code>app.log</code>.</p>
  
  <p>Here is app.log contents:</p>
  
  <pre><code>custom_format log info from foo
  </code></pre>
  
  <p>And here is celery.log contents:</p>
  
  <pre><code>[2017-07-26 21:17:24,962: INFO/MainProcess] Connected to redis://localhost:6379/0
  [2017-07-26 21:17:24,967: INFO/MainProcess] mingle: searching for neighbors
  [2017-07-26 21:17:25,979: INFO/MainProcess] mingle: all alone
  [2017-07-26 21:17:25,991: INFO/MainProcess] celery@jd-t430 ready.
  [2017-07-26 21:17:38,224: INFO/MainProcess] Received task: test.foo[e2c5e6aa-0d2d-4a16-978c-388a5e3cf162]  
  [2017-07-26 21:17:38,225: INFO/ForkPoolWorker-4] log info from foo
  [2017-07-26 21:17:38,226: INFO/ForkPoolWorker-4] Task test.foo[e2c5e6aa-0d2d-4a16-978c-388a5e3cf162] succeeded in 0.000783085000876s: None
  </code></pre>
  
  <p>I considered removing the custom logger handler from the python code, but I don't want to just use celery.log because it doesn't support rotating files.  I considered starting celery with <code>--logfile /dev/null</code> but then I would loose the mingle and other logs that don't show up in <code>app.log</code>.</p>
  
  <p>Can I prevent "log info from foo" from showing up in <code>celery.log</code>?  Given that I created the logger from scratch and only setup logging to <code>app.log</code> why is "log info from foo" showing up in <code>celery.log</code> anyway?</p>
  
  <p>Is it possible to get the celery MainProcess and Worker logs (e.g. <code>Connected to redis://localhost:6379/0</code>) to be logged by a RotatingFileHandler (e.g. go in my <code>app.log</code>)?</p>