Logger getParent() Method in Java with Examples Last Updated : 12 Apr, 2023 Comments Improve Suggest changes Like Article Like Report getParent() method of a Logger class is used to get the parent of this Logger.This method returns the nearest extant parent in the namespace.if there is a Logger called "com.javac.core.api", and a Logger called "com.javac" has been created but no logger "com.javac.core" exists, then a call of getParent on the Logger "com.javac.core.api" will return the Logger "com.javac". The result will be null if we apply getParent() method on root Logger in the namespace. Syntax: public Logger getParent() Parameters: This method accepts nothing. Return value: This method return nearest existing parent Logger. Below programs illustrate the getParent() method: Program 1: Java // Java program to demonstrate // Logger.getParent() method import java.util.logging.*; public class GFG { public static void main(String[] args) { // Create a logger using getLogger() Logger logger = Logger.getLogger("com.java.core"); // Assign other package to logger logger = Logger .getLogger("com.java.core.api"); // Print parent name System.out.println("logger name = " + logger .getParent() .getName()); } } Output:logger name = com.java.core Program 2: Java // Java program to demonstrate // Logger.getParent() method import java.util.logging.*; public class GFG { public static void main(String[] args) { // Create a logger using getLogger() Logger logger = Logger.getLogger("com.java"); // Assign other package to logger logger = Logger.getLogger("com.java.core.api.base"); // Get Parent logger Logger parentLogger = logger.getParent(); // Print parent name System.out.println("Parent logger name = " + parentLogger.getName()); } } Output:Parent logger name = com.java References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#getParent() Comment More infoAdvertise with us Next Article Logger getParent() Method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java - util package Java-Functions Java-Logger Practice Tags : Java Similar Reads 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 getLevel() method in Java with Examples 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 level 2 min read LogManager getProperty() method in Java with Examples The getProperty() method of java.util.logging.LogManager is used to get the value of the specified propertyName in this LogManager instance. This method will get this property in this LogManager if it exists. If it does not exists, then this method returns null. Syntax: public String getProperty(Str 1 min read Logger getHandler() Method in Java with Examples The getHandlers() method of the Logger class is used to get the Handlers linked with this logger. Handler is used to taking care of the actual logging. one or more Handler can be added to a Logger. When messages are logged via the Logger, the messages are forwarded to the Handler. This method is hel 2 min read Logger getUseParentHandlers() Method in Java with Examples getUseParentHandlers() method of a Logger class used to get value as boolean value which answer that whether or not this logger is sending its output to its parent logger. Syntax: public boolean getUseParentHandlers() Parameters: This method accepts nothing. Return value: This method returns true if 2 min read Like