Improve application logging.

More code borrowed from chrisseto. Also introduce the CachedProxy
factory to prevent the HTTPClient from interfering with forking Tornado.