Level toString() method in Java with Examples
The toString() method of java.util.logging.Level is used to get the string value which represents this Level.This method returns a string representation of this Level.
Syntax:
public String toString()
Parameters: This method accepts nothing.
Return: This method returns a string representation of this Level..
Below programs illustrate toString() method:
Program 1:
// Java program to illustrate toString() 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( String.class.getName()) .getParent(); // Get level of logger Level level = logger.getLevel(); // get string value of level String val = level.toString(); // print result System.out.println("toString = " + val); } } |
toString = INFO
Program 2:
// Java program to illustrate toString() 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 string representation String value = level.toString(); // print result System.out.println("toString = " + value); } } |
toString = SEVERE
References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Level.html#toString()
Recommended Posts:
- Duration toString() method in Java with Examples
- IntSummaryStatistics toString() method in Java with Examples
- OptionalLong toString() method in Java with examples
- LocalDate toString() method in Java with Examples
- ZoneOffset toString() method in Java with Examples
- Calendar toString() Method in Java with Examples
- StringBuilder toString() method in Java with Examples
- DoubleAdder toString() method in Java with Examples
- LinkedBlockingQueue toString() Method in Java with Examples
- LongSummaryStatistics toString() method in Java with Examples
- MessageDigest toString() method in Java with Examples
- AlgorithmParameters toString() method in Java with Examples
- AtomicLongArray toString() method in Java with Examples
- OptionalDouble toString() method in Java with examples
- OptionalInt toString() method in Java with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



