akka/akka-core

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

Open

#18,079 创建于 2015年7月26日

在 GitHub 查看
 (4 评论) (2 反应) (0 负责人)Scala (13,277 star) (3,547 fork)batch import
1 - triagedhelp wantedt:core

描述

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

贡献者指南