Article Author: Tyan
Blog: noahsnail.com | CSDN | Jianshu
In software, log is essential, log can be used to debug programs, and to see the sequence of execution and execution time of the program, but also in the case of problems can be used to see the point of occurrence of the problem. In Java, there are many log libraries, there are Java from the belt, there are open source, commonly used log log4j,slf4j and so on. Regardless of the number of log libraries, it generally provides five levels (priority from low to high) log: 1. Debug
In general, debug is the lowest level (and of course there are lower--trace,all), in general, when the actual running of the application is not output debug log, so you can debug the program to use, write the program should develop a good habit of output log, This can be a problem in the program in a timely manner to locate the wrong location, while others read your code, it is easy to understand the program's running process, just look at the log can understand.
SLF4J Official document definition : Debug level Specifies fine-grained informational events, which are most useful for debugging applications. 2. Info
Info is used to reflect the system's current state of operation information, so the information output here must be meaningful, commonly used to output the business process of some key information or business execution information, but also often used to output the system impact of a large number of information, such as system upgrades. The system declares a cycle event (start, stop), Session lifecycle events (login, exit, etc.), a typical business logic exception (logon failure at logon) is exported from info. The info level is the log level used when the actual online runtime is applied.
SLF4J The Official document definition : INFO level specifies coarse-grained messages that emphasize the application running process information. 3. Warn
Warn represents an unexpected technical or business event that occurs, the user may be affected, but may not need to be processed immediately, and the call will not be immediately affected, but technical support personnel need to check these issues as soon as possible. Basically the warn problem needs to be checked, but it may not need to be processed immediately.
SLF4J The Official document definition : WARN level specifies potentially harmful conditions. 4. Error
The error represents a problem that must be handled at once, and the customer may be affected by the error, and the error can allow the program to continue running after it has occurred.
SLF4J The Official document definition : Error level specifies a fault event, but the system continues to run. 5. Fatal
Fatal said that the most serious error occurred, the entire service may have stopped, "Two point theory" can be applied to this place, if this error occurs at two o ' night, you must immediately get up and fix the error, you can use the fatal level.
SLF4J The Official document definition : The FATAL level specifies a very serious error event and assumes that the program has been run terminated. 6. Other log Levels
Off:off represents the highest level of log, indicating that log will be closed.
TRACE: Log, which is lower than debug level, represents information that is finer than the debug granularity.
All: The lowest level log, which means that log is open.
Resources:
Http://www.slf4j.org/apidocs/org/apache/log4j/Level.html
Http://stackoverflow.com/questions/7839565/logging-levels-logback-rule-of-thumb-to-assign-log-levels
Http://www.cnblogs.com/shwen99/archive/2007/12/29/1019853.html
Http://www.bkjia.com/Javabc/1021481.html