July 2019
Beginner to intermediate
302 pages
9h 38m
English
Follow these steps to configure and set up a logging library to use with our application:
app.config['LOG_FILE'] = 'application.log'
if not app.debug:
import logging logging.basicConfig(level=logging.INFO)
from logging import FileHandler
file_handler = FileHandler(app.config['LOG_FILE'])
app.logger.addHandler(file_handler)
Here, we added a configuration parameter to specify the log file's location. This takes the relative path from the application folder, unless an absolute path is explicitly specified. Next, we will check whether the application is already in debug mode, and then we will add a handler logging ...