How do I prevent the logger send log messages to its parent logger?

To prevent log records being forwarded to the logger’s parent handlers we can
set false the useParentHandlers field using the
Logger.setUserParentHandlers(boolean useParentHandlers) method.

package org.kodejava.example.util.logging;

import java.util.logging.Logger;
import java.util.logging.ConsoleHandler;

public class NoParentLogger {
    public static void main(String[] args) {
        Logger logger = Logger.getLogger(NoParentLogger.class.getName());

        // Do not forward any log messages the the logger parent handlers.

        // Specify a ConsoleHanlder for this logger instance.
        logger.addHandler(new ConsoleHandler());"Logging an information message.");


Programmer, runner, recreational diver, live in the island of Bali, Indonesia. Mostly programming in Java, Spring Framework, Hibernate / JPA. Support me by donating.

Leave a Reply