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 output is to be sent to the logger’s parent.

Below programs illustrate the getUseParentHandlers() method:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);
    }
}

chevron_right


The output printed on eclipse IDE shown below-

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);
    }
}

chevron_right


The output printed on eclipse IDE shown below-

Reference: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#getUseParentHandlers()



My Personal Notes arrow_drop_up

I am a Developer I love to code and bring my ideas alive

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.