java.util.logging.LogRecord的setResourceBundle()方法用于设置本地化资源包。资源包用于本地化此LogRecord的消息。
用法:
public void setResourceBundle(ResourceBundle bundle)
参数:此方法接受为本地化包的包,它可以为null。
返回:此方法不返回任何内容。
以下示例程序旨在说明setResourceBundle()方法:
示例1:
// Java program to illustrate setResourceBundle() method
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.ResourceBundle;
public class GFG {
public static void main(String[] args)
{
// Create LogRecord object
LogRecord logRecord = new LogRecord(
Level.parse("800"),
"Hi Logger");
// Create ResourceBundle using getBundle
// myResource is a properties file
ResourceBundle bundle
= ResourceBundle
.getBundle("myResource");
// set ResourceBundle
logRecord.setResourceBundle(bundle);
// print the ResourceBundle details
System.out.println(
"Resource Bundle = "
+ logRecord
.getResourceBundle()
.getBaseBundleName());
}
}
输出:
Resource Bundle = myResource
示例2:
// Java program to illustrate setResourceBundle() method
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.ResourceBundle;
public class GFG {
public static void main(String[] args)
{
// Create LogRecord object
LogRecord logRecord = new LogRecord(
Level.parse("800"),
"Hi Logger");
// Create ResourceBundle having null value
ResourceBundle bundle
= null;
// set ResourceBundle
logRecord.setResourceBundle(bundle);
// print the ResourceBundle details
System.out.println(
"Resource Bundle = "
+ logRecord.getResourceBundle());
}
}
输出:
Resource Bundle = null
相关用法
- Java Logger setResourceBundle()用法及代码示例
- Java LogRecord getThrown()用法及代码示例
- Java LogRecord getSourceMethodName()用法及代码示例
- Java LogRecord setSequenceNumber()用法及代码示例
- Java LogRecord getInstant()用法及代码示例
- Java LogRecord setInstant()用法及代码示例
- Java LogRecord getSourceClassName()用法及代码示例
- Java LogRecord getParameters()用法及代码示例
- Java LogRecord getThreadID()用法及代码示例
- Java LogRecord setSourceClassName()用法及代码示例
- Java LogRecord setThreadID()用法及代码示例
- Java LogRecord setMillis()用法及代码示例
- Java LogRecord setParameters()用法及代码示例
- Java LogRecord setResourceBundleName()用法及代码示例
- Java LogRecord setLoggerName()用法及代码示例
注:本文由纯净天空筛选整理自AmanSingh2210大神的英文原创作品 LogRecord setResourceBundle() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。