By default, the Requests python library writes log messages to the console, along the lines of:
Starting new HTTP connection (1): example.com
http://example.com:80 "GET / HTTP/1.1" 200 606
I'm usually not interested in these messages, and would like to disable them. What would be the best way to silence those messages or decrease Requests' verbosity?
Let me copy/paste the documentation section which it I wrote about week or two ago, after having a problem similar to yours:
For anybody using
logging.config.dictConfig
you can alter the requests library log level in the dictionary like this:If You have configuration file, You can configure it.
Add urllib3 in loggers section:
Add logger_urllib3 section:
Kbrose's guidance on finding which logger was generating log messages was immensely useful. For my Django project, I had to sort through 120 different loggers until I found that it was the
elasticsearch
Python library that was causing issues for me. As per the guidance in most of the questions, I disabled it by adding this to my loggers:Posting here in case someone else is seeing the unhelpful log messages come through whenever they run an Elasticsearch query.