Log4j 1.3alpha-8

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, Curt Arnold

Field Summary
protected static int FACILITY_OI
           
static int LOG_AUTH
          security/authorization messages
static int LOG_AUTHPRIV
          security/authorization messages (private)
static int LOG_CRON
          clock daemon
static int LOG_DAEMON
          System daemons
static int LOG_FTP
          ftp daemon
static int LOG_KERN
          Kernel messages
static int LOG_LOCAL0
          reserved for local use
static int LOG_LOCAL1
          reserved for local use
static int LOG_LOCAL2
          reserved for local use
static int LOG_LOCAL3
          reserved for local use
static int LOG_LOCAL4
          reserved for local use
static int LOG_LOCAL5
          reserved for local use
static int LOG_LOCAL6
          reserved for local use
static int LOG_LOCAL7
          reserved for local use
static int LOG_LPR
          line printer subsystem
static int LOG_MAIL
          Mail system
static int LOG_NEWS
          network news subsystem
static int LOG_SYSLOG
          messages generated internally by syslogd
static int LOG_USER
          Random user-level messages
static int LOG_UUCP
          UUCP subsystem
protected static int SYSLOG_HOST_OI
           
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
active, closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
Fields inherited from class org.apache.log4j.spi.ComponentBase
repository
 
Constructor Summary
SyslogAppender()
           
SyslogAppender(Layout layout, int syslogFacility)
           
SyslogAppender(Layout layout, String syslogHost, int syslogFacility)
           
 
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.
 String getFacility()
          Returns the value of the Facility option.
static int getFacility(String facilityStr)
          Returns the integer value corresponding to the named syslog facility, or -1 if it couldn't be recognized.
 boolean getFacilityPrinting()
          Deprecated. No effect in log4j 1.3
static String getFacilityString(int syslogFacility)
          Deprecated. since 1.3
 Layout getLayout()
          Returns the layout of this appender.
 String getLocalHostname()
          This method gets the network name of the machine we are running on.
 String getSyslogHost()
          Returns the value of the SyslogHost option.
 boolean requiresLayout()
          The SyslogAppender requires a layout.
 void setFacility(String facility)
          Set the syslog facility.
 void setFacilityPrinting(boolean on)
          Deprecated. No effect in log4j 1.3
 void setLayout(Layout layout)
          Set the layout for this appender.
 void setSyslogHost(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, getErrorHandler, getFilter, getFirstFilter, getName, getThreshold, isActive, isAsSevereAsThreshold, isAsSevereAsThreshold, isClosed, setErrorHandler, setName, setThreshold
 
Methods inherited from class org.apache.log4j.spi.ComponentBase
getLogger, getLoggerRepository, getNonFloodingLogger, resetErrorCount, 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.spi.Component
setLoggerRepository
 

Field Detail

LOG_KERN

public static final int LOG_KERN
Kernel messages

LOG_USER

public static final int LOG_USER
Random user-level messages

LOG_MAIL

public static final int LOG_MAIL
Mail system

LOG_DAEMON

public static final int LOG_DAEMON
System daemons

LOG_AUTH

public static final int LOG_AUTH
security/authorization messages

LOG_SYSLOG

public static final int LOG_SYSLOG
messages generated internally by syslogd

LOG_LPR

public static final int LOG_LPR
line printer subsystem

LOG_NEWS

public static final int LOG_NEWS
network news subsystem

LOG_UUCP

public static final int LOG_UUCP
UUCP subsystem

LOG_CRON

public static final int LOG_CRON
clock daemon

LOG_AUTHPRIV

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

LOG_FTP

public static final int LOG_FTP
ftp daemon

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

SYSLOG_HOST_OI

protected static final int SYSLOG_HOST_OI

FACILITY_OI

protected static final int FACILITY_OI
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

getLocalHostname

public 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

getFacilityString

public static String getFacilityString(int syslogFacility)
Deprecated. since 1.3

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

getFacility

public static int getFacility(String facilityStr)
Returns the integer value corresponding to the named syslog facility, or -1 if it couldn't be recognized.

activateOptions

public void activateOptions()
This method returns immediately as options are activated when they are set.
Overrides:
activateOptions in class AppenderSkeleton

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. 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 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 RFC 3164 for more information about the Facility option.


getFacility

public 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.
Overrides:
append in class AppenderSkeleton

getLayout

public Layout getLayout()
Description copied from class: AppenderSkeleton
Returns the layout of this appender. The value may be null.
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.
Overrides:
setLayout in class AppenderSkeleton

setFacilityPrinting

public void setFacilityPrinting(boolean on)
Deprecated. No effect in log4j 1.3

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()
Deprecated. No effect in log4j 1.3

Returns the value of the FacilityPrinting option.

Log4j 1.3alpha-8

Copyright © 2000-2006 Apache Software Foundation.
Licensed under the Apache License, Version 2.0.