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

Remko Popma commented on LOG4J2-1296:
-------------------------------------

Fixed in master in commit 15d95ec.

* Added class ReusableParameterizedMessageFactory
* AbstractLogger uses this new factory if Constants.ENABLE_THREADLOCALS is true 
(needed to copy some log4j-core logic to log4j-api here...)
* Added interface ReusableMessage
* ParameterizedMessage now implements ReusableMessage so downstream components 
can determine if the Message instance can safely be passed on to another thread 
or not
* AsyncLogger will not call getFormattedMessage on a reused ReusableMessage any 
more
* RingBufferLogEvent will copy the content of a reused ReusableMessage instead 
of holding a reference to that Message
* RingBufferLogEvent.FACTORY will pre-allocate a 128-char StringBuilder on each 
slot in the ring buffer if Constants.ENABLE_THREADLOCALS is true
* DisruptorUtil will use a smaller ring buffer size (8*1024 instead of 
256*1024) if Constants.ENABLE_THREADLOCALS is true
* MessagePatternConverter now avoids calling toString on the Message if it 
implements StringBuilderFormattable

I'm keeping this ticket open for now because I want to add more unit tests.

> Add MessageFactory that reuses a cached Message instance
> --------------------------------------------------------
>
>                 Key: LOG4J2-1296
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1296
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: API
>    Affects Versions: 2.5
>            Reporter: Remko Popma
>            Assignee: Remko Popma
>
> As discussed in LOG4J2-1270, all current MessageFactory implementations 
> create new temporary Message objects. A GC-free configuration needs a 
> different MessageFactory that reuses Message instances.
> When Messages are being reused, async logging components need to be aware of 
> this and ensure the Message _content_  (rather than the Message instance 
> itself) is passed to the background thread. However, Messages that are not 
> reusable should be passed to the background thread unchanged.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to