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:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
public boolean getUseParentHandlers()
Parameters: This method accepts nothing.
Return value: This method returns true if output is to be sent to the logger’s parent.
Below programs illustrate the getUseParentHandlers() method:
Program 1:
// Java program to demonstrate// Logger.getUseParentHandlers() method import java.util.logging.Logger; public class GFG { private static Logger logger = Logger.getLogger( GFG.class .getPackage() .getName()); public static void main(String args[]) { // Check output is to be // sent to the logger's parent boolean flag = logger.getUseParentHandlers(); // Log the flag value logger.info("output sent to the" + " logger's parent - " + flag); }} |
The output printed on eclipse IDE shown below-
Program 2:
// Java program to demonstrate// Logger.getUseParentHandlers() method import java.util.logging.Logger; public class GFG { private static Logger logger = Logger.getLogger( GFG.class .getPackage() .getName()); public static void main(String args[]) { // Set setUseParentHandlers logger.setUseParentHandlers(false); // Check output is to be // sent to the logger's parent boolean flag = logger.getUseParentHandlers(); // Print value System.out.println("output sent to the" + " logger's parent - " + flag); }} |
The output printed on eclipse IDE shown below-
Reference: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#getUseParentHandlers()


