Skip to content

Instantly share code, notes, and snippets.

@alexrutherford
Created October 19, 2015 16:24
Show Gist options
  • Select an option

  • Save alexrutherford/2e55a3ddba7642489203 to your computer and use it in GitHub Desktop.

Select an option

Save alexrutherford/2e55a3ddba7642489203 to your computer and use it in GitHub Desktop.
Snippet to add logging with timestamps to Flask app
import logging
hdlr = logging.FileHandler('log.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
app = Flask(__name__)
app.debug=True
app.logger.addHandler(hdlr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment