[logback-dev] [JIRA] Issue Comment Edited: (LBCLASSIC-88) Use System.nanoTime() instead of System.currentTimeMillis() for LogEvent timestamp

Joern Huxhorn (JIRA) noreply-jira at qos.ch
Thu Nov 20 10:06:35 CET 2008


    [ http://jira.qos.ch/browse/LBCLASSIC-88?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=10919#action_10919 ] 

Joern Huxhorn edited comment on LBCLASSIC-88 at 11/20/08 10:06 AM:
-------------------------------------------------------------------

Wouldn't it be possible to retrieve System.currentTimeMillis and System.nanoTime() once upon initialization of the logging context and then use those values to calculate precise (non-relative) currentTimeMillis from subsequent nanoTime() calls and the initial values?
Seems a reasonable thing to do and be a smaller change since it could work with existing LoggingEvents. Or are we aiming for sub-milli precision concerning logging events?

      was (Author: jhuxhorn):
    Wouldn't it be possible to retrieve System.currentTimeMillis and System.nanoTime() once upon application start and then use those values to calculate precise (non-relative) currentTimeMillis from subsequent nanoTime() calls and the initial values?
Seems a reasonable thing to do and be a smaller change since it could work with existing LoggingEvents. Or are we aiming for sub-milli precision concerning logging events?
  
> Use System.nanoTime() instead of System.currentTimeMillis() for LogEvent timestamp
> ----------------------------------------------------------------------------------
>
>                 Key: LBCLASSIC-88
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-88
>             Project: logback-classic
>          Issue Type: Improvement
>    Affects Versions: 0.9.12
>            Reporter: Thorbjoern Ravn Andersen
>            Assignee: Logback dev list
>            Priority: Minor
>
> Apparently the System.nanoTime() is better suited than System.currentTimeMillis() for the relative time measurements done in logback, plus hopefully the resolution is finer giving more reliable figures for small operations.   Apparently the currentTimeMillis resolution is 15 ms under XP where the nanoTimer is much finer.  Under OS X both have a resolution of 1 ms.
> As logback requires Java 5 where this is standard, it would be simple to make the switch.
> Note:  http://www.techper.net/2008/08/10/systemcurrenttimemillis-systemnanotime-and-their-resolution/ lists that it may be relevant to create a factory for this instead of just hardlinking to the java runtime so it is possible to link to another time source:
> "A more robust timer with a 1msec resolution is LWJGL's Sys.getTime which uses TGT (time get time) on Windows and currentTimeMillis elsewhere."

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the logback-dev mailing list