----- Original Message -----
From: "Ceki Gülcü" <[EMAIL PROTECTED]>
To: "Log4J Users List" <[EMAIL PROTECTED]>
Sent: Wednesday, January 09, 2002 3:12 PM
Subject: Re:
org.apache.log4j.helpers.AppenderAttachableImpl.addAppender(Appender
newAppender)


>
> T Master,
>
> Interesting point. I think what you are asking is whether appenders
> having the same name should be treated as equal and treated as such. In
> particular, whether when adding an appender, the new appender replaces a
> previously added appender with the same name.


Correct.
I suggest if an appender with newAppender.getName() exists, then the method
should return immediately.
Why?  If newAppender is of the same class, there is no point in replacing
because if the attributes of that
appender had changed after adding to the Category, the Vector would still
hold the same instance.
However, if it is a different Appender sub-class, that would cause
corruption IMHO.



> I think that would be a clean coherent policy, easy to implement using a
> Hasttable. What do you think? Did I correctly rephrase your question?

A Hashtable would be suitable yet.  Just don't replace if the name
pre-exists!
Use the Appenders name as the key.  The value can be the Appender.

>
> Regards, Ceki
>
> ps: Is T Master your real name?

Yes.  I prefer not to use my first name, otherwise a search on my full-name
would return every email to all mailing lists!

Thanks for hearing me out.


T Master.


>
> At 14:57 09.01.2002 -0700, T Master wrote:
> >Ceki,
> >
> >I've been looking at the code for adding an Appender.
> >
> >1.  In Log4J config files (i use properties), appenders must have a
_unique_
> >name as I understand it.
> >
> >2.  In Log4J system, appenders are _not_ required to have a name for
> >instantiation - the name is null by default.
> >
> >3.  I've noticed in
> >org.apache.log4j.helpers.AppenderAttachableImpl.addAppender(Appender
> >newAppender) the code:
> >   //@since version 0.9.1
> >    if(!appenderList.contains(newAppender))
> >      appenderList.addElement(newAppender);
> >
> >   This will check if the Vector appenderList has the same Appender by
> >equality ( the equals() is used).
> >   However, neither AppenderSkeleton, or WriterAppender or FileAppender
or
> >RollingFileAppender
> >(the object i was using) implements the equals() method.
> >
> >  In my opinion, each and every non-abstract Appender should implement
> >public boolean equals().
> >  The following should be tested for equality:
> >     - object reference, null, then the appender's name.
> >
> >
> >   I could be talking absolute rubbish, but I noticed one of my Category
> >objects had two RollingFileAppenders with the same name in it,
> > produced from the following code:
> >    CODE:
> >          Enumeration enum = category.getAllAppenders();
> >          while (enum.hasMoreElements())
> >          {
> >               Appender appender = (Appender) enum.nextElement();
> >               System.out.println("category has -" + appender.getName()
> >+".");
> >           }
> >    OUTPUT:
> >        category has -FILE_DEST.
> >        category has -FILE_DEST.
> >
> >Forgive me for babbling, or being mistaken.
> >
> >
> >T Master
> >
> >
> >
> >--
> >To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
> --
> Ceki Gülcü - http://qos.ch



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

Reply via email to