I wanted to enable debug output mode when doing a Python http request. I started having this
import requests
requests.get('https://httpbin.org/headers')
To enable debug output I had to add the logging stages. First importing the logging and then set the logginglevel. Here’s the final example.
import requests
import logging
import http.client as http_client
http_client.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
requests.get('https://httpbin.org/headers')
Follow up post: https://spacetech.dk/python-infopy4j-java_gatewayreceived-command-c-on-object-id-p0.html