logging
Compare Logger Level
In this example we shall show you how to compareLoggerLevel. The logging Level is used to control logging output. Level objects, such as SEVERE, WARNING and INFO are ordered and specified by ordered integers, so in order to compare them, one should perform the following steps:
- Use threeLevel constants.
- Compare the
intValuesof each Level constant with the other ones, using theintValue()of the Level. The levels with bigger values than others are the ones that are the more severe,
as described in the code snippet below.
package com.javacodegeeks.snippets.core;import java.util.logging.Level; public class LogLevelComparison { public static void main(String[] args) { Level info = Level.INFO; Level warning = Level.WARNING; Level finest = Level.FINEST; // Compare the intValue of the Level 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()+ ")"); } }}Output:
INFO(800) is less severe than WARNING(900)FINEST(300) is less severe than INFO(800)
This was an example of how to compare Logger Level in Java.
Do you want to know how to develop your skillset to become aJava Rockstar?
Subscribe to our newsletter to start Rockingright now!
To get you started we give you our best selling eBooks forFREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to theTerms andPrivacy Policy

Thank you!
We will contact you soon.
Ilias Tsagklis
Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor atJava Code Geeks.



