logging - Log all requests from the python-requests module -
i using python requests. need debug oauth activity, , log requests being performed. information ngrep, unfortunately not possible grep https connections (which needed oauth)
how can activate logging of urls (+ parameters) requests accessing?
the underlying urllib3 library logs new connections , urls logging module, not post bodies. get requests should enough:
import logging logging.basicconfig(level=logging.debug) which gives verbose logging option; see logging howto more details on how configure logging levels , destinations.
short demo:
>>> import requests >>> import logging >>> logging.basicconfig(level=logging.debug) >>> r = requests.get('http://httpbin.org/get?foo=bar&baz=python') info:requests.packages.urllib3.connectionpool:starting new http connection (1): httpbin.org debug:requests.packages.urllib3.connectionpool:"get /get?foo=bar&baz=python http/1.1" 200 353 the following messages logged:
info: new connections (http or https)info: dropped connectionsinfo: redirectswarn: connection pool full (if happens increase connection pool size)warn: retrying connectiondebug: connection details: method, path, http version, status code , response length
Comments
Post a Comment