org.liquidsite.util.log
Class SyslogHandler

java.lang.Object
  extended byjava.util.logging.Handler
      extended byorg.liquidsite.util.log.SyslogHandler

public class SyslogHandler
extends java.util.logging.Handler

A UNIX syslog handler. This implementation is based on RFC 3164.


Field Summary
protected static int ALERT_SEVERITY
          The alert log severity.
protected static int CRITICAL_SEVERITY
          The critical log severity.
protected static int DEBUG_SEVERITY
          The debug log severity.
protected static int EMERGENCY_SEVERITY
          The emergency log severity.
protected static int ERROR_SEVERITY
          The error log severity.
protected static int INFO_SEVERITY
          The informational log severity.
protected static int NOTICE_SEVERITY
          The notice log severity.
protected static int WARNING_SEVERITY
          The warning log severity.
 
Constructor Summary
SyslogHandler()
          Creates a new syslog handler.
 
Method Summary
 void close()
          Closes the log handler and frees any resources.
 void flush()
          Flushes any buffered output.
 java.net.InetAddress getAddress()
          Returns the IP address of the syslog server.
 int getFacility()
          Returns the log facility to use.
 java.lang.String getHostname()
          Returns the hostname to use.
 int getPort()
          Returns the port number of the syslog server.
 java.lang.String getTag()
          Returns the log tag to use.
 void publish(java.util.logging.LogRecord record)
          Publishes a log record.
 void setAddress(java.net.InetAddress address)
          Sets the IP address of the syslog server.
 void setFacility(int facility)
          Sets the log facility to use.
 void setHostname(java.lang.String hostname)
          Sets the hostname to use.
 void setPort(int port)
          Sets the port number of the syslog server.
 void setTag(java.lang.String tag)
          Sets the log tag to use.
 
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMERGENCY_SEVERITY

protected static final int EMERGENCY_SEVERITY
The emergency log severity. Used when the system is unusable.

See Also:
Constant Field Values

ALERT_SEVERITY

protected static final int ALERT_SEVERITY
The alert log severity. Used when action must be taken immediately.

See Also:
Constant Field Values

CRITICAL_SEVERITY

protected static final int CRITICAL_SEVERITY
The critical log severity. Used for critical conditions.

See Also:
Constant Field Values

ERROR_SEVERITY

protected static final int ERROR_SEVERITY
The error log severity. Used for error conditions.

See Also:
Constant Field Values

WARNING_SEVERITY

protected static final int WARNING_SEVERITY
The warning log severity. Used for warning conditions.

See Also:
Constant Field Values

NOTICE_SEVERITY

protected static final int NOTICE_SEVERITY
The notice log severity. Used for normal but significant conditions.

See Also:
Constant Field Values

INFO_SEVERITY

protected static final int INFO_SEVERITY
The informational log severity. Used for informational messages.

See Also:
Constant Field Values

DEBUG_SEVERITY

protected static final int DEBUG_SEVERITY
The debug log severity. Used for debug-level messages.

See Also:
Constant Field Values
Constructor Detail

SyslogHandler

public SyslogHandler()
              throws java.net.SocketException,
                     java.net.UnknownHostException
Creates a new syslog handler.

Throws:
java.net.SocketException - if an UDP socket couldn't be opened
java.net.UnknownHostException - if the localhost IP address couldn't be determined
Method Detail

getAddress

public java.net.InetAddress getAddress()
Returns the IP address of the syslog server. The default is to use localhost.

Returns:
the IP address of the syslog server

setAddress

public void setAddress(java.net.InetAddress address)
Sets the IP address of the syslog server.

Parameters:
address - the IP address of the syslog server

getPort

public int getPort()
Returns the port number of the syslog server. The default is to use port 514.

Returns:
the port number of the syslog server

setPort

public void setPort(int port)
Sets the port number of the syslog server.

Parameters:
port - the port number of the syslog server

getFacility

public int getFacility()
Returns the log facility to use.

Returns:
the log facility to use

setFacility

public void setFacility(int facility)
Sets the log facility to use.

Parameters:
facility - the new log facility

getHostname

public java.lang.String getHostname()
Returns the hostname to use.

Returns:
the hostname to use

setHostname

public void setHostname(java.lang.String hostname)
Sets the hostname to use.

Parameters:
hostname - the new hostname

getTag

public java.lang.String getTag()
Returns the log tag to use.

Returns:
the log tag to use

setTag

public void setTag(java.lang.String tag)
Sets the log tag to use.

Parameters:
tag - the new log tag

publish

public void publish(java.util.logging.LogRecord record)
Publishes a log record.

Parameters:
record - the log record to publish

close

public void close()
Closes the log handler and frees any resources.


flush

public void flush()
Flushes any buffered output.