Class SyslogFormatter

  • All Implemented Interfaces:
    Formatter

    public class SyslogFormatter
    extends java.lang.Object
    implements Formatter
    A formatter that serializes in the format originally used by BSD syslog daemon.
    Author:
    Peter Donald
    • Constructor Detail

      • SyslogFormatter

        public SyslogFormatter()
        Constructor that assumes FACILITY_USER.
      • SyslogFormatter

        public SyslogFormatter​(int facility)
        Constructor so that you can associate facility with formatter.
        Parameters:
        facility - the facility constant
      • SyslogFormatter

        public SyslogFormatter​(int facility,
                               boolean showFacilityBanner)
        Constructor allowing setting of facility and whether to show banner.
        Parameters:
        facility - the facility code.
        showFacilityBanner - true if facility banner should be shown
    • Method Detail

      • format

        public java.lang.String format​(LogEvent event)
        Format log event into syslog string.
        Specified by:
        format in interface Formatter
        Parameters:
        event - the event
        Returns:
        the formatted string
      • getFacilityDescription

        protected java.lang.String getFacilityDescription​(int facility)
        Retrieve description for facility.
        Parameters:
        facility - the facility code
        Returns:
        the facility description
      • getSyslogFacility

        protected int getSyslogFacility​(LogEvent event)
        Get facility associated with event. Default implementation returns facility set in constructor.
        Parameters:
        event - the log event
        Returns:
        the facility code
      • getSyslogPriority

        protected int getSyslogPriority​(LogEvent event)
        Get syslog priority code for LogEvent. This is done by translating LogKit priority to syslog priority.
        Parameters:
        event - the log event
        Returns:
        the priority code