You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Kavitha Balan Nair <ka...@oracle.com> on 2017/12/14 06:23:28 UTC

Configuring properties file which is in resourcebundle

 

 

 

Hi,

 

In our project we get the properties file into a resourcebundle. So I need to configure it through that bundle. 

 

Is there any way to get  that bundle for configuring it.

 

Log4j 2.9.1 version is been used.

 

Code snippet:

               PropertyResourceBundle bundle = (PropertyResourceBundle) PropertyResourceBundle.getBundle("log4j2");
 
                 //what should be the format to fill the parameters .
                 ConfigurationSource configurationSource = new ConfigurationSource(________);
 
I cannot use the ConfigurationSource.fromUri or fromResource.
 
Any idea with this ?
 
Thanks,
Kavitha
 

 

Re: Configuring properties file which is in resourcebundle

Posted by Ralph Goers <ra...@dslextreme.com>.
Resource bundles contain localized text for internationalization purposes, not configuration data. It is unfortunate that Sun chose to use the same properties file format for resource bundles and properties files, but using the PropertyResourceBundle class to read a property file is not something you should be doing as the getBundle call will be looking for files such as log4j2_en_us.properties and using those along with log4j2.properties. As such, Log4j 2 doesn’t support using a resource bundle like that. Instead, you should be using the Properties class.

Ralph


> On Dec 13, 2017, at 11:23 PM, Kavitha Balan Nair <ka...@oracle.com> wrote:
> 
> 
> 
> 
> 
> 
> 
> Hi,
> 
> 
> 
> In our project we get the properties file into a resourcebundle. So I need to configure it through that bundle. 
> 
> 
> 
> Is there any way to get  that bundle for configuring it.
> 
> 
> 
> Log4j 2.9.1 version is been used.
> 
> 
> 
> Code snippet:
> 
>               PropertyResourceBundle bundle = (PropertyResourceBundle) PropertyResourceBundle.getBundle("log4j2");
> 
>                 //what should be the format to fill the parameters .
>                 ConfigurationSource configurationSource = new ConfigurationSource(________);
> 
> I cannot use the ConfigurationSource.fromUri or fromResource.
> 
> Any idea with this ?
> 
> Thanks,
> Kavitha
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org