Skip to content

Add PreciseClock implementation for JRE 8 systems #3198

@ppkarwasz

Description

@ppkarwasz

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions