title: Flask logging not working at all
body: <p>I'm trying to log messages in Flask both to file and to stdout. I've been reading the official Flask docs and came up with this:</p>
  
  <pre><code>from flask import Flask
  import logging
  from logging import Formatter, FileHandler
  
  app = Flask(__name__)
  
  
  
  @app.route('/')
  def hello_world():
      app.logger.debug('second test message...')
      return 'Hello World!'
  
  
  if __name__ == '__main__':
      #Setup the logger
      file_handler = FileHandler('output.log')
      handler = logging.StreamHandler()
      file_handler.setLevel(logging.DEBUG)
      handler.setLevel(logging.DEBUG)
      file_handler.setFormatter(Formatter(
          '%(asctime)s %(levelname)s: %(message)s '
          '[in %(pathname)s:%(lineno)d]'
       ))
       handler.setFormatter(Formatter(
          '%(asctime)s %(levelname)s: %(message)s '
          '[in %(pathname)s:%(lineno)d]'
       ))
       app.logger.addHandler(handler)
       app.logger.addHandler(file_handler)
       app.logger.error('first test message...')
       app.run()
  </code></pre>
  
  <p>There are several problems:</p>
  
  <ol>
  <li>No <code>output.log</code> file is generated</li>
  <li><p>Only the first logging message works:</p>
  
  <p>app.logger.error('testing...')</p></li>
  </ol>
  
  <p>And only in stdout...the one in the view "/" does not even print to stdout... am I doing something wrong?</p>
  
  <p>This is the output from starting the app and going to /:</p>
  
  <pre><code>2015-03-08 11:33:27,183 ERROR: first test message... [in /home/mosquito/python_projects/flask_tst/flask_tst.py:31]
  * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  127.0.0.1 - - [08/Mar/2015 11:33:43] "GET / HTTP/1.1" 200 -
  </code></pre>