LogRecord getThrown() method in Java with Examples Last Updated : 23 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The getThrown() method of java.lang.reflect.LogRecord is used to get 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 Throwable getThrown() Parameters: This method accepts nothing. Return: This method returns a throwable. Below programs illustrate getThrown() method: Program 1: Java // Java program to illustrate // getThrown() method import java.io.IOException; 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.INFO, "GFG Logger"); logRecord.setThrown( new IOException( "Error in Input")); // get Throwable object Throwable throwObj = logRecord.getThrown(); // print result System.out.println( "throwable object = " + throwObj .toString()); } } Output: throwable object = java.io.IOException: Error in Input Program 2: Java // Java program to illustrate // getThrown() 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.WARNING, "Logger"); logRecord.setThrown( new ArithmeticException()); // get Throwable object Throwable throwObj = logRecord.getThrown(); // print result System.out.println( "throwable object = " + throwObj .toString()); } } Output: throwable object = java.lang.ArithmeticException References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/LogRecord.html#getThrown() Comment More infoAdvertise with us Next Article LogRecord getThrown() 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 getThreadID() method in Java with Examples The getThreadID() method of java.lang.reflect.LogRecord is used to get an identifier for the thread where the message originated. This method is helpful to identify thread which generates the logger message. Syntax: public int getThreadID() Parameters: This method accepts nothing. Return: This metho 2 min read LogRecord getInstant() method in Java with Examples The getInstant() method of java.lang.reflect.LogRecord is used to get this instant that the event occurred this is helpful to record logging events instant. Syntax: public Instant getInstant() Parameters: This method accepts nothing. Return: This method returns the instant that the event occurred. B 1 min read LogRecord getLoggerName() method in Java with Examples The getLoggerName() method of java.util.logging.LogRecord is used to get the logger name of source.This method returns source logger name if present else returns null. Syntax: public String getLoggerName() Parameters: This method accepts nothing. Return: This method returns source logger name if pre 1 min read 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 retur 1 min read LogRecord getLevel() method in Java with Examples The getLevel() method of java.util.logging.LogRecord is used to get the logging message level of this current LogRecord object, for example Level.Info. Syntax: public Level getLevel() Parameters: This method accepts nothing. Return: This method returns the logging message level. Below programs illus 1 min read Like