DO NOT REPLY [Bug 44551] New: SocketHubAppender in the 1.2. 16 does not support a scroll back buffer or application property

2008-03-06 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44551

   Summary: SocketHubAppender in the 1.2.16 does not support a
scroll back buffer or application property
   Product: Log4j
   Version: 1.2
  Platform: PC
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Appender
AssignedTo: log4j-dev@logging.apache.org
ReportedBy: [EMAIL PROTECTED]


Created an attachment (id=21644)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21644)
Patch to fix the issues listed in the description

Part 1)
The 1.3 version of SocketHubAppender uses a cyclic buffer to store the last X
log messages that are delivered to the client on connection so that they can
have some of the recently logged events. This was never back ported to the
1.2.X branch.

Part 2)
The 1.2.X version of SocketAppender supports an application property which
chainsaw can read to specify which application the log is for. 
SocketHubAppender should also support this functionality.

The attached patch resolves these issues.

Thanks to Scott Deboy for his guidance.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 44551] SocketHubAppender in the 1.2. 16 does not support a scroll back buffer or application property

2008-03-06 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44551


Jason Tholstrup <[EMAIL PROTECTED]> changed:

   What|Removed |Added

 CC||[EMAIL PROTECTED]




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 44551] SocketHubAppender in the 1.2. 16 does not support a scroll back buffer or application property

2008-03-06 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44551





--- Comment #1 from Paul Smith <[EMAIL PROTECTED]>  2008-03-06 18:49:05 PST ---
This patch looks good to me, I can't see any reason not to apply it.

Scott?  any final comments?


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 44551] SocketHubAppender in the 1.2. 16 does not support a scroll back buffer or application property

2008-03-06 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44551





--- Comment #2 from Scott Deboy <[EMAIL PROTECTED]>  2008-03-06 20:53:21 PST ---
Looks good to me as well.

Thanks for the contribution Jason


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r634545 - in /logging/log4j/trunk/src: changes/changes.xml main/java/org/apache/log4j/net/SocketHubAppender.java

2008-03-06 Thread psmith
Author: psmith
Date: Thu Mar  6 21:44:32 2008
New Revision: 634545

URL: http://svn.apache.org/viewvc?rev=634545&view=rev
Log:
Bug 44551 SocketHubAppender in the 1.2.16 does not support a scroll back buffer 
or application property.

This returns a feature from the old 1.3 codebase (yay!)

Applied patch generously  provided by Jason Tholstrup.

Modified:
logging/log4j/trunk/src/changes/changes.xml

logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketHubAppender.java

Modified: logging/log4j/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/trunk/src/changes/changes.xml?rev=634545&r1=634544&r2=634545&view=diff
==
--- logging/log4j/trunk/src/changes/changes.xml (original)
+++ logging/log4j/trunk/src/changes/changes.xml Thu Mar  6 21:44:32 2008
@@ -36,6 +36,7 @@
Minor documentation changes.
Make javamail, jmx, jms dependencies 
optional in pom.xml.
SocketHubAppender should expose 
actual port in use to extending classes.
+   SocketHubAppender in the 1.2.16 does 
not support a scroll back buffer or application property
 
   
 

Modified: 
logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketHubAppender.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketHubAppender.java?rev=634545&r1=634544&r2=634545&view=diff
==
--- 
logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketHubAppender.java 
(original)
+++ 
logging/log4j/trunk/src/main/java/org/apache/log4j/net/SocketHubAppender.java 
Thu Mar  6 21:44:32 2008
@@ -26,6 +26,7 @@
 import java.io.InterruptedIOException;
 import java.net.InetAddress;
 
+import org.apache.log4j.helpers.CyclicBuffer;
 import org.apache.log4j.helpers.LogLog;
 import org.apache.log4j.spi.LoggingEvent;
 import org.apache.log4j.AppenderSkeleton;
@@ -114,6 +115,8 @@
   private Vector oosList = new Vector();
   private ServerMonitor serverMonitor = null;
   private boolean locationInfo = false;
+  private CyclicBuffer buffer = null;
+  private String application;
   
   public SocketHubAppender() { }
 
@@ -179,14 +182,23 @@
 Append an event to all of current connections. */
   public
   void append(LoggingEvent event) {
-   // if no event or no open connections, exit now
-if(event == null || oosList.size() == 0)
-  return;
+if (event != null) {
+  // set up location info if requested
+  if (locationInfo) {
+event.getLocationInformation();
+  }
+  if (application != null) {
+  event.setProperty("application", application);
+} 
+  if (buffer != null) {
+buffer.add(event);
+  }
+}
 
-// set up location info if requested
-if (locationInfo) {
-   event.getLocationInformation(); 
-} 
+// if no event or no open connections, exit now
+if ((event == null) || (oosList.size() == 0)) {
+  return;
+}
 
// loop through the current set of open connections, appending the 
event to each
 for (int streamCount = 0; streamCount < oosList.size(); streamCount++) {   

@@ -238,6 +250,23 @@
   public
   void setPort(int _port) {
 port = _port;
+   }
+
+  /**
+   * The App option takes a string value which should be the name of 
the application getting logged. If property was already set (via system
+   * property), don't set here.
+   */
+  public 
+  void setApplication(String lapp) {
+this.application = lapp;
+  }
+
+  /**
+   * Returns value of the Application option.
+   */
+  public 
+  String getApplication() {
+return application;
   }
   
   /**
@@ -246,6 +275,27 @@
   int getPort() {
 return port;
   }
+
+  /**
+   * The BufferSize option takes a positive integer representing the 
number of events this appender will buffer and send to newly connected
+   * clients.
+   */
+  public 
+  void setBufferSize(int _bufferSize) {
+buffer = new CyclicBuffer(_bufferSize);
+  }
+
+  /**
+   * Returns value of the bufferSize option.
+   */
+  public 
+  int getBufferSize() {
+if (buffer == null) {
+  return 0;
+} else {
+  return buffer.getMaxSize();
+}
+  }
   
   /**
  The LocationInfo option takes a boolean value. If true,
@@ -325,6 +375,17 @@
   }
 }
 
+private 
+void sendCachedEvents(ObjectOutputStream stream) throws IOException {
+  if (buffer != null) {
+for (int i = 0; i < buffer.length(); i++) {
+  stream.writeObject(buffer.get(i));
+}
+stream.flush();
+stream.reset();
+  }
+}
+
 /**
   Method that runs, monitoring the ServerSocket and adding connections as
   they connect to the socket. */
@@ -375,11 +436,13 @@

   // create an ObjectOutputStream
   ObjectOutputStream oos = new 
ObjectOutputStream(socket.getOu

DO NOT REPLY [Bug 44551] SocketHubAppender in the 1.2. 16 does not support a scroll back buffer or application property

2008-03-06 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44551


Paul Smith <[EMAIL PROTECTED]> changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED




--- Comment #3 from Paul Smith <[EMAIL PROTECTED]>  2008-03-06 21:44:00 PST ---
Patch applied as of revision 634545.

Thanks muchly.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 43295] Zeroconf always uses default port (4560)

2008-03-06 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=43295





--- Comment #10 from Paul Smith <[EMAIL PROTECTED]>  2008-03-06 21:48:11 PST ---
(slow response I know).  A change to log4j is required for this to work, which
is currently targetted for 1.2.16 release.

I'm amending the zeroconf package to take advantage of that; it will require
you to upgrade to log4j 1.2.16 once released though, but that should easy
enough.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 44551] SocketHubAppender in the 1.2. 16 does not support a scroll back buffer or application property

2008-03-06 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44551





--- Comment #4 from Jacob Kjome <[EMAIL PROTECTED]>  2008-03-06 21:51:51 PST ---
Can we presume that the Apache Contributor Agreement has been signed and is on
file at the foundation?

Jake


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r634548 - in /logging/log4j/companions/zeroconf/trunk: ./ src/main/java/org/apache/log4j/net/ src/test/java/org/apache/log4j/net/

2008-03-06 Thread psmith
Author: psmith
Date: Thu Mar  6 22:07:58 2008
New Revision: 634548

URL: http://svn.apache.org/viewvc?rev=634548&view=rev
Log:
Now that log4j 1.2.16 has the new createSocket method, we can trap this, store 
the details
of the port/address, and use that in the broadcast of what the 
SocketHubAppender is listening on.

Includes test case.  Changed dependency on zeroconf to require log4j 
1.2.16-SNAPSHOT until release.


Modified:
logging/log4j/companions/zeroconf/trunk/pom.xml

logging/log4j/companions/zeroconf/trunk/src/main/java/org/apache/log4j/net/ZeroConfSocketHubAppender.java

logging/log4j/companions/zeroconf/trunk/src/main/java/org/apache/log4j/net/Zeroconf4log4j.java

logging/log4j/companions/zeroconf/trunk/src/test/java/org/apache/log4j/net/ZeroConfSocketHubAppenderTest.java

Modified: logging/log4j/companions/zeroconf/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/companions/zeroconf/trunk/pom.xml?rev=634548&r1=634547&r2=634548&view=diff
==
--- logging/log4j/companions/zeroconf/trunk/pom.xml (original)
+++ logging/log4j/companions/zeroconf/trunk/pom.xml Thu Mar  6 22:07:58 2008
@@ -163,6 +163,7 @@

  
  maven-assembly-plugin
+
  

   src/assembly/bin.xml
@@ -171,6 +172,7 @@
 
 
 
+   package
 
 assembly
 
@@ -181,6 +183,7 @@
 maven-javadoc-plugin
 
 
+package
 
 jar
 javadoc
@@ -210,7 +213,7 @@
 
   log4j
   log4j
-  1.2.9
+  1.2.16-SNAPSHOT
 
 
   jmdns

Modified: 
logging/log4j/companions/zeroconf/trunk/src/main/java/org/apache/log4j/net/ZeroConfSocketHubAppender.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/companions/zeroconf/trunk/src/main/java/org/apache/log4j/net/ZeroConfSocketHubAppender.java?rev=634548&r1=634547&r2=634548&view=diff
==
--- 
logging/log4j/companions/zeroconf/trunk/src/main/java/org/apache/log4j/net/ZeroConfSocketHubAppender.java
 (original)
+++ 
logging/log4j/companions/zeroconf/trunk/src/main/java/org/apache/log4j/net/ZeroConfSocketHubAppender.java
 Thu Mar  6 22:07:58 2008
@@ -18,60 +18,74 @@
 
 import java.io.IOException;
 import java.lang.reflect.Method;
+import java.net.InetAddress;
+import java.net.ServerSocket;
 
 import javax.jmdns.JmDNS;
 import javax.jmdns.ServiceInfo;
 
 import org.apache.log4j.Level;
 
-
 /**
  * A sub-class of SocketHubAppender that broadcasts its configuration via 
Zeroconf.
  * 
  * This allows Zeroconf aware applications such as Chainsaw to be able to 
detect them, and automatically configure
  * themselves to be able to connect to them.
  * 
+ * This class relies on log4j 1.2.16 or later.
+ * 
  * @author psmith
  *
  */
 public class ZeroConfSocketHubAppender extends SocketHubAppender {
 
-public static final String DEFAULT_ZEROCONF_ZONE="_log4j._tcp.local.";
+public static final String DEFAULT_ZEROCONF_ZONE = "_log4j._tcp.local.";
 private String zeroConfZone = DEFAULT_ZEROCONF_ZONE;
-
+
 private Object logger;
 private Method logInfoMethod;
 private Method logErrorMethod;
-
+
+private int actualPortUsed;
+private InetAddress actualAddressUsed;
+
 public ZeroConfSocketHubAppender() {
 setName("SocketHubAppender");
 try {
-Method getLoggerMethod = this.getClass().getMethod("getLogger", 
new Class[0]);
+Method getLoggerMethod = this.getClass().getMethod("getLogger",
+new Class[0]);
 logger = getLoggerMethod.invoke(this, new Object[0]);
-logInfoMethod = logger.getClass().getMethod("info", new Class[] 
{Object.class});
-logErrorMethod = logger.getClass().getMethod("error", new Class[] 
{Object.class});
-}catch(Exception e) {
+logInfoMethod = logger.getClass().getMethod("info",
+new Class[] { Object.class });
+logErrorMethod = logger.getClass().getMethod("error",
+new Class[] { Object.class });
+} catch (Exception e) {
 // we're not in log4j1.3 land
 }
 }
+
 public void activateOptions() {
 super.activateOptions();
-
 try {
 JmDNS jmDNS = Zeroconf4log4j.getInstance();
 ServiceInfo info = buildServiceInfo();
-logWithlog4j12Compatibility(Level.INFO,"Registering this 
SocketHubAppender as :" + info);
+logWithlog4j12Compatibility(Level.INFO,
+"Registering this SocketHubAppender as :" + info);
 jmDNS.registerService(info);
 } catch (IOException e) {
-logWithlog4j12Compatibility(Level.ERROR,"Failed to 

DO NOT REPLY [Bug 44551] SocketHubAppender in the 1.2. 16 does not support a scroll back buffer or application property

2008-03-06 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44551





--- Comment #5 from Paul Smith <[EMAIL PROTECTED]>  2008-03-06 22:08:57 PST ---
I thought that if a person attached their contribution to bugzilla that was
implied donation to Apache?


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 44551] SocketHubAppender in the 1.2. 16 does not support a scroll back buffer or application property

2008-03-06 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44551





--- Comment #7 from Jacob Kjome <[EMAIL PROTECTED]>  2008-03-06 22:27:31 PST ---
My misunderstanding.  From http://www.apache.org/licenses/ ...

"The ASF desires that all contributors of ideas, code, or documentation to the
Apache projects complete, sign, and submit (via postal mail, fax or email) an
Individual Contributor License Agreement (CLA) [PDF form]."

Looks like it isn't "required", but "desired" for general contributors. 
However, for committers it is required...

"A signed CLA is required to be on file before an individual is given commit
rights to an ASF project."

Sorry for the noise.

Jake


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 44551] SocketHubAppender in the 1.2. 16 does not support a scroll back buffer or application property

2008-03-06 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44551





--- Comment #6 from Scott Deboy <[EMAIL PROTECTED]>  2008-03-06 22:24:17 PST ---
I agree with Paul..I don't think a CLA is required for submitted patches.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]