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 could 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 that all the loggers created prior to the configuration will still propagate to the root logger created by the configuration.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset