Why should there be only three levels of logs?

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.