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 2013/02/04 08:44:12 UTC

[jira] [Comment Edited] (LOG4J2-153) Async Logger/Appender performance improvement: provide mechanism to discover if location StackTraceElement is actually required downstream.

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

Remko Popma edited comment on LOG4J2-153 at 2/4/13 7:42 AM:
------------------------------------------------------------

Understood. In my domain (trading applications, including low-latency trading apps), logging latency is the most important consideration, so I am biased. In practice we can always tell from the Logger name and the log message where in our code the message was generated, so we don't use location in our layout pattern.

I am okay with any approach that has some way to avoid incurring the location cost. My preference would be to make this the default, but I understand that opinions can differ on this. :-)
                
      was (Author: remkop@yahoo.com):
    Understood. In my domain (trading applications, including low-latency trading apps), logging latency is the most important requirement, so I am biased. In practice we can always tell from the Logger name and the log message where in our code the message was generated, so we don't use location in our layout pattern.

I am okay with any approach that has some way to avoid incurring the location cost. My preference would be to make this the default, but I understand that opinions can differ on this. :-)
                  
> Async Logger/Appender performance improvement: provide mechanism to discover if location StackTraceElement is actually required downstream.
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-153
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-153
>             Project: Log4j 2
>          Issue Type: Improvement
>            Reporter: Remko Popma
>
> (update 2013 Feb 4: changed summary.
> Previous title: Add a method to the Layout interface to allow Loggers to discover if any of their Appenders need the location StackTraceElement.)
> ----
> Use Case: any asynchronous Logger or Appender has this problem:
> should it take a snapshot of the call stack (as implemented in Log4jLogEvent.getSource) or not?
> This is an expensive method (1600+ nanoseconds on a machine with 2.9GHz cores) so you only want to call it if you need it. Currently there is no way to discover if the location information is used by any of the configured layouts.
> If the Layout interface has a method that indicates whether the layout calls the LogEvent.getSource method, then the Logger can query its LoggerConfig if any of the configured Appenders has a Layout which needs location info. (Maybe boolean needsLocationInfo() would be a good name?)
> With this information, a Logger can construct Log4jLogEvents with a non-null dummy StackTraceElement location if none of the layouts downstream need location info. The non-null dummy location would prevent LogEvent.getSource from taking a call stack snapshot.
> The current AsynchAppender class would get an immediate performance boost from this, and custom asynchronous Loggers or Appenders would reap the same benefits.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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