[
https://issues.apache.org/jira/browse/LOG4J2-1365?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15240833#comment-15240833
]
Mikael Ståldal edited comment on LOG4J2-1365 at 4/14/16 9:03 AM:
-----------------------------------------------------------------
I would say that Messages should implement this if they can do so easily and
with significantly better performance (less copying and/or less allocations)
than {{getFormattedMessage()}}. I realize that I overdid it a bit, see updated
branch now.
As you can see in my branch, it is a big improvement for SimpleMessage,
ReusableSimpleMessage and RingBufferLogEvent. Maybe questionable for
ParameterizedMessage and ReusableParameterizedMessage.
I did not add any mutable buffer in any Message, I only reuse the one already
in place for supporting {{getFormattedMessage()}} in ParameterizedMessage and
ReusableParameterizedMessage. (But maybe we should remove this from them.)
Layouts should choose {{formatTo(StringBuilder)}} if they can do so efficiently
(like PatternLayout), otherwise prefer {{getFormattedCharSequence()}} when
available (like GelfLayout does in this branch).
I believe that this does not only benefit GelfLayout, but can also benefit
XmlLayout, JsonLayout, HtmlLayout, SyslogLayout, RFC5424Layout and CsvLayout
(i.e. all layouts except PatternLayout and SerializedLayout).
was (Author: mikaelstaldal):
I would say that Messages should implement this if they can do so easily and
with better performance (less copying and/or less allocations) than
{{getFormattedMessage()}}. I realize that I overdid it a bit, see updated
branch now.
As you can see in my branch, it is a big improvement for SimpleMessage,
ReusableSimpleMessage and RingBufferLogEvent. Maybe questionable for
ParameterizedMessage and ReusableParameterizedMessage.
I did not add any mutable buffer in any Message, I only reuse the one already
in place for supporting {{getFormattedMessage()}} in ParameterizedMessage and
ReusableParameterizedMessage. (But maybe we should remove this from them.)
Layouts should choose {{formatTo(StringBuilder)}} if they can do so efficiently
(like PatternLayout), otherwise prefer {{getFormattedCharSequence()}} when
available (like GelfLayout does in this branch).
I believe that this does not only benefit GelfLayout, but can also benefit
XmlLayout, JsonLayout, HtmlLayout, SyslogLayout, RFC5424Layout and CsvLayout
(i.e. all layouts except PatternLayout and SerializedLayout).
> Add CharSequenceFormattable interface for Messages to improve performance of
> Layouts
> ------------------------------------------------------------------------------------
>
> Key: LOG4J2-1365
> URL: https://issues.apache.org/jira/browse/LOG4J2-1365
> Project: Log4j 2
> Issue Type: Improvement
> Components: Layouts
> Affects Versions: 2.5
> Reporter: Mikael Ståldal
> Assignee: Mikael Ståldal
> Priority: Minor
>
> {code}
> public interface CharSequenceFormattable {
> CharSequence getFormattedCharSequence();
> }
> {code}
> This can be implemented by Messages where it makes sense and used by Layouts
> where it makes sense.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]