sdeboy 2003/07/08 23:10:01 Modified: src/java/org/apache/log4j/net UDPReceiver.java XMLSocketReceiver.java MulticastReceiver.java XMLSocketNode.java src/java/org/apache/log4j/xml XMLLayout.java src/java/org/apache/log4j/chainsaw LogUI.java DisplayFilter.java . build.xml Removed: build .cvsignore package-list Log: XMLLayout: Modified MDC entries to not create CDATA attributes. Also changed String casts to toString calls. LogUI: If config.file property was defined for configuration, and the log4j.configuration system property was also provided, receivers were being loaded from both locations. This caused 'could not bind' issues with socket-based receivers. Not sure of a way to -unset- the config.file property, so now if a log4j.configuration exists, the config.file configuration is not used. Modified PR: Obtained from: Submitted by: Reviewed by: CVS: ---------------------------------------------------------------------- CVS: PR: CVS: If this change addresses a PR in the problem report tracking CVS: database, then enter the PR number(s) here. CVS: Obtained from: CVS: If this change has been taken from another system, such as NCSA, CVS: then name the system in this line, otherwise delete it. CVS: Submitted by: CVS: If this code has been contributed to Apache by someone else; i.e., CVS: they sent us a patch or a new module, then include their name/email CVS: address here. If this is your work then delete this line. CVS: Reviewed by: CVS: If we are doing pre-commit code reviews and someone else has CVS: reviewed your changes, include their name(s) here. CVS: If you have not had it reviewed then delete this line. Revision Changes Path 1.2 +7 -3 jakarta-log4j/src/java/org/apache/log4j/net/UDPReceiver.java Index: UDPReceiver.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/UDPReceiver.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- UDPReceiver.java 24 Jun 2003 08:21:52 -0000 1.1 +++ UDPReceiver.java 9 Jul 2003 06:10:01 -0000 1.2 @@ -62,7 +62,7 @@ import java.util.ArrayList; import java.util.Iterator; -import java.util.Vector; +import java.util.List; /** @@ -124,11 +124,15 @@ this.decoderImpl = (Decoder) o; } } catch (ClassNotFoundException cnfe) { + LogLog.warn("Unable to find decoder", cnfe); } catch (IllegalAccessException iae) { + LogLog.warn("Could not construct decoder", iae); } catch (InstantiationException ie) { + LogLog.warn("Could not construct decoder", ie); } try { + isActive=true; socket = new DatagramSocket(port); receiverThread = new UDPReceiverThread(); receiverThread.start(); @@ -140,7 +144,7 @@ } class UDPHandlerThread extends Thread { - private ArrayList list = new ArrayList(); + private List list = new ArrayList(); public UDPHandlerThread() { setDaemon(true); @@ -168,7 +172,7 @@ while (iter.hasNext()) { String data = (String) iter.next(); - Vector v= decoderImpl.decodeEvents(data); + List v= decoderImpl.decodeEvents(data); if (v != null) { Iterator eventIter = v.iterator(); 1.2 +11 -3 jakarta-log4j/src/java/org/apache/log4j/net/XMLSocketReceiver.java Index: XMLSocketReceiver.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/XMLSocketReceiver.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- XMLSocketReceiver.java 24 Jun 2003 08:21:52 -0000 1.1 +++ XMLSocketReceiver.java 9 Jul 2003 06:10:01 -0000 1.2 @@ -56,6 +56,7 @@ import java.net.ServerSocket; import java.net.Socket; +import java.util.List; import java.util.Vector; @@ -78,7 +79,7 @@ //default to log4j xml decoder protected String decoder = "org.apache.log4j.xml.XMLDecoder"; private ServerSocket serverSocket; - private Vector socketList = new Vector(); + private List socketList = new Vector(); public XMLSocketReceiver() { } @@ -131,6 +132,13 @@ return false; } + public int hashCode() { + + int result = 37 * (repository != null? repository.hashCode():0); + result = result * 37 + port; + return (result * 37 + (getName() != null? getName().hashCode():0)); + } + /** Returns true if this receiver is active. */ public synchronized boolean isActive() { @@ -161,7 +169,7 @@ serverSocket.close(); } } catch (Exception e) { - // ignore for now + //ignore for now } // close all of the accepted sockets @@ -169,7 +177,7 @@ try { ((Socket) socketList.get(x)).close(); } catch (Exception e) { - // ignore for now + //ignore for now } } 1.2 +8 -5 jakarta-log4j/src/java/org/apache/log4j/net/MulticastReceiver.java Index: MulticastReceiver.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/MulticastReceiver.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MulticastReceiver.java 24 Jun 2003 08:21:52 -0000 1.1 +++ MulticastReceiver.java 9 Jul 2003 06:10:01 -0000 1.2 @@ -50,6 +50,7 @@ package org.apache.log4j.net; import org.apache.log4j.Decoder; +import org.apache.log4j.helpers.LogLog; import org.apache.log4j.plugins.Receiver; import org.apache.log4j.spi.LoggingEvent; @@ -63,8 +64,7 @@ import java.util.ArrayList; import java.util.Iterator; -import java.util.Vector; - +import java.util.List; /** * Multicast-based receiver. Accepts LoggingEvents encoded using @@ -132,8 +132,11 @@ this.decoderImpl = (Decoder) o; } } catch (ClassNotFoundException cnfe) { + LogLog.warn("Unable to find decoder", cnfe); } catch (IllegalAccessException iae) { + LogLog.warn("Could not construct decoder", iae); } catch (InstantiationException ie) { + LogLog.warn("Could not construct decoder", ie); } try { @@ -155,7 +158,7 @@ } class MulticastHandlerThread extends Thread { - private ArrayList list = new ArrayList(); + private List list = new ArrayList(); public MulticastHandlerThread() { setDaemon(true); @@ -183,7 +186,7 @@ while (iter.hasNext()) { String data = (String) iter.next(); - Vector v= decoderImpl.decodeEvents(data); + List v= decoderImpl.decodeEvents(data); if (v != null) { Iterator eventIter = v.iterator(); @@ -222,7 +225,7 @@ String data = new String(p.getData(), 0, p.getLength()).trim(); handlerThread.append(data); } catch (SocketException se) { - //disconnected + //disconnected } catch (IOException ioe) { ioe.printStackTrace(); } 1.2 +10 -3 jakarta-log4j/src/java/org/apache/log4j/net/XMLSocketNode.java Index: XMLSocketNode.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/XMLSocketNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- XMLSocketNode.java 24 Jun 2003 08:21:52 -0000 1.1 +++ XMLSocketNode.java 9 Jul 2003 06:10:01 -0000 1.2 @@ -50,6 +50,7 @@ package org.apache.log4j.net; import org.apache.log4j.*; +import org.apache.log4j.helpers.LogLog; import org.apache.log4j.plugins.Receiver; import org.apache.log4j.spi.*; @@ -59,7 +60,7 @@ import java.net.Socket; import java.util.Iterator; -import java.util.Vector; +import java.util.List; /** @@ -94,8 +95,11 @@ this.decoder = (Decoder) o; } } catch (ClassNotFoundException cnfe) { + LogLog.warn("Unable to find decoder", cnfe); } catch (IllegalAccessException iae) { + LogLog.warn("Unable to construct decoder", iae); } catch (InstantiationException ie) { + LogLog.warn("Unable to construct decoder", ie); } this.socket = socket; @@ -113,8 +117,11 @@ this.decoder = (Decoder) o; } } catch (ClassNotFoundException cnfe) { + LogLog.warn("Unable to find decoder", cnfe); } catch (IllegalAccessException iae) { + LogLog.warn("Unable to construct decoder", iae); } catch (InstantiationException ie) { + LogLog.warn("Unable to construct decoder", ie); } this.socket = socket; @@ -159,7 +166,7 @@ while (true) { byte[] b=new byte[1024]; is.read(b); - Vector v= decoder.decodeEvents(new String(b).trim()); + List v= decoder.decodeEvents(new String(b).trim()); if (v != null) { Iterator iter = v.iterator(); @@ -220,7 +227,7 @@ is.close(); } } catch (Exception e) { - //logger.info("Could not close connection.", e); + //logger.info("Could not close connection.", e); } // send event to listener, if configured 1.23 +7 -14 jakarta-log4j/src/java/org/apache/log4j/xml/XMLLayout.java Index: XMLLayout.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/XMLLayout.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- XMLLayout.java 23 Jun 2003 16:04:28 -0000 1.22 +++ XMLLayout.java 9 Jul 2003 06:10:01 -0000 1.23 @@ -100,10 +100,7 @@ * @since 0.9.0 * */ public class XMLLayout extends Layout { - private final int DEFAULT_SIZE = 256; - private final int UPPER_LIMIT = 2048; - //private StringBuffer buf = new StringBuffer(DEFAULT_SIZE); private boolean locationInfo = false; /** @@ -181,16 +178,12 @@ Iterator iter = sortedList.iterator(); while (iter.hasNext()) { - String propName = (String) iter.next(); + String propName = iter.next().toString(); + output.write("<log4j:data name=\"" + propName); - output.write(" <log4j:data name=\"<![CDATA["); - Transform.appendEscapingCDATA(output, propName); - output.write("]]>\""); - - String propValue = (String) event.getMDC(propName); - output.write(" value=\"<![CDATA["); - Transform.appendEscapingCDATA(output, propValue); - output.write("]]>\"/>\r\n"); + String propValue = event.getMDC(propName).toString(); + output.write("\" value=\"" + propValue); + output.write("\"/>\r\n"); } output.write("</log4j:MDC>\r\n"); @@ -230,10 +223,10 @@ Iterator propIter = propertySet.iterator(); while (propIter.hasNext()) { - String propName = (String) propIter.next(); + String propName = propIter.next().toString(); output.write("<log4j:data name=\"" + propName); - String propValue = (String) event.getProperty(propName); + String propValue = event.getProperty(propName).toString(); output.write("\" value=\"" + propValue); output.write("\"/>\r\n"); } 1.4 +10 -6 jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java Index: LogUI.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- LogUI.java 29 Jun 2003 22:57:55 -0000 1.3 +++ LogUI.java 9 Jul 2003 06:10:01 -0000 1.4 @@ -360,13 +360,17 @@ public void loadSettings(LoadSettingsEvent event) { String configFile = event.getSetting(LogUI.CONFIG_FILE_TO_USE); - if ((configFile != null) && !configFile.trim().equals("")) { + //if both a config file are defined and a log4j.configuration property are set, + //don't use configFile's configuration + if ((configFile != null) && !configFile.trim().equals("") && System.getProperty("log4j.configuration") == null) { try { URL url = new URL(configFile); OptionConverter.selectAndConfigure( url, null, LogManager.getLoggerRepository()); - LogUI.this.getStatusBar().setMessage( - "Configured Log4j using remembered URL :: " + url); + if (LogUI.this.getStatusBar() != null) { + LogUI.this.getStatusBar().setMessage( + "Configured Log4j using remembered URL :: " + url); + } LogUI.this.configURLToUse = url; } catch (Exception e) { LogLog.error("error occurred initializing log4j", e); @@ -988,9 +992,9 @@ * @param v */ private void addRows(final String ident, final List eventBatchEntrys) { - final EventContainer tableModel; - final JSortTable table; - final ScrollToBottom scrollToBottom; + EventContainer tableModel; + JSortTable table; + ScrollToBottom scrollToBottom; HashMap map = null; if (!isGUIFullyInitialized) { 1.2 +3 -0 jakarta-log4j/src/java/org/apache/log4j/chainsaw/DisplayFilter.java Index: DisplayFilter.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/DisplayFilter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DisplayFilter.java 25 Jun 2003 04:05:21 -0000 1.1 +++ DisplayFilter.java 9 Jul 2003 06:10:01 -0000 1.2 @@ -78,6 +78,9 @@ * @author Scott Deboy <[EMAIL PROTECTED]> */ public class DisplayFilter implements Serializable { + + static final long serialVersionUID = 5583905936243239630L; + private static final DateFormat DATE_FORMATTER = new SimpleDateFormat(ChainsawConstants.DATETIME_FORMAT); private transient Vector filterListeners = new Vector(); 1.70 +1 -7 jakarta-log4j/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/build.xml,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- build.xml 7 Jul 2003 13:55:17 -0000 1.69 +++ build.xml 9 Jul 2003 06:10:01 -0000 1.70 @@ -13,10 +13,6 @@ <!-- The build.properties file defines the parth to local jar files --> <property file="build.properties"/> - <!-- Read the system environment variables and stores them in properties, --> - <!-- prefixed with "env". --> - <property environment="env"/> - <property name="version" value="1.3alpha"/> <!-- The base directory relative to which most targets are built --> @@ -110,8 +106,6 @@ jar - build log4j-core and log4j jar files dist - will create a complete distribution in dist/ - Setting the env variable NO_JAVADOC will build the distribution - without running the javadoc target. </echo> </target> @@ -545,7 +539,7 @@ <!-- ================================================================= --> <!-- This target builds the javadoc files. --> <!-- ================================================================= --> - <target name="javadoc" depends="init" unless="env.NO_JAVADOC"> + <target name="javadoc" depends="init"> <mkdir dir="${javadoc.dest}" />
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]