logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-1074) Add a logformat token for nanotime
Date Sun, 05 Jul 2015 23:25:04 GMT

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

Remko Popma commented on LOG4J2-1074:

The overhead of System.nanoTime() apparently varies greatly across platforms. Aleksey Shipilёv
(the author of JMH) in his [blog about nanotime|http://shipilev.net/blog/2014/nanotrusting-nanotime/]
mentions the best we can hope for on modern hardware is around 30 nanoseconds, but there is
a scalability bottleneck if many threads call System.nanoTime() concurrently. Some people
[report|http://stackoverflow.com/a/19052481/1446916] that System.nanoTime() may take microseconds
to execute on some platforms (but no further reference so we cannot verify this).

See also Stas's blog about [platform specific differences|http://stas-blogspot.blogspot.jp/2012/02/what-is-behind-systemnanotime.html]
with System.nanoTime().

Gary raised a good point: the log event will carry an additional long, which will change the
serialized form of the LogEvent. And we need to add a method getNanoTime() to the LogEvent
Are there any concerns regarding this?

> Add a logformat token for nanotime
> ----------------------------------
>                 Key: LOG4J2-1074
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1074
>             Project: Log4j 2
>          Issue Type: New Feature
>            Reporter: Will Hains
> Add a token in the log format specifier to output the current value of {{System.nanotime()}}.
> We are currently adding the nanotime value to our log messages manually, which we find
very useful for troubleshooting unexpected latency, and as a quick-and-dirty data source to
feed into performance analysis tools.
> It would be very nice if Log4j could do this for us. It would also be nice to have this
in the log format specified, so we can turn it on/off at runtime by editing the Log4j config

This message was sent by Atlassian JIRA

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

View raw message