Sends spi::LoggingEvent elements to a remote a log server, usually in XML format.
More...
#include <xmlsocketappender.h>
Inheritance diagram for log4cxx::net::XMLSocketAppender:
Connects to remote server at address and port.
Connects to remote server at host and port.
Connects to remote server at address and port.
Connects to remote server at host and port.
Activate the options that were previously set with calls to option setters.
Release any resources allocated within the appender such as file handles, network connections, etc.
This appender does not use a layout.
The RemoteHost option takes a string value which should be the host name of the server where a Apache Chainsaw or compatible is running.
Returns value of the RemoteHost option.
The Port option takes a positive integer representing the port where the server is waiting for connections.
Returns value of the Port option.
The LocationInfo option takes a boolean value.
Returns value of the LocationInfo option.
The ReconnectionDelay option takes a positive integer representing the number of milliseconds to wait between each failed connection attempt to the server.
Returns value of the ReconnectionDelay option.
Set option to value.
Finalize this appender by calling the derived class' close method.
Activate the options that were previously set with calls to option setters.
Set option to value.
Add a filter to end of the filter list.
Clear the filters chain.
Returns the head Filter.
Return the first filter in the filter chain for this
Appender.
Returns the layout of this appender.
Returns this appenders threshold level.
Check whether the message level is below the appender's threshold.
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific
AppenderSkeleton::append method.
Set the layout for this appender.
Set the threshold level.
Add a filter to the end of the filter list.
Returns the head Filter.
Clear the list of filters by removing all the filters in it.
Release any resources allocated within the appender such as file handles, network connections, etc.
Get the name of this appender.
Set the
Layout for this appender.
Returns this appenders layout.
Set the name of this appender.
Configurators call this method to determine if the appender requires a layout.
Activate the options that were previously set with calls to option setters.
Set option to value.
virtual const void *
cast (const
Class &clazz) const =0
The default port number of remote logging server (4560).
The default reconnection delay (30000 milliseconds or 30 seconds).
Unused.
Protected Member Functions
Subclasses of
AppenderSkeleton should implement this method to perform actual logging.
Subclasses of
AppenderSkeleton should implement this method to perform actual logging.
Detailed Description
Sends spi::LoggingEvent elements to a remote a log server, usually in XML format.
Here is an example configuration that writes JSON to the TCP input plugin of a fluent-bit log server running on the same system as the application:
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="A1" class="XMLSocketAppender">
<param name="RemoteHost" value="localhost" />
<param name="Port" value="5170" />
<layout class="JSONLayout"/>
</appender>
<root>
<priority value ="INFO" />
<appender-ref ref="A1" />
</root>
</log4j:configuration>
XMLSocketAppender has the following properties:
- The event will be logged with the same time stamp, NDC, location info as if it were logged locally by the client.
- 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.
Constructor & Destructor Documentation
◆ XMLSocketAppender() [1/3]
log4cxx::net::XMLSocketAppender::XMLSocketAppender
(
)
◆ ~XMLSocketAppender()
log4cxx::net::XMLSocketAppender::~XMLSocketAppender
(
)
◆ XMLSocketAppender() [2/3]
log4cxx::net::XMLSocketAppender::XMLSocketAppender
(
helpers::InetAddressPtr
address,
int
port
)
Connects to remote server at address and port.
◆ XMLSocketAppender() [3/3]
log4cxx::net::XMLSocketAppender::XMLSocketAppender
(
const
LogString &
host,
int
port
)
Connects to remote server at host and port.
Member Function Documentation
◆ append()
)
overrideprotectedvirtual
◆ cleanUp()
void log4cxx::net::XMLSocketAppender::cleanUp
(
helpers::Pool &
p )
overrideprotectedvirtual
◆ getDefaultDelay()
int log4cxx::net::XMLSocketAppender::getDefaultDelay
(
)
const
overrideprotectedvirtual
◆ getDefaultPort()
int log4cxx::net::XMLSocketAppender::getDefaultPort
(
)
const
overrideprotectedvirtual
◆ setSocket()
void log4cxx::net::XMLSocketAppender::setSocket
(
log4cxx::helpers::SocketPtr &
socket,
)
overrideprotectedvirtual
Member Data Documentation
◆ DEFAULT_PORT
int log4cxx::net::XMLSocketAppender::DEFAULT_PORT
static
The default port number of remote logging server (4560).
◆ DEFAULT_RECONNECTION_DELAY
int log4cxx::net::XMLSocketAppender::DEFAULT_RECONNECTION_DELAY
static
The default reconnection delay (30000 milliseconds or 30 seconds).
◆ MAX_EVENT_LEN
const int log4cxx::net::XMLSocketAppender::MAX_EVENT_LEN
static
The documentation for this class was generated from the following file: