Configuration gotcha

The basicConfig() method of logging is careful about preserving any loggers created before the configuration is made. The logging.config.dictConfig() method, however, has the default behavior of disabling any loggers created prior to configuration.

When assembling a large and complex application, we may have module-level loggers that are created during the import process. The modules imported by the main script can potentially create loggers before logging.config is created. Also, any global objects or class definitions might have loggers created prior to the configuration.

We often have to add a line such as this to our configuration file:

disable_existing_loggers: False

This will ensure all the loggers created prior to the configuration ...

Get Mastering Object-oriented Python 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.