Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.8, 2.8.1
-
None
-
None
Description
The issue (LOG4J2-1715) sought to make the NdcPatternConverter GC-free, but it looks as though that work doesn't get used. The interface StringBuilderFormattable is never checked for when formatting in the convertor, and as a result the builder is left to fend for itself, resorting ultimately to String.valueOf.
I believe the code should end up looking something like this.
NdcPatternConverter.java
public void format(final LogEvent event, final StringBuilder toAppendTo) { ThreadContext.ContextStack stack = event.getContextStack(); if (stack instanceof StringBuilderFormattable) { ((StringBuilderFormattable) stack).formatTo(toAppendTo); } else { toAppendTo.append(stack); } }
Happy to submit a patch if this makes sense or for someone else to. Still getting my head around Log4j internals so confirmation of this would be helpful.