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 家庭新春聚餐祝福语简短