LoggerAppenderSocket

LoggerAppenderSocket appends to a network socket.

Layout

This appender requires a layout. If no layout is specified in configuration, LoggerLayoutSerialized will be used by default.

Prior to version 2.2, a layout was not required.

Parameters

The following parameters are available:

Parameter Type Required Default Description
remoteHost string Yes - Target host. On how to define a remote hostname see fsockopen() documentation.
port integer No 4446 Target port of the socket.
timeout integer No ini_get('default_socket_timeout') Timeout in ms.

Changelog

Version Description
2.2.0 From this version, the socket appender uses a layout to format the logging events. Because of this change, the following parameters are no longer used: useXml, locationInfo, log4jNamespace. These settings can be configured on the layout.

Examples

In this example, log events are sent to a socket server at localhost:4242, using the default (serialized) layout.

  • XML
  • PHP
<configuration xmlns="http://logging.apache.org/log4php/">
    <appender name="default" class="LoggerAppenderSocket">
        <param name="remoteHost" value="localhost" />
        <param name="port" value="4242" />
    </appender>
    <root>
        <appender_ref ref="default" />
    </root>
</configuration>
array(
    'appenders' => array(
        'default' => array(
            'class' => 'LoggerAppenderSocket',
            'params' => array(
                'remoteHost' => 'localhost',
                'port' => 4242
            ),
        ),
    ),
    'rootLogger' => array(
        'appenders' => array('default'),
    ),
);