Skip to content

Instantly share code, notes, and snippets.

@iorionda
Created July 8, 2016 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iorionda/e48ddab1197ddecc909abef390c98ee4 to your computer and use it in GitHub Desktop.
Save iorionda/e48ddab1197ddecc909abef390c98ee4 to your computer and use it in GitHub Desktop.
import logging
from logging.handlers import RotatingFileHandler
from flask import Flask
app = Flask(__name__)
@app.route('/')
def foo():
app.logger.warning('A warning occurred (%d apples)', 42)
app.logger.error('An error occurred')
app.logger.info('Info')
return "foo"
if __name__ == '__main__':
handler = RotatingFileHandler('foo.log', maxBytes=10000, backupCount=1)
handler.setLevel(logging.INFO)
app.logger.addHandler(handler)
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment