This handler can write to syslog servers that accept the RFC3164
and RFC5424 formats. Writes can be done via TCP, SSL over TCP or
UDP protocols. You can also override the output stream if a custom
protocol is needed.
| Configuration Properties: | |||
| Property | Description | Type | Default |
|---|---|---|---|
| serverHostname | The address of the syslog server | String |
localhost |
| port | The port of the syslog server | int | 514 |
| facility | The facility used to calculate the priority of the log message | Facility |
USER_LEVEL |
| appName | The name of the application that is logging | String |
java |
| hostname | The name of the host the messages are being sent from. See setHostname(String) for more
details |
String |
null
|
| syslogType | The type of the syslog used to format the message | SyslogType |
RFC5424 |
| protocol | The protocol to send the message over | Protocol |
UDP |
| delimiter | The delimiter to use at the end of the message if useDelimiter
is set to true
|
String |
For UDP null
- For TCP or SSL_TCP \n |
| useDelimiter | Whether or not the message should be appended with a delimiter |
boolean |
For UDP false
- For TCP or SSL_TCP true
|
| useCountingFraming | Prefixes the size of the message, mainly used for TCP or SSL_TCP, connections to the message being sent to the syslog server. See http://tools.ietf.org/html/rfc6587
for more details on framing types. |
boolean |
false
|
| truncate | Whether or not a message, including the header, should truncate the message if the length in bytes is
greater than the maximum length. If set to false
messages will be split and sent
with the same header values. |
boolean |
true
|
| maxLength | The maximum length a log message, including the header, is allowed to be. | int |
For RFC3164 1024 (1k) - For RFC5424 2048
(2k) |
| Modifier and Type | Class and Description |
|---|---|
| public static enum | SyslogHandler.
Facility as defined by RFC-5424 (http://tools.ietf.org/html/rfc5424) and RFC-3164 (http://tools.ietf.org/html/rfc3164). |
| public static enum | SyslogHandler.
The type of socket the syslog should write to |
| public static enum | SyslogHandler.
Severity as defined by RFC-5424 (http://tools.ietf.org/html/rfc5424) and RFC-3164 (http://tools.ietf.org/html/rfc3164). |
| public static enum | SyslogHandler.
The syslog type used for formatting the message. |
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private boolean | |
| private ClientSocketFactory | |
| public static final InetAddress | |
| public static final String | |
| public static final SyslogHandler. | |
| public static final int | |
| public static final int | |
| private String | |
| private SyslogHandler. | |
| private String | |
| private boolean | |
| private int | |
| public static final String | |
| private OutputStream | |
| private boolean | |
| private int | |
| private static final Pattern | |
| private SyslogHandler. | |
| private static final DateTimeFormatter | |
| private static final DateTimeFormatter | |
| private InetAddress | |
| private SyslogHandler. | |
| private boolean | |
| private boolean | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SyslogHandler(final String
the server to send the messages to serverHostname, final int the port the syslogd is listening on port)Creates a new syslog handler that sends the messages to the server represented by the |
| public | SyslogHandler(final InetAddress
the server to send the messages to serverAddress, final int the port the syslogd is listening on port)Creates a new syslog handler that sends the messages to the server represented by the |
| public | SyslogHandler(final String
the server to send the messages to serverHostname, final int the port the syslogd is listening on port, final SyslogHandler.the facility to use when calculating priority facility,the name of the host the messages are being sent from see hostname)setHostname(String) for
details on the hostnameCreates a new syslog handler that sends the messages to the server represented by the |
| public | SyslogHandler(final InetAddress
the server to send the messages to serverAddress, final int the port the syslogd is listening on port, final SyslogHandler.the facility to use when calculating priority facility,the name of the host the messages are being sent from see hostname)setHostname(String) for
details on the hostnameCreates a new syslog handler that sends the messages to the server represented by the |
| public | SyslogHandler(final String
the server to send the messages to serverHostname, final int the port the syslogd is listening on port, final SyslogHandler.the facility to use when calculating priority facility,the type of the syslog used to format the message syslogType,the name of the host the messages are being sent from see hostname)setHostname(String) for
details on the hostnameCreates a new syslog handler that sends the messages to the server represented by the |
| public | SyslogHandler(final InetAddress
the server to send the messages to serverAddress, final int the port the syslogd is listening on port, final SyslogHandler.the facility to use when calculating priority facility,the type of the syslog used to format the message syslogType,the name of the host the messages are being sent from see hostname)setHostname(String) for
details on the hostnameCreates a new syslog handler that sends the messages to the server represented by the |
| public | SyslogHandler(final String
the server to send the messages to serverHostname, final int the port the syslogd is listening on port, final SyslogHandler.the facility to use when calculating priority facility,the type of the syslog used to format the message syslogType,the socket type used to the connect to the syslog server protocol,the name of the host the messages are being sent from see hostname)setHostname(String) for
details on the hostnameCreates a new syslog handler that sends the messages to the server represented by the |
| public | SyslogHandler(final InetAddress
the server to send the messages to serverAddress, final int the port the syslogd is listening on port, final SyslogHandler.the facility to use when calculating priority facility,the type of the syslog used to format the message syslogType,the socket type used to the connect to the syslog server protocol,the name of the host the messages are being sent from see hostname)setHostname(String) for
details on the hostnameCreates a new syslog handler that sends the messages to the server represented by the |
| Modifier and Type | Method and Description |
|---|---|
| protected int | |
| private static String | |
| public void | close()
Overrides org. Implements java. Close all child handlers. |
| protected byte[] | |
| protected byte[] | |
| public final void | doPublish(final ExtLogRecord
the log record to publish record)Overrides org. Do the actual work of publication; the record will have been filtered already. |
| public void | flush()
Overrides org. Implements java. Flush all child handlers. |
| public String | Returns: the app name being usedGets app name used when formatting the message in RFC5424 format. |
| private ClientSocketFactory | |
| public SyslogHandler. | Returns: the facilityReturns the facility used for calculating the priority of the message. |
| public String | Returns: the host nameReturns the host name which is used when sending the message to the syslog. |
| public int | Returns: the maximum length, in bytes, of the message allowed to be sentReturns the maximum length, in bytes, of the message allowed to be sent. |
| public String | Returns: the delimiter being used for the messageReturns the delimiter being used for the message if |
| public String | Returns: the pid ornull if the pid could not be determined
Deprecated
for removal since 3.1. Always returns the current process ID, as a string.
Returns the pid being used as the PROCID for RFC5424 messages. |
| public int | |
| public SyslogHandler. | |
| public InetAddress | Returns: the server addressReturns the server address the messages are being sent to. |
| public SyslogHandler. | Returns: the syslog typeReturns the |
| private void | |
| public boolean | Returns: true if blocking is enabled, otherwise falseIndicates whether or not a |
| public boolean | Returns: false
Deprecated
escaping message values is not required per
RFC5424
and is no longer supported in this handler
Checks whether or not characters below decimal 32, traditional US-ASCII control values expect |
| public boolean | Returns: true if the message should be truncated if too large, otherwise falseChecks if the message should truncated if the total length exceeds the |
| public boolean | Returns: the message transfer typeReturns |
| public boolean | Returns: true to append the message with a delimiter, otherwise falseChecks whether to append the message with a delimiter or not. |
| pack-priv static void | |
| pack-priv static void | |
| private void | sendMessage(final byte[] header, final ByteStringBuilder
the message to write message, final byte[] trailer)Writes the message to the output stream. |
| public void | setAppName(final String
the app name to use appName)Sets app name used when formatting the message in RFC5424 format. |
| public void | setBlockOnReconnect(final boolean
true to block when reconnecting or false to reconnect asynchronously
discarding any new messages coming inEnables or disables blocking when attempting to reconnect a |
| public void | setClientSocketFactory(final ClientSocketFactory
the client socket factory to use clientSocketFactory)Sets the client socket factory used to create sockets. |
| public void | setEscapeEnabled(final boolean
true to escape characters, false to not escape characters
Deprecated
escaping message values is not required per
RFC5424
and is no longer supported in this handler
Set to |
| public void | setFacility(final SyslogHandler.
the facility facilitySets the facility used when calculating the priority of the message. |
| public void | setHostname(final String
the host name hostname)Sets the host name which is used when sending the message to the syslog. |
| public void | setMaxLength(final int
the maximum length, in bytes, allowed to be sent to the syslog server maxLen)Sets the maximum length, in bytes, of the message allowed to tbe sent. |
| public void | setMessageDelimiter(final String
the delimiter to use for the message delimiter)Sets the message delimiter to be used if |
| public void | setOutputStream(final OutputStream
the output stream to write to out)Sets the output stream for the syslog handler to write to. |
| private void | |
| public void | |
| public void | setProtocol(final SyslogHandler.
the protocol typeSets the protocol used to connect to the syslog server |
| public void | setServerAddress(final InetAddress
the server address serverAddress)Sets the server address the messages should be sent to. |
| public void | setServerHostname(final String
the hostname used to created the connection hostname)Sets the server address the messages should be sent to. |
| public void | setSyslogType(final SyslogHandler.
the syslog type syslogTypeSet the |
| public void | setTruncate(final boolean
true to truncate, otherwise false to send multiple messagesSet to |
| public void | setUseCountingFraming(final boolean
true if the message being sent should be prefixed with the size of the messageSet to |
| public void | setUseMessageDelimiter(final boolean
true to append the message with a delimiter, otherwise falseWhether to append the message with a delimiter or not. |