title: flask logging duplicate output
body: <p>I would like to change the flask logging format to the console, and I tried this,</p>
  
  <p><a href="https://stackoverflow.com/questions/27775026/provide-extra-information-to-flasks-app-logger">Provide extra information to Flask&#39;s app.logger</a></p>
  
  <p>But it did not work for me; its 3+ years old and perhaps out of date?  </p>
  
  <p>I can add an additional console handler, which works, but then I get duplicate output, once from the flask default console handler, and once from my added handler. </p>
  
  <p>The source,</p>
  
  <pre><code>import sys
  import logging
  from flask import Flask
  
  
  def setup_logging(level=logging.INFO):
  
      # FIXME: logs are coming out "twice", once with the format from flask, and again from
      #        the format from consoleHandler.  app.logger level and the console handler
      #        level seem to be linked
      app.logger.setLevel(level)
  
      # Here we define our formatter
      FORMAT = "%(relativeCreated)6d %(threadName)15s %(filename)25s:%(lineno)4s - %(name)30s:%(funcName)20s() %(levelname)-5.5s : %(message)s"
      formatter = logging.Formatter(FORMAT)
  
      consoleHandler = logging.StreamHandler(stream=sys.stdout)
      consoleHandler.setFormatter(formatter)
      consoleHandler.setLevel(level)
  
      app.logger.addHandler(consoleHandler)
  
      # this did not work :(
      # https://stackoverflow.com/questions/27775026/provide-extra-information-to-flasks-app-logger
  
  
  app = Flask(__name__)
  
  @app.route('/')
  def hello_world():
      app.logger.info("Foo Bar")
      return 'Hello, World!'
  
  
  setup_logging()
  
  app.run(host="0.0.0.0", port=6800, debug=False)
  </code></pre>
  
  <p>The output,</p>
  
  <pre><code> * Serving Flask app "SO_log_01" (lazy loading)
   * Environment: production
     WARNING: Do not use the development server in a production environment.
     Use a production WSGI server instead.
   * Debug mode: off
   * Running on http://0.0.0.0:6800/ (Press CTRL+C to quit)
  [2018-07-02 17:35:52,906] INFO in SO_log_01: Foo Bar
  127.0.0.1 - - [02/Jul/2018 17:35:52] "GET / HTTP/1.1" 200 -
    5083        Thread-1              SO_log_01.py:  39 -                      flask.app:         hello_world() INFO  : Foo Bar
  127.0.0.1 - - [02/Jul/2018 17:35:55] "GET /favicon.ico HTTP/1.1" 404 -
  </code></pre>