You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ma...@yahoo.com on 2009/07/01 21:02:11 UTC

LocalizedLogger (enhancement)

I've written an enhancement to the localization support the generic Logger class provides. 


A new LocalizedLogger overrides basic log4j logging methods (trace(), debug(), info(), warn(), error(), fatal()) to use a localization mechanism. Instead of the actual log messages, keys to localization log messages can be passed into these logging methods. Full parameterization is supported. If keys are not found in the ResourceBundle, they are logged directly, skipping the localization.

Internally, LocalizedLogger simply calls the l7dlog() method that already exists in Logger. LocalizedLogger is just a convenience class for applications that don't want to call this special method. 

A LocalizationResourceBundle and a LocalizedLoggerFactory classes are also included. These helper classes provide easy integration with your application by simply changing the loggerFactory defined in the log4j configuration to point to this new LocalizedLoggerFactory.

I've attached an SVN diff that can be applied to log4j trunk.

Thanks,

Manish



      

Re: LocalizedLogger (enhancement)

Posted by ma...@yahoo.com.
I saw the i18nlog API. It pretty much does exactly what my patch does. However, it's written for JDK 1.5 and later. 

Also, since what I provided is very light weight - just 3 convenience classes that just wrap the already existing localization functionality, I don't see why it shouldn't be included in log4j itself. Projects still on JDK 1.4 would be happy.

Thanks for the link though, I'll consider using it if my patch doesn't get included.


Manish



________________________________
From: Jacob Kjome <ho...@visi.com>
To: Log4J Developers List <lo...@logging.apache.org>
Sent: Monday, July 13, 2009 2:34:41 AM
Subject: Re: LocalizedLogger (enhancement)


Have you considered the i18n functionality already provided by i18nlog which
supports Log4j?...

http://i18nlog.sourceforge.net/
http://i18nlog.sourceforge.net/api/


Jake

On 7/2/2009 10:03 AM, manishmotwani@yahoo.com wrote:
> Curt,
> 
> Thanks for taking time out to review the code.
> 
> I forgot to mention another convenience feature:  The included
> LocalizationResourceBundle provides the ability to load localized log
> messages from multiple "logmessages_<LOCALE>.properties" files (e.g.
> logmessages_en_US.properties) from classpath. One of these files can be
> in each source directory and/or jar and all of them will be loaded
> automatically. The file name itself, of course, is also configurable via
> a system property. I'm not sure the extras utility classes provide the
> ability to load log messages from multiple files.
> 
> Besides, considering how light weight it is, it would be nice to have
> this convenience in core log4j, so we don't have to import multiple
> jars. Please feel free to rename the package from "localization" to
> "l18n" or something else.
> 
> Thanks!!
> 
> Manish
> 
> ------------------------------------------------------------------------
> *From:* Curt Arnold <ca...@apache.org>
> *To:* Log4J Developers List <lo...@logging.apache.org>
> *Sent:* Thursday, July 2, 2009 8:03:57 AM
> *Subject:* Re: LocalizedLogger (enhancement)
> 
> There was discussion a few years back that was spread across several
> mailing lists on localization of logging, see
> http://article.gmane.org/gmane.comp.jakarta.commons.devel/59103/ for a
> jumping off place.  Searching for "localization" on the mailing list has
> two many false hits on Gump messages, searching for I18N and L7D hit
> more relevant matches.
> 
> Not having looked at your code, my instinct would be to go with a
> utility class approach like LogMF and LogSF in the extras companion. 
> Where the call would end up like:
> 
> LogL7D.info<http://LogL7D.info>(logger, ....)
> 
> Will try to review your code over the weekend.  Thanks for the submission.
> 
> 
> 
> On Jul 1, 2009, at 2:02 PM, manishmotwani@yahoo.com
> <ma...@yahoo.com> wrote:
> 
>> I've written an enhancement to the localization support the generic
> Logger class provides.
>>
>> A new LocalizedLogger overrides basic log4j logging methods (trace(),
> debug(), info(), warn(), error(), fatal()) to use a localization
> mechanism. Instead of the actual log messages, keys to localization log
> messages can be passed into these logging methods. Full parameterization
> is supported. If keys are not found in the ResourceBundle, they are
> logged directly, skipping the localization.
>>
>>
>>
>> Internally, LocalizedLogger simply calls the l7dlog() method that
> already exists in Logger. LocalizedLogger is just a convenience class
> for applications that don't want to call this special method.
>>
>>
>> A LocalizationResourceBundle and a LocalizedLoggerFactory classes are
> also included. These helper classes provide easy integration with your
> application by simply changing the loggerFactory defined in the log4j
> configuration to point to this new LocalizedLoggerFactory.
>>
>> I've attached an SVN diff that can be applied to log4j trunk.
>>
>> Thanks,
>>
>> Manish
>>
>> <localization.patch>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> <ma...@logging.apache.org>
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
> <ma...@logging.apache.org>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> <ma...@logging.apache.org>
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
> <ma...@logging.apache.org>
> 
> 

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


      

Re: LocalizedLogger (enhancement)

Posted by Jacob Kjome <ho...@visi.com>.
Have you considered the i18n functionality already provided by i18nlog which
supports Log4j?...

http://i18nlog.sourceforge.net/
http://i18nlog.sourceforge.net/api/


Jake

On 7/2/2009 10:03 AM, manishmotwani@yahoo.com wrote:
> Curt,
> 
> Thanks for taking time out to review the code.
> 
> I forgot to mention another convenience feature:  The included
> LocalizationResourceBundle provides the ability to load localized log
> messages from multiple "logmessages_<LOCALE>.properties" files (e.g.
> logmessages_en_US.properties) from classpath. One of these files can be
> in each source directory and/or jar and all of them will be loaded
> automatically. The file name itself, of course, is also configurable via
> a system property. I'm not sure the extras utility classes provide the
> ability to load log messages from multiple files.
> 
> Besides, considering how light weight it is, it would be nice to have
> this convenience in core log4j, so we don't have to import multiple
> jars. Please feel free to rename the package from "localization" to
> "l18n" or something else.
> 
> Thanks!!
> 
> Manish
> 
> ------------------------------------------------------------------------
> *From:* Curt Arnold <ca...@apache.org>
> *To:* Log4J Developers List <lo...@logging.apache.org>
> *Sent:* Thursday, July 2, 2009 8:03:57 AM
> *Subject:* Re: LocalizedLogger (enhancement)
> 
> There was discussion a few years back that was spread across several
> mailing lists on localization of logging, see
> http://article.gmane.org/gmane.comp.jakarta.commons.devel/59103/ for a
> jumping off place.  Searching for "localization" on the mailing list has
> two many false hits on Gump messages, searching for I18N and L7D hit
> more relevant matches.
> 
> Not having looked at your code, my instinct would be to go with a
> utility class approach like LogMF and LogSF in the extras companion. 
> Where the call would end up like:
> 
> LogL7D.info <http://LogL7D.info>(logger, ....)
> 
> Will try to review your code over the weekend.  Thanks for the submission.
> 
> 
> 
> On Jul 1, 2009, at 2:02 PM, manishmotwani@yahoo.com
> <ma...@yahoo.com> wrote:
> 
>> I've written an enhancement to the localization support the generic
> Logger class provides.
>>
>> A new LocalizedLogger overrides basic log4j logging methods (trace(),
> debug(), info(), warn(), error(), fatal()) to use a localization
> mechanism. Instead of the actual log messages, keys to localization log
> messages can be passed into these logging methods. Full parameterization
> is supported. If keys are not found in the ResourceBundle, they are
> logged directly, skipping the localization.
>>
>>
>>
>> Internally, LocalizedLogger simply calls the l7dlog() method that
> already exists in Logger. LocalizedLogger is just a convenience class
> for applications that don't want to call this special method.
>>
>>
>> A LocalizationResourceBundle and a LocalizedLoggerFactory classes are
> also included. These helper classes provide easy integration with your
> application by simply changing the loggerFactory defined in the log4j
> configuration to point to this new LocalizedLoggerFactory.
>>
>> I've attached an SVN diff that can be applied to log4j trunk.
>>
>> Thanks,
>>
>> Manish
>>
>> <localization.patch>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> <ma...@logging.apache.org>
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
> <ma...@logging.apache.org>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> <ma...@logging.apache.org>
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
> <ma...@logging.apache.org>
> 
> 

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


Re: LocalizedLogger (enhancement)

Posted by ma...@yahoo.com.
Curt,

Thanks for taking time out to review the code. 

I forgot to mention another convenience feature:  The included LocalizationResourceBundle provides the ability to load localized log messages from multiple "logmessages_<LOCALE>.properties" files (e.g. logmessages_en_US.properties) from classpath. One of these files can be in each source directory and/or jar and all of them will be loaded automatically. The file name itself, of course, is also configurable via a system property. I'm not sure the extras utility classes provide the ability to load log messages from multiple files.

Besides, considering how light weight it is, it would be nice to have this convenience in core log4j, so we don't have to import multiple jars. Please feel free to rename the package from "localization" to "l18n" or something else.

Thanks!!

Manish




________________________________
From: Curt Arnold <ca...@apache.org>
To: Log4J Developers List <lo...@logging.apache.org>
Sent: Thursday, July 2, 2009 8:03:57 AM
Subject: Re: LocalizedLogger (enhancement)

There was discussion a few years back that was spread across several mailing lists on localization of logging, see http://article.gmane.org/gmane.comp.jakarta.commons.devel/59103/ for a jumping off place.  Searching for "localization" on the mailing list has two many false hits on Gump messages, searching for I18N and L7D hit more relevant matches.

Not having looked at your code, my instinct would be to go with a utility class approach like LogMF and LogSF in the extras companion.  Where the call would end up like:

LogL7D.info(logger, ....)

Will try to review your code over the weekend.  Thanks for the submission.



On Jul 1, 2009, at 2:02 PM, manishmotwani@yahoo.com wrote:

> I've written an enhancement to the localization support the generic Logger class provides.
> 
> A new LocalizedLogger overrides basic log4j logging methods (trace(), debug(), info(), warn(), error(), fatal()) to use a localization mechanism. Instead of the actual log messages, keys to localization log messages can be passed into these logging methods. Full parameterization is supported. If keys are not found in the ResourceBundle, they are logged directly, skipping the localization.
> 
> 
> 
> Internally, LocalizedLogger simply calls the l7dlog() method that already exists in Logger. LocalizedLogger is just a convenience class for applications that don't want to call this special method.
> 
> 
> A LocalizationResourceBundle and a LocalizedLoggerFactory classes are also included. These helper classes provide easy integration with your application by simply changing the loggerFactory defined in the log4j configuration to point to this new LocalizedLoggerFactory.
> 
> I've attached an SVN diff that can be applied to log4j trunk.
> 
> Thanks,
> 
> Manish
> 
> <localization.patch>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org


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


      

Re: LocalizedLogger (enhancement)

Posted by Curt Arnold <ca...@apache.org>.
There was discussion a few years back that was spread across several  
mailing lists on localization of logging, see http://article.gmane.org/gmane.comp.jakarta.commons.devel/59103/ 
  for a jumping off place.  Searching for "localization" on the  
mailing list has two many false hits on Gump messages, searching for  
I18N and L7D hit more relevant matches.

Not having looked at your code, my instinct would be to go with a  
utility class approach like LogMF and LogSF in the extras companion.   
Where the call would end up like:

LogL7D.info(logger, ....)

Will try to review your code over the weekend.  Thanks for the  
submission.



On Jul 1, 2009, at 2:02 PM, manishmotwani@yahoo.com wrote:

> I've written an enhancement to the localization support the generic  
> Logger class provides.
>
> A new LocalizedLogger overrides basic log4j logging methods  
> (trace(), debug(), info(), warn(), error(), fatal()) to use a  
> localization mechanism. Instead of the actual log messages, keys to  
> localization log messages can be passed into these logging methods.  
> Full parameterization is supported. If keys are not found in the  
> ResourceBundle, they are logged directly, skipping the localization.
>
>
>
> Internally, LocalizedLogger simply calls the l7dlog() method that  
> already exists in Logger. LocalizedLogger is just a convenience  
> class for applications that don't want to call this special method.
>
>
> A LocalizationResourceBundle and a LocalizedLoggerFactory classes  
> are also included. These helper classes provide easy integration  
> with your application by simply changing the loggerFactory defined  
> in the log4j configuration to point to this new  
> LocalizedLoggerFactory.
>
> I've attached an SVN diff that can be applied to log4j trunk.
>
> Thanks,
>
> Manish
>
> <localization.patch>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org


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