You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2016/03/23 10:22:25 UTC

[jira] [Comment Edited] (LOG4J2-1326) Provide support for CharSequence parameters for low and zero-GC applications

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

Remko Popma edited comment on LOG4J2-1326 at 3/23/16 9:21 AM:
--------------------------------------------------------------

Vlad, thanks for raising this request.

To clarify, you are proposing to modify the current Logger API methods that take a String parameter to instead take a CharSequence, correct?

Before:
{code}
//org.apache.logging.log4j.Logger
debug(Marker marker, String message)
debug(Marker marker, String message, Object... params)
debug(Marker marker, String message, Supplier<?>... paramSuppliers)
debug(Marker marker, String message, Throwable t)
debug(String message)
debug(String message, Object... params)
debug(String message, Supplier<?>... paramSuppliers)
debug(String message, Throwable t)
{code}

After:
{code}
//org.apache.logging.log4j.Logger
debug(Marker marker, CharSequence message)
debug(Marker marker, CharSequence message, Object... params)
debug(Marker marker, CharSequence message, Supplier<?>... paramSuppliers)
debug(Marker marker, CharSequence message, Throwable t)
debug(CharSequence message)
debug(CharSequence message, Object... params)
debug(CharSequence message, Supplier<?>... paramSuppliers)
debug(CharSequence message, Throwable t)
{code}

Actually, I just realized that _replacing_ these methods will result in NoSuchMethodErrors in user code that was compiled against the current log4j API.

If the message String is the concern then for backwards compatibility these methods would have to be added instead of replacing the existing methods.


was (Author: remkop@yahoo.com):
Vlad, thanks for raising this request.

To clarify, you are proposing to modify the current Logger API methods that take a String parameter to instead take a CharSequence, correct?

Before:
{code}
//org.apache.logging.log4j.Logger
debug(Marker marker, String message)
debug(Marker marker, String message, Object... params)
debug(Marker marker, String message, Supplier<?>... paramSuppliers)
debug(Marker marker, String message, Throwable t)
debug(String message)
debug(String message, Object... params)
debug(String message, Supplier<?>... paramSuppliers)
debug(String message, Throwable t)
{code}

After:
{code}
//org.apache.logging.log4j.Logger
debug(Marker marker, CharSequence message)
debug(Marker marker, CharSequence message, Object... params)
debug(Marker marker, CharSequence message, Supplier<?>... paramSuppliers)
debug(Marker marker, CharSequence message, Throwable t)
debug(CharSequence message)
debug(CharSequence message, Object... params)
debug(CharSequence message, Supplier<?>... paramSuppliers)
debug(CharSequence message, Throwable t)
{code}


> Provide support for CharSequence parameters for low and zero-GC applications
> ----------------------------------------------------------------------------
>
>                 Key: LOG4J2-1326
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1326
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: API
>    Affects Versions: 2.5
>            Reporter: Vlad Shurupov
>              Labels: features, performance
>
> Currently, the preferred way of logging character sequences in log4j 2 is by passing in tokens of type {{java.lang.String}}. It would be very beneficial if the API could provide methods that take {{java.lang.CharSequence}} tokens. This would allow high performance zero or low-GC applications to re-use the existing mutable structures implementing {{java.lang.CharSequence}}  for continuous logging without new objects being created.
> A high-performance implementation of the logger would be expected to copy out the contents of a single or multiple instances of {{java.lang.CharSequence}} so that they could be re-used in the subsequent logging call.



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

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