Logging
The Python logging
module is one of those modules that are extremely useful, but it tends to be very difficult to use correctly. The result is often that people just disable logging completely and use print
statements instead. While it is somewhat understandable, this is a waste of the very extensive logging system in Python.
The Python logging
module is largely based on the Java log4j
library so it might be familiar to you if you’ve written Java before. That is also one of the biggest problems with the logging
module in my opinion; Python is not Java and the logging
module feels pretty un-Pythonic because of it. That does not make it a bad library, but it takes a little effort to get used to its design.
The most important objects of the logging
module are the following:
- Logger: The actual logging interface
- Handler: This processes the log statements and outputs them
- Formatter: This formats the input data into a string
- Filter: This...