Understanding the correct log output level

Source: Internet
Author: User

Original link: http://macrochen.iteye.com/blog/1399082

Many programmers ignore the log output level and do not even know how to specify the output level of the log. Compared to System.out, the two greatest advantages of the log framework are the ability to specify the output category and level. For the log output level, here are some of the principles that we should keep in mind:
Error : The system has serious errors that must be processed immediately or the system will not be able to continue running. For example, NPE, database unavailable, and so on.

WARN: The system can continue to operate, but must cause concern. There are generally two types of problems: a system has obvious problems (for example, the data is not available), the other is the system has potential problems, need to attract attention or give some advice (for example, the system is running in security mode or access to the current system's account has security risks). In short, the system is still available, but it is best to check and adjust.

INFO: Important business logic processing is complete. Ideally, the log information for info can be understood by advanced users and system administrators, and the current operating state of the system can be known from the log information. For example, for an airline reservation system, when a user completes a ticket booking operation, a reminder should be given "who booked the ticket from A to B". Another place that needs to output info information is a system operation that causes significant changes in the state of the system (such as database updates, excessive system requests).

DEBUG: mainly for developers to see, the following will be discussed further.

TRACE: system details, mainly for developers, in general, if it is an online system, it can be considered as a temporary output, and can be switched off at any time. Sometimes it's hard to separate the debug from the trace, which, in general, should be set to the trace level if it is a system that has been developed for testing and adds log output to the system.

These are just suggestions, and you can create a set of rules that belong to you. But a good log system should be the first to be able to adjust the output of the log content quickly and flexibly according to the situation.

Understanding the correct log output level

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.