简体   繁体   English

如何找到我先前设置的log4j级别

[英]how to find my previously set log4j level

Am looking for help for my assignment in finding out log4j level after setting the same. 我正在为我的作业寻求帮助,以便在设置log4j级别后找到它。 I tried searching but couldn't find any help. 我尝试搜索,但找不到任何帮助。 Please excuse for the poor question as am still a learner. 请为这个仍然是学习者的可怜的问题找借口。

As we have setLevel(), do we have anything to get this level somewhere after it is set? 有了setLevel()后,设置此级别后,我们是否有任何东西可以使此级别到某个地方? Something as getLevel() which returns previously set level. getLevel()之类的东西,它返回先前设置的水平。

 private static Logger logger;
 ........
 ........
 logger.setLevel(Level.INFO);    --setting the level


 //do we have something wherein we can get the level which was set?
 int value = logger.getLevel();  --can this be done?

Log4j Logger class inherits getLevel() method from its parent: https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Logger.html Log4j Logger类从其父级继承getLevel()方法: https : //logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Logger.html

This method returns Level instance but you can get int value: 此方法返回Level实例,但您可以获取int值:

Level level = logger.getLevel();
int levelInt = level.toInt();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM