Class SyslogAppender

  • All Implemented Interfaces:
    Appender, OptionHandler

    public class SyslogAppender
    extends AppenderSkeleton
    Use SyslogAppender to send log messages to a remote syslog daemon.
    Author:
    Ceki Gülcü, Anders Kristensen
    • Constructor Detail

      • SyslogAppender

        public SyslogAppender()
      • SyslogAppender

        public SyslogAppender​(Layout layout,
                              int syslogFacility)
      • SyslogAppender

        public SyslogAppender​(Layout layout,
                              String syslogHost,
                              int syslogFacility)
    • Method Detail

      • close

        public void close()
        Release any resources held by this SyslogAppender.
        Since:
        0.8.4
      • getFacilityString

        public static String getFacilityString​(int syslogFacility)
        Returns the specified syslog facility as a lower-case String, e.g. "kern", "user", etc.
      • getFacility

        public static int getFacility​(String facilityName)
        Returns the integer value corresponding to the named syslog facility, or -1 if it couldn't be recognized.
        Parameters:
        facilityName - one of the strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. The matching is case-insensitive.
        Since:
        1.1
      • requiresLayout

        public boolean requiresLayout()
        The SyslogAppender requires a layout. Hence, this method returns true.
        Since:
        0.8.4
      • setSyslogHost

        public void setSyslogHost​(String syslogHost)
        The SyslogHost option is the name of the the syslog host where log output should go. A non-default port can be specified by appending a colon and port number to a host name, an IPv4 address or an IPv6 address enclosed in square brackets. WARNING If the SyslogHost is not set, then this appender will fail.
      • getSyslogHost

        public String getSyslogHost()
        Returns the value of the SyslogHost option.
      • setFacility

        public void setFacility​(String facilityName)
        Set the syslog facility. This is the Facility option.

        The facilityName parameter must be one of the strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. Case is unimportant.

        Since:
        0.8.1
      • getFacility

        public String getFacility()
        Returns the value of the Facility option.
      • setFacilityPrinting

        public void setFacilityPrinting​(boolean on)
        If the FacilityPrinting option is set to true, the printed message will include the facility name of the application. It is false by default.
      • getFacilityPrinting

        public boolean getFacilityPrinting()
        Returns the value of the FacilityPrinting option.
      • getHeader

        public final boolean getHeader()
        If true, the appender will generate the HEADER part (that is, timestamp and host name) of the syslog packet. Default value is false for compatibility with existing behavior, however should be true unless there is a specific justification.
        Since:
        1.2.15
      • setHeader

        public final void setHeader​(boolean val)
        Returns whether the appender produces the HEADER part (that is, timestamp and host name) of the syslog packet.
        Since:
        1.2.15