blob: 72c520374f831d42af5dd4cd245458ceb6989ab6 [file] [log] [blame]
<html>
<head>
<title>
log4cxx - Documentation
</title>
<link href="../css/doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body bgcolor="#ffffff" text="#000000" link="#525D76">
<!-- START Header table -->
<table border="0" cellspacing="0" width="90%">
<!-- TOP IMAGE -->
<tr>
<td colspan="2">
<a href="http://logging.apache.org">
<img src="http://logging.apache.org/images/ls-logo.jpg" align="left" border="0"/>
</a>
</td>
</tr>
</table>
<!-- END Header table -->
<!-- START main table -->
<table id="main" border="0" width="90%" cellspacing="2" cellpadding="0">
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr>
<!-- LEFT SIDE NAVIGATION -->
<td id="navbar" valign="top">
<!-- ============================================================ -->
<table id="navbar" border="0" cellspacing="0" cellpadding="0">
<tr >
<td class="navbarHeader" nowrap="true">
<strong>Apache</strong>
</td>
</tr>
<tr><td class="navbarItem"><small> <a href="http://www.apache.org">Apache Home</a>
</small></td></tr>
<tr><td class="navbarItem"><small> <a href="http://logging.apache.org/">Logging Services</a>
</small></td></tr>
<tr >
<td class="navbarHeader" nowrap="true">
<strong>log4cxx project</strong>
</td>
</tr>
<tr><td class="navbarItem"><small> <a href="../index.html">About</a>
</small></td></tr>
<tr><td class="navbarItem"><small> <a href="../news.html">News</a>
</small></td></tr>
<tr><td class="navbarItem"><small> <a href="../team.html">Team</a>
</small></td></tr>
<tr><td class="navbarItem"><small> <a href="../manual/index.html">Documentation</a>
</small></td></tr>
<tr><td class="navbarItem"><small> <a href="../performance.html">Performance</a>
</small></td></tr>
<tr><td class="navbarItem"><small> <a href="../download.html">Download</a>
</small></td></tr>
</table>
</td>
<td id="mainContents" align="left" valign="top">
<hr>
<!-- Generated by Doxygen 1.3.5 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a></div>
<h1>SocketHubAppender Class Reference</h1>Inheritance diagram for SocketHubAppender:<p><center><img src="classlog4cxx_1_1net_1_1SocketHubAppender__inherit__graph.png" border="0" usemap="#SocketHubAppender__inherit__map" alt="Inheritance graph"></center>
<map name="SocketHubAppender__inherit__map">
<area href="classlog4cxx_1_1AppenderSkeleton.html" shape="rect" coords="36,242,158,266" alt="">
<area href="classlog4cxx_1_1Appender.html" shape="rect" coords="13,168,85,191" alt="">
<area href="classlog4cxx_1_1spi_1_1OptionHandler.html" shape="rect" coords="6,93,102,117" alt="">
<area href="classlog4cxx_1_1helpers_1_1Object.html" shape="rect" coords="73,18,124,42" alt="">
<area href="classlog4cxx_1_1helpers_1_1ObjectImpl.html" shape="rect" coords="109,168,184,191" alt="">
</map>
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center>Collaboration diagram for SocketHubAppender:<p><center><img src="classlog4cxx_1_1net_1_1SocketHubAppender__coll__graph.png" border="0" usemap="#SocketHubAppender__coll__map" alt="Collaboration graph"></center>
<map name="SocketHubAppender__coll__map">
<area href="classlog4cxx_1_1AppenderSkeleton.html" shape="rect" coords="90,346,213,370" alt="">
<area href="classlog4cxx_1_1Appender.html" shape="rect" coords="21,197,93,221" alt="">
<area href="classlog4cxx_1_1spi_1_1OptionHandler.html" shape="rect" coords="6,96,102,120" alt="">
<area href="classlog4cxx_1_1helpers_1_1Object.html" shape="rect" coords="80,18,130,42" alt="">
<area href="classlog4cxx_1_1helpers_1_1ObjectImpl.html" shape="rect" coords="100,146,174,170" alt="">
<area href="classlog4cxx_1_1helpers_1_1ObjectPtrT.html" shape="rect" coords="217,197,289,221" alt="">
</map>
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center><a href="classlog4cxx_1_1net_1_1SocketHubAppender-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a2">SocketHubAppender</a> (int port)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a3">activateOptions</a> ()</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a4">setOption</a> (const String &amp;option, const String &amp;value)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a5">close</a> ()</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a6">cleanUp</a> ()</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a7">append</a> (const <a class="el" href="classlog4cxx_1_1helpers_1_1ObjectPtrT.html">spi::LoggingEventPtr</a> &amp;event)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>virtual bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a8">requiresLayout</a> () const </td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a9">setPort</a> (int port)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a10">getPort</a> () const </td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a11">setLocationInfo</a> (bool locationInfo)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a12">getLocationInfo</a> () const </td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Sends <a class="el" href="classlog4cxx_1_1spi_1_1LoggingEvent.html">LoggingEvent</a> objects to a set of remote log servers, usually a <a class="el" href="classlog4cxx_1_1net_1_1SocketNode.html">SocketNode</a>.<p>
Acts just like <a class="el" href="classlog4cxx_1_1net_1_1SocketAppender.html">SocketAppender</a> except that instead of connecting to a given remote log server, <code><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html">SocketHubAppender</a></code> accepts connections from the remote log servers as clients. It can accept more than one connection. When a log event is received, the event is sent to the set of currently connected remote log servers. Implemented this way it does not require any update to the configuration file to send data to another remote log server. The remote log server simply connects to the host and port the <code><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html">SocketHubAppender</a></code> is running on.<p>
The <code><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html">SocketHubAppender</a></code> does not store events such that the remote side will events that arrived after the establishment of its connection. Once connected, events arrive in order as guaranteed by the TCP protocol.<p>
This implementation borrows heavily from the <a class="el" href="classlog4cxx_1_1net_1_1SocketAppender.html">SocketAppender</a>.<p>
The <a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html">SocketHubAppender</a> has the following characteristics:<p>
<ul>
<li>If sent to a <a class="el" href="classlog4cxx_1_1net_1_1SocketNode.html">SocketNode</a>, 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, <a class="el" href="classlog4cxx_1_1NDC.html">NDC</a>, location info as if it were logged locally.</li></ul>
<p>
<ul>
<li><code><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html">SocketHubAppender</a></code> does not use a layout. It ships a serialized <a class="el" href="classlog4cxx_1_1spi_1_1LoggingEvent.html">spi::LoggingEvent</a> object to the remote side.</li></ul>
<p>
<ul>
<li><code><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html">SocketHubAppender</a></code> relies on the TCP protocol. Consequently, if the remote side is reachable, then log events will eventually arrive at remote client.</li></ul>
<p>
<ul>
<li>If no remote clients are attached, the logging requests are simply dropped.</li></ul>
<p>
<ul>
<li>Logging events are automatically <em>buffered</em> by the native TCP implementation. This means that if the link to remote client is slow but still faster than the rate of (log) event production, the application will not be affected by the slow network connection. However, if the network connection is slower then the rate of event production, then the local application can only progress at the network rate. In particular, if the network link to the the remote client is down, the application will be blocked. <br>
<br>
On the other hand, if the network link is up, but the remote client is down, the client will not be blocked when making log requests but the log events will be lost due to client unavailability. <br>
<br>
The single remote client case extends to multiple clients connections. The rate of logging will be determined by the slowest link.</li></ul>
<p>
<ul>
<li>If the application hosting the <code><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html">SocketHubAppender</a></code> exits before the <code><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html">SocketHubAppender</a></code> is closed either explicitly or subsequent to garbage collection, then there might be untransmitted data in the pipe which might be lost. This is a common problem on Windows based systems. <br>
<br>
To avoid lost data, it is usually sufficient to <a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a5">close</a> the <code><a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html">SocketHubAppender</a></code> either explicitly or by calling the <a class="el" href="classlog4cxx_1_1LogManager.html#e7">LogManager::shutdown</a> method before exiting the application.</li></ul>
<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="a2" doxytag="log4cxx::net::SocketHubAppender::SocketHubAppender" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html">SocketHubAppender</a> </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">int&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>port</em> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Connects to remote server at <code>address</code> and <code>port</code>. </td>
</tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="a3" doxytag="log4cxx::net::SocketHubAppender::activateOptions" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void activateOptions </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Set up the socket server on the specified port.
<p>
Reimplemented from <a class="el" href="classlog4cxx_1_1AppenderSkeleton.html#a2">AppenderSkeleton</a>. </td>
</tr>
</table>
<a class="anchor" name="a7" doxytag="log4cxx::net::SocketHubAppender::append" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void append </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const <a class="el" href="classlog4cxx_1_1helpers_1_1ObjectPtrT.html">spi::LoggingEventPtr</a> &amp;&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>event</em> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Append an event to all of current connections.
<p>
Implements <a class="el" href="classlog4cxx_1_1AppenderSkeleton.html#b0">AppenderSkeleton</a>. </td>
</tr>
</table>
<a class="anchor" name="a6" doxytag="log4cxx::net::SocketHubAppender::cleanUp" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void cleanUp </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Release the underlying ServerMonitor thread, and drop the connections to all connected remote servers. </td>
</tr>
</table>
<a class="anchor" name="a5" doxytag="log4cxx::net::SocketHubAppender::close" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void close </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Close this appender. <p>
This will mark the appender as closed and call then <a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html#a6">cleanUp</a> method.
<p>
Implements <a class="el" href="classlog4cxx_1_1Appender.html#a4">Appender</a>. </td>
</tr>
</table>
<a class="anchor" name="a12" doxytag="log4cxx::net::SocketHubAppender::getLocationInfo" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> bool getLocationInfo </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap> const<code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Returns value of the <b>LocationInfo</b> option. </td>
</tr>
</table>
<a class="anchor" name="a10" doxytag="log4cxx::net::SocketHubAppender::getPort" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> int getPort </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap> const<code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Returns value of the <b>Port</b> option. </td>
</tr>
</table>
<a class="anchor" name="a8" doxytag="log4cxx::net::SocketHubAppender::requiresLayout" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> virtual bool requiresLayout </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap> const<code> [inline, virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
The <a class="el" href="classlog4cxx_1_1net_1_1SocketHubAppender.html">SocketHubAppender</a> does not use a layout. Hence, this method returns <code>false</code>.
<p>
Implements <a class="el" href="classlog4cxx_1_1Appender.html#a12">Appender</a>. </td>
</tr>
</table>
<a class="anchor" name="a11" doxytag="log4cxx::net::SocketHubAppender::setLocationInfo" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void setLocationInfo </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">bool&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>locationInfo</em> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
The <b>LocationInfo</b> option takes a boolean value. If true, the information sent to the remote host will include location information. By default no location information is sent to the server. </td>
</tr>
</table>
<a class="anchor" name="a4" doxytag="log4cxx::net::SocketHubAppender::setOption" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void setOption </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const String &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>option</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>const String &amp;&nbsp;</td>
<td class="mdname" nowrap> <em>value</em></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"><code> [virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Set options
<p>
Reimplemented from <a class="el" href="classlog4cxx_1_1AppenderSkeleton.html#a3">AppenderSkeleton</a>. </td>
</tr>
</table>
<a class="anchor" name="a9" doxytag="log4cxx::net::SocketHubAppender::setPort" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void setPort </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">int&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>port</em> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
The <b>Port</b> option takes a positive integer representing the port where the server is waiting for connections. </td>
</tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li>sockethubappender.h<li>sockethubappender.cpp</ul>
</td>
</tr>
<!-- FOOTER -->
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
Copyright &#169; 1999-2004, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
<!-- END main table -->
</body>
</html>
<!-- end the processing -->