0

We have a policy where I work that all web services must log exceptions at the service boundary. If an exception occurs due to invalid inputs, should this be logged as an error?

I think that any time a service can't complete what it was asked to do, that is by default an error, no matter what the reason is. Others think that I should be considering the bigger picture of the system as a whole, and log those exceptions as warnings, because the consumer of the service could handle the exception and correct the inputs. Isn't the fact that the inputs might be corrected in a subsequent request irrelevant to whether or not an error has occurred?

4

1 回答 1

0

天气错误是由于来自客户端的无效输入或服务端的一些问题/错误,Web 服务应具有可能发生的所有类型错误的错误代码。

现在对于确定的用例,当您知道客户端肯定传递了错误的参数时,您应该只向客户端返回错误代码。您不需要记录此内容,因为您不想阻塞日志,因为多个客户端可能以不正确的方式调用您的服务。

但是,如果发生超出您定义的错误代码的错误,您应该将其记录为错误。

于 2013-08-24T03:42:00.663 回答