Python Logging - Disable logging from imported modules

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

    Simply doing something like this solves the problem:

    logging.config.dictConfig({'disable_existing_loggers': True,})
    

    NOTE: Wherever you're placing this line, make sure all the imports everywhere in your project are done within that file itself. :)

提交回复
热议问题