The getParameters() method of java.lang.reflect.LogRecord is used to get the parameters to the log message.These parameters are the parameters to be inserted into the message of this LogRecord.
Syntax:
public Object[] getParameters()
Parameters: This method accepts nothing.
Return: This method returns the log message parameters.It can be null if there are no parameters to return.
Below programs illustrate getParameters() method:
Program 1:
// Java program to illustrate // getParameters() 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.parse( "800" ), "Hi Logger" ); logRecord.setParameters( new Object[] {}); // get object parameters Object[] params = logRecord.getParameters(); System.out.println( "Object Array length: " + params.length); } } |
Object Array length: 0
Program 2:
// Java program to illustrate // getParameters() method import java.lang.reflect.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.parse( "400" ), "GFG logger" ); Object[] objArr = String . class .getDeclaredMethods()[ 4 ] .getParameters(); logRecord.setParameters(objArr); // get object parameters Object[] params = logRecord.getParameters(); for ( int i = 0 ; i < params.length; i++) { System.out.println(params[i]); } } } |
java.lang.Object arg0
References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/LogRecord.html#getParameters()