There are three steps to producing a log. The two necessary steps are the following:
- Get a logging.Logger instance with the logging.getLogger() function; for example, logger=logging.getLogger("demo").
- Create messages with that Logger. There are a number of methods, with names such as warn(), info(), debug(), error(), and fatal(), that create messages with different levels of importance. For example, logger.info("hello world").
These two steps are not sufficient to give us any output, however. There's a third, optional step that we take when we want to see logged messages. The reason for having a third step is because seeing a log isn't always required. Consider a debugging log that is generally left silent. The optional step is to configure the logging module's handlers, filters, and formatters. We can use the logging.basicConfig...