When to log a stacktrace for a caught exception

后端 未结 5 1118
萌比男神i
萌比男神i 2020-12-02 00:51

I recently asked whether to report the getMessage() text of a caught exception. Rather surprisingly, most answers misunderstood my question and thought I was asking whether

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 01:33

    I would report all of them. But if you are using log4j then you can control which ones you know for sure you will not be interested to see in the log. If a particular user exception has a different class, then disable logging in that class in production and enable it in lower environments. In that way, you are not doing anything at the code level for reporting. Its all abstracted at the logging framework.

提交回复
热议问题