Added logging to exception handling.