Created
February 29, 2020 19:46
-
-
Save kuznetsov-m/9268231957e1bd33ea28ce60e894a67b to your computer and use it in GitHub Desktop.
Enable debug logging for python requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://stackoverflow.com/a/57325050/10504918 | |
import requests | |
import logging | |
from http.client import HTTPConnection # py3 | |
log = logging.getLogger('urllib3') | |
log.setLevel(logging.DEBUG) | |
# logging from urllib3 to console | |
ch = logging.StreamHandler() | |
ch.setLevel(logging.DEBUG) | |
log.addHandler(ch) | |
# print statements from `http.client.HTTPConnection` to console/stdout | |
HTTPConnection.debuglevel = 1 | |
requests.get('http://httpbin.org/') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment