Skip to content

Commit 52ca6a3

Browse files
Fix UuidPatternConverter docs (#3768)
1 parent d6fe40d commit 52ca6a3

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/UuidPatternConverter.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.apache.logging.log4j.core.util.UuidUtil;
2323

2424
/**
25-
* Formats the event sequence number.
25+
* Formats a UUID.
2626
*/
2727
@Plugin(name = "UuidPatternConverter", category = PatternConverter.CATEGORY)
2828
@ConverterKeys({"u", "uuid"})
@@ -39,10 +39,19 @@ private UuidPatternConverter(final boolean isRandom) {
3939
}
4040

4141
/**
42-
* Obtains an instance of SequencePatternConverter.
42+
* Creates an instance of {@link UuidPatternConverter}.
43+
* <p>
44+
* The {@code RANDOM} option generates a Type 4 (pseudo-randomly generated) UUID.
45+
* The UUID is generated using a cryptographically strong pseudo-random number generator.
46+
* <p>
47+
* The {@code TIME} option generates a Type 1 (date and time based) UUID using the local network interface's MAC address.
48+
* To ensure uniqueness across multiple JVMs and/or class loaders on the same host, a random number between 0 and 16384 will be associated with each instance of the UUID generator class, and included in each time-based UUID generated.
49+
* See {@link UuidUtil#UUID_SEQUENCE} how to seed the UUID generation with an integer value.
50+
* Because time-based UUIDs contain the MAC address and timestamp, they should be used with care.
4351
*
44-
* @param options options, currently ignored, may be null.
45-
* @return instance of SequencePatternConverter.
52+
* @param options An array containing either {@code RANDOM} or {@code TIME}.
53+
* If empty, {@code TIME} will be used.
54+
* @return a new {@link UuidPatternConverter} instance
4655
*/
4756
public static UuidPatternConverter newInstance(final String[] options) {
4857
if (options.length == 0) {

src/site/antora/modules/ROOT/pages/manual/pattern-layout.adoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,15 +1339,19 @@ Includes either a random or a time-based UUID
13391339
.link:../javadoc/log4j-core/org/apache/logging/log4j/core/pattern/UuidPatternConverter.html[`UuidPatternConverter`] specifier grammar
13401340
[source,text]
13411341
----
1342-
u{RANDOM|TIME}
1343-
uuid{RANDOM|TIME}
1342+
u[{RANDOM|TIME}]
1343+
uuid[{RANDOM|TIME}]
13441344
----
13451345
1346-
The time-based UUID is a Type 1 UUID generated using the MAC address of each host
1346+
The random UUID is a type 4 UUID. The UUID is generated using a cryptographically strong pseudo-random number generator.
1347+
1348+
The time-based UUID is a Type 1 (date and time based) UUID generated using the MAC address of each host.
13471349
To ensure uniqueness across multiple JVMs and/or class loaders on the same host, a random number between 0 and 16,384 will be associated with each instance of the UUID generator class, and included in each time-based UUID generated.
13481350
See also xref:manual/systemproperties.adoc#log4j2.uuidSequence[`log4j2.uuidSequence`].
13491351
Because time-based UUIDs contain the MAC address and timestamp, they should be used with care.
13501352
1353+
TIME is the default.
1354+
13511355
[#format-modifiers]
13521356
=== Format modifiers
13531357

0 commit comments

Comments
 (0)