(Including log4j-dev list)

For a Layout to be garbage-free it needs to override encode(LogEvent,
ByteBufferDestination).

Generally, Layouts that extend AbstractStringLayout have two jobs: building
a text representation of the LogEvent, and turning that text into bytes.

The latter part can be done garbage-free by using StringBuilderEncoder.

To build a CSV text representation of the LogEvent without generating
garbage, you need to cache  a ThreadLocal StringBuilder and append the
parameters while preserving the quoting rules the user specified in
configuration. This may mean reimplementing some of the Commons CSV logic
since I don't think that library is garbage-free.

There's one issue that the current code in master does not correctly
preserve parameters with async logging:
https://issues.apache.org/jira/browse/LOG4J2-1342.
I'm working on that one and hope to commit a fix in the next few days.

Remko

On Wednesday, 20 April 2016, Gary Gregory <[email protected]> wrote:

> Hi,
>
> The guts of the CSV layout is really about appending to an Appendable.
>
> With the new code in master, can this layout be made to write directly to
> whatever is the endpoint/stream thingy?
>
> Gary
>
> --
> E-Mail: [email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');> | [email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>

Reply via email to