Sunday, November 17, 2024
Google search engine
HomeLanguagesJavaLogRecord setResourceBundleName() method in Java with Examples

LogRecord setResourceBundleName() method in Java with Examples

The setResourceBundleName() method of java.util.logging.LogRecord is used to set the localization resource bundle name.

Syntax:

public void setResourceBundleName(String name)

Parameters: This method accepts the name of the localization bundle name in String format. It can be null also.

Return: This method returns nothing.

Below programs illustrate setResourceBundleName() method:
Program 1:




// Java program to illustrate
// setResourceBundleName() 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 ResourceBundle Name
        logRecord
            .setResourceBundleName(
                "MyResource Bundle");
  
        // print the ResourceBundle Name
        System.out.println(
            "Resource Bundle Name= "
            + logRecord.getResourceBundleName());
    }
}


Output:

Resource Bundle Name= MyResource Bundle

Program 2:




// Java program to illustrate
// setResourceBundleName() 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.INFO,
                            "GFG Logger");
  
        // set ResourceBundle Name
        logRecord.setResourceBundleName(null);
  
        // print the ResourceBundle Name
        System.out.println(
            "Resource Bundle Name= "
            + logRecord.getResourceBundleName());
    }
}


Output:

Resource Bundle Name= null

References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/LogRecord.html#setResourceBundleName(java.lang.String)

RELATED ARTICLES

Most Popular

Recent Comments