Class UuidPatternConverter
- java.lang.Object
-
- org.apache.logging.log4j.core.pattern.AbstractPatternConverter
-
- org.apache.logging.log4j.core.pattern.LogEventPatternConverter
-
- org.apache.logging.log4j.core.pattern.UuidPatternConverter
-
- All Implemented Interfaces:
PatternConverter
@Plugin(name="UuidPatternConverter", category="Converter") public final class UuidPatternConverter extends LogEventPatternConverter
Formats a UUID.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanisRandom-
Fields inherited from class org.apache.logging.log4j.core.pattern.AbstractPatternConverter
LOGGER
-
Fields inherited from interface org.apache.logging.log4j.core.pattern.PatternConverter
CATEGORY
-
-
Constructor Summary
Constructors Modifier Constructor Description privateUuidPatternConverter(boolean isRandom)Private constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidformat(LogEvent event, java.lang.StringBuilder toAppendTo)Formats an event into a string buffer.static UuidPatternConverternewInstance(java.lang.String[] options)Creates an instance ofUuidPatternConverter.-
Methods inherited from class org.apache.logging.log4j.core.pattern.LogEventPatternConverter
emptyVariableOutput, format, handlesThrowable, isVariable
-
Methods inherited from class org.apache.logging.log4j.core.pattern.AbstractPatternConverter
getName, getStyleClass
-
-
-
-
Method Detail
-
newInstance
public static UuidPatternConverter newInstance(java.lang.String[] options)
Creates an instance ofUuidPatternConverter.The
RANDOMoption generates a Type 4 (pseudo-randomly generated) UUID. The UUID is generated using a cryptographically strong pseudo-random number generator.The
TIMEoption generates a Type 1 (date and time based) UUID using the local network interface's MAC address. 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. SeeUuidUtil.UUID_SEQUENCEhow to seed the UUID generation with an integer value. Because time-based UUIDs contain the MAC address and timestamp, they should be used with care.- Parameters:
options- An array containing eitherRANDOMorTIME. If empty,TIMEwill be used.- Returns:
- a new
UuidPatternConverterinstance
-
format
public void format(LogEvent event, java.lang.StringBuilder toAppendTo)
Formats an event into a string buffer.- Specified by:
formatin classLogEventPatternConverter- Parameters:
event- event to format, may not be null.toAppendTo- string buffer to which the formatted event will be appended. May not be null.
-
-