Java如何比较记录器级别的严重性?
在此示例中,我们看到了如何比较Level两个级别之间的严重性。的Level类有一个intValue()返回的整数值的方法Level的严重程度。
package org.nhooo.example.util.logging;
import java.util.logging.Level;
public class LogLevelSeverityCompare {
public static void main(String[] args) {
Level info = Level.INFO;
Level warning = Level.WARNING;
Level finest = Level.FINEST;
//为了比较级别的严重性,我们比较级别的intValue。
//每个级别分配一个唯一的整数值作为严重性
//水平的重量。
if (info.intValue() < warning.intValue()) {
System.out.println(info + "(" + info.intValue() + ") is less severe than " +
warning + "(" + warning.intValue() + ")");
}
if (finest.intValue() < info.intValue()) {
System.out.println(finest + "(" + finest.intValue() + ") is less severe than " +
info + "(" + info.intValue()+ ")");
}
}
}当我们运行上面的程序时,将看到以下结果:
INFO(800) is less severe than WARNING(900) FINEST(300) is less severe than INFO(800)
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短