Class CreateSocketAppenderTask

  • All Implemented Interfaces:
    SubTask

    public class CreateSocketAppenderTask
    extends CreateOutputStreamAppenderTask

    A Rhino management sub task for creating a log socket appender.

    Ant Parameters
    Attribute Type Description Required

    appendername

    String

    Name of the appender to create. This name must be unique.

    Yes.

    remotehost

    String

    Name or IP address of the remote host to connect to.

    Yes.

    port

    int

    Port on the remote host to connect to.

    Yes.

    protocol

    String

    "TCP" (default), "SSL" or "UDP".

    No. If not specified, the default is TCP

    immediatefail

    boolean

    When set to true, log events will not wait to try to reconnect and will fail immediately if the socket is not available.

    Yes.

    immediateflush

    boolean

    When set to true, each write will be followed by a flush. This will guarantee the data is written to the socket but could impact performance.

    No. If not specified, defaults to true.

    bufferedio

    boolean

    When true, events are written to a buffer and the data will be written to the socket when the buffer is full or, if immediateFlush is set, when the record is written.

    No. If not specified, defaults to true.

    buffersize

    int

    When bufferedIO is true, this is the buffer size, the default is 8192 bytes.

    No.

    reconnectiondelaymillis

    int

    If set to a value greater than 0, after an error the SocketManager will attempt to reconnect to the server after waiting the specified number of milliseconds. If the reconnect fails then an exception will be thrown (which can be caught by the application if ignoreExceptions is set to false).

    No. If not specified, the default is 0

    connecttimeoutmillis

    int

    The connect timeout in milliseconds. The default is 0 (infinite timeout, like Socket.connect() methods).

    No.

    keystorelocation

    String

    The location of the KeyStore which is used to create an SslConfiguration

    No.

    keystorepassword

    String

    The password to access the KeyStore.

    No.

    truststorelocation

    String

    The location of the TrustStore which is used to create an SslConfiguration

    No.

    truststorepassword

    String

    The password of the TrustStore

    No.

    ignoreexceptions

    boolean

    The default is true, causing exceptions encountered while appending events to be internally logged and then ignored. When set to false exceptions will be propagated to the caller, instead.

    No.

    failonerror

    boolean

    Flag to control failure behaviour. If 'true', the sub task will throw a BuildException when an error is encountered. If 'false', the sub task will throw a NonFatalBuildException instead of a BuildException under specific circumstances. See below for conditions (if any) which will cause a NonFatalBuildException.

    No. Default value is taken from the Rhino management parent task.

    Nested elements

    Element

    Description

    Required

    filter

    A filter to select events that will be reported by this appender.

    No.

    layout

    The layout to use to format log events. If no layout is supplied the default pattern layout of "%m%n" will be used.

    No.

    NonFatalBuildException throw conditions
    • This task will throw a NonFatalBuildException if the appender cannot be created, eg. an appender with the same name already exists.

    This example creates a socket appender that sends JSON formatted log events to the host and port specified in the host and port properties. It filters outgoing messages to a maximum of 3 INFO level messages per second and 50 WARN/Warning messages. All Severe and ERROR messages are transmitted.

    <property name="host"value="localhost"/>
    <property name="port"value="5000"/>
    </slee-management>
        <createsocketappender appendername="bar"properties="protocol=UDP,bufferedIO=true,immediateFlush=false,immediateFail=false,bufferSize=65536">
            <propertyset>
                <propertyref name="host"/>
                <propertyref name="port"/>
            </propertyset>
            <component pluginname="filters">
                <component pluginname="BurstFilter"properties="level=WARN,rate=50"/>
                <component pluginname="BurstFilter"properties="level=INFO,rate=3"/>
                <component pluginname="ThresholdFilter"properties="level=INFO"/>
            </component>
            <component pluginname="JsonLayout"properties="compact=false,complete=false,includeStacktrace=true,properties=true"/>
        </createsocketappender>
    </slee-management>

    This example requires that the three jackson library jars jackson-annotations-2.5.0.jar, jackson-core-2.5.0.jar and jackson-databind-2.5.0.jar be present in rhino/lib/logging-plugins/ NOTE: the complete configuration property of JsonLayout should always be set to the default value of false as setting it to true will produce malformed JSON on unclean shutdown and node restart requiring manual cleanup. Do not use this layout with file appenders as the written JSON will be invalid.

    To search the output of the appender "bar", use a tool such as jq

    # Select all log entries for key "rhino"
    jq '.[] | select(.loggerName=="rhino")' < node-101/work/log/baz
    # Select all log entries for transaction ID 101:235885817027593
    jq '.[] | select(.contextMap.txID=="101:235885817027593")' < node-101/work/log/baz
    • Constructor Detail

      • CreateSocketAppenderTask

        public CreateSocketAppenderTask()
    • Method Detail

      • validateParameters

        protected void validateParameters()
                                   throws org.apache.tools.ant.BuildException
        Overrides:
        validateParameters in class CreateAppenderTask
        Throws:
        org.apache.tools.ant.BuildException
      • setRemoteHost

        public void setRemoteHost​(String remoteHost)
      • setPort

        public void setPort​(Integer port)
      • setProtocol

        public void setProtocol​(String protocol)
      • setImmediateFail

        public void setImmediateFail​(Boolean immediateFail)
      • setImmediateFlush

        public void setImmediateFlush​(Boolean immediateFlush)
      • setBufferedIO

        public void setBufferedIO​(Boolean bufferedIO)
      • setBufferSize

        public void setBufferSize​(Integer bufferSize)
      • setReconnectionDelayMillis

        public void setReconnectionDelayMillis​(Integer reconnectionDelayMillis)
      • setConnectTimeoutMillis

        public void setConnectTimeoutMillis​(Integer connectTimeoutMillis)