> Internally, I'm sure the info() method is calling Object.toString(),
> which does create a new String object.
you are right Layout.format will turn it into a String. smart appenders do this
using StringBuffer/Builder.
format could format to a StringBuffer/Builder but this does not realy matter,
writing the formated string to a file/socket/whatever appender will cost a lot
more than creating this string.
however as curt was pointing out it does not make a lot of sense to build the
message object (be it a string or a String Buffer) if the thing is not loged in
the end because loglevel is to low. have a look at the formatter project in the
log4j sandbox...
> > so use StringBuffers (or if using java1.5 StringBuilder) if
> you like to. however IMHO your code is generating unnecessary
> String objects as well.
> >
> >> // to log a new message
> >> buf.clear();
> >> buf.append("some string here");
> >
> > this creates a String object on every call as well...
> > it's the same as:
> > buf.append(new String("some string here"));
> >
>
> No, I don't think so. "some string here" is a constant. It gets
> interned. No new object gets created on each call. The String gets
> created once when the class loads.
how much would you bet :-]]]]]
cheers
patrick
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]