Changed the logging code to be more responsible about attaching handlers.

Still need to figure out a good way of managing the hierarchical logging.