Java Programing laungage

java.util Projects

java.util Project 1

Comparing Log Levels in Java

In This programming tutorials we are going to describes, how we are compare to log levels to each other. In Java application, the Level class assigns a set of multiple logging levels which has already an individual integer type value. With the help of this we can compare log levels and get specified results.

Previous Home Next

There are seven levels in descending order

  1. SEVERE (Grater level)


  3. INFO


  5. FINE

  6. FINER


Additional levels

  • ALL level: This level finds all the logging messages which are enabled.
  • OFF level: This is a special type of level that assists to turn off logging.

Code Descriptions

In This program, creates two objects of the Level class which has different logging levels. One is with the Level.FINEST level and another object is created with the Level.SEVERE level. And this program gets it's different integer value by using it's intValue() method. This value is by default specific for the specific logging levels. These retrieved integer value of the different level are compared at last in the following program.


package r4r;
import java.util.*;
import java.util.logging.Level;
public class comparelogleveltest {
public static void main(String[] args) {
Level level1 = Level.FINEST;
Level level2 = Level.SEVERE;
if (level1.intValue() == level2.intValue()){
System.out.println("Both are equal");

else if (level1.intValue() > level2.intValue()){
System.out.println("level 1 is grater than level 2.");
System.out.println("level 2 is grater than level 1.");

Previous Home Next