java.util.logging.LogRecord的setSequenceNumber()方法用於將序列號設置為LogRecord以進行記錄。
用法:
public void setSequenceNumber(long seq)
參數:此方法接受seq作為長型參數,這是我們要設置的序列號。
返回:此方法不返回任何內容。
以下示例程序旨在說明setSequenceNumber()方法:
示例1:
// Java program to illustrate
// setSequenceNumber() 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.SEVERE,
"Hello Logger");
// set sequence number
logRecord.setSequenceNumber(41545412);
// print the sequence number
System.out.println(
"Sequence Number = "
+ logRecord.getSequenceNumber());
}
}
輸出:
Sequence Number = 41545412
示例2:
// Java program to illustrate
// setSequenceNumber() method
import java.util.logging.Level;
import java.util.logging.LogRecord;
public class Main {
public static void main(String[] args)
{
// Create LogRecord object
LogRecord logRecord
= new LogRecord(Level.INFO,
"GFG Logger");
// set sequence number
logRecord.setSequenceNumber(96236641);
// print the sequence number
System.out.println(
"Sequence Number = "
+ logRecord.getSequenceNumber());
}
輸出:
Sequence Number = 96236641
參考文獻: https://docs.oracle.com/javase/10/docs/api/java/util/logging/LogRecord.html#setSequenceNumber(long)
相關用法
- Java LogRecord getMessage()用法及代碼示例
- Java LogRecord getSourceMethodName()用法及代碼示例
- Java LogRecord getInstant()用法及代碼示例
- Java LogRecord getThreadID()用法及代碼示例
- Java LogRecord getSourceClassName()用法及代碼示例
- Java LogRecord getParameters()用法及代碼示例
- Java LogRecord getSequenceNumber()用法及代碼示例
- Java LogRecord setSourceClassName()用法及代碼示例
- Java LogRecord getLoggerName()用法及代碼示例
- Java LogRecord setResourceBundleName()用法及代碼示例
- Java LogRecord setResourceBundle()用法及代碼示例
- Java LogRecord setParameters()用法及代碼示例
- Java LogRecord setMillis()用法及代碼示例
- Java LogRecord setLoggerName()用法及代碼示例
- Java LogRecord setSourceMethodName()用法及代碼示例
注:本文由純淨天空篩選整理自AmanSingh2210大神的英文原創作品 LogRecord setSequenceNumber() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。