Logger getLevel() method in Java with Examples Last Updated : 19 Mar, 2019 Comments Improve Suggest changes Like Article Like Report The getLevel() method of the Logger class in Java is used to get the log Level that has been specified for this Logger instance. Every Logger has specific log levels and if the result is null, which means that this logger's effective level will be inherited from its parent. Log Levels: The log levels control the logging details. They determine the extent to which depth the log files are generated. Each level is associated with a numeric value and there are 7 basic log levels and 2 special ones. We need to specify the desired level of logging every time, we seek to interact with the log system. To know more about Log Levels, refer this Log Levels in Logging Syntax: public Level getLevel() Parameters: This method accepts no parameters. Return value: This method returns Level which represents level of logger. Below programs illustrate the getLevel() method: Program 1: Java // Java program to demonstrate // Logger.getLevel() method import java.util.logging.Logger; import java.util.logging.Level; public class GFG { public static void main(String[] args) { // Create a Logger Logger logger = Logger.getLogger( GFG.class.getName()); // Get level of logger Level level = logger.getLevel(); // If logger level is null // then take a level of the parent of logger if (level == null && logger.getParent() != null) { level = logger.getParent().getLevel(); } System.out.println("Logger Level = " + level); } } Output: Logger Level = INFO Program 2: Java // Java program to demonstrate // Logger.getLevel() method import java.util.logging.Logger; import java.util.logging.Level; import java.util.*; public class GFG { public static void main(String[] args) { // Create a Logger Logger logger = Logger.getLogger( ArrayList.class.getName()); // Get level of logger Level level = logger.getLevel(); System.out.println("Logger Level = " + level); } } Output: Logger Level = null Reference: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#getLevel() Comment More infoAdvertise with us Next Article Logger getLevel() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java - util package Java-Functions Java-Logger Practice Tags : Java Similar Reads LogRecord getLevel() method in Java with Examples The getLevel() method of java.util.logging.LogRecord is used to get the logging message level of this current LogRecord object, for example Level.Info. Syntax: public Level getLevel() Parameters: This method accepts nothing. Return: This method returns the logging message level. Below programs illus 1 min read Logger getLogger() Method in Java with Examples The getLogger() method of a Logger class used find or create a logger. If there is a logger exists with the passed name then the method will return that logger else method will create a new logger with that name and return it. There are two types of getLogger() method depending upon no of the parame 4 min read Logger getGlobal() Method in Java with Examples getGlobal() method of a Logger class is used to get global logger object with the name Logger.GLOBAL_LOGGER_NAME.The "global" Logger object is helpful for developers who are making casual use of the Logging package. For making serious use of the logging package developers have to create and use thei 2 min read Logger getName() Method in Java with Examples getName() method of a Logger class used to get the name of logger. Many times you have to check the logger name so we can use this method to get the logger name. Syntax: public String getName() Parameters: This method accepts nothing. Return value: This method return logger name and it will be null 1 min read Logger getFilter() Method in Java with Examples The getFilter() method of the Logger class is used to get the current filter for this Logger instance. A Filter is useful to filter out log messages. we can say that filter decide the message gets logged or not. Filters are represented by the Java interface java.util.logging.Filter Syntax: public Fi 2 min read Like