add error handling to logging