I found a "bug" in the org.apache.log4j.net.SocketServer class.

If a machine only has an IP and no host name, the InetAddres.toString() call
only return "/D1.D2.D3.D4" which yields an empty string for String key =
s.substring(0,i) //where I is the index of the '/' in the returned string.
This patch will return the IP address to the 'key' variable so that you can
use IP addresses for conf files like 192.168.1.30.lcf .  :)

It's been suggested that InetAddress has more functions that there could be
a better way of getting the host name.  I'll investigate this weekend (from
first glance, InetAddress wasn't pretty to look at).

Jonathan Paul Cowherd
Linux and Java Administrator
Genscape, Inc.
Email:  [EMAIL PROTECTED]
Office: (502) 583-3730
Mobile: (502) 314-0444



-----Original Message-----
From: Jonathan Cowherd [mailto:[EMAIL PROTECTED]] 
Sent: Friday, January 03, 2003 7:43 PM
To: [EMAIL PROTECTED]
Subject: log4j socket patch


--- SocketServerorig.java       Fri Jan  3 19:42:08 2003
+++ SocketServer.java   Fri Jan  3 19:42:08 2003
@@ -70,7 +70,7 @@
 
  @since 1.0 */
 
-public class SocketServerorig {
+public class SocketServer {
 
     static String GENERIC = "generic";
     static String CONFIG_FILE_EXT = ".lcf";
@@ -143,7 +143,7 @@
 
 
     public
-            SocketServerorig(File directory) {
+            SocketServer(File directory) {
         this.dir = directory;
         hierarchyMap = new Hashtable(11);
     }
@@ -161,7 +161,16 @@
                     "]. Using default hierarchy.");
             return genericHierarchy();
         } else {
-            String key = s.substring(0, i);
+
+            String key = null;
+
+            //  This will return the IP string if there is no host 
+ name.
+
+            if (i == 0) {
+                key = s.substring(1);
+            } else {
+                key = s.substring(0, i);
+            }
 
             File configFile = new File(dir, key + CONFIG_FILE_EXT);
             if (configFile.exists()) {

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

Reply via email to