在log4j日志中包括微秒级的时间戳?[英] Include microsecond timestamps in log4j logging?

本文是小编为大家收集整理的关于在log4j日志中包括微秒级的时间戳?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

是否可以在Log4J日志记录中具有微秒级的时间戳?这是在Linux运行Java 1.6上.

我们彼此相邻有几个服务器(通过LAN同步到同一NTP服务器),我想在日志行中有微秒.

如果log4j不提供此信息,是否可以登录?

推荐答案

log4j不包括微秒精度时间戳. logback当前不包括微秒精度时间戳,但未来版本的记录可能会.

其他推荐答案

从 Java 9 和 log4j 2.11.0 开始,即使使用 nanoseconds,也可以获得时间戳.

有关更多详细信息,请检查以下答案:

本文地址:https://www.itbaoku.cn/post/1575005.html

问题描述

Is it possible to have microsecond level timestamps in log4j logging? This is on linux running Java 1.6.

We have a couple servers right next to each other (synced via LAN to the same NTP server), and I'd like to have microseconds in the log lines.

If log4j doesn't offer this, does logback?

推荐答案

Log4j does not include microsecond precision timestamps. Logback does not currently include microsecond precision timestamps but future versions of logback probably will.

其他推荐答案

Starting from Java 9 and log4j 2.11.0, it is possible to get the timestamp even with nanoseconds.

For more details, check this answer:
https://stackoverflow.com/a/49429972/1824361