Level parse() method in Java with Examples
The parse() method of java.util.logging.Level is used to parse a level name string into a Level. The name of the logging level must be a valid logging name. The argument string may consist of either a level name or an integer value. Level example name: “INFO”, “800”.
Syntax:
public static Level parse(String name)
throws IllegalArgumentException
Parameters: This method accepts a name which is the string to be parsed.
Return: This method returns parsed value.
Exception: This method throws the following Exception:
- NullPointerException: if the name is null.
- IllegalArgumentException: if the value is not valid. Valid values are integers between Integer.MIN_VALUE and Integer.MAX_VALUE, and all known level names.
Below programs illustrate parse() method:
Program 1:
// Java program to illustrate parse() method import java.util.logging.Level; public class GFG { public static void main(String[] args) { // Get level of logger using // parse method. Level level = Level.parse("WARNING"); // print result System.out.println("Level = " + level.toString()); } } |
Level = WARNING
Program 2:
// Java program to illustrate parse() method import java.util.logging.Level; public class GFG { public static void main(String[] args) { // Get level of logger using // parse method. Level level = Level.parse("400"); // print result System.out.println("Level = " + level.toString()); } } |
Level = FINER
References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Level.html#parse(java.lang.Object)
Recommended Posts:
- OffsetTime parse() method in Java with examples
- NumberFormat parse() method in Java with Examples
- LocalDateTime parse() method in Java with Examples
- SimpleDateFormat parse() Method in Java with Examples
- LocalTime parse() method in Java with Examples
- Period parse() method in Java with Examples
- LocalDate parse() method in Java with Examples
- Instant parse() method in Java with Examples
- ZonedDateTime parse() method in Java with Examples
- Duration parse(CharSequence) method in Java with Examples
- Year parse(CharSequence) method in Java with Examples
- YearMonth parse(CharSequence) method in Java with Examples
- DateFormat parse(string , ParsePosition) Method in Java with Examples
- Year parse(CharSequence,DateTimeFormatter) method in Java with Examples
- YearMonth parse(CharSequence,DateTimeFormatter) 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.



