Logger setParent() method in Java with Examples Last Updated : 26 Mar, 2019 Comments Improve Suggest changes Like Article Like Report setParent() method of a Logger class used to set the parent Logger of this current Logger.The parent Logger we want to set is passed as a parameter. LogManager use this method to update a Logger when the namespace changes. Syntax: public void setParent(Logger parent) Parameters: This method accepts one parameter parent which represents the new parent logger. Return value: This method returns nothing. Exception: This method throws SecurityException if a security manager exists and if the caller does not have LoggingPermission("control"). Below programs illustrate the setParent() method: Program 1: Java // Java program to demonstrate // Logger.setParent() method import java.util.logging.*; public class GFG { public static void main(String[] args) { // Create a logger1 using getLogger() Logger logger1 = Logger.getLogger("com.java.core"); // Assign other package to logger Logger logger2 = Logger .getLogger("com.java.core.api"); // Set logger1 as parent to logger2 logger2.setParent(logger1); // Print parent name System.out.println("logger2 parent name = " + logger2 .getParent() .getName()); } } Output: The output printed on console of Eclipse is shown below- Program 2: Java // Java program to demonstrate // Logger.setParent() method import java.util.logging.*; public class GFG { public static void main(String[] args) { // Create a logger1 using getLogger() Logger logger1 = Logger.getLogger(GFG.class.getName()); // Assign other package to logger Logger logger2 = Logger .getLogger(String.class.getName()); // Set logger2 as parent to logger1 logger1.setParent(logger2); // Print parent name System.out.println("logger1 parent name = " + logger1 .getParent() .getName()); } } Output: The output printed on console output is shown below- Reference: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#setParent(java.util.logging.Logger) Comment More infoAdvertise with us Next Article Logger setParent() 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 setLevel() method in Java with Examples setLevel() method of a Logger class used to set the log level to describe which message levels will be logged by this logger. The level we want to set is passed as a parameter. Message levels lower than passed log level value will be discarded by the logger. The level value Level.OFF can be used to 2 min read Logger setUseParentHandlers() method in Java with Examples setUseParentHandlers() method of a Logger class used to set the configuration which defines whether or not this logger should send its output to its parent Logger. if we want to send the output to its parent Logger then we have to set the parameter to this method equal to true. This means that any l 2 min read LogRecord setParameters() method in Java with Examples The setParameters() method of java.util.logging.LogRecord is used to set the parameters to the log message.These parameters are the parameters to be inserted into the message of this LogRecord. Syntax: public void setParameters(Object[] parameters) Parameters: This method accepts parameters as param 2 min read Logger setFilter() method in Java with Examples setFilter() method of a Logger class is used to set a filter to control output on this Logger. The filter is passed as a parameter. A Filter is useful to filter out log messages. It can be said that the filter decides the message gets to be logged or not. Filters are represented by the Java interfac 2 min read LogRecord setInstant() method in Java with Examples The setInstant() method of java.lang.reflect.LogRecord is used to set this instant that the event occurred this is helpful to record logging events instant. An arithmeticException will be thrown if the given instant represents a point on the timeline too far in the future or past to fit in long mill 2 min read Like