logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Cowherd <jonathan.cowh...@genscape.com>
Subject RE: log4j socket patch
Date Mon, 06 Jan 2003 22:01:01 GMT
I prefer the way it works now.  For equivalent functionality, one would need
to make two functions calls with two conditions to check.  For instance:

<example.java>
InetAddress ipaddr = null;
String ipname = null;

ipaddr = InetAddress.getByName("jakarta.apache.org");
ipname = ipaddr.getHostName();
  if (ipname.length() == 0) {
	ipname = ipaddr.getHostAddress();
  }
</example.java>

I don't know which would be faster, but I assume the two different calls
would have a greater cost without any investigation.

Jonathan Paul Cowherd
Linux and Java Administrator
Genscape, Inc.
Email:  jonathan.cowherd@genscape.com
Office: (502) 583-3730
Mobile: (502) 314-0444



-----Original Message-----
From: Jonathan Cowherd [mailto:jonathan.cowherd@genscape.com] 
Sent: Friday, January 03, 2003 6:48 PM
To: 'log4j-dev@jakarta.apache.org'
Subject: log4j socket patch


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:  jonathan.cowherd@genscape.com
Office: (502) 583-3730
Mobile: (502) 314-0444



-----Original Message-----
From: Jonathan Cowherd [mailto:jcowherd@thor.int.genscape.com] 
Sent: Friday, January 03, 2003 7:43 PM
To: jonathan.cowherd@genscape.com
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:log4j-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:log4j-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org>


Mime
View raw message