Logger getUseParentHandlers() Method in Java with Examples
Last Updated :
26 Mar, 2019
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:
import java.util.logging.Logger;
public class GFG {
private static Logger logger
= Logger.getLogger(
GFG. class
.getPackage()
.getName());
public static void main(String args[])
{
boolean flag
= logger.getUseParentHandlers();
logger.info( "output sent to the"
+ " logger's parent - "
+ flag);
}
}
|
The output printed on eclipse IDE shown below-
Program 2:
import java.util.logging.Logger;
public class GFG {
private static Logger logger
= Logger.getLogger(
GFG. class
.getPackage()
.getName());
public static void main(String args[])
{
logger.setUseParentHandlers( false );
boolean flag = logger.getUseParentHandlers();
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()
Share your thoughts in the comments
Please Login to comment...