public interface Message extends Serializable
Custom Message implementations should consider implementing the
interface for more efficient processing. Garbage-free Layouts will call
formatTo(StringBuilder) instead of
getFormattedMessage() if the Message implements StringBuilderFormattable.
Note: Message objects should not be considered to be thread safe nor should they be assumed to be safely reusable even on the same thread. The logging system may provide information to the Message objects and the Messages might be queued for asynchronous delivery. Thus, any modifications to a Message object by an application should by avoided after the Message has been passed as a parameter on a Logger method.
|Modifier and Type||Method and Description|
Gets the format portion of the Message.
Gets the Message formatted as a String.
Gets parameter values, if any.
Gets the throwable, if any.
When configured to log asynchronously, this method is called before the Message is queued, unless this
ReusableMessage or is annotated with
This gives the Message implementation class a chance to create a formatted message String with the current value
of any mutable objects.
The intention is that the Message implementation caches this formatted message and returns it on subsequent
calls. (See LOG4J2-763.)
When logging synchronously, this method will not be called for Messages that implement the
StringBuilderFormattable interface: instead, the
formatTo(StringBuilder) method will be called so the
Message can format its contents without creating intermediate String objects.
Copyright © 1999-2021 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.