Class Rfc5424Layout

    • 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 java.lang.String DEFAULT_ID
        The default event id.
        See Also:
        Constant Field Values
      • NEWLINE_PATTERN

        public static final java.util.regex.Pattern NEWLINE_PATTERN
        Match newlines in a platform-independent manner.
      • PARAM_VALUE_ESCAPE_PATTERN

        public static final java.util.regex.Pattern PARAM_VALUE_ESCAPE_PATTERN
        Match characters which require escaping.
      • DEFAULT_MDCID

        public static final java.lang.String DEFAULT_MDCID
        Default MDC ID: "mdc" .
        See Also:
        Constant Field Values
      • facility

        private final Facility facility
      • defaultId

        private final java.lang.String defaultId
      • enterpriseNumber

        private final int enterpriseNumber
      • includeMdc

        private final boolean includeMdc
      • mdcId

        private final java.lang.String mdcId
      • localHostName

        private final java.lang.String localHostName
      • appName

        private final java.lang.String appName
      • messageId

        private final java.lang.String messageId
      • configName

        private final java.lang.String configName
      • mdcPrefix

        private final java.lang.String mdcPrefix
      • eventPrefix

        private final java.lang.String eventPrefix
      • mdcExcludes

        private final java.util.List<java.lang.String> mdcExcludes
      • mdcIncludes

        private final java.util.List<java.lang.String> mdcIncludes
      • mdcRequired

        private final java.util.List<java.lang.String> mdcRequired
      • includeNewLine

        private final boolean includeNewLine
      • escapeNewLine

        private final java.lang.String escapeNewLine
      • useTlsMessageFormat

        private final boolean useTlsMessageFormat
      • lastTimestamp

        private long lastTimestamp
      • timestamppStr

        private java.lang.String timestamppStr
      • exceptionFormatters

        private final java.util.List<PatternFormatter> exceptionFormatters
      • procId

        private final java.lang.String procId
    • Constructor Detail

      • Rfc5424Layout

        private Rfc5424Layout​(Configuration config,
                              Facility facility,
                              java.lang.String id,
                              int ein,
                              boolean includeMDC,
                              boolean includeNL,
                              java.lang.String escapeNL,
                              java.lang.String mdcId,
                              java.lang.String mdcPrefix,
                              java.lang.String eventPrefix,
                              java.lang.String appName,
                              java.lang.String messageId,
                              java.lang.String excludes,
                              java.lang.String includes,
                              java.lang.String required,
                              java.nio.charset.Charset charset,
                              java.lang.String exceptionPattern,
                              boolean useTLSMessageFormat,
                              LoggerFields[] loggerFields)
    • Method Detail

      • createPatternParser

        private static PatternParser createPatternParser​(Configuration config,
                                                         java.lang.Class<? extends PatternConverter> filterClass)
        Create a PatternParser.
        Parameters:
        config - The Configuration.
        filterClass - Filter the returned plugins after calling the plugin manager.
        Returns:
        The PatternParser.
      • getContentFormat

        public java.util.Map<java.lang.String,​java.lang.String> getContentFormat()
        Gets this Rfc5424Layout's content format. Specified by:
        • Key: "structured" Value: "true"
        • Key: "format" Value: "RFC5424"
        Specified by:
        getContentFormat in interface Layout<java.lang.String>
        Overrides:
        getContentFormat in class AbstractLayout<java.lang.String>
        Returns:
        Map of content format keys supporting Rfc5424Layout
      • toSerializable

        public java.lang.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.
      • appendPriority

        private void appendPriority​(java.lang.StringBuilder buffer,
                                    Level logLevel)
      • appendTimestamp

        private void appendTimestamp​(java.lang.StringBuilder buffer,
                                     long milliseconds)
      • appendSpace

        private void appendSpace​(java.lang.StringBuilder buffer)
      • appendHostName

        private void appendHostName​(java.lang.StringBuilder buffer)
      • appendAppName

        private void appendAppName​(java.lang.StringBuilder buffer)
      • appendProcessId

        private void appendProcessId​(java.lang.StringBuilder buffer)
      • appendMessageId

        private void appendMessageId​(java.lang.StringBuilder buffer,
                                     Message message)
      • appendMessage

        private void appendMessage​(java.lang.StringBuilder buffer,
                                   LogEvent event)
      • appendStructuredElements

        private void appendStructuredElements​(java.lang.StringBuilder buffer,
                                              LogEvent event)
      • escapeNewlines

        private java.lang.String escapeNewlines​(java.lang.String text,
                                                java.lang.String replacement)
      • getProcId

        protected java.lang.String getProcId()
      • getMdcExcludes

        protected java.util.List<java.lang.String> getMdcExcludes()
      • getMdcIncludes

        protected java.util.List<java.lang.String> getMdcIncludes()
      • computeTimeStampString

        private java.lang.String computeTimeStampString​(long now)
      • pad

        private void pad​(int val,
                         int max,
                         java.lang.StringBuilder buf)
      • checkRequired

        private void checkRequired​(java.util.Map<java.lang.String,​java.lang.String> map)
      • appendMap

        private void appendMap​(java.lang.String prefix,
                               java.util.Map<java.lang.String,​java.lang.String> map,
                               java.lang.StringBuilder sb,
                               ListChecker checker)
      • escapeSDParams

        private java.lang.String escapeSDParams​(java.lang.String value)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • createLayout

        @PluginFactory
        public static Rfc5424Layout createLayout​(@PluginAttribute(value="facility",defaultString="LOCAL0")
                                                 Facility facility,
                                                 @PluginAttribute("id")
                                                 java.lang.String id,
                                                 @PluginAttribute(value="enterpriseNumber",defaultInt=18060)
                                                 int enterpriseNumber,
                                                 @PluginAttribute(value="includeMDC",defaultBoolean=true)
                                                 boolean includeMDC,
                                                 @PluginAttribute(value="mdcId",defaultString="mdc")
                                                 java.lang.String mdcId,
                                                 @PluginAttribute("mdcPrefix")
                                                 java.lang.String mdcPrefix,
                                                 @PluginAttribute("eventPrefix")
                                                 java.lang.String eventPrefix,
                                                 @PluginAttribute("newLine")
                                                 boolean newLine,
                                                 @PluginAttribute("newLineEscape")
                                                 java.lang.String escapeNL,
                                                 @PluginAttribute("appName")
                                                 java.lang.String appName,
                                                 @PluginAttribute("messageId")
                                                 java.lang.String msgId,
                                                 @PluginAttribute("mdcExcludes")
                                                 java.lang.String excludes,
                                                 @PluginAttribute("mdcIncludes")
                                                 java.lang.String includes,
                                                 @PluginAttribute("mdcRequired")
                                                 java.lang.String required,
                                                 @PluginAttribute("exceptionPattern")
                                                 java.lang.String exceptionPattern,
                                                 @PluginAttribute("useTlsMessageFormat")
                                                 boolean useTlsMessageFormat,
                                                 @PluginElement("LoggerFields")
                                                 LoggerFields[] loggerFields,
                                                 @PluginConfiguration
                                                 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.
        enterpriseNumber - 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.
        mdcPrefix - The prefix to add to MDC key names.
        eventPrefix - The prefix to add to event key names.
        newLine - If true, a newline will be appended to the end of the syslog record. The default is false.
        escapeNL - String that should be used to replace newlines within the message text.
        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.
        exceptionPattern - The pattern for formatting exceptions.
        useTlsMessageFormat - If true the message will be formatted according to RFC 5425.
        loggerFields - Container for the KeyValuePairs containing the patterns
        config - The Configuration. Some Converters require access to the Interpolator.
        Returns:
        An Rfc5424Layout.
      • getFacility

        public Facility getFacility()