Enabling Debug Output with boto

Occasionally, things don’t work exactly as you expected. When you are interacting with remote services via HTTP-based APIs, the best debugging tool you can have is detailed logs of the actual HTTP requests and responses sent to and received from the remote services.

boto provides a way to get very detailed logging by using the Python logging module. Full details of the capabilities of the Python logging module can be found at http://docs.python.org/library/logging.html, but this example shows a quick way to get full debug output printed to your interactive console when using boto:

% python
>>> import boto
>>> boto.set_stream_logger('paws')
>>> ec2 = boto.connect_ec2(debug=2)
>>> s3 = boto.connect_s3(debug=2)
>>>

The string passed to set_stream_logger can be anything you want; it will appear in the header of log entries. Any operations performed with the ec2 or s3 connections from this point forward will dump full debug logs out to the interactive Python shell.