Log error in right place