title: automatically logging flask's messages to a logger
body: <p>I was following <a href="http://flask.pocoo.org/docs/errorhandling/#logging-to-a-file" rel="nofollow">Flask's documentation on how to configure logging</a>. However, it seems that it does not write to the logger unless I explicitly tell it to (and the documentation seems to agree.)</p>
  
  <p>Here is how I configured my logger, within <code>create_app()</code></p>
  
  <pre><code>def create_app(environment):
    """ creates the flask application. Uses a parameter to choose which config to use """
    app = Flask(__name__)
    # ...
  
    error_handler = RotatingFileHandler(
      os.path.join(app.config['LOG_FOLDER'], 'flask.log'),
      maxBytes=100000,
      backupCount=1
    )
    error_handler.setLevel(logging.NOTSET)
    error_handler.setFormatter(Formatter(
      '%(asctime)s %(levelname)s: %(message)s'
      '[in %(pathname)s:%(lineno)d]'
    ))
    app.logger.addHandler(error_handler)
  </code></pre>
  
  <p>Now I want it such that, whenever an error occurs like it would in the debugger, to put the traceback in the log. Is this possible while on production?</p>