Python 3 Flask Logging Module to Print Log Messages in Console or Terminal Full Project For Beginners



pip install flask



After installing flask make an file and copy paste the following code



from flask import Flask
import logging
app = Flask(__name__)
logging.basicConfig(filename='record.log', level=logging.DEBUG, format=f'%(asctime)s %(levelname)s %(name)s %(threadName)s : %(message)s')
def blog():'Info level log')
    app.logger.warning('Warning level log')
    return f"Welcome to the Blog"'localhost', debug=True)



Now if you run your flask app by typing the below command






Leave a Reply