public class StructuredDataMessage extends MapMessage
Thread-safety note: the contents of this message can be modified after construction. When using asynchronous loggers and appenders it is not recommended to modify this message after the message is logged, because it is undefined whether the logged message string will contain the old values or the modified values.
| Modifier and Type | Class and Description |
|---|---|
static class |
StructuredDataMessage
Supported formats.
|
MapMessage.MapFormat | Modifier | Constructor and Description |
|---|---|
protected |
StructuredDataMessage()
Basic constructor.
|
|
StructuredDataMessage(String
Creates a StructuredDataMessage using an ID (max 32 characters), message, and type (max 32 characters).
|
|
StructuredDataMessage(String
Creates a StructuredDataMessage using an ID (max 32 characters), message, type (max 32 characters), and an initial map of structured data to include.
|
|
StructuredDataMessage(StructuredDataId
Creates a StructuredDataMessage using a StructuredDataId, message, and type (max 32 characters).
|
|
StructuredDataMessage(StructuredDataId
Creates a StructuredDataMessage using a StructuredDataId, message, type (max 32 characters), and an initial map of structured data to include.
|
| Modifier and Type | Method and Description |
|---|---|
String |
asString()
Formats the structured data as described in RFC 5424.
|
String |
asString(String
Formats the structured data as described in RFC 5424.
|
String |
asString(StructuredDataMessage
Formats the structured data as described in RFC 5424.
|
boolean |
equals(Object
|
String |
getFormat()
Returns the message.
|
String |
getFormats()
Returns the supported formats.
|
String |
getFormattedMessage()
Formats the message and return it.
|
String |
getFormattedMessage(String
Formats the message according the the specified format.
|
StructuredDataId |
getId()
Returns this message id.
|
String |
getType()
Returns this message type.
|
int |
hashCode()
|
MapMessage |
newInstance(Map
|
protected void |
setId(String
Sets the id from a String.
|
protected void |
setId(StructuredDataId
Sets the id.
|
protected void |
setMessageFormat(String
|
protected void |
setType(String
|
String |
toString()
|
protected void |
validate(String
|
StructuredDataMessage |
with(String
Add an item to the data Map in fluent style.
|
appendMap, asJava, asJson, asXml, clear, get, getData, getParameters, getThrowable, put, putAll, removepublic StructuredDataMessage(Stringid, String msg, String type)
id - The String id.
msg - The message.
type - The message type.
public StructuredDataMessage(Stringid, String msg, String type, Map <String ,String > data)
id - The String id.
msg - The message.
type - The message type.
data - The StructuredData map.
public StructuredDataMessage(StructuredDataIdid, String msg, String type)
id - The StructuredDataId.
msg - The message.
type - The message type.
public StructuredDataMessage(StructuredDataIdid, String msg, String type, Map <String ,String > data)
id - The StructuredDataId.
msg - The message.
type - The message type.
data - The StructuredData map.
protected StructuredDataMessage()
public StructuredDataMessagewith(String key, String value)
with in class
MapMessage
key - The name of the data item.
value - The value of the data item.
this
public String[] getFormats()
getFormats in interface
MultiformatMessage
getFormats in class
MapMessage
public StructuredDataIdgetId()
protected void setId(Stringid)
id - The String id.
protected void setId(StructuredDataIdid)
id - The StructuredDataId.
public StringgetType()
protected void setType(Stringtype)
public StringgetFormat()
getFormat in interface
Message
getFormat in class
MapMessage
protected void setMessageFormat(Stringmsg)
public StringasString()
asString in class
MapMessage
public StringasString(String format)
asString in class
MapMessage
format - The format identifier. Ignored in this implementation.
public final StringasString(StructuredDataMessage .Format format, StructuredDataId structuredDataId)
format - "full" will include the type and message. null will return only the STRUCTURED-DATA as described in RFC 5424
structuredDataId - The SD-ID as described in RFC 5424. If null the value in the StructuredData will be used.
public StringgetFormattedMessage()
getFormattedMessage in interface
Message
getFormattedMessage in class
MapMessage
public StringgetFormattedMessage(String [] formats)
getFormattedMessage in interface
MultiformatMessage
getFormattedMessage in class
MapMessage
formats - An array of Strings that provide extra information about how to format the message. StructuredDataMessage accepts only a format of "FULL" which will cause the event type to be prepended and the event message to be appended. Specifying any other value will cause only the StructuredData to be included. The default is "FULL".
public StringtoString()
public MapMessagenewInstance(Map <String ,String > map)
public boolean equals(Objecto)
public int hashCode()