Thursday, July 2, 2026
HomeLanguagesJavaLogger getResourceBundleName() method in Java with Examples

Logger getResourceBundleName() method in Java with Examples

getResourceBundleName() method of a Logger class is used to retrieve the localization resource bundle name for this logger.We can set ResourceBundle either by the setResourceBundle method or mapped from the resource bundle name set via the getLogger factory method for the current default locale. This method returns the name specified base ResourceBundle set by above-mentioned ways. 
Note that if the result is null, then the Logger will use a resource bundle or resource bundle name inherited from its parent.
Syntax: 
 

public String getResourceBundleName()

Parameters: This method accepts nothing.
Return value: This method returns localization bundle name.
Below programs illustrate the info(String) method:
Program 1: 
 

Java




// Java program to demonstrate
// Logger.getResourceBundleName() method
 
import java.util.logging.Logger;
 
public class GFG {
 
    private static Logger logger
        = Logger.getLogger(
            String
                .class
                .getPackage()
                .getName());
 
    public static void main(String args[])
    {
 
        logger.info("printing the message...");
 
        String resourceBundleName
            = logger.getResourceBundleName();
 
        logger.info("Resource Bundle Name = "
 + resourceBundleName);
    }
}


The output printed on eclipse IDE shown below- 
Output: 
 

Program 2: 
 

Java




// Java program to demonstrate
// Logger.getResourceBundleName() method
 
import java.util.logging.*;
import java.util.ResourceBundle;
 
public class GFG {
 
    private static Logger logger
        = Logger.getLogger(
            GFG
                .class
                .getPackage()
                .getName());
 
    public static void main(String args[])
    {
 
        // Create ResourceBundle using getBundle
        // myResource is a properties file
        ResourceBundle bundle
            = ResourceBundle
                  .getBundle("myResource");
 
        // Set ResourceBundle to logger
        logger.setResourceBundle(bundle);
 
        // Get ResourceBundle Name from logger
        String rsBundleNAme
            = logger.getResourceBundleName();
 
        // Log the ResourceBundle name
        logger.info("Resource Bundle Name - "
                    + rsBundleNAme);
    }
}


For the above program, there is a properties file name myResource. we have to add this file alongside the class to execute the program. 
The output printed on eclipse IDE shown below- 
Output: 
 

Reference: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#getResourceBundleName()
 

RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32518 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6900 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12110 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6966 POSTS0 COMMENTS