Logger exiting() method in Java with Examples Last Updated : 28 Mar, 2019 Comments Improve Suggest changes Like Article Like Report The exiting() method of a Logger class used to Log a method return. There are two types of exiting() method depending upon the parameters passed. exiting(String sourceClass, String sourceMethod): This method is used to Log a method return. we need to log what method returns and this is a convenience method that can be used to log returning from a method. This method logs with the message "RETURN", log level FINER, and the given sourceMethod and sourceClass are also logged. Syntax: public void exiting(String sourceClass, String sourceMethod) Parameters: This method accepts two parameters: sourceClass is the name of the class that issued the logging request, sourceMethod is the name of the method Return value: This method returns nothing. Below program illustrate exiting(String sourceClass, String sourceMethod) method: Program 1: Java // Java program to demonstrate // exiting(String, String) method import java.io.IOException; import java.util.logging.FileHandler; import java.util.logging.Level; import java.util.logging.Logger; import java.util.logging.SimpleFormatter; public class GFG { public static void main(String[] args) throws SecurityException, IOException { // Create a Logger Logger logger = Logger.getLogger( GFG.class.getName()); // Create a file handler object FileHandler handler = new FileHandler("logs.txt"); handler.setFormatter(new SimpleFormatter()); // Add file handler as // handler of logs logger.addHandler(handler); // set Logger level() logger.setLevel(Level.FINER); // call exiting methods with class // name = GFG and method name = main logger.exiting(GFG.class.getName(), GFG.class.getMethods()[0].getName()); } } The output printed on log.txg file is shown below. Output: exiting(String sourceClass, String sourceMethod, Object result): This method is used to Log a method entry, with result object. This is a very helpful method to log entry related to a method of a class with its return value. This method logs with the message "RETURN {0}", log level FINER, and the gives sourceMethod, sourceClass, and result object is logged. Syntax: public void exiting(String sourceClass, String sourceMethod, Object result) Parameters: This method accepts three parameters: sourceClass is the name of the class that issued the logging request, sourceMethod is the name of the method and Object that is being returned. Return value: This method returns nothing. Below programs illustrate exiting(String sourceClass, String sourceMethod, Object result) method: Program 1: Java // Java program to demonstrate // exiting(String, String, Object) method import java.io.IOException; import java.util.logging.FileHandler; import java.util.logging.Level; import java.util.logging.Logger; import java.util.logging.SimpleFormatter; public class GFG { public static void main(String[] args) throws SecurityException, IOException { // Create a Logger Logger logger = Logger.getLogger( GFG.class.getName()); // Create a file handler object FileHandler handler = new FileHandler("logs.txt"); handler.setFormatter(new SimpleFormatter()); // Add file handler as // handler of logs logger.addHandler(handler); // set Logger level() logger.setLevel(Level.FINER); // set Logger level() logger.setLevel(Level.FINER); // call exiting method with class // name = GFG and method name = main logger.exiting(GFG.class.getName(), GFG.class.getMethods()[0].getName(), new String("Java is Platform Independent")); } } The output printed on log.txt is shown below. Output: References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#exiting(java.lang.String, java.lang.String, java.lang.Object) https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#exiting(java.lang.String, java.lang.String) Comment More infoAdvertise with us Next Article Logger exiting() 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 fine() method in Java with Examples The fine() method of a Logger class used to Log a FINE message. This method is used to pass FINE types logs to all the registered output Handler objects. FINE, FINER and FINEST provide tracking information as when what is happening/ has happened in our application. FINE displays the most important m 3 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 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 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 Logger finest() method in Java with Examples The finest() method of a Logger class used to Log an FINEST message.This method is used to pass FINEST types logs to all the registered output Handler objects. FINEST message: FINEST provides highly detailed tracing message. There are two types of finest() method depending upon the number of the par 3 min read Like