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/02/19 05:26:18 UTC
[jira] [Reopened] (LOG4J2-1280) Logger methods taking Supplier>
parameters should check if supplied value is Message
[ https://issues.apache.org/jira/browse/LOG4J2-1280?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Remko Popma reopened LOG4J2-1280:
---------------------------------
Taking a long hard look at my own work from last night I see I made a mistake.
{code}
protected void logMessage(final String fqcn, final Level level, final Marker marker,
final Supplier<?> msgSupplier, final Throwable t) {
// This is wrong:
// LamdaUtil detects if the supplied object is a Message,
// and prevents that Message from being wrapped in another message
// (this is good).
// However, we want to log the _supplied_ Message here, instead of
// creating a new message for the formattedString of the supplied Message.
final Object message = LambdaUtil.get(msgSupplier);
logMessage(fqcn, level, marker, messageFactory.newMessage(message), t);
}
{code}
> Logger methods taking Supplier<?> parameters should check if supplied value is Message
> --------------------------------------------------------------------------------------
>
> Key: LOG4J2-1280
> URL: https://issues.apache.org/jira/browse/LOG4J2-1280
> Project: Log4j 2
> Issue Type: Bug
> Components: API
> Affects Versions: 2.5
> Reporter: Remko Popma
> Assignee: Remko Popma
> Fix For: 2.6
>
>
> Methods on the Logger interface that take a Supplier<?> argument currently do not correctly handle the case where the supplied value is of type Message.
> Currently, either the Message value will be wrapped in an ObjectMessage, or it will be used as one of the parameter values in a parameterized text message. In both cases, the result of Message.toString() will eventually be logged, rather than Message.getFormattedString().
--
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