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