public class SyslogHandler extends ExtHandler
SyslogHandler.SyslogType
. Note that not all settable fields
are used on all format types.
Setting formatter
has no effect on this handler. The syslog RFC
specifications require explicit message formats.Modifier and Type | Class and Description |
---|---|
static class |
SyslogHandler.Facility
Facility as defined by RFC-5424 (http://tools.ietf.org/html/rfc5424)
and RFC-3164 (http://tools.ietf.org/html/rfc3164).
|
static class |
SyslogHandler.Severity
Severity as defined by RFC-5424 (http://tools.ietf.org/html/rfc5424)
and RFC-3164 (http://tools.ietf.org/html/rfc3164).
|
static class |
SyslogHandler.SyslogType
The syslog type used for formatting the message.
|
Modifier and Type | Field and Description |
---|---|
static InetAddress |
DEFAULT_ADDRESS |
static SyslogHandler.Facility |
DEFAULT_FACILITY |
static int |
DEFAULT_PORT |
static char |
NILVALUE |
handlers, handlersUpdater
Constructor and Description |
---|
SyslogHandler()
The default class constructor.
|
SyslogHandler(InetAddress serverAddress,
int port)
Creates a new syslog handler that sends the messages to the server represented by the
serverAddress
parameter on the port represented by the port parameter. |
SyslogHandler(InetAddress serverAddress,
int port,
SyslogHandler.Facility facility,
String hostname)
Creates a new syslog handler that sends the messages to the server represented by the
serverAddress
parameter on the port represented by the port parameter. |
SyslogHandler(InetAddress serverAddress,
int port,
SyslogHandler.Facility facility,
SyslogHandler.SyslogType syslogType,
String hostname)
Creates a new syslog handler that sends the messages to the server represented by the
serverAddress
parameter on the port represented by the port parameter. |
SyslogHandler(String serverHostname,
int port)
Creates a new syslog handler that sends the messages to the server represented by the
serverHostname
parameter on the port represented by the port parameter. |
SyslogHandler(String serverHostname,
int port,
SyslogHandler.Facility facility,
String hostname)
Creates a new syslog handler that sends the messages to the server represented by the
serverAddress
parameter on the port represented by the port parameter. |
SyslogHandler(String serverHostname,
int port,
SyslogHandler.Facility facility,
SyslogHandler.SyslogType syslogType,
String hostname)
Creates a new syslog handler that sends the messages to the server represented by the
serverAddress
parameter on the port represented by the port parameter. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close all child handlers.
|
void |
doPublish(ExtLogRecord record)
Do the actual work of publication; the record will have been filtered already.
|
String |
getAppName()
Gets app name used when formatting the message in RFC5424 format.
|
SyslogHandler.Facility |
getFacility()
Returns the facility used for calculating the priority of the message.
|
String |
getHostname()
Returns the host name which is used when sending the message to the syslog.
|
String |
getPid()
Returns the pid being used as the PROCID for RFC5424 messages.
|
int |
getPort()
Returns the port the syslogd is listening on.
|
InetAddress |
getServerAddress()
Returns the server address the messages are being sent to.
|
SyslogHandler.SyslogType |
getSyslogType()
Returns the
syslog type this handler is using to format the message sent. |
void |
setAppName(String appName)
Sets app name used when formatting the message in RFC5424 format.
|
void |
setFacility(SyslogHandler.Facility facility)
Sets the facility used when calculating the priority of the message.
|
void |
setFormatter(Formatter newFormatter) |
void |
setHostname(String hostname)
Sets the host name which is used when sending the message to the syslog.
|
void |
setPort(int port)
Sets the port the syslogd server is listening on.
|
void |
setServerAddress(InetAddress serverAddress)
Sets the server address the messages should be sent to.
|
void |
setServerHostname(String hostname)
Sets the server address the messages should be sent to.
|
void |
setSyslogType(SyslogHandler.SyslogType syslogType)
Set the
syslog type this handler should use to format the message sent. |
addHandler, checkAccess, checkAccess, clearHandlers, disableAccess, enableAccess, flush, getHandlers, isAutoFlush, isEnabled, protect, publish, publish, removeHandler, setAutoFlush, setEnabled, setEncoding, setErrorManager, setFilter, setHandlers, setLevel, unprotect
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError
public static final InetAddress DEFAULT_ADDRESS
public static final int DEFAULT_PORT
public static final SyslogHandler.Facility DEFAULT_FACILITY
public static final char NILVALUE
public SyslogHandler() throws IOException
IOException
- if an error occurs creating the UDP socketpublic SyslogHandler(String serverHostname, int port) throws IOException
serverHostname
parameter on the port represented by the port
parameter.serverHostname
- the server to send the messages toport
- the port the syslogd is listening onIOException
- if an error occurs creating the UDP socketpublic SyslogHandler(InetAddress serverAddress, int port) throws IOException
serverAddress
parameter on the port represented by the port
parameter.serverAddress
- the server to send the messages toport
- the port the syslogd is listening onIOException
- if an error occurs creating the UDP socketpublic SyslogHandler(String serverHostname, int port, SyslogHandler.Facility facility, String hostname) throws IOException
serverAddress
parameter on the port represented by the port
parameter.serverHostname
- the server to send the messages toport
- the port the syslogd is listening onfacility
- the facility to use when calculating priorityhostname
- the name of the host the messages are being sent fromIOException
- if an error occurs creating the UDP socketpublic SyslogHandler(InetAddress serverAddress, int port, SyslogHandler.Facility facility, String hostname) throws IOException
serverAddress
parameter on the port represented by the port
parameter.serverAddress
- the server to send the messages toport
- the port the syslogd is listening onfacility
- the facility to use when calculating priorityhostname
- the name of the host the messages are being sent fromIOException
- if an error occurs creating the UDP socketpublic SyslogHandler(String serverHostname, int port, SyslogHandler.Facility facility, SyslogHandler.SyslogType syslogType, String hostname) throws IOException
serverAddress
parameter on the port represented by the port
parameter.serverHostname
- the server to send the messages toport
- the port the syslogd is listening onfacility
- the facility to use when calculating prioritysyslogType
- the type of the syslog used to format the messagehostname
- the name of the host the messages are being sent fromIOException
- if an error occurs creating the UDP socketpublic SyslogHandler(InetAddress serverAddress, int port, SyslogHandler.Facility facility, SyslogHandler.SyslogType syslogType, String hostname) throws IOException
serverAddress
parameter on the port represented by the port
parameter.serverAddress
- the server to send the messages toport
- the port the syslogd is listening onfacility
- the facility to use when calculating prioritysyslogType
- the type of the syslog used to format the messagehostname
- the name of the host the messages are being sent fromIOException
- if an error occurs creating the UDP socketpublic final void doPublish(ExtLogRecord record)
ExtHandler
autoFlush
property is set to true
; if this behavior is to be
preserved in a subclass then this method should be called after the record is physically written.doPublish
in class ExtHandler
record
- the log record to publishpublic void close()
ExtHandler
close
in interface Closeable
close
in interface AutoCloseable
close
in class ExtHandler
public void setFormatter(Formatter newFormatter) throws SecurityException
setFormatter
in class ExtHandler
SecurityException
public String getAppName()
public void setAppName(String appName)
appName
- the app name to useSecurityException
- if a security manager exists and if the caller does not have LoggingPermission(control)
or the handler is protected
public String getPid()
public int getPort()
public void setPort(int port)
port
- the portSecurityException
- if a security manager exists and if the caller does not have LoggingPermission(control)
or the handler is protected
public SyslogHandler.Facility getFacility()
public void setFacility(SyslogHandler.Facility facility)
facility
- the facilitySecurityException
- if a security manager exists and if the caller does not have LoggingPermission(control)
or the handler is protected
public String getHostname()
public void setHostname(String hostname)
hostname
- the host namepublic void setServerHostname(String hostname) throws UnknownHostException
hostname
- the hostname used to created the connectionUnknownHostException
- if no IP address for the host could be found, or if a scope_id was specified for a
global IPv6 address.SecurityException
- if a security manager exists and if the caller does not have LoggingPermission(control)
or the handler is protected
InetAddress.getByName(String)
public InetAddress getServerAddress()
public void setServerAddress(InetAddress serverAddress)
serverAddress
- the server addressSecurityException
- if a security manager exists and if the caller does not have LoggingPermission(control)
or the handler is protected
public SyslogHandler.SyslogType getSyslogType()
syslog type
this handler is using to format the message sent.public void setSyslogType(SyslogHandler.SyslogType syslogType)
syslog type
this handler should use to format the message sent.syslogType
- the syslog typeSecurityException
- if a security manager exists and if the caller does not have LoggingPermission(control)
or the handler is protected
Copyright © 2013 JBoss by Red Hat. All Rights Reserved.