Package de.galan.commons.logging
Class PayloadMessage
- java.lang.Object
-
- de.galan.commons.logging.PayloadMessage
-
- All Implemented Interfaces:
Serializable,org.apache.logging.log4j.message.Message
public class PayloadMessage extends Object implements org.apache.logging.log4j.message.Message
Log4j2 Message for Logger that support parameterized messages, using {} as placeholder, eg.:
info("Hello {}", "world"); // => "Hello {world}"
info("Hello {} {}", "beautiful", "world"); // => "Hello {beautiful} {world}"
error("Something failed: {}", ex, "do'h"); // => "Hello {beautiful} {world}"
It is also encouraged to give the parameter names with identifier set to true. This can be useful for later integrations/parsing. If no parameters are given, key will be generated as sequence numbers. Example:
info("Hello {}", "world"); // => "Hello {0:world}"
info("Hello {} {}", "beautiful", "world"); // => "Hello {0:beautiful} {1:world}"
info("The Answer is {answer}", 42L); // => "The Answer is {answer:42}"- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PayloadMessage(String messagePattern, Object[] argumentsObject)PayloadMessage(String messagePattern, Object[] argumentsObject, boolean includeIdentifier, Throwable throwable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String[]argumentsToStrings(Object[] argumentsObject)protected StringconvertToString(Object object)StringgetFormat()StringgetFormattedMessage()Object[]getParameters()protected intgetPatternAmountArguments()ThrowablegetThrowable()protected voidparseMessage(String messagePattern)
-
-
-
Method Detail
-
getPatternAmountArguments
protected int getPatternAmountArguments()
-
parseMessage
protected void parseMessage(String messagePattern)
-
getFormattedMessage
public String getFormattedMessage()
- Specified by:
getFormattedMessagein interfaceorg.apache.logging.log4j.message.Message
-
getFormat
public String getFormat()
- Specified by:
getFormatin interfaceorg.apache.logging.log4j.message.Message
-
getParameters
public Object[] getParameters()
- Specified by:
getParametersin interfaceorg.apache.logging.log4j.message.Message
-
getThrowable
public Throwable getThrowable()
- Specified by:
getThrowablein interfaceorg.apache.logging.log4j.message.Message
-
-