Apache log4cxx: XMLSocketAppender Class Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# XMLSocketAppender Class Reference

Inherits SocketAppenderSkeleton.

List of all members.

## Detailed Description

Sends LoggingEvent objects in XML format to a remote a log server, usually a XMLSocketNode.

The XMLSocketAppender has the following properties:

- If sent to a XMLSocketNode, remote logging is non-intrusive as far as the log event is concerned. In other words, the event will be logged with the same time stamp, NDC, location info as if it were logged locally by the client.

- XMLSocketAppenders use exclusively an XMLLayout. They ship an XML stream representing a LoggingEvent object to the server side.

- Remote logging uses the TCP protocol. Consequently, if the server is reachable, then log events will eventually arrive at the server.

- If the remote server is down, the logging requests are simply dropped. However, if and when the server comes back up, then event transmission is resumed transparently. This transparent reconneciton is performed by a connector thread which periodically attempts to connect to the server.

- Logging events are automatically buffered by the native TCP implementation. This means that if the link to server is slow but still faster than the rate of (log) event production by the client, the client will not be affected by the slow network connection. However, if the network connection is slower then the rate of event production, then the client can only progress at the network rate. In particular, if the network link to the the server is down, the client will be blocked.
  On the other hand, if the network link is up, but the server is down, the client will not be blocked when making log requests but the log events will be lost due to server unavailability.

- Even if an `XMLSocketAppender` is no longer attached to any logger, it will not be destroyed in the presence of a connector thread. A connector thread exists only if the connection to the server is down. To avoid this destruction problem, you should close the the `XMLSocketAppender` explicitly. See also next item.
  Long lived applications which create/destroy many `XMLSocketAppender` instances should be aware of this destruction problem. Most other applications can safely ignore it.

- If the application hosting the `XMLSocketAppender` exits before the `XMLSocketAppender` is closed either explicitly or subsequent to destruction, then there might be untransmitted data in the pipe which might be lost.
  To avoid lost data, it is usually sufficient to close the `XMLSocketAppender` either explicitly or by calling the LogManager::shutdown method before exiting the application.

## Public Member Functions
| XMLSocketAppender ()
| ~XMLSocketAppender ()
| XMLSocketAppender (helpers::InetAddressPtr address, int port)
| Connects to remote server at `address` and `port`.
| XMLSocketAppender (const LogString &host, int port)
| Connects to remote server at `host` and `port`.
## Static Public Attributes
static int | DEFAULT_PORT
| The default port number of remote logging server (4560).
static int | DEFAULT_RECONNECTION_DELAY
| The default reconnection delay (30000 milliseconds or 30 seconds).
static const int | MAX_EVENT_LEN
| An event XML stream cannot exceed 1024 bytes.
## Protected Member Functions
virtual void | setSocket (log4cxx::helpers::SocketPtr &socket, log4cxx::helpers::Pool &p)
virtual void | cleanUp (log4cxx::helpers::Pool &p)
virtual int | getDefaultDelay () const
virtual int | getDefaultPort () const
void | append (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool)
| Subclasses of `AppenderSkeleton` should implement this method to perform actual logging.

## Constructor & Destructor Documentation

XMLSocketAppender | ( |  | ) |

~XMLSocketAppender | ( |  | ) |

XMLSocketAppender | ( | helpers::InetAddressPtr | address,
|  | int | port
| ) |

| Connects to remote server at `address` and `port`.

XMLSocketAppender | ( | const LogString & | host,
|  | int | port
| ) |

| Connects to remote server at `host` and `port`.

## Member Function Documentation

void append | ( | const spi::LoggingEventPtr & | event,
|  | log4cxx::helpers::Pool & | pool
| ) | `[protected, virtual]`

| Subclasses of `AppenderSkeleton` should implement this method to perform actual logging. See also AppenderSkeleton::doAppend method. Implements AppenderSkeleton.

virtual void cleanUp | ( | log4cxx::helpers::Pool & | p | ) | `[protected, virtual]`

| Implements SocketAppenderSkeleton.

virtual int getDefaultDelay | ( |  | ) | const`[protected, virtual]`

| Implements SocketAppenderSkeleton.

virtual int getDefaultPort | ( |  | ) | const`[protected, virtual]`

| Implements SocketAppenderSkeleton.

virtual void setSocket | ( | log4cxx::helpers::SocketPtr & | socket,
|  | log4cxx::helpers::Pool & | p
| ) | `[protected, virtual]`

| Implements SocketAppenderSkeleton.

## Member Data Documentation

int DEFAULT_PORT`[static]`

| The default port number of remote logging server (4560).

int DEFAULT_RECONNECTION_DELAY`[static]`

| The default reconnection delay (30000 milliseconds or 30 seconds).

const int MAX_EVENT_LEN`[static]`

| An event XML stream cannot exceed 1024 bytes.

The documentation for this class was generated from the following file:

- xmlsocketappender.h