Software is always unavoidable to use such as Log4net, log4j, Tracer and other east to write the log, no matter what, these things are mostly similar, generally provide such 5 log levels:
Xdebug
Xinfo
Xwarn
Xerror
Xfatal
One level is higher (these five levels are sequential, DEBUG < INFO < WARN < ERROR < FATAL, it is important to understand this, log4j there is a rule: assuming that the level is set to P, if a level q is higher than P, Can be started, otherwise shielded off), but in the specific development, about how to choose the level of adaptation, but did not find a good article to explain. Keep a record of some of your ideas so that you can use them later.
= = = Debug = =
This level of the lowest east, generally speaking, in the actual operation of the system is generally not output.
So this level of information, can be used arbitrarily, any feel conducive to in the debugging more detailed understanding of the system operating state of the east, such as the value of variables and so on, are lost to look at the same.
Of course, before each Debug call, be sure to add an If judgment.
= = = Info = =
This should be used to feed back the current state of the system to the end user, so the information that is exported here should have practical implications for the end user, that is, the end user should be able to see what it means.
From a certain point of view, info output information can be viewed as part of a software product (like those on the interactive interface), so it needs to be treated with care, not casually.
= = = Warn, Error, Fatal = = =
Warning, error, critical error, all three should be in the system to detect an abnormal state of operation, the difference between them, to distinguish is really not so simple things. I have a general distinction:
The so-called warning, should be the time to do some repair work, should also be able to restore the system to a normal state, the system should be able to continue to run.
The so-called error, that is, can do some repair work, but not sure that the system will work properly, at some later stage, the system may be due to the current problem, resulting in an irreparable error (such as downtime), but also may have been working until stopped and no serious problems.
The so-called fatal, that is quite serious, can be sure that this error has been unable to repair, and if the system continues to run, it will certainly be more and more chaotic. The best thing to do at this time is not to try to restore the system state to normal, but to keep the system's valid data and stop running as much as possible.
In other words, choose Warn, Error, Fatal in the specific, is based on the current problem on the possible impact of the future, if the basic no impact on the future, then warning, if it must be a serious problem later, then Fatal, unsure will be how, then The Error.
Log-level selection: Debug, Info, Warn, error, or fatal