Adding logging to exception handling.