Python Logging - Disable logging from imported modules

前端 未结 10 825
清酒与你
清酒与你 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:34

    In my case the only thing that helped was forcing a propagate attribute of unwanted logger to False, i.e.

    logging.getLogger("module").propagate = False
    

    If this evaluates to false, logging messages are not passed to the handlers of ancestor loggers.

提交回复
热议问题