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

PythonServer Side ProgrammingProgramming

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.

raja
Published on 20-Dec-2017 13:23:10
Advertisements