-
-
Save evie404/fad6cb44061945d5b814721d49bfebc6 to your computer and use it in GitHub Desktop.
Flask logging example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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