log4j logging levels and use

Disclaimer: This article from the original Shi Yong, please indicate the author and the source! http://blog.csdn.net/shiyong1949/article/details/52643711

log4j defines eight levels of log (removal and OFF ALL, can be said to be divided into six levels), order of highest to lowest priority: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL.

ALL lowest level, to open all logging.

TRACE designates finer-grained informational events than the DEBUG.Since: 1.2.12, the log level is very low, generally do not use.

DEBUG pointed out that fine-grained information events for debugging applications are very helpful, mainly for the development process of the print run of some information.

INFO messages on a coarse-grained level to highlight the process of running the application. Print some of your interesting or important information, this information may be used in some important production environments running output, but not abuse, avoid printing too many logs.

WARN indicates that there will be a potential error situations, some information is not an error message, but also to give some tips programmers.

ERROR pointed out that although the error event, but still does not affect the continued operation of the system. Printing error and exception information, you do not want too many log output, you can use this level.

FATAL pointed out that every serious error occurs if exiting the application. This level is relatively high. Major error, this level you can stop the program directly.

OFF highest level for close all logging.

If the log level is set at a certain level, then this higher level than the priority log can be printed out. For example, if the set priority WARN, then OFF, FATAL, ERROR, WARN 4 log normal levels of output, INFO, DEBUG, TRACE, ALL log level are ignored. Log4j recommended to use only four levels, from highest to lowest priority are ERROR, WARN, INFO, DEBUG.

As can be seen from the results of our experiments, log4j default priority of ERROR or WARN (actually ERROR).

 

Guess you like

Origin blog.csdn.net/weixin_40126236/article/details/82843607