Skip to content

Commit 9faca2b

Browse files
committed
Document garbage-free behavior of SystemClock
1 parent f51d079 commit 9faca2b

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/site/antora/modules/ROOT/pages/manual/garbagefree.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ include::partial$manual/systemproperties/properties-garbage-collection.adoc[leve
7171
7272
include::partial$manual/systemproperties/properties-thread-context-core.adoc[leveloffset=+2,tag=gcfree]
7373
74+
include::partial$manual/systemproperties/properties-log4j-core-misc.adoc[leveloffset=+2,tag=clock]
75+
7476
[#Layouts]
7577
=== Layouts
7678

src/site/antora/modules/ROOT/partials/manual/systemproperties/properties-log4j-core-misc.adoc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
////
17+
// tag::clock[]
1718
[id=log4j2.clock]
1819
== `log4j2.clock`
1920
@@ -24,26 +25,36 @@
2425
| Default value | ``SystemClock``
2526
|===
2627
27-
Specifies the
28+
It specifies the
2829
link:../javadoc/log4j-core/org/apache/logging/log4j/core/util/Clock.html[`Clock`]
2930
implementation used to timestamp log events.
3031
3132
This must be the fully qualified class name of the implementation or one of these predefined constants:
3233
33-
SystemClock:: uses the best available system clock as time source.
34+
SystemClock:: It uses the best available system time source.
3435
See https://docs.oracle.com/javase/{java-target-version}/docs/api/java/time/Clock.html#systemDefaultZone--[`Clock#systemDefaultZone()`] for details.
36+
+
37+
[NOTE]
38+
====
39+
Depending on the version of the JRE, this implementation might not be garbage-free or might only become garbage-free when the code is hot enough.
40+
41+
If you don't require a nanosecond precision, and you need a garbage-free implementation, use <<log4j2.clock.SystemMillisClock,`SystemMillisClock`>>.
42+
====
3543
36-
SystemMillisClock:: same as `SystemClock`, but truncates the result to a millisecond.
44+
[id=log4j2.clock.SystemMillisClock]
45+
SystemMillisClock:: It is similar to `SystemClock`, but truncates the result to a millisecond.
46+
This implementation is garbage-free.
3747
38-
CachedClock:: uses a separate thread to update the timestamp value.
48+
CachedClock:: It uses a separate thread to update the timestamp value.
3949
See
4050
link:../javadoc/log4j-core/org/apache/logging/log4j/core/util/CachedClock.html[`CachedClock`]
4151
for details.
4252
43-
CoarseCachedClock:: alternative implementation of `CachedClock` with a slightly lower precision.
53+
CoarseCachedClock:: This is an alternative implementation of `CachedClock` with a slightly lower precision.
4454
See
4555
link:../javadoc/log4j-core/org/apache/logging/log4j/core/util/CoarseCachedClock.html[`CoarseCachedClock`]
4656
for details.
57+
// end::clock[]
4758
4859
[id=log4j2.contextData]
4960
== `log4j2.contextData`

0 commit comments

Comments
 (0)