/** * Returns the delimiter being used for the message if {@link #setUseMessageDelimiter(boolean) use message * delimiter} is set to {@code true}. * * @return the delimiter being used for the message */ public String getMessageDelimiter() { checkAccess(this); synchronized (outputLock) { return delimiter; } }
/** * Whether to append the message with a delimiter or not. * * @param useDelimiter {@code true} to append the message with a delimiter, otherwise {@code false} */ public void setUseMessageDelimiter(final boolean useDelimiter) { checkAccess(this); synchronized (outputLock) { this.useDelimiter = useDelimiter; } }
/** * Sets the client socket factory used to create sockets. * * @param clientSocketFactory the client socket factory to use */ public void setClientSocketFactory(final ClientSocketFactory clientSocketFactory) { checkAccess(this); synchronized (outputLock) { this.clientSocketFactory = clientSocketFactory; initializeConnection = true; } }
/** * Sets the maximum length, in bytes, of the message allowed to tbe sent. Note that the message length includes the * header and the message itself. * * @param maxLen the maximum length, in bytes, allowed to be sent to the syslog server */ public void setMaxLength(final int maxLen) { checkAccess(this); synchronized (outputLock) { this.maxLen = maxLen; } }
/** * Sets the message delimiter to be used if {@link #setUseMessageDelimiter(boolean) use message * delimiter} is set to {@code true}. * * @param delimiter the delimiter to use for the message */ public void setMessageDelimiter(final String delimiter) { checkAccess(this); synchronized (outputLock) { this.delimiter = delimiter; } }
/** * Sets the protocol used to connect to the syslog server * * @param type the protocol */ public void setProtocol(final Protocol type) { checkAccess(this); synchronized (outputLock) { this.protocol = type; initializeConnection = true; } }
/** * Set the {@link SyslogType syslog type} this handler should use to format the message sent. * * @param syslogType the syslog type * * @throws SecurityException if a security manager exists and if the caller does not have {@code * LoggingPermission(control)} or the handler is {@link #protect(Object) protected} */ public void setSyslogType(final SyslogType syslogType) { checkAccess(this); synchronized (outputLock) { this.syslogType = syslogType; } }
/** * Sets the facility used when calculating the priority of the message. * * @param facility the facility * * @throws SecurityException if a security manager exists and if the caller does not have {@code * LoggingPermission(control)} or the handler is {@link #protect(Object) protected} */ public void setFacility(final Facility facility) { checkAccess(this); synchronized (outputLock) { this.facility = facility; } }
/** * Sets the port the syslogd server is listening on. * * @param port the port * * @throws SecurityException if a security manager exists and if the caller does not have {@code * LoggingPermission(control)} or the handler is {@link #protect(Object) protected} */ public void setPort(final int port) { checkAccess(this); synchronized (outputLock) { this.port = port; initializeConnection = true; } }
/** * Sets the server address the messages should be sent to. * * @param serverAddress the server address * * @throws SecurityException if a security manager exists and if the caller does not have {@code * LoggingPermission(control)} or the handler is {@link #protect(Object) protected} */ public void setServerAddress(final InetAddress serverAddress) { checkAccess(this); synchronized (outputLock) { this.serverAddress = serverAddress; initializeConnection = true; } }
/** * Set to {@code true} if the message should be truncated if the total length the {@link #getMaxLength() maximum * length}. * <p/> * Set to {@code false} if the message should be split and sent as multiple messages. The header will remain the * same for each message sent. The wrapping is not a word based wrap and could split words between log messages. * * @param truncate {@code true} to truncate, otherwise {@code false} to send multiple messages */ public void setTruncate(final boolean truncate) { checkAccess(this); synchronized (outputLock) { this.truncate = truncate; } }
/** * Set to {@code true} if the message being sent should be prefixed with the size of the message. * <p/> * See <a href="http://tools.ietf.org/html/rfc6587#section-3.4.1">http://tools.ietf.org/html/rfc6587</a> * for more details on framing types. * * @param useCountingFraming {@code true} if the message being sent should be prefixed with the size of the message * * @throws SecurityException if a security manager exists and if the caller does not have {@code * LoggingPermission(control)} or the handler is {@link #protect(Object) protected} */ public void setUseCountingFraming(final boolean useCountingFraming) { checkAccess(this); synchronized (outputLock) { this.useCountingFraming = useCountingFraming; } }
/** * <b>Note:</b> This method no longer does anything. * <p/> * Set to {@code true} to escape characters within the message string that are below decimal 32. These values are * tradition US-ASCII control values. The values will be replaced in a {@code #xxx} format where {@code xxx} is the * octal value of the character being replaced. * * @param escapeEnabled {@code true} to escape characters, {@code false} to not escape characters * * @deprecated escaping message values is not required per <a href="http://tools.ietf.org/html/rfc5424#section-6.2">RFC5424</a> * and is no longer supported in this handler */ @Deprecated public void setEscapeEnabled(final boolean escapeEnabled) { checkAccess(this); }
/** * Sets app name used when formatting the message in RFC5424 format. By default the app name is "java". If * set to {@code null} the {@link ExtLogRecord#getProcessName()} will be used. * * @param appName the app name to use * * @throws SecurityException if a security manager exists and if the caller does not have {@code * LoggingPermission(control)} or the handler is {@link #protect(Object) protected} */ public void setAppName(final String appName) { checkAccess(this); synchronized (outputLock) { this.appName = checkPrintableAscii("app name", appName); } }
/** * Sets the output stream for the syslog handler to write to. * <p/> * Setting the output stream closes any already established connections or open output streams and will not open * any new connections until the output stream is set to {@code null}. The {@link * #setProtocol(org.jboss.logmanager.handlers.SyslogHandler.Protocol) protocol}, {@link * #setServerAddress(java.net.InetAddress), server address}, {@link #setServerHostname(String) server hostname} or * {@link #setPort(int) port} have no effect when the output stream is set. * * @param out the output stream to write to */ public void setOutputStream(final OutputStream out) { checkAccess(this); setOutputStream(out, true); }
/** * Sets the server address the messages should be sent to. * * @param hostname the hostname used to created the connection * * @throws UnknownHostException if no IP address for the host could be found, or if a scope_id was specified for a * global IPv6 address. * @throws SecurityException if a security manager exists and if the caller does not have {@code * LoggingPermission(control)} or the handler is {@link #protect(Object) protected} * @see InetAddress#getByName(String) */ public void setServerHostname(final String hostname) throws UnknownHostException { checkAccess(this); setServerAddress(InetAddress.getByName(hostname)); }
/** * Enables or disables blocking when attempting to reconnect a {@link org.jboss.logmanager.handlers.SyslogHandler.Protocol#TCP * TCP} or {@link org.jboss.logmanager.handlers.SyslogHandler.Protocol#SSL_TCP SSL TCP} protocol. * <p/> * If set to {@code true} the {@code publish} methods will block when attempting to reconnect. This is only * advisable to be set to {@code true} if using an asynchronous handler. * * @param blockOnReconnect {@code true} to block when reconnecting or {@code false} to reconnect asynchronously * discarding any new messages coming in */ public void setBlockOnReconnect(final boolean blockOnReconnect) { checkAccess(this); synchronized (outputLock) { this.blockOnReconnect = blockOnReconnect; if (out instanceof TcpOutputStream) { ((TcpOutputStream) out).setBlockOnReconnect(blockOnReconnect); } } }
/** * Sets the host name which is used when sending the message to the syslog. * <p/> * This should be the name of the host sending the log messages, Note that the name cannot contain any whitespace. * <p/> * The hostname should be the most specific available value first. The order of preference for the contents of the * hostname is as follows: * <ol> * <li>FQDN</li> * <li>Static IP address</li> * <li>hostname</li> * <li>Dynamic IP address</li> * <li>{@code null}</li> * </ol> * * @param hostname the host name */ public void setHostname(final String hostname) { checkAccess(this); synchronized (outputLock) { this.hostname = checkPrintableAscii("host name", hostname); } }