Inserted logging into exception handling.