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 2014/07/29 19:14:40 UTC
[jira] [Created] (LOG4J2-754) Log4jLogEvent constructor
unnecessarily clones ThreadContext stack
Remko Popma created LOG4J2-754:
----------------------------------
Summary: Log4jLogEvent constructor unnecessarily clones ThreadContext stack
Key: LOG4J2-754
URL: https://issues.apache.org/jira/browse/LOG4J2-754
Project: Log4j 2
Issue Type: Improvement
Components: Core
Affects Versions: 2.0
Reporter: Remko Popma
One of the Log4jLogEvent constructors currently looks like this:
{code}
public Log4jLogEvent(final String loggerName, final Marker marker, final String loggerFQCN, final Level level,
final Message message, final List<Property> properties, final Throwable t) {
this(loggerName, marker, loggerFQCN, level, message, t,
createMap(properties),
ThreadContext.getDepth() == 0 ? null : ThreadContext.cloneStack(), null,
null,
// LOG4J2-628 use log4j.Clock for timestamps
// LOG4J2-744 unless TimestampMessage already has one
message instanceof TimestampMessage ? ((TimestampMessage) message).getTimestamp() :
clock.currentTimeMillis());
}
{code}
This can be improved to call ThreadContext.getImmutableStack() to avoid making unnecessary copies of the stack, as was the intention of LOG4J2-154.
{code}
public Log4jLogEvent(final String loggerName, final Marker marker, final String loggerFQCN, final Level level,
final Message message, final List<Property> properties, final Throwable t) {
this(loggerName, marker, loggerFQCN, level, message, t,
createMap(properties),
ThreadContext.getImmutableStack(), null, null,
// LOG4J2-628 use log4j.Clock for timestamps
// LOG4J2-744 unless TimestampMessage already has one
message instanceof TimestampMessage ? ((TimestampMessage) message).getTimestamp() :
clock.currentTimeMillis());
}
{code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org