You are right I need to give more detail. If the first argument is a String then it is presumed to be a format specification. In that case the second argument, if it is a StringBuilderFormattable, has its formatTo() method called. [All good]
If the first argument is a Message then the formatTo() is not called. class Foo implements StringBuilderFormattable { @Override public void formatTo(StringBuilder buffer) { buffer.append("bar"); } } ... final Message em = log.traceEntry(); ... log.traceExit("{}", new Foo()); // logs the formatTo method [all good] log.traceExit(em, new Foo()); // logs the toString method *[not what I expected]* On Wed, Jun 17, 2020 at 4:05 AM Volkan Yazıcı <volkan.yaz...@gmail.com> wrote: > Hello Fred, > > If the Message you pass to traceExit(Message,R) implements > StringBuilderFormattable, indeed formatTo(StringBuilder) will be used > by the layout for serialization. What do you mean by "this does not > seem to be the case"? Would you mind elaborating a bit more on what > you're exactly trying to do? Further, a reproduction path will be > greatly appreciated. > > Kind regards. > > On Tue, Jun 16, 2020 at 4:16 PM Fred Eisele <fredrick.eis...@gmail.com> > wrote: > > > > When traceExit(m,r) is used... > > Is there a mechanism for controlling the formatting of the result? > > Other than overriding the 'toString()' method. > > When formatted messages are used and the object's class implements > > the StringBuilderFormattable interface the 'formatTo()' method > > is used preferentially over 'toString()'. > > This does not seem to be the case for serializing the result by > traceExit. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > > For additional commands, e-mail: log4j-user-h...@logging.apache.org > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > >