Log-level options: Debug, Info, Warn, Error or Fatal, warnfatal

Source: Internet
Author: User

Log-level options: Debug, Info, Warn, Error or Fatal, warnfatal

Original article address: Log Level Selection: Debug, Info, Warn, Error or Fatal Author: shanshan2627

In the software, it is inevitable to use something like Log4net, Log4j, Tracer to write logs. No matter what you use, these things are mostly similar and generally provide such five log levels:
× Debug
× Info
× Warn
× Error
× Fatal
A level is higher than a level (these five levels are ordered. DEBUG <INFO <WARN <ERROR <FATAL. It is important to understand this. Here, Log4j has a rule: assume that the level is set to P. If a level Q is higher than P, it can be started; otherwise, it will be blocked). However, in specific development, how should we select an appropriate level, but no good articles are found. Record some of your opinions for future use.

=== Debug ===
The lowest level is generally not output during the actual operation of the system.


Therefore, this level of information can be used at will. Anyone who feels that it is helpful to know more about the system running status during debugging, such as the value of the variable, can output it for a look.


Of course, before each Debug call, you must add If judgment.

=== Info ===
This should be used to feedback the current status of the system to the end user. Therefore, the output information here should be of practical significance to the end user, that is, the end user must be able to understand what it means.


From a certain point of view, the information output by Info can be considered as part of a software product (just like the text on the interactive interface). Therefore, you need to be cautious about it.

=== Warn, Error, Fatal ===
Warnings, errors, and serious errors should all be detected in an abnormal state during system operation. The difference between them is that it is not that simple to distinguish between them. I roughly distinguish it like this:


The so-called warning should be that at this time some repairs should be carried out, and the system should be able to be restored to a normal state, and the system should be able to continue running.


The so-called error means that some corrective work can be carried out, but it cannot be determined that the system will work normally. In a future stage, the system may be due to the current problem, it may cause an irreparable error (such as downtime), but it may still work until it is stopped, and no serious problem occurs.

The so-called Fatal is very serious. It is certain that this error cannot be fixed, and if the system continues to run, it will inevitably become messy. At this time, the best measure is not to try to restore the system status to normal, but to keep the system valid data as much as possible and stop running.

That is to say, the specific one in Warn, Error, and Fatal is determined based on the potential impact of the current problem on the future. If there is no impact on the future, warning: If it must be a serious problem in the future, then Fatal will not be able to determine what will happen, then Error will occur.

 

Source: http://blog.chinaunix.net/uid-26434689-id-3017353.html

 

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.