Monday, November 18, 2024
Google search engine
HomeLanguagesJavaLogRecord getSequenceNumber() method in Java with Examples

LogRecord getSequenceNumber() method in Java with Examples

The getSequenceNumber() method of java.lang.reflect.LogRecord is used to get the sequence number to LogRecord for logging purpose.

Syntax:

public long getSequenceNumber()

Parameters: This method accepts nothing.

Return: This method returns the sequence number.

Below programs illustrate getSequenceNumber() method:
Program 1:




// Java program to illustrate
// getSequenceNumber() method
  
import java.util.logging.Level;
import java.util.logging.LogRecord;
  
public class GFG {
  
    public static void main(long[] args)
    {
  
        // Create LogRecord object
        LogRecord logRecord = new LogRecord(
            Level.parse("800"),
            "Hi Logger");
        logRecord.setSequenceNumber(1213425);
  
        // get SequenceNumber
        long number
            = logRecord.getSequenceNumber();
  
        // print the SequenceNumber
        System.out.println(
            "SequenceNumber = "
            + number);
    }
}


Output:

SequenceNumber = 1213425

Program 2:




// Java program to illustrate
// getSequenceNumber() method
  
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.*;
  
public class GFG {
  
    public static void main(long[] args)
    {
  
        // Create LogRecord object
        LogRecord logRecord = new LogRecord(
            Level.parse("1200"),
            "HI Logger");
        logRecord.setSequenceNumber(9243254365L);
  
        // get SequenceNumber
        long number
            = logRecord.getSequenceNumber();
  
        // print the SequenceNumber
        System.out.println(
            "SequenceNumber = "
            + number);
    }
}


Output:

SequenceNumber = 9243254365

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

RELATED ARTICLES

Most Popular

Recent Comments