Log4j 1.3alpha-6

org.apache.log4j.net
Class SyslogAppender

java.lang.Object
  |
  +--org.apache.log4j.spi.ComponentBase
        |
        +--org.apache.log4j.AppenderSkeleton
              |
              +--org.apache.log4j.net.SyslogAppender
All Implemented Interfaces:
Appender, Component, OptionHandler

public class SyslogAppender
extends AppenderSkeleton

Implements an RFC 3164 compliant agent to send log messages to a remote syslog daemon.

Author:
Ceki Gülcü, Anders Kristensen, Hermod Opstvedt

Field Summary
protected static int FACILITY_OI
           
protected  java.text.FieldPosition pos
           
protected static int SYSLOG_HOST_OI
           
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, headFilter, layout, name, tailFilter, threshold
 
Fields inherited from class org.apache.log4j.spi.ComponentBase
repository
 
Constructor Summary
SyslogAppender()
           
 
Method Summary
 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.
 void close()
          Release any resources held by this SyslogAppender.
 java.lang.String getFacility()
          Returns the value of the Facility option.
 Layout getLayout()
          Returns the layout of this appender.
 java.lang.String getLocalHostname()
          This method gets the network name of the machine we are running on.
 java.lang.String getSyslogHost()
          Returns the value of the SyslogHost option.
 void setFacility(java.lang.String facility)
          Set the syslog facility.
 void setLayout(Layout layout)
          Set the layout for this appender.
 void setSyslogHost(java.lang.String syslogHost)
          The SyslogHost option is the name of the the syslog host where log output should go.
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
addFilter, clearFilters, doAppend, finalize, getFilter, getFirstFilter, getName, getThreshold, isAsSevereAsThreshold, setName, setThreshold
 
Methods inherited from class org.apache.log4j.spi.ComponentBase
getLogger, setLoggerRepository
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.log4j.Appender
setLoggerRepository
 

Field Detail

SYSLOG_HOST_OI

protected static final int SYSLOG_HOST_OI
See Also:
Constant Field Values

FACILITY_OI

protected static final int FACILITY_OI
See Also:
Constant Field Values

pos

protected java.text.FieldPosition pos
Constructor Detail

SyslogAppender

public SyslogAppender()
Method Detail

close

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

Since:
0.8.4

getLocalHostname

public java.lang.String getLocalHostname()
This method gets the network name of the machine we are running on. Returns "UNKNOWN_HOST" in the unlikely case where the host name cannot be found.

Returns:
String

activateOptions

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

Specified by:
activateOptions in interface OptionHandler
Overrides:
activateOptions in class AppenderSkeleton

setSyslogHost

public void setSyslogHost(java.lang.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.


getSyslogHost

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


setFacility

public void setFacility(java.lang.String facility)
Set the syslog facility. This is the Facility option.

The facility parameter must be one of the strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, NTP, AUDIT, ALERT, CLOCK, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. Case is not important. See SyslogConstants and RFC 3164 for more information about the Facility option.


getFacility

public java.lang.String getFacility()
Returns the value of the Facility option. See setFacility(java.lang.String) for the set of allowed values.


append

public void append(LoggingEvent event)
Description copied from class: AppenderSkeleton
Subclasses of AppenderSkeleton should implement this method to perform actual logging. See also AppenderSkeleton.doAppend method.

Specified by:
append in class AppenderSkeleton

getLayout

public Layout getLayout()
Description copied from class: AppenderSkeleton
Returns the layout of this appender. The value may be null.

Specified by:
getLayout in interface Appender
Overrides:
getLayout in class AppenderSkeleton

setLayout

public void setLayout(Layout layout)
Description copied from class: AppenderSkeleton
Set the layout for this appender. Note that some appenders have their own (fixed) layouts or do not use one. For example, the SocketAppender ignores the layout set here.

Specified by:
setLayout in interface Appender
Overrides:
setLayout in class AppenderSkeleton

Log4j 1.3alpha-6

Copyright 2000-2005 Apache Software Foundation.