Logs only need three levels: Normal, error, and debug.
Normal is used to record GeneralProgramOperation Information. errors are used to record the error information that must be handled, and debug is used to record detailed debugging information. When the program runs normally, only the normal and error logs are enabled. When the problem needs to be traced, debug logs are enabled again.
This represents the three responses we can make: daily check status (normal), error, debug ).
Because we can only make these three responses to logs, logs should only be divided into these three levels.
The logs in Java are divided into nine levels, which basically only causes confusion. For example, at the warning level, this is purely a nonsense. No one knows how to deal with warning. Do you have to deal with it or not? In the real world, all the warnings will be ignored and become meaningless.
As evidence, I have seen some java projects in a large company. The logs of those projects are messy, so all the logs are ignored during routine maintenance. Most programmers do not know how to write logs because they lack an executable guide: What type of logs should be written. Some programmers often write the errors that must be handled in warning, so that the error log cannot overwrite all the errors that must be processed, making the monitoring Error Log meaningless.
Logs must be divided into three levels to provide a clear guide for programmers: all errors to be processed must be written into the error log; all other information must be written in normal, normal information does not need to be processed and does not affect system operation. debug is used for debugging information.
Q: Do I need to write error logs when I receive an exception request?
A: If the exception request is within expectation, write the normal log. If the request requires processing by a programmer or O & M personnel, write the error log.
Q: What logs should I write when the system fails to be started?
A: The startup fails. The O & M personnel should at least check why. Therefore, the error log must be written.
Q: What logs should I write when the buffer queue in the system is full?
A: In a correctly designed system, the buffer should not be full normally. This situation requires programmers to changeCodeOr modify the O & M configuration. Therefore, the error log must be written.