Thursday, June 11, 2026
HomeLanguagesJavaLevel getName() method in Java with Examples

Level getName() method in Java with Examples

The getName() method of java.util.logging.Level is used to get the non-localized string name of the Level. This method return name of this method.

Syntax:

public String getName()

Parameters: This method accepts nothing.

Return: This method returns non-localized name of this Level.

Below programs illustrate getName() method:
Program 1:




// Java program to illustrate getName() method
  
import java.util.logging.Level;
import java.util.logging.Logger;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // Create a Logger
        Logger logger
            = Logger.getLogger(
                        Object.class.getName())
                  .getParent();
  
        // Get level of logger
        Level level
            = logger.getLevel();
  
        // get Level name
        String name = level.getName();
  
        // print level names
        System.out.println("Level Name = "
                           + name);
    }
}


Output:

Level Name = INFO

Program 2:




// Java program to illustrate getName() method
  
import java.util.logging.Level;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // Get level of logger
        Level level
            = Level.parse("SEVERE");
  
        // get Level name
        String name = level.getName();
  
        // print level names
        System.out.println("Level Name = "
                           + name);
    }
}


Output:

Level Name = SEVERE

References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Level.html#getName()

RELATED ARTICLES

4 COMMENTS

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6896 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS