ceki 2003/12/10 13:35:06 Modified: src/java/org/apache/log4j/net SocketAppender.java UDPAppender.java SocketHubAppender.java MulticastAppender.java XMLSocketNode.java src/java/org/apache/log4j/chainsaw FileLoadAction.java Generator.java ChainsawConstants.java ChainsawAppenderHandler.java src/java/org/apache/log4j PatternLayout.java Added: src/java/org/apache/log4j/helpers Constants.java Log: Created a new common Constants file. Renamed: 'log4jApp' as 'application' log4jMachinName' as 'hostname' field and method names have been updated accordingly. Revision Changes Path 1.20 +15 -14 jakarta-log4j/src/java/org/apache/log4j/net/SocketAppender.java Index: SocketAppender.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/SocketAppender.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- SocketAppender.java 26 Jun 2003 22:58:11 -0000 1.19 +++ SocketAppender.java 10 Dec 2003 21:35:06 -0000 1.20 @@ -52,6 +52,7 @@ package org.apache.log4j.net; import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.helpers.Constants; import org.apache.log4j.helpers.LogLog; import org.apache.log4j.spi.LoggingEvent; @@ -158,8 +159,8 @@ boolean locationInfo = false; private Connector connector; int counter = 0; - String localMachine; - String log4jApp; + String hostname; + String application; public SocketAppender() { } @@ -189,12 +190,12 @@ */ public void activateOptions() { try { - localMachine = InetAddress.getLocalHost().getHostName(); + hostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException uhe) { try { - localMachine = InetAddress.getLocalHost().getHostAddress(); + hostname = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException uhe2) { - localMachine = "unknown"; + hostname = "unknown"; } } @@ -281,12 +282,12 @@ event.getLocationInformation(); } - if (localMachine != null) { - event.setProperty("log4jMachineName", localMachine); + if (hostname != null) { + event.setProperty(Constants.HOSTNAME_KEY, hostname); } - if (log4jApp != null) { - event.setProperty("log4jApp", log4jApp); + if (application != null) { + event.setProperty(Constants.APPLICATION_KEY, application); } oos.writeObject(event); @@ -394,15 +395,15 @@ * name of the application getting logged * If property was already set (via system property), don't set here. */ - public void setLog4jApp(String lapp) { - this.log4jApp = lapp; + public void setApplication(String lapp) { + this.application = lapp; } /** - Returns value of the <b>Log4jApp</b> option. + * Returns value of the <b>Application</b> option. */ - public String getLog4jApp() { - return log4jApp; + public String getApplication() { + return application; } /** 1.4 +20 -19 jakarta-log4j/src/java/org/apache/log4j/net/UDPAppender.java Index: UDPAppender.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/UDPAppender.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- UDPAppender.java 2 Nov 2003 19:53:47 -0000 1.3 +++ UDPAppender.java 10 Dec 2003 21:35:06 -0000 1.4 @@ -56,6 +56,7 @@ import java.net.UnknownHostException; import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.helpers.*; import org.apache.log4j.helpers.LogLog; import org.apache.log4j.spi.LoggingEvent; @@ -98,9 +99,9 @@ We remember host name as String in addition to the resolved InetAddress so that it can be returned via getOption(). */ - String localMachine; + String hostname; String remoteHost; - String log4japp; + String application; String encoding; String overrideProperties = "true"; InetAddress address; @@ -139,21 +140,21 @@ */ public void activateOptions() { try { - localMachine = InetAddress.getLocalHost().getHostName(); + hostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException uhe) { try { - localMachine = InetAddress.getLocalHost().getHostAddress(); + hostname = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException uhe2) { - localMachine = "unknown"; + hostname = "unknown"; } } - //allow system property of log4japp to be primary - if (log4japp == null) { - log4japp = System.getProperty("log4japp"); + //allow system property of application to be primary + if (application == null) { + application = System.getProperty(Constants.APPLICATION_KEY); } else { - if (System.getProperty("log4japp") != null) { - log4japp = log4japp + "-" + System.getProperty("log4japp"); + if (System.getProperty(Constants.APPLICATION_KEY) != null) { + application = application + "-" + System.getProperty(Constants.APPLICATION_KEY); } } @@ -231,10 +232,10 @@ if ( (overrideProperties != null) && overrideProperties.equalsIgnoreCase("true")) { - event.setProperty("log4jmachinename", localMachine); + event.setProperty(Constants.HOSTNAME_KEY, hostname); - if (log4japp != null) { - event.setProperty("log4japp", log4japp); + if (application != null) { + event.setProperty(Constants.APPLICATION_KEY, application); } } @@ -248,8 +249,8 @@ new DatagramPacket(buf.toString().getBytes(encoding), buf.length(), address, port); outSocket.send(dp); //remove these properties, in case other appenders need to set them to different values - event.setProperty("log4jmachinename", null); - event.setProperty("log4japp", null); + event.setProperty(Constants.HOSTNAME_KEY, null); + event.setProperty(Constants.APPLICATION_KEY, null); } catch (IOException e) { outSocket = null; LogLog.warn("Detected problem with UDP connection: " + e); @@ -309,15 +310,15 @@ The <b>App</b> 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 setLog4JApp(String log4japp) { - this.log4japp = log4japp; + public void setApplication(String app) { + this.application = app; } /** Returns value of the <b>App</b> option. */ - public String getLog4JApp() { - return log4japp; + public String getApplication() { + return application; } /** 1.7 +170 -124 jakarta-log4j/src/java/org/apache/log4j/net/SocketHubAppender.java Index: SocketHubAppender.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/SocketHubAppender.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SocketHubAppender.java 28 Aug 2003 23:57:44 -0000 1.6 +++ SocketHubAppender.java 10 Dec 2003 21:35:06 -0000 1.7 @@ -1,29 +1,74 @@ /* - * Copyright (C) The Apache Software Foundation. All rights reserved. + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ * - * This software is published under the terms of the Apache Software - * License version 1.1, a copy of which has been included with this - * distribution in the LICENSE.txt file. */ + * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "log4j" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * [EMAIL PROTECTED] + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation. For more information on the + * Apache Software Foundation, please see <http://www.apache.org/>. + * + */ package org.apache.log4j.net; -import java.util.Vector; -import java.net.Socket; -import java.net.ServerSocket; -import java.net.SocketException; -import java.io.ObjectOutputStream; +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.helpers.LogLog; +import org.apache.log4j.spi.LoggingEvent; + import java.io.IOException; import java.io.InterruptedIOException; +import java.io.ObjectOutputStream; + import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketException; + +import java.util.Vector; -import org.apache.log4j.helpers.LogLog; -import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.AppenderSkeleton; /** Sends [EMAIL PROTECTED] LoggingEvent} objects to a set of remote log servers, usually a [EMAIL PROTECTED] SocketNode SocketNodes}. - + <p>Acts just like [EMAIL PROTECTED] SocketAppender} except that instead of connecting to a given remote log server, <code>SocketHubAppender</code> accepts connections from the remote @@ -33,7 +78,7 @@ not require any update to the configuration file to send data to another remote log server. The remote log server simply connects to the host and port the <code>SocketHubAppender</code> is running on. - + <p>The <code>SocketHubAppender</code> does not store events such that the remote side will events that arrived after the establishment of its connection. Once connected, events arrive in @@ -43,24 +88,24 @@ SocketAppender}. <p>The SocketHubAppender has the following characteristics: - + <ul> - + <p><li>If sent to a [EMAIL PROTECTED] SocketNode}, logging is non-intrusive as far as the log event is concerned. In other words, the event will be logged with the same time stamp, [EMAIL PROTECTED] org.apache.log4j.NDC}, location info as if it were logged locally. - + <p><li><code>SocketHubAppender</code> does not use a layout. It ships a serialized [EMAIL PROTECTED] LoggingEvent} object to the remote side. - + <p><li><code>SocketHubAppender</code> relies on the TCP protocol. Consequently, if the remote side is reachable, then log events will eventually arrive at remote client. - + <p><li>If no remote clients are attached, the logging requests are simply dropped. - + <p><li>Logging events are automatically <em>buffered</em> by the native TCP implementation. This means that if the link to remote client is slow but still faster than the rate of (log) event @@ -69,43 +114,41 @@ rate of event production, then the local application can only progress at the network rate. In particular, if the network link to the the remote client is down, the application will be blocked. - + <p>On the other hand, if the network link is up, but the remote client is down, the client will not be blocked when making log requests but the log events will be lost due to client - unavailability. + unavailability. <p>The single remote client case extends to multiple clients connections. The rate of logging will be determined by the slowest link. - + <p><li>If the JVM hosting the <code>SocketHubAppender</code> exits before the <code>SocketHubAppender</code> is closed either explicitly or subsequent to garbage collection, then there might be untransmitted data in the pipe which might be lost. This is a common problem on Windows based systems. - + <p>To avoid lost data, it is usually sufficient to [EMAIL PROTECTED] #close} the <code>SocketHubAppender</code> either explicitly or by calling the [EMAIL PROTECTED] org.apache.log4j.LogManager#shutdown} method before exiting the application. - + </ul> - - @author Mark Womack */ + @author Mark Womack */ public class SocketHubAppender extends AppenderSkeleton { - /** The default port number of the ServerSocket will be created on. */ public static final int DEFAULT_PORT = 4560; - private int port = DEFAULT_PORT; private Vector oosList = new Vector(); private ServerMonitor serverMonitor = null; private boolean locationInfo = false; - - public SocketHubAppender() { } + + public SocketHubAppender() { + } /** Connects to remote server at <code>address</code> and <code>port</code>. */ @@ -121,17 +164,18 @@ } /** - Close this appender. + Close this appender. <p>This will mark the appender as closed and call then [EMAIL PROTECTED] #cleanUp} method. */ public synchronized void close() { - if(closed) + if (closed) { return; + } - LogLog.debug("closing SocketHubAppender " + getName()); + LogLog.debug("closing SocketHubAppender " + getName()); this.closed = true; cleanUp(); - LogLog.debug("SocketHubAppender " + getName() + " closed"); + LogLog.debug("SocketHubAppender " + getName() + " closed"); } /** @@ -139,23 +183,24 @@ to all connected remote servers. */ public void cleanUp() { // stop the monitor thread - LogLog.debug("stopping ServerSocket"); + LogLog.debug("stopping ServerSocket"); serverMonitor.stopMonitor(); serverMonitor = null; - + // close all of the connections - LogLog.debug("closing client connections"); + LogLog.debug("closing client connections"); + while (oosList.size() != 0) { - ObjectOutputStream oos = (ObjectOutputStream)oosList.elementAt(0); - if(oos != null) { + ObjectOutputStream oos = (ObjectOutputStream) oosList.elementAt(0); + + if (oos != null) { try { - oos.close(); - } - catch(IOException e) { - LogLog.error("could not close oos.", e); + oos.close(); + } catch (IOException e) { + LogLog.error("could not close oos.", e); } - - oosList.removeElementAt(0); + + oosList.removeElementAt(0); } } } @@ -163,71 +208,72 @@ /** 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) + // if no event or no open connections, exit now + if ((event == null) || (oosList.size() == 0)) { return; + } // set up location info if requested if (locationInfo) { - event.getLocationInformation(); - } - - // loop through the current set of open connections, appending the event to each - for (int streamCount = 0; streamCount < oosList.size(); streamCount++) { + event.getLocationInformation(); + } + // loop through the current set of open connections, appending the event to each + for (int streamCount = 0; streamCount < oosList.size(); streamCount++) { ObjectOutputStream oos = null; + try { - oos = (ObjectOutputStream)oosList.elementAt(streamCount); - } - catch (ArrayIndexOutOfBoundsException e) { + oos = (ObjectOutputStream) oosList.elementAt(streamCount); + } catch (ArrayIndexOutOfBoundsException e) { // catch this, but just don't assign a value // this should not really occur as this method is // the only one that can remove oos's (besides cleanUp). } - + // list size changed unexpectedly? Just exit the append. - if (oos == null) + if (oos == null) { break; - - try { - oos.writeObject(event); - oos.flush(); - // Failing to reset the object output stream every now and - // then creates a serious memory leak. - // right now we always reset. TODO - set up frequency counter per oos? - oos.reset(); } - catch(IOException e) { - // there was an io exception so just drop the connection - oosList.removeElementAt(streamCount); - LogLog.debug("dropped connection"); - - // decrement to keep the counter in place (for loop always increments) - streamCount--; + + try { + oos.writeObject(event); + oos.flush(); + + // Failing to reset the object output stream every now and + // then creates a serious memory leak. + // right now we always reset. TODO - set up frequency counter per oos? + oos.reset(); + } catch (IOException e) { + // there was an io exception so just drop the connection + oosList.removeElementAt(streamCount); + LogLog.debug("dropped connection"); + + // decrement to keep the counter in place (for loop always increments) + streamCount--; } } } - + /** The SocketHubAppender does not use a layout. Hence, this method returns <code>false</code>. */ public boolean requiresLayout() { return false; } - + /** The <b>Port</b> option takes a positive integer representing the port where the server is waiting for connections. */ public void setPort(int _port) { port = _port; } - + /** Returns value of the <b>Port</b> option. */ public int getPort() { return port; } - + /** The <b>LocationInfo</b> option takes a boolean value. If true, the information sent to the remote host will include location @@ -235,19 +281,19 @@ public void setLocationInfo(boolean _locationInfo) { locationInfo = _locationInfo; } - + /** Returns value of the <b>LocationInfo</b> option. */ public boolean getLocationInfo() { return locationInfo; } - + /** Start the ServerMonitor thread. */ private void startServer() { serverMonitor = new ServerMonitor(port, oosList); } - + /** This class is used internally to monitor a ServerSocket and register new connections in a vector passed in the @@ -257,7 +303,7 @@ private Vector oosList; private boolean keepRunning; private Thread monitorThread; - + /** Create a thread and start the monitor. */ public ServerMonitor(int _port, Vector _oosList) { @@ -268,96 +314,96 @@ monitorThread.setDaemon(true); monitorThread.start(); } - + /** Stops the monitor. This method will not return until the thread has finished executing. */ public synchronized void stopMonitor() { if (keepRunning) { - LogLog.debug("server monitor thread shutting down"); + LogLog.debug("server monitor thread shutting down"); keepRunning = false; + try { monitorThread.join(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { // do nothing? } - + // release the thread monitorThread = null; - LogLog.debug("server monitor thread shut down"); + LogLog.debug("server monitor thread shut down"); } } - + /** Method that runs, monitoring the ServerSocket and adding connections as they connect to the socket. */ public void run() { ServerSocket serverSocket = null; + try { serverSocket = new ServerSocket(port); serverSocket.setSoTimeout(1000); - } - catch (Exception e) { - LogLog.error("exception setting timeout, shutting down server socket.", e); + } catch (Exception e) { + LogLog.error( + "exception setting timeout, shutting down server socket.", e); keepRunning = false; + return; } try { - try { - serverSocket.setSoTimeout(1000); - } - catch (SocketException e) { - LogLog.error("exception setting timeout, shutting down server socket.", e); + try { + serverSocket.setSoTimeout(1000); + } catch (SocketException e) { + LogLog.error( + "exception setting timeout, shutting down server socket.", e); + return; - } - - while (keepRunning) { + } + + while (keepRunning) { Socket socket = null; + try { socket = serverSocket.accept(); - } - catch (InterruptedIOException e) { + } catch (InterruptedIOException e) { // timeout occurred, so just loop - } - catch (SocketException e) { - LogLog.error("exception accepting socket, shutting down server socket.", e); + } catch (SocketException e) { + LogLog.error( + "exception accepting socket, shutting down server socket.", e); keepRunning = false; - } - catch (IOException e) { + } catch (IOException e) { LogLog.error("exception accepting socket.", e); } - + // if there was a socket accepted if (socket != null) { try { InetAddress remoteAddress = socket.getInetAddress(); - LogLog.debug("accepting connection from " + remoteAddress.getHostName() - + " (" + remoteAddress.getHostAddress() + ")"); - + LogLog.debug( + "accepting connection from " + remoteAddress.getHostName() + + " (" + remoteAddress.getHostAddress() + ")"); + // create an ObjectOutputStream - ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); - + ObjectOutputStream oos = + new ObjectOutputStream(socket.getOutputStream()); + // add it to the oosList. OK since Vector is synchronized. oosList.addElement(oos); - } - catch (IOException e) { + } catch (IOException e) { LogLog.error("exception creating output stream on socket.", e); } } } - } - finally { - // close the socket - try { - serverSocket.close(); - } - catch (IOException e) { - // do nothing with it? - } + } finally { + // close the socket + try { + serverSocket.close(); + } catch (IOException e) { + // do nothing with it? + } } } } } - 1.3 +20 -19 jakarta-log4j/src/java/org/apache/log4j/net/MulticastAppender.java Index: MulticastAppender.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/MulticastAppender.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MulticastAppender.java 2 Nov 2003 19:53:47 -0000 1.2 +++ MulticastAppender.java 10 Dec 2003 21:35:06 -0000 1.3 @@ -56,6 +56,7 @@ import java.net.UnknownHostException; import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.helpers.Constants; import org.apache.log4j.helpers.LogLog; import org.apache.log4j.spi.LoggingEvent; @@ -97,9 +98,9 @@ We remember host name as String in addition to the resolved InetAddress so that it can be returned via getOption(). */ - String localMachine; + String hostname; String remoteHost; - String log4japp; + String application; String overrideProperties = "true"; int timeToLive; InetAddress address; @@ -138,21 +139,21 @@ */ public void activateOptions() { try { - localMachine = InetAddress.getLocalHost().getHostName(); + hostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException uhe) { try { - localMachine = InetAddress.getLocalHost().getHostAddress(); + hostname = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException uhe2) { - localMachine = "unknown"; + hostname = "unknown"; } } - //allow system property of log4japp to be primary - if (log4japp == null) { - log4japp = System.getProperty("log4japp"); + //allow system property of application to be primary + if (application == null) { + application = System.getProperty(Constants.APPLICATION_KEY); } else { - if (System.getProperty("log4japp") != null) { - log4japp = log4japp + "-" + System.getProperty("log4japp"); + if (System.getProperty(Constants.APPLICATION_KEY) != null) { + application = application + "-" + System.getProperty(Constants.APPLICATION_KEY); } } @@ -220,10 +221,10 @@ if ( (overrideProperties != null) && overrideProperties.equalsIgnoreCase("true")) { - event.setProperty("log4jmachinename", localMachine); + event.setProperty(Constants.HOSTNAME_KEY, hostname); - if (log4japp != null) { - event.setProperty("log4japp", log4japp); + if (application != null) { + event.setProperty(Constants.APPLICATION_KEY, application); } } @@ -237,8 +238,8 @@ new DatagramPacket(buf.toString().getBytes(encoding), buf.length(), address, port); outSocket.send(dp); //remove these properties, in case other appenders need to set them to different values - event.setProperty("log4jmachinename", null); - event.setProperty("log4japp", null); + event.setProperty(Constants.HOSTNAME_KEY, null); + event.setProperty(Constants.APPLICATION_KEY, null); } catch (IOException e) { outSocket = null; LogLog.warn("Detected problem with Multicast connection: " + e); @@ -299,15 +300,15 @@ The <b>App</b> 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 setLog4JApp(String log4japp) { - this.log4japp = log4japp; + public void setApplicationp(String app) { + this.application = app; } /** Returns value of the <b>App</b> option. */ - public String getLog4JApp() { - return log4japp; + public String getApplication() { + return application; } /** 1.3 +3 -2 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- XMLSocketNode.java 9 Jul 2003 06:10:01 -0000 1.2 +++ XMLSocketNode.java 10 Dec 2003 21:35:06 -0000 1.3 @@ -50,6 +50,7 @@ package org.apache.log4j.net; import org.apache.log4j.*; +import org.apache.log4j.helpers.Constants; import org.apache.log4j.helpers.LogLog; import org.apache.log4j.plugins.Receiver; import org.apache.log4j.spi.*; @@ -175,8 +176,8 @@ LoggingEvent e = (LoggingEvent) iter.next(); //if machinename property was not set (the case if properties //not supported by the DTD), use remoteinfo as machine name - if (e.getProperty("log4jmachinename")==null) { - e.setProperty("log4jmachinename", remoteInfo); + if (e.getProperty(Constants.HOSTNAME_KEY)==null) { + e.setProperty(Constants.HOSTNAME_KEY, remoteInfo); } // store the known remote info in an event property 1.1 jakarta-log4j/src/java/org/apache/log4j/helpers/Constants.java Index: Constants.java =================================================================== /* * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ * * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. The end-user documentation included with the redistribution, if any, must * include the following acknowledgment: "This product includes software * developed by the Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, if * and wherever such third-party acknowledgments normally appear. * * 4. The names "log4j" and "Apache Software Foundation" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", nor may * "Apache" appear in their name, without prior written permission of the * Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals * on behalf of the Apache Software Foundation. For more information on the * Apache Software Foundation, please see <http://www.apache.org/>. * */ package org.apache.log4j.helpers; /** * Constants used by netwrok-based appenders and others. */ public interface Constants { static final String APPLICATION_KEY = "application"; static final String HOSTNAME_KEY = "hostname"; } 1.5 +2 -1 jakarta-log4j/src/java/org/apache/log4j/chainsaw/FileLoadAction.java Index: FileLoadAction.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/FileLoadAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- FileLoadAction.java 20 Nov 2003 22:10:19 -0000 1.4 +++ FileLoadAction.java 10 Dec 2003 21:35:06 -0000 1.5 @@ -52,6 +52,7 @@ import org.apache.log4j.Decoder; import org.apache.log4j.Logger; import org.apache.log4j.chainsaw.icons.ChainsawIcons; +import org.apache.log4j.helpers.Constants; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; @@ -185,7 +186,7 @@ if (url != null) { Map additionalProperties = new HashMap(); - additionalProperties.put(ChainsawConstants.LOG4J_MACHINE_KEY, name); + additionalProperties.put(Constants.HOSTNAME_KEY, name); decoder.setAdditionalProperties(additionalProperties); final URL urlToUse = url; 1.5 +2 -1 jakarta-log4j/src/java/org/apache/log4j/chainsaw/Generator.java Index: Generator.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/Generator.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Generator.java 23 Sep 2003 23:12:07 -0000 1.4 +++ Generator.java 10 Dec 2003 21:35:06 -0000 1.5 @@ -53,6 +53,7 @@ import org.apache.log4j.Logger; import org.apache.log4j.MDC; import org.apache.log4j.NDC; +import org.apache.log4j.helpers.Constants; import org.apache.log4j.plugins.Receiver; import org.apache.log4j.spi.LoggingEvent; @@ -86,7 +87,7 @@ new LoggingEvent( logger.getClass().getName(), logger, System.currentTimeMillis(), level, msg, t); - e.setProperty(ChainsawConstants.LOG4J_APP_KEY, getName()); + e.setProperty(Constants.APPLICATION_KEY, getName()); return e; } 1.5 +0 -2 jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawConstants.java Index: ChainsawConstants.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawConstants.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ChainsawConstants.java 29 Oct 2003 08:50:37 -0000 1.4 +++ ChainsawConstants.java 10 Dec 2003 21:35:06 -0000 1.5 @@ -37,8 +37,6 @@ //none is not a real column name, but is used by filters as a way to apply no filter for colors or display static final String NONE_COL_NAME = "None"; - static final String LOG4J_APP_KEY = "log4japp"; - static final String LOG4J_MACHINE_KEY = "log4jmachinename"; static final String LOG4J_REMOTEHOST_KEY = "log4j.remoteSourceInfo"; public static final String LOG4J_ID_KEY = "log4jid"; static final String UNKNOWN_TAB_NAME = "Unknown"; 1.9 +6 -5 jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawAppenderHandler.java Index: ChainsawAppenderHandler.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawAppenderHandler.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ChainsawAppenderHandler.java 2 Nov 2003 19:53:47 -0000 1.8 +++ ChainsawAppenderHandler.java 10 Dec 2003 21:35:06 -0000 1.9 @@ -51,6 +51,7 @@ import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.LogManager; +import org.apache.log4j.helpers.Constants; import org.apache.log4j.helpers.LogLog; import org.apache.log4j.net.SocketReceiver; import org.apache.log4j.plugins.PluginRegistry; @@ -140,19 +141,19 @@ /** * Determines an appropriate title for the Tab for the Tab Pane - * by locating a the log4jmachinename property + * by locating a the hostname property * @param v * @return */ private static String getTabIdentifier(LoggingEvent e) { StringBuffer ident = new StringBuffer(); - String machinename = e.getProperty(ChainsawConstants.LOG4J_MACHINE_KEY); + String hostname = e.getProperty(Constants.HOSTNAME_KEY); - if (machinename != null) { - ident.append(machinename); + if (hostname != null) { + ident.append(hostname); } - String appname = e.getProperty(ChainsawConstants.LOG4J_APP_KEY); + String appname = e.getProperty(Constants.APPLICATION_KEY); if (appname != null) { if (ident.length() > 0) { 1.26 +2 -2 jakarta-log4j/src/java/org/apache/log4j/PatternLayout.java Index: PatternLayout.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/PatternLayout.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- PatternLayout.java 10 Dec 2003 02:45:12 -0000 1.25 +++ PatternLayout.java 10 Dec 2003 21:35:06 -0000 1.26 @@ -317,8 +317,8 @@ <p>Used to output the Properties associated with the logging event. The <b>Y</b> conversion character can be followed by the key for the - map placed between braces, as in <b>%Y{log4japp}</b> where - <code>log4japp</code> is the key. The value in the Properties bundle + map placed between braces, as in <b>%Y{application}</b> where + <code>application</code> is the key. The value in the Properties bundle corresponding to the key will be output. If no additional sub-option is specified, then the entire contents of the Properties key value pair set is output using a format {{key1,val1},{key2,val2}}</p>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]