At 17:28 06.03.2001 -0600, Johnson, Clay wrote:
>> > A colleague thinks the answer may involve ObjectRenderer.  
>> There's little
>> > said about it in the javadoc.  Is it, or can it be used as 
>> a plugin to alter
>> > the behavior of a predefined appender?  If so, could I use 
>> it perform l10n
>> > in the appender(s)?
>> 
>> Yes you probably could. Your ObjectRenderer would know about your
>> special type of Objects and would convert to String in locale specific
>> manner.
>> 
>
>I took a look at the Category source, and it would appear ObjectRenderer is
>called there (and not by the appenders) to create the LoggingEvent:
>
>  protected
>  void forcedLog(String fqn, Priority priority, Object message, Throwable t)
>{
>    String s;
>    if(message instanceof String) {
>      s = (String) message;
>    } else {
>      s = myContext.rendererMap.findAndRender(message);
>    }
>    callAppenders(new LoggingEvent(fqn, this, priority, s, t));
>  }
>
>So, unless the appearance here is very misleading, ObjectRenderer is just a
>log4j alternative to toString(), presumably so that the latter is preserved
>for other use by the application.  


Clay,

ObjectRenderer is similar to the toString method in that it converts an object to a 
string. There are significant differences.

1) ObjectRenderer can be applied to an object completely unaware of log4j. For 
example, the org.apache.log4j.or.ThreadGroupRenderer renders java.lang.ThreadGroups 
whose toString method is not very useful.


2) ObjectRenderer can be applied to interfaces. If object X implements interface Y, 
then a YRenderer will render X objects as well.

Point 1 is crucial. Point 2 is secondary. I am not convinced that the ObjectRenderer 
would yield the best solution to your problem. So I will answer to your original 
question in a separate mail. Ceki





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to