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:
import java.util.logging.Level;
import java.util.logging.Logger;
public class GFG {
public static void main(String[] args)
{
Logger logger
= Logger.getLogger(
Object. class .getName())
.getParent();
Level level
= logger.getLevel();
String name = level.getName();
System.out.println( "Level Name = "
+ name);
}
}
|
Output:
Level Name = INFO
Program 2:
import java.util.logging.Level;
public class GFG {
public static void main(String[] args)
{
Level level
= Level.parse( "SEVERE" );
String name = level.getName();
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()
Last Updated :
14 Oct, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...