import java.util.logging.Logger; public class MyClass { private static final Logger LOGGER = Logger.getLogger(MyClass.class.getName()); public static void main(String[] args) { LOGGER.setUseParentHandlers(false); // disable parent handlers LOGGER.info("Logging without parent handlers"); } }
import java.util.logging.Logger; public class MyClass { private static final Logger LOGGER = Logger.getLogger(MyClass.class.getName()); public static void main(String[] args) { LOGGER.setUseParentHandlers(true); // enable parent handlers LOGGER.info("Logging with parent handlers enabled"); } }In this example, the useParentHandlers property of the LOGGER object is set to true, which means that the parent handlers will be used along with the handler attached to this logger instance. The java.util.logging package is part of the Java Standard Library.