Hello list, I need to get more granular timestamps in my logs.
The question is what is the best way get Log4j to handle sub-millisecond timestamps? A top search result provides this deceptively-simple approach: http://blog.caplin.com/2017/10/13/microsecond-time-stamp-logging-for-mifid-ii/ However, that will provide wrong results, since they're generating the timestamp inside the Converter, which would run in the AsyncLogger thread and in effect log when the event was processed rather than when it actually occurred. The hack I came up with is to implement a custom Clock whose currentTimeMillis() returns nanoseconds since the epoch, and a corresponding Converter plugin that handles nanoseconds in the millisecond field (Hopefully it won't still be around by year 2262 :) It works pretty well for what I'm doing so long as both the custom clock and a correct layout are used, but I imagine it could cause unexpected consequences if some time-related functionality is used (e.g. file rolling). Any suggestions for a cleaner but low-overhead approach? Cheers, Al. --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org