Monday, November 24, 2025
HomeLanguagesJavaLogRecord getParameters() method in Java with Examples

LogRecord getParameters() method in Java with Examples

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);
    }
}


Output:

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]);
        }
    }
}


Output:

java.lang.Object arg0

References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/LogRecord.html#getParameters()

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32411 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6909 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6866 POSTS0 COMMENTS
Umr Jansen
6853 POSTS0 COMMENTS