Skip to content

Instantly share code, notes, and snippets.

@Daenyth
Created August 27, 2015 14:35
Show Gist options
  • Star 58 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save Daenyth/b57f8522b388e66fcf3b to your computer and use it in GitHub Desktop.
Save Daenyth/b57f8522b388e66fcf3b to your computer and use it in GitHub Desktop.
Enable debug logging for python requests
import requests
import logging
import httplib
# Debug logging
httplib.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
req_log = logging.getLogger('requests.packages.urllib3')
req_log.setLevel(logging.DEBUG)
req_log.propagate = True
@rca
Copy link

rca commented Jun 19, 2020

The HTTPConnection.debuglevel = 1 statement is magic; thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment