LogRecord setMessage() method in Java with Examples Last Updated : 15 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The setMessage() method of java.util.logging.LogRecord is used to set the "raw" log message, before localization or formatting for this LogRecord object.we can also set null as raw message. Syntax: public void setMessage(String message) Parameters: This method accepts message which is the raw message string. Return: This method returns nothing. Below programs illustrate setMessage() method: Program 1: Java // Java program to illustrate setMessage() method import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.*; public class GFG { public static void main(String[] args) { // Create LogRecord object LogRecord logRecord = new LogRecord( Level.parse("800"), "Hi Logger"); System.out.println( "Previous Message: " + logRecord.getMessage()); // set message of the LogRecord logRecord.setMessage("GFG Logger"); // print result System.out.println( "New Message: " + logRecord.getMessage()); } } Output: Previous Message: Hi Logger New Message: GFG Logger Program 2: Java // Java program to illustrate setMessage() method import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.*; public class GFG { public static void main(String[] args) { // Create LogRecord object LogRecord logRecord = new LogRecord( Level.INFO, "GFG Logger"); System.out.println( "Previous Message: " + logRecord.getMessage()); // set message of the LogRecord logRecord.setMessage(null); // print result System.out.println( "New Message: " + logRecord.getMessage()); } } Output: Previous Message: GFG Logger New Message: null References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/LogRecord.html#setMessage(java.lang.String) Comment More infoAdvertise with us Next Article LogRecord setMessage() 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 setLevel() method in Java with Examples The setLevel() method of java.util.logging.LogRecord is used to set the level of logging message, for example Level.INFO for this LogRecord Object. Syntax: public void setLevel(Level level) Parameters: This method accepts level which is the logging message level. Return: This method returns nothing. 1 min read LogRecord setMillis() method in Java with Examples The setMillis() method of java.util.logging.LogRecord is used to set the event time in LogRecord.This event time has unit in MilliSeconds since 1970.Syntax: public void setMillis(long millis) Parameters: This method accepts millis as parameter which is event time in milli-seconds since 1970Return: T 2 min read LogRecord setInstant() method in Java with Examples The setInstant() method of java.lang.reflect.LogRecord is used to set this instant that the event occurred this is helpful to record logging events instant. An arithmeticException will be thrown if the given instant represents a point on the timeline too far in the future or past to fit in long mill 2 min read LogRecord setParameters() method in Java with Examples The setParameters() method of java.util.logging.LogRecord is used to set the parameters to the log message.These parameters are the parameters to be inserted into the message of this LogRecord. Syntax: public void setParameters(Object[] parameters) Parameters: This method accepts parameters as param 2 min read LogRecord setThreadID() method in Java with Examples The setThreadID() method of java.util.logging.LogRecord is used to set an identifier for the thread where the message originated. This method is helpful to identify thread which generates the logger message. Syntax: public void setThreadID(int threadID) Parameters: This method accepts threadID which 2 min read Like