You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Jonathan Cowherd <jo...@genscape.com> on 2003/01/04 00:47:51 UTC
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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
new configure method for DOMConfigurator
Posted by Richard Bair <rb...@dtint.com>.
Ceki/Mark,
I added a really simple config method to DOMConfigurator. It made my
life easier since I could now use an in memory string representation of
an xml file to initialize the log4j system (via a StringReader and the
InputSource). I don't know how to go about contributing, or anything,
but here it is.
/**
A static version of {@link #doConfigure(InputSource,
LoggerRepository)}.
*/
static
public
void configure(InputSource xmlData) throws FactoryConfigurationError {
new DOMConfigurator().doConfigure(xmlData,
LogManager.getLoggerRepository());
}
Feel free. BTW, let me know if this will be added. If not, then I'll
add it to my proprietary code.
Thanks,
Richard
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>