akka/akka-core

Slf4jLogger formatTimestamp return date/time in ISO 8601 (akkaTimestamp)

Aperta

#18.079 aperta il 26 lug 2015

 (4 commenti) (2 reazioni) (0 assegnatari)Scala (3547 fork)batch import
1 - triagedhelp wantedt:core

Metriche repository

Star
 (13.277 stelle)
Metriche merge PR
 (Merge medio 8g 19h) (10 PR mergiate in 30 g)

Descrizione

Currently %X{akkaTimestamp} returns only a time portion of the timestamp, e.g.:

00:13:35.140UTC

Absence of the date part is very inconvenient for logging, would be great to have it contain the date, especially return it in the ISO 8601 format, like:

2015-07-26T17:40:08.484Z

This is a very common format these days, especially when readability is essential (as opposite to numeric timestamps), heavily used in JSON, very easy for parsing, also this is a default output format for the java.time.OffsetDateTime toString method.

protected def formatTimestamp(timestamp: Long): String =
  OffsetDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneOffset.UTC).toString

Guida contributor