error log based on sql