Google News
logo
Flask - Interview Questions
How to enable logging in python flask?
Set app.debug to True and add the below code in your function where you want to enable logging in Flask.
import logging
from flask import Flask
app = Flask(__name__)

@app.route('/')
def foo():
    app.logger.warning('A warning occurred')
    app.logger.error('An error occurred')
    app.logger.info('Info')
    return "foo"

 

Advertisement