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

Remko Popma edited comment on LOG4J2-1074 at 7/14/15 6:33 AM:
--------------------------------------------------------------

Another idea is to let the log event itself own the NanoClock and generate 
nanoTime stamps itself (similar to what we do with the millisecond timestamp).

Advantages:

* nanoTime can be final in Log4jLogEvent, no need for an externally called 
setNanoTime() method
* existing LogEventFactory implementations all work without modification
* it is nice to have the NanoClock and the millisecond Clock use a similar 
mechanism in the same place

However, I would still like to be able to switch the NanoClock if a new 
configuration is loaded. This can be accomplished by calling 
Log4jLogEvent/AsyncLogger.setNanoClock() from the Configuration.start() method.

Drawbacks:
* tighter coupling between Configuration and Log4jLogEvent/AsyncLogger
* the static NanoClock field would have to be volatile in Log4jLogEvent and 
AsyncLogger.

Both these drawbacks may have workarounds, still thinking about this.


was (Author: [email protected]):
Another idea is to let the log event itself own the NanoClock and generate 
nanoTime stamps itself (similar to what we do with the millisecond timestamp).

Advantages:

* nanoTime can be final in Log4jLogEvent, no need for an externally called 
setNanoTime() method
* existing LogEventFactory implementations all work without modification
* it is nice to have the NanoClock and the Clock for millisecond timestamps use 
a similar mechanism in the same place

However, I would still like to be able to switch the NanoClock if a new 
configuration is loaded. This can be accomplished by calling 
Log4jLogEvent/AsyncLogger.setNanoClock() from the Configuration.start() method.

Drawbacks:
* tighter coupling between Configuration and Log4jLogEvent/AsyncLogger
* the static NanoClock field would have to be volatile in Log4jLogEvent and 
AsyncLogger.

Both these drawbacks may have workarounds, still thinking about 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
>            Assignee: Remko Popma
>
> 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 file.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to