logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikael Ståldal (JIRA) <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-1365) Add CharSequenceFormattable interface for Messages to improve performance of Layouts
Date Thu, 14 Apr 2016 09:02:25 GMT

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

Mikael Ståldal commented on LOG4J2-1365:

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

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

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

View raw message