LogRecord setSourceMethodName() method in Java with Examples Last Updated : 18 Oct, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The setSourceMethodName() method of java.util.logging.LogRecord is used to set the name of the method that allegedly issued the logging request. The source method name which is used in logRecord for logging purpose has to be set via this method. Syntax: public void setSourceMethodName(String sourceMethodName) Parameters: This method accepts sourceMethodName as a parameter which is the source method name. It can be null also. Return: This method returns nothing. Below programs illustrate setSourceMethodName() method: Program 1: Java // Java program to illustrate // setSourceMethodName() method import java.util.logging.Level; import java.util.logging.LogRecord; public class GFG { public static void main(String[] args) { // Create LogRecord object LogRecord logRecord = new LogRecord(Level.SEVERE, "Hello Logger"); // set source method logRecord .setSourceMethodName( "MyFirstSourceMethod"); // print the method name System.out.println( "Source method Name = " + logRecord.getSourceMethodName()); } } Output: Source method Name = MyFirstSourceMethod Program 2: Java // Java program to illustrate // setSourceMethodName() method import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.*; public class GFG { public static void main(String[] args) { // Create LogRecord object LogRecord logRecord = new LogRecord(Level.INFO, "GFG Logger"); // set a method from ArrayList class // as source method logRecord.setSourceMethodName( ArrayList .class .getMethods()[0] .getName()); // print the method name System.out.println( "Source method Name = " + logRecord.getSourceMethodName()); // now set null as method name logRecord.setSourceMethodName(null); // print the method name System.out.println( "Now new Source method Name = " + logRecord.getSourceMethodName()); } } Output: Source method Name = add Now new Source method Name = null References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/LogRecord.html#setSourceMethodName(java.lang.String) Comment More infoAdvertise with us Next Article LogRecord setSourceMethodName() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions Java-LogRecord java.util.logging package Practice Tags : Java Similar Reads LogRecord setSourceClassName() method in Java with Examples The setSourceClassName() method of java.util.logging.LogRecord is used to set the name of the class that allegedly issued the logging request. The source class name which is used in logRecord for logging purpose has to be set via this method. Syntax: public void setSourceClassName(String sourceClass 2 min read LogRecord setResourceBundleName() method in Java with Examples The setResourceBundleName() method of java.util.logging.LogRecord is used to set the localization resource bundle name. Syntax: public void setResourceBundleName(String name) Parameters: This method accepts the name of the localization bundle name in String format. It can be null also. Return: This 1 min read LogRecord setResourceBundle() method in Java with Examples The setResourceBundle() method of java.util.logging.LogRecord is used to set the localization resource bundle.Resource bundle used to localize the message of this LogRecord. Syntax: public void setResourceBundle(ResourceBundle bundle) Parameters: This method accepts bundle which is the localization 2 min read LogRecord setLoggerName() method in Java with Examples The setLoggerName() method of java.util.logging.LogRecord is used to set the logger name of source.This method returns source logger name if present else returns null. Syntax: public void setLoggerName(String name) Parameters: This method accepts the Source Logger name as a string which can be null 1 min read LogRecord setThrown() method in Java with Examples The setThrown() method of java.util.logging.LogRecord is used to a throwable associated with the log event.This is used to log Exceptions in the logRecord that can be used for logging messages. Syntax: public void setThrown(Throwable thrown) Parameters: This method accepts thrown as a parameter whic 2 min read Like