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.
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 informative.