When I first entered the company, I did not realize the importance of abnormality. I've known that logging is important before, but I've never really felt its importance in a project. The picture is a classic case of catching an exception and printing a log, and I will try to write this in the future code.Copy the code
Why are logs so important
What will happen if logs are not added? If you don’t log, you may not even know why or where an error was reported in your project. To put it bluntly, adding an exception is to determine the approximate location of an abnormal item if an exception occurs, and adding a log is to roughly know the abnormal information after an exception occurs.
Abnormal how to solve
Due to exceptions and logs, it is possible to determine the approximate scope of the occurrence of exceptions and basic exception information. What is not clear, however, is which line is the exception. And the solution is debug, line by line.