What are the best practices to log an error?

后端 未结 8 876
野的像风
野的像风 2020-12-29 07:47

Many times I saw logging of errors like these:

System.out.println(\"Method aMethod with parameters a:\"+a+\" b: \"+b);
print(\"Error in line 88\");
         


        
8条回答
  •  醉话见心
    2020-12-29 08:36

    There really is no best practice for logging an error. It basically just needs to follow a consistent pattern (within the software/company/etc) that provides enough information to track the problem down. For Example, you might want to keep track of the time, the method, parameters, calling method, etc.

    So long as you dont just print "Error in "

提交回复
热议问题