Disable INFO logging messages in Ipython Notebook

前端 未结 3 849
天命终不由人
天命终不由人 2021-01-02 04:08

I\'m using requests_throttler and requests modules for communication through API. My script are writen in Ipython Notebook. I\'m getting a lot of logging messages from reque

相关标签:
3条回答
  • 2021-01-02 04:40

    If you just want to disable all INFO loggings in Jupyter Notebook just do the following inside your notebook:

    #Supress default INFO logging
    
    import logging
    logger = logging.getLogger()
    logger.setLevel(logging.CRITICAL)
    
    0 讨论(0)
  • 2021-01-02 04:41

    For Python 3 you can simply do:

    import logging, sys
    logging.disable(sys.maxsize)
    
    0 讨论(0)
  • 2021-01-02 04:45

    This worked for me under Python 2.7. (Other suggestions welcomed!)

    import logging
    
    logger = logging.getLogger('requests_throttler')
    logger.addHandler(logging.NullHandler())
    logger.propagate = False
    

    Setting logger.propagate to False suppresses the lone remaining "No handlers could be found for logger X.Y.Z" message that you'd otherwise see.

    To save to a file, check out logging.FileHandler().

    0 讨论(0)
提交回复
热议问题