当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java LogRecord setSequenceNumber()用法及代码示例


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)



相关用法


注:本文由纯净天空筛选整理自AmanSingh2210大神的英文原创作品 LogRecord setSequenceNumber() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。