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 connections
  • info: redirects
  • warn: connection pool full (if happens increase connection pool size)
  • warn: retrying connection
  • debug: connection details: method, path, http version, status code , response length

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -