Setting up basic file logging

By default, Flask will not log anything for us anywhere, except for the errors with their stack traces, which are sent to the logger (we will see more of this in the remaining part of the chapter). This creates a lot of stack traces when we run the application in the development mode using run.py, but in production systems, we don't have this luxury. Thankfully, the logging library provides a whole lot of log handlers, which can be used as per our requirements.

Getting ready

We will start with our catalog application and add some basic logging to it using FileHandler, which logs messages to a specified file on the filesystem. We will start with a basic log format and then see how to format the log messages to be more ...

Get Flask Framework Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.