Search code examples
pythonneo4jpy2neo

How do I stop py2neo watch()?


I run this earlier in the code

watch("httpstream")

Subsequently, any py2neo commands that triggers HTTP traffic will result in verbose logging. How can I stop the effect of watch() logging without creating a new Graph instance?


Solution

  • You can set the logging level to a higher value, for example

    import logging
    
    logging.getLogger("httpstream").setLevel(Logging.WARNING)
    

    Get Logger Information

    You can enumerate a list of all available loggers

    print logging.Logger.manager.loggerDict.keys()

    Then, you can use either

    logging.getLogger("httpstream").getEffectiveLevel()

    or

    logging.getLogger("httpstream").isEnabledFor(logging.DEBUG)

    to get the logging level.