java.util.logging.LogManager的getLoggerNames()方法用於獲取已知記錄器名稱的列表。此方法以Enumeration對象的形式返回此列表。
用法:
public Enumeration getLoggerNames()
參數:此方法不接受任何參數。
返回值:此方法以Enumeration對象的形式返回已知記錄器名稱列表。
以下示例程序旨在說明getLoggerNames()方法:
示例1:
// Java program to illustrate
// LogManager getLoggerNames() method
import java.util.logging.*;
import java.util.*;
public class GFG {
public static void main(String[] args)
{
// Create LogManager object
LogManager logManager
= LogManager.getLogManager();
Enumeration<String> listOfNames
= logManager.getLoggerNames();
System.out.println("List of Logger Names: ");
while (listOfNames.hasMoreElements())
System.out.println(listOfNames.nextElement());
}
}
輸出:
List of Logger Names: global
示例2:
// Java program to illustrate
// LogManager getLoggerNames() method
import java.util.logging.*;
import java.util.*;
public class GFG {
public static void main(String[] args)
{
// Create LogManager object
LogManager logManager
= LogManager.getLogManager();
logManager.addLogger(Logger.getLogger("GFG"));
Enumeration<String> listOfNames
= logManager.getLoggerNames();
System.out.println("\nList of Logger Names: ");
while (listOfNames.hasMoreElements())
System.out.println(listOfNames.nextElement());
}
}
輸出:
List of Logger Names: GFG global
參考:https://docs.oracle.com/javase/9/docs/api/java/util/logging/LogManager.html#getLoggerNames–
相關用法
- Java LogManager getLogger()用法及代碼示例
- Java LogManager addLogger()用法及代碼示例
- Java LogManager getLogManager()用法及代碼示例
- Java LogManager reset()用法及代碼示例
- Java LogManager checkAccess()用法及代碼示例
- Java LogManager getProperty()用法及代碼示例
- Java LogManager readConfiguration()用法及代碼示例
- Java Java lang.Long.byteValue()用法及代碼示例
- Java Java lang.Long.builtcount()用法及代碼示例
- Java Java lang.Long.reverse()用法及代碼示例
- Java Java.util.Collections.rotate()用法及代碼示例
- Java Java.util.Collections.disjoint()用法及代碼示例
- Java Java lang.Long.highestOneBit()用法及代碼示例
- Java Java lang.Long.numberOfLeadingZeros()用法及代碼示例
注:本文由純淨天空篩選整理自guptayashgupta53大神的英文原創作品 LogManager getLoggerNames() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。