logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gulcu <...@urbanet.ch>
Subject RE: l7dlog enhancement
Date Thu, 08 Mar 2001 16:12:09 GMT


The change has not been applied nor is it likely to be. One alternative to re-applying the
patch for all future log4j version is to sub-class the Category class and introducing a new
method that returns the results of the message localization. 

There have been several complaints about the way log4j does localization. I am not satisfied
with it either. There is a good chance that future versions will let appenders/layouts see
the message localization key and parameters within the LoggingEvent instance. It will be up
to the appender or layout to select which resource bundle to apply on a message key. Thus,
you should be able to control/view the localized message if you need to. Would that help at
all? Regards, Ceki

ps: I am CCing the log4j-user list to see if other users would like to have the functionality
that you mentioned. If enough users ask for it, then we will reconsider.

At 09:08 08.03.2001 -0500, Marius S. Lazer wrote:
>I applied the change, but I didn't see it in 1.0.4 (I had to re-apply it) or in the upcoming
1.1. Will it be officially applied or do I have to apply it on all releases myself?
>Marius S. Lazer
>Lucent Technologies
>-----Original Message-----
>From: Ceki Gulcu [mailto:cgu@urbanet.ch]
>Sent: Friday, December 01, 2000 9:59 AM
>To: msl@wind.lc.lucent.com
>Cc: cgu@urbanet.ch
>Subject: Re: l7dlog enhancement
>Hi Marius,
>It is certainly possible for l7dlog to return the result of MessageFormat . As in:
>  public
>  String l7dlog(Priority priority, String key, Throwable t) {
>    if(disable <= priority.value) {
>      return null; // we can't return a value we don't compute
>    }
>    if(priority.isAsSevereAs(this.getChainedPriority())) {
>      String msg = getResourceBundleString(key);
>      // if message corresponding to 'key' could not be found in the
>      // resource bundle, then default to 'key'.
>      if(msg == null) {
>        msg = key;
>      }
>      callAppenders(new LoggingEvent(instanceFQN, this, priority, msg, t));
>    }
>    return msg; // 
>  }
> public
> String l7dlog(Priority priority, String key,  Object[] params, Throwable t) {
>    if(disable <= priority.value) {
>      return;
>    }    
>    if(priority.isAsSevereAs(this.getChainedPriority())) {
>      String pattern = getResourceBundleString(key);
>      String msg;
>      if(pattern == null) 
>        msg = key;
>      else 
>        msg = java.text.MessageFormat.format(pattern, params);
>      callAppenders(new LoggingEvent(instanceFQN, this, priority, msg, t));
>    }
>    return msg;
>  }
>Would the above changes meet your needs? 
>The other method such as debug, warn etc. cannot return the value of what they log because
a message can be logged using multiple appenders and layouts.
>What do you mean by additional public methods? What do you have in mind?
>May I ask you why you need to know the value of what is being logged? Cheers, Ceki
>At 09:42 01.12.2000 -0500, Marius S. Lazer wrote:
>>Overall, we're very satisfied with the package with the exception of one thing: there
is no way to get the expanded message that l7dlog() formats unless we do again the equivalent
of the protected getResourceBundleString() and then call MessageFormat again. The proposed
enhancement is either one of the following:  
>>    * have l7dlog() return the String it logs (it might be a good idea for all logging
methods except debug() to return what they log)  
>>    * additional public methods to expand the message l7dlog() logs 
>>In the mean time I'll make the change myself, but it would be nice to have this in
the standard distribution.
>>Marius S. Lazer - Lucent Technologies

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

View raw message