Python Requests logging to file
Question: How can I configure logging to file requests's get or post?

    
    
    my_config = {'verbose': sys.stderr}
    requests.get('http://httpbin.org/headers', config=my_config)
    

What should I use in verbose?


Answer: Have you tried simply opening a file?

    
    
    >>> import sys
    >>> type(sys.stderr)
    file
    >>> f = open('test.log', 'w')
    >>> type(f)
    f
    

So the example above will look like this:

    
    
    my_config = { 'verbose': open('/path/to/file', 'w') }
    requests.get('http://httpbin.org/headers', config = my_config)
    

HTH

