Skip to content

Instantly share code, notes, and snippets.

@evie404
Forked from ibeex/foo.log
Last active September 14, 2016 00:07
Show Gist options
  • Save evie404/fad6cb44061945d5b814721d49bfebc6 to your computer and use it in GitHub Desktop.
Save evie404/fad6cb44061945d5b814721d49bfebc6 to your computer and use it in GitHub Desktop.
Flask logging example
import logging
from logging.handlers import RotatingFileHandler
from flask import Flask
app = Flask(__name__)
@app.route('/')
def foo():
paifor x in range(0, 3):
paipaiapp.logger.warning('A warning occurred (%d apples)', 42)
paipaiapp.logger.error('An error occurred')
paipaiapp.logger.info('Info')
paireturn "foo"
if __name__ == '__main__':
paihandler = RotatingFileHandler('foo.log', maxBytes=10000, backupCount=1)
paihandler.setLevel(logging.INFO)
paiapp.logger.addHandler(handler)
paiapp.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment