|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.logging.log4j.message.MapMessage
org.apache.logging.log4j.message.StructuredDataMessage
public class StructuredDataMessage
Represents a Message that conforms to an RFC 5424 StructuredData element along with the syslog message.
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.
Nested Class Summary | |
---|---|
static class |
StructuredDataMessage.Format
Supported formats. |
Nested classes/interfaces inherited from class org.apache.logging.log4j.message.MapMessage |
---|
MapMessage.MapFormat |
Constructor Summary | |
---|---|
protected |
StructuredDataMessage()
Basic constructor. |
|
StructuredDataMessage(String id,
String msg,
String type)
Creates a StructuredDataMessage using an ID (max 32 characters), message, and type (max 32 characters). |
|
StructuredDataMessage(String id,
String msg,
String type,
Map<String,String> data)
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 id,
String msg,
String type)
Creates a StructuredDataMessage using a StructuredDataId, message, and type (max 32 characters). |
|
StructuredDataMessage(StructuredDataId id,
String msg,
String type,
Map<String,String> data)
Creates a StructuredDataMessage using a StructuredDataId, message, type (max 32 characters), and an initial map of structured data to include. |
Method Summary | |
---|---|
String |
asString()
Formats the structured data as described in RFC 5424. |
String |
asString(String format)
Formats the structured data as described in RFC 5424. |
String |
asString(StructuredDataMessage.Format format,
StructuredDataId structuredDataId)
Formats the structured data as described in RFC 5424. |
boolean |
equals(Object o)
|
String |
getFormat()
Returns the message. |
String[] |
getFormats()
Returns the supported formats. |
String |
getFormattedMessage()
Formats the message and return it. |
String |
getFormattedMessage(String[] formats)
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<String,String> map)
|
protected void |
setId(String id)
Sets the id from a String. |
protected void |
setId(StructuredDataId id)
Sets the id. |
protected void |
setMessageFormat(String msg)
|
protected void |
setType(String type)
|
String |
toString()
|
protected void |
validate(String key,
String value)
|
Methods inherited from class org.apache.logging.log4j.message.MapMessage |
---|
appendMap, asJava, asJson, asXml, clear, get, getData, getParameters, getThrowable, put, putAll, remove |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StructuredDataMessage(String id, String msg, String type)
id
- The String id.msg
- The message.type
- The message type.public StructuredDataMessage(String id, 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(StructuredDataId id, String msg, String type)
id
- The StructuredDataId.msg
- The message.type
- The message type.public StructuredDataMessage(StructuredDataId id, String msg, String type, Map<String,String> data)
id
- The StructuredDataId.msg
- The message.type
- The message type.data
- The StructuredData map.protected StructuredDataMessage()
Method Detail |
---|
public String[] getFormats()
getFormats
in interface MultiformatMessage
getFormats
in class MapMessage
public StructuredDataId getId()
protected void setId(String id)
id
- The String id.protected void setId(StructuredDataId id)
id
- The StructuredDataId.public String getType()
protected void setType(String type)
public String getFormat()
getFormat
in interface Message
getFormat
in class MapMessage
protected void setMessageFormat(String msg)
protected void validate(String key, String value)
validate
in class MapMessage
public String asString()
asString
in class MapMessage
public String asString(String format)
asString
in class MapMessage
format
- The format identifier. Ignored in this implementation.
public final String asString(StructuredDataMessage.Format format, StructuredDataId structuredDataId)
format
- "full" will include the type and message. null will return only the STRUCTURED-DATA as
described in RFC 5424structuredDataId
- The SD-ID as described in RFC 5424. If null the value in the StructuredData
will be used.
public String getFormattedMessage()
getFormattedMessage
in interface Message
getFormattedMessage
in class MapMessage
public String getFormattedMessage(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 String toString()
toString
in class MapMessage
public MapMessage newInstance(Map<String,String> map)
newInstance
in class MapMessage
public boolean equals(Object o)
equals
in class MapMessage
public int hashCode()
hashCode
in class MapMessage
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1999-2015 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.