Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

LogRecord getResourceBundle() method in Java with Examples

  • Last Updated : 23 Oct, 2019

The getResourceBundle() method of java.lang.reflect.LogRecord is used to get the localization resource bundle.Resource bundle used to localize the message of this LogRecord.

Syntax:

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

public ResourceBundle getResourceBundle()

Parameters: This method accepts nothing.

Return: This method returns the localization resource bundle.



Below programs illustrate getResourceBundle() method:
Program 1:




// Java program to illustrate
// getResourceBundle() 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");
  
        logRecord
            .setResourceBundle(
                ResourceBundle
                    .getBundle("myResource"));
  
        // get ResourceBundle
        ResourceBundle resourceBundle
            = logRecord.getResourceBundle();
  
        // print the ResourceBundle details
        System.out.println(
            "Resource Bundle = "
            + resourceBundle.getBaseBundleName());
    }
}
Output:
Resource Bundle = myResource

Program 2:




// Java program to illustrate
// getResourceBundle() 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("600"),
            "GFG Logger");
        logRecord.setResourceBundle(null);
  
        // get ResourceBundle
        ResourceBundle resourceBundle
            = logRecord.getResourceBundle();
  
        // print the ResourceBundle details
        System.out.println(
            "Resource Bundle = "
            + resourceBundle);
    }
}
Output:
Resource Bundle = null

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




My Personal Notes arrow_drop_up
Recommended Articles
Page :