Logger config() method in Java with Examples Last Updated : 26 Mar, 2019 Comments Improve Suggest changes Like Article Like Report The config() method of a Logger class used to Log an config message. This method is used to pass config types logs to all the registered output Handler objects. Config Level: Configuration Information may be like what CPU the application is running on, how much is the disk and memory space. There are two types of config() method depending upon the number of parameters passed. config(String msg): This method is used to log a CONFIG message. If the logger is enabled for logging CONFIG level message then the given message is forwarded to all the registered output Handler objects. Syntax: public void config(String msg) Parameters: This method accepts a single parameter String which is the string message. Return value: This method returns nothing. Below programs illustrate config(String msg) method: Program 1: Java // Java program to demonstrate // Logger.config(String msg) method import java.io.IOException; import java.util.logging.*; 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"); // Add file handler as // handler of logs logger.addHandler(handler); // Set Logger level() logger.setLevel(Level.CONFIG); // Call config method logger.config("Set Geeks=CODING"); } } The output printed on logs.txt file is shown below. Output: Program 2: Java // Java program to demonstrate // Logger.config(String msg) method import java.io.IOException; import java.util.logging.*; 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"); // Add file handler as // handler of logs logger.addHandler(handler); // Set Logger level() logger.setLevel(Level.CONFIG); // Call config method logger.config("This is config message 1"); logger.config("This is config message 2"); } } The output printed on logs.txt file is shown below. Output: config(Supplier msgSupplier): This method is used Log a CONFIG message, constructed only if the logging level is such that the message will actually be logged. It means If the logger is enabled for the CONFIG message level then the message is constructed by invoking the provided supplier function and forwarded to all the registered output Handler objects. Syntax: public void config(Supplier msgSupplier) Parameters: This method accepts a single parameter msgSupplier which is a function, which when called, produces the desired log message. Return value: This method returns nothing. Below programs illustrate config(Supplier msgSupplier) method: Program 1: Java // Java program to demonstrate // Logger.config(Supplier<String>) method import java.io.IOException; import java.util.function.Supplier; import java.util.logging.*; 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"); // Add file handler as // handler of logs logger.addHandler(handler); // Set Logger level() logger.setLevel(Level.CONFIG); // Create a supplier<String> method Supplier<String> StrSupplier = () -> new String("Welcome to GFG"); // Call config(Supplier<String>) logger.config(StrSupplier); } } The output printed on log.txt is shown below. Output: References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#config(java.lang.String) https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#config(java.util.function.Supplier) Comment More infoAdvertise with us Next Article Logger config() 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 entering() method in Java with Examples The entering() method of a Logger class used to Log a method entry. There are three types of entering() method depending upon the parameters passed. entering(String sourceClass, String sourceMethod): This method is used to Log a method entry.Actually many times in application development we need to 4 min read Logger log() Method in Java with Examples The log() method of Logger is used to Log a message. If the logger is currently enabled for the given message level which is passed as parameter then a corresponding LogRecord is created and forwarded to all the registered Output Handler objects. But in logger class, there are seven different log() 6 min read 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 LogManager addLogger() method in Java with Examples The addLogger() method of java.util.logging.LogManager is used to insert the specified Logger in this LogManager instance. This Logger must be a named Logger. This method will add this Logger in this LogManager if it does not exist already. If it exists already, then this method returns false. Synta 2 min read Logger finer() method in Java with Examples The finer() method of a Logger class used to Log an FINER message.This method is used to pass FINER types logs to all the registered output Handler objects. FINER message: FINER outputs a detailed tracing message and may include logging calls regarding method entering, exiting, throwing exceptions. 3 min read Like