當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Java LogRecord getSequenceNumber()用法及代碼示例


java.lang.reflect.LogRecord的getSequenceNumber()方法用於將序列號獲取到LogRecord以進行記錄。

用法:

public long getSequenceNumber()

參數:此方法不接受任何內容。


返回:此方法返回序列號。

以下示例程序旨在說明getSequenceNumber()方法:
示例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); 
    } 
}
輸出:
SequenceNumber = 1213425

示例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); 
    } 
}
輸出:
SequenceNumber = 9243254365

參考文獻: https://docs.oracle.com/javase/10/docs/api/java/util/logging/LogRecord.html#getSequenceNumber()



相關用法


注:本文由純淨天空篩選整理自AmanSingh2210大神的英文原創作品 LogRecord getSequenceNumber() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。