StatusLogger是用来打印Log4J2的信息的,包括加载插件的过程,信息,解析自定义配置的信息,譬如当系统未检测到自定义的配置时:
No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' o show Log4j2 internal initialization logging.
配置属性
- StatusLogger相关的属性可以在log4j2.StatusLogger.properties中配置,Log4J2会通过PropertiesUtil工具类把相关属性读取出来:
# StatusLogger的队列中保存的最大日志条数,默认200条
log4j2.StatusLogger.entries
# status listeners的日志级别默认是warn
log4j2.StatusLogger.level
# 布尔值,如果配置为true,则会显示所有的status日志
log4j2.debug
- 在自定义配置文件,如xml中,配置status属性, 例子:
<Configuration status="info" monitorInterval="60">
<!--中间部分省略-->
<Configuration/>
status的合法属性在Level类中有定义, 默认level是ERROR,不区分大小写
static {
OFF = new Level("OFF", StandardLevel.OFF.intLevel());
FATAL = new Level("FATAL", StandardLevel.FATAL.intLevel());
ERROR = new Level("ERROR", StandardLevel.ERROR.intLevel());
WARN = new Level("WARN", StandardLevel.WARN.intLevel());
INFO = new Level("INFO", StandardLevel.INFO.intLevel());
DEBUG = new Level("DEBUG", StandardLevel.DEBUG.intLevel());
TRACE = new Level("TRACE", StandardLevel.TRACE.intLevel());
ALL = new Level("ALL", StandardLevel.ALL.intLevel