logging extended to show cause of error