org.apache.log4j.net

Class SyslogAppender

public class SyslogAppender extends AppenderSkeleton

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

Author: Ceki Gülcü Anders Kristensen

Field Summary
protected static intFACILITY_OI
static intLOG_AUTH
security/authorization messages
static intLOG_AUTHPRIV
security/authorization messages (private)
static intLOG_CRON
clock daemon
static intLOG_DAEMON
System daemons
static intLOG_FTP
ftp daemon
static intLOG_KERN
Kernel messages
static intLOG_LOCAL0
reserved for local use
static intLOG_LOCAL1
reserved for local use
static intLOG_LOCAL2
reserved for local use
static intLOG_LOCAL3
reserved for local use
static intLOG_LOCAL4
reserved for local use
static intLOG_LOCAL5
reserved for local use
static intLOG_LOCAL6
reserved for local use
static intLOG_LOCAL7
reserved for local use
static intLOG_LPR
line printer subsystem
static intLOG_MAIL
Mail system
static intLOG_NEWS
network news subsystem
static intLOG_SYSLOG
messages generated internally by syslogd
static intLOG_USER
Random user-level messages
static intLOG_UUCP
UUCP subsystem
protected static intSYSLOG_HOST_OI
Constructor Summary
SyslogAppender()
SyslogAppender(Layout layout, int syslogFacility)
SyslogAppender(Layout layout, String syslogHost, int syslogFacility)
Method Summary
voidactivateOptions()
This method returns immediately as options are activated when they are set.
voidappend(LoggingEvent event)
voidclose()
Release any resources held by this SyslogAppender.
static intgetFacility(String facilityName)
Returns the integer value corresponding to the named syslog facility, or -1 if it couldn't be recognized.
StringgetFacility()
Returns the value of the Facility option.
booleangetFacilityPrinting()
Returns the value of the FacilityPrinting option.
static StringgetFacilityString(int syslogFacility)
Returns the specified syslog facility as a lower-case String, e.g.
StringgetSyslogHost()
Returns the value of the SyslogHost option.
booleanrequiresLayout()
The SyslogAppender requires a layout.
voidsetFacility(String facilityName)
Set the syslog facility.
voidsetFacilityPrinting(boolean on)
If the FacilityPrinting option is set to true, the printed message will include the facility name of the application.
voidsetSyslogHost(String syslogHost)
The SyslogHost option is the name of the the syslog host where log output should go.

Field Detail

FACILITY_OI

protected static final int FACILITY_OI

LOG_AUTH

public static final int LOG_AUTH
security/authorization messages

LOG_AUTHPRIV

public static final int LOG_AUTHPRIV
security/authorization messages (private)

LOG_CRON

public static final int LOG_CRON
clock daemon

LOG_DAEMON

public static final int LOG_DAEMON
System daemons

LOG_FTP

public static final int LOG_FTP
ftp daemon

LOG_KERN

public static final int LOG_KERN
Kernel messages

LOG_LOCAL0

public static final int LOG_LOCAL0
reserved for local use

LOG_LOCAL1

public static final int LOG_LOCAL1
reserved for local use

LOG_LOCAL2

public static final int LOG_LOCAL2
reserved for local use

LOG_LOCAL3

public static final int LOG_LOCAL3
reserved for local use

LOG_LOCAL4

public static final int LOG_LOCAL4
reserved for local use

LOG_LOCAL5

public static final int LOG_LOCAL5
reserved for local use

LOG_LOCAL6

public static final int LOG_LOCAL6
reserved for local use

LOG_LOCAL7

public static final int LOG_LOCAL7
reserved for local use

LOG_LPR

public static final int LOG_LPR
line printer subsystem

LOG_MAIL

public static final int LOG_MAIL
Mail system

LOG_NEWS

public static final int LOG_NEWS
network news subsystem

LOG_SYSLOG

public static final int LOG_SYSLOG
messages generated internally by syslogd

LOG_USER

public static final int LOG_USER
Random user-level messages

LOG_UUCP

public static final int LOG_UUCP
UUCP subsystem

SYSLOG_HOST_OI

protected static final int SYSLOG_HOST_OI

Constructor Detail

SyslogAppender

public SyslogAppender()

SyslogAppender

public SyslogAppender(Layout layout, int syslogFacility)

SyslogAppender

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

Method Detail

activateOptions

public void activateOptions()
This method returns immediately as options are activated when they are set.

append

public void append(LoggingEvent event)

close

public void close()
Release any resources held by this SyslogAppender.

Since: 0.8.4

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

getFacility

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

getFacilityPrinting

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

getFacilityString

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

getSyslogHost

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

requiresLayout

public boolean requiresLayout()
The SyslogAppender requires a layout. Hence, this method returns true.

Since: 0.8.4

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

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.

setSyslogHost

public void setSyslogHost(String syslogHost)
The SyslogHost option is the name of the the syslog host where log output should go. WARNING If the SyslogHost is not set, then this appender will fail.
Copyright 2000-2005 Apache Software Foundation.