Implement support for automatically re-logging. Fixes #36.