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 "Tomasz Kowalczewski (JIRA)" <ji...@apache.org> on 2015/06/16 09:03:00 UTC

[jira] [Created] (LOG4J2-1055) Logger method overloads for multiple message formatting params

Tomasz Kowalczewski created LOG4J2-1055:
-------------------------------------------

             Summary: Logger method overloads for multiple message formatting params
                 Key: LOG4J2-1055
                 URL: https://issues.apache.org/jira/browse/LOG4J2-1055
             Project: Log4j 2
          Issue Type: Improvement
          Components: API
    Affects Versions: 2.3
            Reporter: Tomasz Kowalczewski
            Priority: Critical


When logging message with parameters Logger interface provide methods of the form {debug/info/error}(Marker marker, String message, Object... params);

This means there will be an array of params created for each call. There should be overrides that accept one param, two params etc.

SLF4J has such overrides and require explicit array creation if someone provides too many params (there is no varargs version). If people use LOG4J2 under the covers they will be surprised that arrays are created for every call. 

What is worse, people think that call of the form

LOGGER.debug("Message: {}", foobar);

when using SLF4J does not need to be wrapped in if(LEGGER.isDebugEnabled()) check as the API is specifically designed that there should be no object allocation happening if the level is disabled. LOG4J2 breaks that promise.

This array creation is visible in our applications - it is not optimised away by escape analysis.



--
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