cvs commit: jakarta-log4j/src/java/org/apache/log4j/net SocketHubAppender.java
[email protected] 25 Mar 2002 22:37:21 -0000
| Newsgroups | gmane.comp.jakarta.log4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
ceki 02/03/25 14:37:21
Modified: . build.xml
docs HISTORY
src/java/org/apache/log4j/jdbc JDBCAppender.java
src/java/org/apache/log4j/net SocketHubAppender.java
Log:
Doc changes.
Revision Changes Path
1.24 +1 -0 jakarta-log4j/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-log4j/build.xml,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- build.xml 24 Mar 2002 23:37:11 -0000 1.23
+++ build.xml 25 Mar 2002 22:37:21 -0000 1.24
@@ -311,6 +311,7 @@
org.apache.log4j.net,
org.apache.log4j.nt,
org.apache.log4j.or,
+ org.apache.log4j.jdbc,
org.apache.log4j.or.sax,
org.apache.log4j.performance,
org.apache.log4j.spi,
1.86 +8 -0 jakarta-log4j/docs/HISTORY
Index: HISTORY
===================================================================
RCS file: /home/cvs/jakarta-log4j/docs/HISTORY,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- HISTORY 11 Mar 2002 23:43:45 -0000 1.85
+++ HISTORY 25 Mar 2002 22:37:21 -0000 1.86
@@ -14,6 +14,14 @@
- In the Category class, the .getChainedPriority method has been
replaced with getEffectiveLevel method. [*]
+ - Added the org.apache.log4j.jdbc.JDBCAppender which as the name
+ indicates sends events to a database using the JDBC API. Thanks to
+ Kevin Steppe for supplying the code. [*]
+
+ - Added SocketHubAppender class as contributed by Mark Womack. This
+ appender sends LoggingEvent objects to a set of remote a log
+ servers. [*]
+
(beta4)
- Replaced the custom class loading based on the thread context class
1.3 +41 -33 jakarta-log4j/src/java/org/apache/log4j/jdbc/JDBCAppender.java
Index: JDBCAppender.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/jdbc/JDBCAppender.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JDBCAppender.java 25 Mar 2002 22:05:36 -0000 1.2
+++ JDBCAppender.java 25 Mar 2002 22:37:21 -0000 1.3
@@ -16,39 +16,48 @@
/**
- * The JDBCAppender provides for sendinhg log messages to a database.
- *
- * Each append call adds to an ArrayList buffer. When the buffer is filled
- * each log event is placed in a sql statement (configurable) and executed.
- *
- * BufferSize, db URL, User, & Password are configurable options in
- * the standard Log4J ways.
- *
- * The setSql(String sql) sets the SQL statement to be used for logging --
- * this statement is sent to a PatternLayout (either created automaticly
- * by the appender or added by the user). Therefore by default all the
- * conversion patterns in PatternLayout can be used inside of the statement.
- * (see the test cases for examples)
- *
- * Overriding the getLogStatement method allows more explicit control of the
- * statement used for logging.
- *
- * For use as a base class:
- *
- * Override getConnection() to pass any connection you want.
- * Typically this is used to enable application wide connection pooling.
- * Override closeConnection(Connection con) -- if you override getConnection
- * make sure to implement closeConnection to handle the connection you
- * generated. Typically this would return the connection to the pool it
- * came from.
- *
- * Override getLogStatement(LoggingEvent event) to produce specialized or
- * dynamic statements The default uses the sql option value
- *
- * @author: Kevin Steppe (<A HREF="mailto:[email protected]">[email protected]</A>)
-*/
-
+ The JDBCAppender provides for sending log events to a database.
+
+ <p>Each append call adds to an <code>ArrayList</code> buffer. When
+ the buffer is filled each log event is placed in a sql statement
+ (configurable) and executed.
+
+ <b>BufferSize</b>, <b>db URL</b>, <b>User</b>, & <b>Password</b> are
+ configurable options in the standard log4j ways.
+
+ <p>The <code>setSql(String sql)</code> sets the SQL statement to be
+ used for logging -- this statement is sent to a
+ <code>PatternLayout</code> (either created automaticly by the
+ appender or added by the user). Therefore by default all the
+ conversion patterns in <code>PatternLayout</code> can be used
+ inside of the statement. (see the test cases for examples)
+
+ <p>Overriding the {@link getLogStatement} method allows more
+ explicit control of the statement used for logging.
+
+ <p>For use as a base class:
+
+ <ul>
+
+ <li>Override <code>getConnection()</code> to pass any connection
+ you want. Typically this is used to enable application wide
+ connection pooling.
+
+ <li>Override <code>closeConnection(Connection con)</code> -- if
+ you override getConnection make sure to implement
+ <code>closeConnection</code> to handle the connection you
+ generated. Typically this would return the connection to the
+ pool it came from.
+
+ <li>Override <code>getLogStatement(LoggingEvent event)</code> to
+ produce specialized or dynamic statements. The default uses the
+ sql option value.
+
+ </ul>
+
+ @author: Kevin Steppe (<A HREF="mailto:[email protected]">[email protected]</A>)
+*/
public class JDBCAppender extends org.apache.log4j.AppenderSkeleton
implements org.apache.log4j.Appender {
@@ -323,6 +332,5 @@
ErrorCode.GENERIC_FAILURE);
}
}
-
}
1.2 +54 -49 jakarta-log4j/src/java/org/apache/log4j/net/SocketHubAppender.java
Index: SocketHubAppender.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/SocketHubAppender.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SocketHubAppender.java 25 Mar 2002 22:05:36 -0000 1.1
+++ SocketHubAppender.java 25 Mar 2002 22:37:21 -0000 1.2
@@ -1,10 +1,9 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
- * This software is published under the terms of the Apache Software License
- * version 1.1, a copy of which has been included with this distribution in
- * the LICENSE file.
- */
+ * This software is published under the terms of the Apache Software
+ * License version 1.1, a copy of which has been included with this
+ * distribution in the LICENSE.txt file. */
package org.apache.log4j.net;
@@ -22,59 +21,63 @@
import org.apache.log4j.AppenderSkeleton;
/**
- Sends {@link LoggingEvent} objects to a set remote a log servers,
- usually a {@link SocketNode}.
+ Sends {@link LoggingEvent} objects to a set of remote log servers,
+ usually a {@link SocketNode SocketNodes}.
- Acts just like {@link SocketAppender} except that instead of
- connecting to a given remote log server, SocketHubAppender
- accepts connections from the remote log servers as clients. It
- can accept more than one connection, and when a log event is
- handled, 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 simple connects to the host and
- port the SocketHubAppender is running on.
-
- However, given the nature of accepting connections on-the-fly, it
- cannot be guaranteed that all events will be received while the
- tcp connection is in process. But once connected, it should behave
- the same as {@link SocketAppender}.
+ <p>Acts just like {@link SocketAppender} except that instead of
+ connecting to a given remote log server,
+ <code>SocketHubAppender</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>SocketHubAppender</code> is running on.
+
+ <p>The <code>SocketHubAppender</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.
- This implementation borrows heavily from the {@link SocketAppender}
- implementation as an example.
+ <p>This implementation borrows heavily from the {@link
+ SocketAppender}.
- <p>The SocketHubAppender has the following properties:
+ <p>The SocketHubAppender has the following characteristics:
<ul>
- <p><li>If sent to a {@link SocketNode}, 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, {@link
- org.apache.log4j.NDC}, location info as if it were logged locally by
- the client.
-
- <p><li>SocketHubAppenders do not use a layout. They ship a
- serialized {@link LoggingEvent} object to the server side.
-
- <p><li>Remote logging uses the TCP protocol. Consequently, if
- the server is reachable, then log events will eventually arrive
- at the server.
+ <p><li>If sent to a {@link SocketNode}, 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, {@link org.apache.log4j.NDC},
+ location info as if it were logged locally.
+
+ <p><li><code>SocketHubAppender</code> does not use a layout. It
+ ships a serialized {@link LoggingEvent} object to the remote side.
+
+ <p><li><code>SocketHubAppender</code> relies on the TCP
+ protocol. Consequently, if the remote side is reachable, then log
+ events will eventually arrive at remote client.
- <p><li>If no remote servers are attached, the logging requests are
+ <p><li>If no remote clients are attached, the logging requests are
simply dropped.
<p><li>Logging events are automatically <em>buffered</em> 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.
-
- <p>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.
+ 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.
+
+ <p>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.
+
+ <p>The single remote client case extends to multiple clients
+ connections. The rate of logging will be determined by the slowest
+ link.
<p><li>If the JVM hosting the <code>SocketHubAppender</code> exits
before the <code>SocketHubAppender</code> is closed either
@@ -89,8 +92,9 @@
</ul>
- @author Mark Womack
+ @author Mark Womack
*/
+
public class SocketHubAppender extends AppenderSkeleton {
/**
@@ -347,7 +351,8 @@
if (socket != null) {
try {
InetAddress remoteAddress = socket.getInetAddress();
- LogLog.debug("accepting connection from " + remoteAddress.getHostName() + " (" + remoteAddress.getHostAddress() + ")");
+ LogLog.debug("accepting connection from " + remoteAddress.getHostName()
+ + " (" + remoteAddress.getHostAddress() + ")");
// create an ObjectOutputStream
ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());