[ 
https://issues.apache.org/jira/browse/LOG4J2-1397?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15321285#comment-15321285
 ] 

Anthony Maire commented on LOG4J2-1397:
---------------------------------------

Basically, a layout that have a dependency on a mutable object will not be 
compatible with asynchronous logger/appender. A copy of the content has to be 
made. And to avoid excessive allocation, the copy should be reusable.

If we want to safely use the buffer content without excessive allocation, we 
already have some solutions that use String (such as wrapping it in a 
StringBuilderFormattable that decode the buffer content into a StringBuilder). 
But this is slow (it takes a few extra microseconds for a message of a few 
hundreds bytes compared to bulk byte copy)

If we want to use a ByteBufferLayout, that means that these few microseconds 
matters, so it's nearly 100% sure that asynchronous logging will be used. 
Without some byte copy support provided by the async logger, I'm afraid that 
this layout can't be really useful.

> Support ByteBufferLayout
> ------------------------
>
>                 Key: LOG4J2-1397
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1397
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: Layouts
>    Affects Versions: 2.6
>            Reporter: Remko Popma
>
> As requested by Kirk Pepperdine on the Mechanical Sympathy [mailing 
> list|https://groups.google.com/d/msg/mechanical-sympathy/klefjRqlpQE/-1WF59IGAwAJ]:
> Support a new Layout that takes ObjectMessages containing a ByteBuffer 
> payload and write them to the appender without modification.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org

Reply via email to