Class Log4j1SyslogLayout

All Implemented Interfaces:
LocationAware, Layout<String>, Encoder<LogEvent>, StringLayout

@Plugin(name="Log4j1SyslogLayout", category="Core", elementType="layout", printObject=true) public final class Log4j1SyslogLayout extends AbstractStringLayout
Port of the layout used by SyslogAppender in Log4j 1.x. Provided for compatibility with existing Log4j 1 configurations. Originally developed by Ceki Gülcü and Anders Kristensen.
  • Field Details

    • localHostname

      private static final String localHostname
      Host name used to identify messages from this appender.
    • facility

      private final Facility facility
    • facilityPrinting

      private final boolean facilityPrinting
    • messageLayout

      private final StringLayout messageLayout
    • dateFormatOptions

      private static final String[] dateFormatOptions
      Date format used if header = true.
    • dateConverter

      private final LogEventPatternConverter dateConverter
  • Constructor Details

    • Log4j1SyslogLayout

      private Log4j1SyslogLayout(Facility facility, boolean facilityPrinting, boolean header, StringLayout messageLayout, Charset charset)
  • Method Details

    • newBuilder

      @PluginBuilderFactory public static <B extends Log4j1SyslogLayout.Builder<B>> B newBuilder()
    • toSerializable

      public String toSerializable(LogEvent event)
      Formats a LogEvent in conformance with the BSD Log record format.
      Parameters:
      event - The LogEvent
      Returns:
      the event formatted as a String.
    • getContentFormat

      public Map<String,String> getContentFormat()
      Gets this SyslogLayout's content format. Specified by:
      • Key: "structured" Value: "false"
      • Key: "dateFormat" Value: "MMM dd HH:mm:ss"
      • Key: "format" Value: "<LEVEL>TIMESTAMP PROP(HOSTNAME) MESSAGE"
      • Key: "formatType" Value: "logfilepatternreceiver" (format uses the keywords supported by LogFilePatternReceiver)
      Specified by:
      getContentFormat in interface Layout<String>
      Overrides:
      getContentFormat in class AbstractLayout<String>
      Returns:
      Map of content format keys supporting SyslogLayout