public class

SyslogAppender

extends AppenderSkeleton
java.lang.Object
   ↳ org.apache.log4j.AppenderSkeleton
     ↳ org.apache.log4j.net.SyslogAppender

Class Overview

Use SyslogAppender to send log messages to a remote syslog daemon.

Summary

Constants
int FACILITY_OI
int LOG_AUTH security/authorization messages
int LOG_AUTHPRIV security/authorization messages (private)
int LOG_CRON clock daemon
int LOG_DAEMON System daemons
int LOG_FTP ftp daemon
int LOG_KERN Kernel messages
int LOG_LOCAL0 reserved for local use
int LOG_LOCAL1 reserved for local use
int LOG_LOCAL2 reserved for local use
int LOG_LOCAL3 reserved for local use
int LOG_LOCAL4 reserved for local use
int LOG_LOCAL5 reserved for local use
int LOG_LOCAL6 reserved for local use
int LOG_LOCAL7 reserved for local use
int LOG_LPR line printer subsystem
int LOG_MAIL Mail system
int LOG_NEWS network news subsystem
int LOG_SYSLOG messages generated internally by syslogd
int LOG_USER Random user-level messages
int LOG_UUCP UUCP subsystem
int SYSLOG_HOST_OI
[Expand]
Inherited Fields
From class org.apache.log4j.AppenderSkeleton
Public Constructors
SyslogAppender()
SyslogAppender(Layout layout, int syslogFacility)
SyslogAppender(Layout layout, String syslogHost, int syslogFacility)
Public Methods
void activateOptions()
This method returns immediately as options are activated when they are set.
void append(LoggingEvent event)
Subclasses of AppenderSkeleton should implement this method to perform actual logging.
synchronized void close()
Release any resources held by this SyslogAppender.
static int getFacility(String facilityName)
Returns the integer value corresponding to the named syslog facility, or -1 if it couldn't be recognized.
String getFacility()
Returns the value of the Facility option.
boolean getFacilityPrinting()
Returns the value of the FacilityPrinting option.
static String getFacilityString(int syslogFacility)
Returns the specified syslog facility as a lower-case String, e.g.
final boolean getHeader()
If true, the appender will generate the HEADER part (that is, timestamp and host name) of the syslog packet.
String getSyslogHost()
Returns the value of the SyslogHost option.
boolean requiresLayout()
The SyslogAppender requires a layout.
void setFacility(String facilityName)
Set the syslog facility.
void setFacilityPrinting(boolean on)
If the FacilityPrinting option is set to true, the printed message will include the facility name of the application.
final void setHeader(boolean val)
Returns whether the appender produces the HEADER part (that is, timestamp and host name) of the syslog packet.
void setSyslogHost(String syslogHost)
The SyslogHost option is the name of the the syslog host where log output should go.
[Expand]
Inherited Methods
From class org.apache.log4j.AppenderSkeleton
From class java.lang.Object
From interface org.apache.log4j.Appender
From interface org.apache.log4j.spi.OptionHandler

Constants

protected static final int FACILITY_OI

Constant Value: 1 (0x00000001)

public static final int LOG_AUTH

security/authorization messages

Constant Value: 32 (0x00000020)

public static final int LOG_AUTHPRIV

security/authorization messages (private)

Constant Value: 80 (0x00000050)

public static final int LOG_CRON

clock daemon

Constant Value: 72 (0x00000048)

public static final int LOG_DAEMON

System daemons

Constant Value: 24 (0x00000018)

public static final int LOG_FTP

ftp daemon

Constant Value: 88 (0x00000058)

public static final int LOG_KERN

Kernel messages

Constant Value: 0 (0x00000000)

public static final int LOG_LOCAL0

reserved for local use

Constant Value: 128 (0x00000080)

public static final int LOG_LOCAL1

reserved for local use

Constant Value: 136 (0x00000088)

public static final int LOG_LOCAL2

reserved for local use

Constant Value: 144 (0x00000090)

public static final int LOG_LOCAL3

reserved for local use

Constant Value: 152 (0x00000098)

public static final int LOG_LOCAL4

reserved for local use

Constant Value: 160 (0x000000a0)

public static final int LOG_LOCAL5

reserved for local use

Constant Value: 168 (0x000000a8)

public static final int LOG_LOCAL6

reserved for local use

Constant Value: 176 (0x000000b0)

public static final int LOG_LOCAL7

reserved for local use

Constant Value: 184 (0x000000b8)

public static final int LOG_LPR

line printer subsystem

Constant Value: 48 (0x00000030)

public static final int LOG_MAIL

Mail system

Constant Value: 16 (0x00000010)

public static final int LOG_NEWS

network news subsystem

Constant Value: 56 (0x00000038)

public static final int LOG_SYSLOG

messages generated internally by syslogd

Constant Value: 40 (0x00000028)

public static final int LOG_USER

Random user-level messages

Constant Value: 8 (0x00000008)

public static final int LOG_UUCP

UUCP subsystem

Constant Value: 64 (0x00000040)

protected static final int SYSLOG_HOST_OI

Constant Value: 0 (0x00000000)

Public Constructors

public SyslogAppender ()

public SyslogAppender (Layout layout, int syslogFacility)

public SyslogAppender (Layout layout, String syslogHost, int syslogFacility)

Public Methods

public void activateOptions ()

This method returns immediately as options are activated when they are set.

public void append (LoggingEvent event)

Subclasses of AppenderSkeleton should implement this method to perform actual logging. See also AppenderSkeleton.doAppend method.

public synchronized void close ()

Release any resources held by this SyslogAppender.

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.

public String getFacility ()

Returns the value of the Facility option.

public boolean getFacilityPrinting ()

Returns the value of the FacilityPrinting option.

public static String getFacilityString (int syslogFacility)

Returns the specified syslog facility as a lower-case String, e.g. "kern", "user", etc.

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.

public String getSyslogHost ()

Returns the value of the SyslogHost option.

public boolean requiresLayout ()

The SyslogAppender requires a layout. Hence, this method returns true.

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.

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.

public final void setHeader (boolean val)

Returns whether the appender produces the HEADER part (that is, timestamp and host name) of the syslog packet.

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.