How do I disable log messages from the Requests Python module?


You can disable logging from the requests module using the logging module.

Example

You can configure it to not log messages unless they are at least warnings using the following code:

import logging
logging.getLogger("requests").setLevel(logging.WARNING)

If you want to go a level higher and only want to log messages when they are errors or critical, you can do replace logging.WARNING with logging.ERROR and logging.CRITICAL respectively.

Updated on: 11-Dec-2019

673 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements