This Java tip illustrates an example of preventing a logger from forwarding log records to its parent. Usually, logger sends a log record to all its handlers and its parent loggers. In case developer needs the parent logger to be unaware of the records, developer may use this code for prevention.

// Get a logger Logger log = Logger.getLogger">"com.mycompany")// Stop forwarding log records to ancestor handlers log.setUseParentHandlers(false // Start forwarding log records to ancestor handlers log.setUseParentHandlers(true);