Currently Java 8 users do not have access to timestamps with sub-millisecond precision.
The only PreciseClock implementation is only available in the SystemClock implementation for JRE 9+.
Since that implementation does not use any JDK 9-specific feature, I propose to:
- Move the
SystemClock implementation from log4j-core-java9 to log4j-core, overriding the current one.
- Document its effects on garbage-free logging. The implementation of
init(MutableInstant):
|
public void init(final MutableInstant mutableInstant) { |
|
final Instant instant = java.time.Clock.systemUTC().instant(); |
|
mutableInstant.initFromEpochSecond(instant.getEpochSecond(), instant.getNano()); |
might create a new java.time.Instant instance for each log event, although I am pretty much convinced that the JRE will inline that instance, when the method becomes hot enough.
Currently Java 8 users do not have access to timestamps with sub-millisecond precision.
The only
PreciseClockimplementation is only available in theSystemClockimplementation for JRE 9+.Since that implementation does not use any JDK 9-specific feature, I propose to:
SystemClockimplementation fromlog4j-core-java9tolog4j-core, overriding the current one.init(MutableInstant):logging-log4j2/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java
Lines 42 to 44 in 89c9b9f
might create a new
java.time.Instantinstance for each log event, although I am pretty much convinced that the JRE will inline that instance, when the method becomes hot enough.