public interface ReusableMessage extends Message, StringBuilderFormattable
If a Message is reusable, downstream components should not hand over this instance to another thread, but extract its
content (via the StringBuilderFormattable.formatTo(StringBuilder)
method) instead.
ReusableMessageFactory
Modifier and Type | Method and Description |
---|---|
short |
getParameterCount()
Returns the number of parameters that was used to initialize this reusable message for the current content.
|
Message |
memento()
Returns an immutable snapshot of the current internal state of this reusable message.
|
Object[] |
swapParameters(Object[] emptyReplacement)
Returns the parameter array that was used to initialize this reusable message and replaces it with the specified
array.
|
getFormat, getFormattedMessage, getParameters, getThrowable
formatTo
Object[] swapParameters(Object[] emptyReplacement)
ReusableMessages that have no parameters return the specified array.
This method is used by asynchronous loggers to pass the parameter array to a background thread without
allocating new objects.
The actual number of parameters in the returned array can be determined with getParameterCount()
.
emptyReplacement
- the parameter array that can be used for subsequent uses of this reusable message.
This replacement array must have at least 10 elements (the number of varargs supported by the Logger
API).getParameterCount()
short getParameterCount()
The parameter array returned by swapParameters(Object[])
may be larger than the actual number of
parameters. Callers should use this method to determine how many elements the array contains.
Copyright © 1999-1969 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.