Logger getHandler() Method in Java with Examples Last Updated : 20 Mar, 2019 Comments Improve Suggest changes Like Article Like Report The getHandlers() method of the Logger class is used to get the Handlers linked with this logger. Handler is used to taking care of the actual logging. one or more Handler can be added to a Logger. When messages are logged via the Logger, the messages are forwarded to the Handler. This method is helpful for getting an array of all registered Handlers. Syntax: public Handler[] getHandlers() Parameters: This method accepts nothing. Return value: This method return an array of all registered Handlers. Below programs illustrate the getHandlers() method: Program 1: Java // Java program to demonstrate // Logger.getHandler() method import java.util.logging.*; import java.io.IOException; public class GFG { public static void main(String[] args) throws SecurityException, IOException { // Create a logger Logger logger = Logger.getLogger( GFG.class.getName()); // Log some logs logger.info("This is message 1"); logger.info("This is message 2"); logger.info("This is message 3"); // Get handler details using getHandler Handler[] handlers = logger.getHandlers(); // Log handler length logger.info("length of Handler " + handlers.length); } } Output: The output printed on eclipse IDE is shown below- Program 2: Java // Java program to demonstrate // Logger.getHandler() method import java.util.logging.*; import java.io.IOException; public class GFG { public static void main(String[] args) throws SecurityException, IOException { // Create a logger Logger logger = Logger.getLogger( GFG.class.getName()); // Set a console Handler logger.addHandler(new ConsoleHandler()); // Get handler details using getHandler Handler[] handlers = logger.getHandlers(); // Print handler details for (int i = 0; i < handlers.length; i++) { System.out.println("Handler details: " + handlers[i].toString()); } } } Output: The output printed on eclipse IDE is shown below- Reference: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#getHandlers() Comment More infoAdvertise with us Next Article Logger getHandler() 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 getLogger() Method in Java with Examples The getLogger() method of a Logger class used find or create a logger. If there is a logger exists with the passed name then the method will return that logger else method will create a new logger with that name and return it. There are two types of getLogger() method depending upon no of the parame 4 min read Logger getName() Method in Java with Examples getName() method of a Logger class used to get the name of logger. Many times you have to check the logger name so we can use this method to get the logger name. Syntax: public String getName() Parameters: This method accepts nothing. Return value: This method return logger name and it will be null 1 min read Logger getFilter() Method in Java with Examples The getFilter() method of the Logger class is used to get the current filter for this Logger instance. A Filter is useful to filter out log messages. we can say that filter decide the message gets logged or not. Filters are represented by the Java interface java.util.logging.Filter Syntax: public Fi 2 min read Logger getLevel() method in Java with Examples The getLevel() method of the Logger class in Java is used to get the log Level that has been specified for this Logger instance. Every Logger has specific log levels and if the result is null, which means that this logger's effective level will be inherited from its parent. Log Levels: The log level 2 min read Logger getGlobal() Method in Java with Examples getGlobal() method of a Logger class is used to get global logger object with the name Logger.GLOBAL_LOGGER_NAME.The "global" Logger object is helpful for developers who are making casual use of the Logging package. For making serious use of the logging package developers have to create and use thei 2 min read Like