org.apache.logging.log4j.core.layout
Class RFC5424Layout

java.lang.Object
  extended by org.apache.logging.log4j.core.layout.AbstractLayout<String>
      extended by org.apache.logging.log4j.core.layout.AbstractStringLayout
          extended by org.apache.logging.log4j.core.layout.RFC5424Layout
All Implemented Interfaces:
Layout<String>

public final class RFC5424Layout
extends AbstractStringLayout

Formats a log event in accordance with RFC 5424.


Field Summary
static int DEFAULT_ENTERPRISE_NUMBER
          Not a very good default - it is the Apache Software Foundation's enterprise number.
static String DEFAULT_ID
          The default event id.
 
Fields inherited from class org.apache.logging.log4j.core.layout.AbstractLayout
footer, header, LOGGER
 
Method Summary
static RFC5424Layout createLayout(String facility, String id, String ein, String includeMDC, String mdcId, String includeNL, String appName, String msgId, String excludes, String includes, String required, String charset, Configuration config)
          Create the RFC 5424 Layout.
 String getLocalHostname()
          This method gets the network name of the machine we are running on.
protected  List<String> getMdcExcludes()
           
protected  List<String> getMdcIncludes()
           
protected  String getProcId()
           
 String toSerializable(LogEvent event)
          Formats a LogEvent in conformance with the RFC 5424 Syslog specification.
 String toString()
           
 
Methods inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout
getCharset, toByteArray
 
Methods inherited from class org.apache.logging.log4j.core.layout.AbstractLayout
getFooter, getHeader, setFooter, setHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_ENTERPRISE_NUMBER

public static final int DEFAULT_ENTERPRISE_NUMBER
Not a very good default - it is the Apache Software Foundation's enterprise number.

See Also:
Constant Field Values

DEFAULT_ID

public static final String DEFAULT_ID
The default event id.

See Also:
Constant Field Values
Method Detail

toSerializable

public String toSerializable(LogEvent event)
Formats a LogEvent in conformance with the RFC 5424 Syslog specification.

Parameters:
event - The LogEvent.
Returns:
The RFC 5424 String representation of the LogEvent.

getProcId

protected String getProcId()

getLocalHostname

public String getLocalHostname()
This method gets the network name of the machine we are running on. Returns "UNKNOWN_LOCALHOST" in the unlikely case where the host name cannot be found.

Returns:
String the name of the local host

getMdcExcludes

protected List<String> getMdcExcludes()

getMdcIncludes

protected List<String> getMdcIncludes()

toString

public String toString()
Overrides:
toString in class Object

createLayout

public static RFC5424Layout createLayout(String facility,
                                         String id,
                                         String ein,
                                         String includeMDC,
                                         String mdcId,
                                         String includeNL,
                                         String appName,
                                         String msgId,
                                         String excludes,
                                         String includes,
                                         String required,
                                         String charset,
                                         Configuration config)
Create the RFC 5424 Layout.

Parameters:
facility - The Facility is used to try to classify the message.
id - The default structured data id to use when formatting according to RFC 5424.
ein - The IANA enterprise number.
includeMDC - Indicates whether data from the ThreadContextMap will be included in the RFC 5424 Syslog record. Defaults to "true:.
mdcId - The id to use for the MDC Structured Data Element.
includeNL - If true, a newline will be appended to the end of the syslog record. The default is false.
appName - The value to use as the APP-NAME in the RFC 5424 syslog record.
msgId - The default value to be used in the MSGID field of RFC 5424 syslog records.
excludes - A comma separated list of mdc keys that should be excluded from the LogEvent.
includes - A comma separated list of mdc keys that should be included in the FlumeEvent.
required - A comma separated list of mdc keys that must be present in the MDC.
charset - The character set.
config - The Configuration. Some Converters require access to the Interpolator.
Returns:
An RFC5424Layout.


Copyright © 1999-2012 Apache Software Foundation. All Rights Reserved.