我应该打印异常堆栈跟踪?堆栈、异常

2023-09-05 23:44:48 作者:窗前舊時光

如何低效是它得到的堆栈跟踪的一个例外?我知道这是昂贵的,但如何昂贵?如果他们绝对的没有的在生产环境中使用?

How inefficient is it to get the stack trace for an exception? I know it's costly, but how costly? Should they definitely not be used in production environment?

推荐答案

在生产环境中,这是有帮助的的登录的堆栈跟踪,以便用户可以找到它时,他们联系技术支持。打印堆栈跟踪到位的理解(由典型用户)消息,应尽量避免。

In a production environment, it's helpful to log the stack trace so the user can find it when they contact tech support. Printing stack trace in place of an understandable (by the typical user) message should be avoided.

您不应该关心的是code特殊块的效率。错误恢复是最重要的事情在这里。

You shouldn't be concerned with the efficiency of exceptional blocks of code. Error recovery is the most important thing here.

 
精彩推荐