Python Logging - Disable logging from imported modules

前端 未结 10 819
清酒与你
清酒与你 2020-12-12 12:52

I\'m using the Python logging module, and would like to disable log messages printed by the third party modules that I import. For example, I\'m using something like the fo

10条回答
  •  感情败类
    2020-12-12 13:32

    @Bakuriu quite elegantly explains the function. Conversely, you can use the getLogger() method to retrieve and reconfigure/disable the unwanted loggers.

    I also wanted to add the logging.fileConfig() method accepts a parameter called disable_existing_loggers which will disable any loggers previously defined (i.e., in imported modules).

提交回复
热议问题