The following commit notification was rejected due to its large size. I am sending it manually for your info/reference.
ceki 2003/03/18 05:33:33
Modified: src/java/org/apache/log4j/plugins Plugin.java
PluginRegistry.java Receiver.java
PluginSkeleton.java
src/java/org/apache/log4j/test AsyncAppenderTest.java
ConfigurationFileParsing.java PatternTest.java
Shallow.java ShortSocketServer.java
src/java/org/apache/log4j/xml/test DOMTest.java
src/java/org/apache/log4j/spi LoggingEvent.java
src/java/org/apache/log4j Appender.java
AppenderSkeleton.java
src/java/org/apache/log4j/chainsaw MyTableModel.java
LoadXMLAction.java Main.java ChainsawAppender.java
Log4JConfigurationFinder.java ChainsawViewer.java
MyTableColumnModel.java PreferencesDialog.java
DetailPanel.java RecentFilesMenu.java Start.java
XMLFileHandler.java DefaultViewer.java
src/java/org/apache/log4j/net SocketNode.java
SMTPAppender.java
src/java/org/apache/log4j/net/test SMTPMin.java
src/java/org/apache/log4j/jmx LoggerDynamicMBean.java
Log:
Eliminated deprecated code. Performed some formatting with Jalopy. Cosmetic changes only.
Revision Changes Path
1.4 +47 -4 jakarta-log4j/src/java/org/apache/log4j/plugins/Plugin.java
Index: Plugin.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/plugins/Plugin.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Plugin.java 20 Feb 2003 07:18:32 -0000 1.3
+++ Plugin.java 18 Mar 2003 13:33:30 -0000 1.4
@@ -1,9 +1,52 @@
/*
- * 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.plugins;
import org.apache.log4j.spi.LoggerRepository;
1.5 +47 -4 jakarta-log4j/src/java/org/apache/log4j/plugins/PluginRegistry.java
Index: PluginRegistry.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/plugins/PluginRegistry.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PluginRegistry.java 20 Feb 2003 07:18:32 -0000 1.4
+++ PluginRegistry.java 18 Mar 2003 13:33:30 -0000 1.5
@@ -1,9 +1,52 @@
/*
- * 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.plugins;
import org.apache.log4j.LogManager;
1.4 +49 -6 jakarta-log4j/src/java/org/apache/log4j/plugins/Receiver.java
Index: Receiver.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/plugins/Receiver.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Receiver.java 20 Feb 2003 07:18:32 -0000 1.3
+++ Receiver.java 18 Mar 2003 13:33:30 -0000 1.4
@@ -1,9 +1,52 @@
/*
- * 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.plugins;
import org.apache.log4j.Logger; @@ -46,8 +89,8 @@ public abstract class Receiver extends PluginSkeleton { /** Posts the logging event to a logger in the configured logger - repository. - + repository. + @param event the log event to post to the local log4j environment. */ public void doPost(LoggingEvent event) { // get the "local" logger for this event from the
1.5 +56 -13 jakarta-log4j/src/java/org/apache/log4j/plugins/PluginSkeleton.java
Index: PluginSkeleton.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/plugins/PluginSkeleton.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PluginSkeleton.java 20 Feb 2003 07:18:32 -0000 1.4
+++ PluginSkeleton.java 18 Mar 2003 13:33:30 -0000 1.5
@@ -1,9 +1,52 @@
/*
- * 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.plugins;
import org.apache.log4j.spi.LoggerRepository; @@ -28,29 +71,29 @@ public abstract class PluginSkeleton implements Plugin { /** Name of this plugin. */ protected String name = ""; - + /** Repository this plugin is attached to. */ protected LoggerRepository repository;
/** - Gets the name of the plugin. - + Gets the name of the plugin. + @return String the name of the plugin. */ public String getName() { return name; }
/** - Sets the name of the plugin. - + Sets the name of the plugin. + @param name the name of the plugin to set. */ public void setName(String name) { this.name = name; }
/**
- Gets the logger repository for this plugin.
-
+ Gets the logger repository for this plugin.
+
@return LoggerRepository the logger repository this plugin will affect. */
public LoggerRepository getLoggerRepository() {
return repository;
@@ -58,8 +101,8 @@
/**
Sets the logger repository used by this plugin. This
- repository will be used by the plugin functionality.
-
+ repository will be used by the plugin functionality.
+
@param repository the logger repository that this plugin should affect. */
public void setLoggerRepository(LoggerRepository repository) {
this.repository = repository;
1.3 +77 -35 jakarta-log4j/src/java/org/apache/log4j/test/AsyncAppenderTest.java
Index: AsyncAppenderTest.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/AsyncAppenderTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AsyncAppenderTest.java 9 Oct 2002 22:50:06 -0000 1.2
+++ AsyncAppenderTest.java 18 Mar 2003 13:33:30 -0000 1.3
@@ -1,66 +1,108 @@
-/* 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.test;
import org.apache.log4j.Category; +import org.apache.log4j.LogManager; import org.apache.log4j.xml.DOMConfigurator;
+ /** - Test the coordination of the AsyncAppender with its Dispatcher. - @author Ceki Gülcü -*/ + * Test the coordination of the AsyncAppender with its Dispatcher. + * + * @author Ceki Gülcü + */ public class AsyncAppenderTest { - static Category cat = Category.getInstance(AsyncAppenderTest.class); static int delayBeforeClose; - - - public - static - void main(String argv[]) {
- if(argv.length == 2) + public static void main(String[] argv) { + if (argv.length == 2) { init(argv[0], argv[1]); - else + } else { usage("Wrong number of arguments."); + } + test(); }
- - static - void usage(String msg) { + static void usage(String msg) { System.err.println(msg); - System.err.println( "Usage: java "+ Shallow.class.getName() + - "configFile"); + System.err.println( + "Usage: java " + Shallow.class.getName() + "configFile"); System.exit(1); }
- static - void init(String configFile, String delayBeforeCloseStr) { + static void init(String configFile, String delayBeforeCloseStr) { DOMConfigurator.configure(configFile); + try { - delayBeforeClose = Integer.parseInt(delayBeforeCloseStr); - } catch(java.lang.NumberFormatException e) { + delayBeforeClose = Integer.parseInt(delayBeforeCloseStr); + } catch (java.lang.NumberFormatException e) { e.printStackTrace(); - usage("Could not convert ["+delayBeforeCloseStr+"] to Integer."); - } + usage("Could not convert [" + delayBeforeCloseStr + "] to Integer."); + } }
+ static void test() { + Category root = Category.getRoot();
- static - void test() { - Category root = Category.getRoot(); - for(int i = 0; i < 100; i++) { - root.debug("Message " + i); + for (int i = 0; i < 100; i++) { + root.debug("Message " + i); }
- try{Thread.currentThread().sleep(delayBeforeClose);}catch(Exception e){}
- Category.shutdown();
- }
+ try {
+ Thread.currentThread().sleep(delayBeforeClose);
+ } catch (Exception e) {
+ }
- + LogManager.shutdown(); + } }
1.6 +59 -23 jakarta-log4j/src/java/org/apache/log4j/test/ConfigurationFileParsing.java
Index: ConfigurationFileParsing.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/ConfigurationFileParsing.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ConfigurationFileParsing.java 9 Oct 2002 22:50:06 -0000 1.5
+++ ConfigurationFileParsing.java 18 Mar 2003 13:33:30 -0000 1.6
@@ -1,44 +1,80 @@
/*
- * 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.test; +package org.apache.log4j.test;
-import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.Category; +import org.apache.log4j.LogManager; import org.apache.log4j.NDC; +import org.apache.log4j.PropertyConfigurator;
-public class ConfigurationFileParsing { - - public - static - void main(String argv[]) {
- if(argv.length == 1) { +public class ConfigurationFileParsing { + public static void main(String[] argv) { + if (argv.length == 1) { NDC.push("testing"); PropertyConfigurator.configure(argv[0]); + Category root = Category.getRoot(); root.debug("Message 1"); - root.debug("Message 2"); + root.debug("Message 2"); NDC.pop(); - Category.shutdown(); - } - else { + LogManager.shutdown(); + } else { Usage("Wrong number of arguments."); } - }
- static
- void Usage(String msg) {
+ static void Usage(String msg) {
System.err.println(msg);
- System.err.println("Usage: java "+ConfigurationFileParsing.class.getName()
- + " fileName");
+ System.err.println(
+ "Usage: java " + ConfigurationFileParsing.class.getName() + " fileName");
System.exit(1);
}
-
-
}
1.5 +2 -1 jakarta-log4j/src/java/org/apache/log4j/test/PatternTest.java
Index: PatternTest.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/PatternTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PatternTest.java 13 Feb 2001 17:37:31 -0000 1.4
+++ PatternTest.java 18 Mar 2003 13:33:30 -0000 1.5
@@ -1,6 +1,7 @@
package org.apache.log4j.test;
+import org.apache.log4j.LogManager; import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.Category; import org.apache.log4j.Priority; @@ -73,6 +74,6 @@ CAT.log(Priority.FATAL, "Message " + ++i, e); root.log(Priority.FATAL, "Message " + i, e);
- Category.shutdown(); + LogManager.shutdown(); } }
1.9 +8 -7 jakarta-log4j/src/java/org/apache/log4j/test/Shallow.java
Index: Shallow.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/Shallow.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Shallow.java 24 Apr 2002 01:16:11 -0000 1.8
+++ Shallow.java 18 Mar 2003 13:33:30 -0000 1.9
@@ -9,8 +9,9 @@
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.xml.DOMConfigurator;
import org.apache.log4j.Category;
+import org.apache.log4j.LogManager;
import org.apache.log4j.NDC;
-import org.apache.log4j.Priority;
+import org.apache.log4j.Level;
/**
This class is a shallow test of the various appenders and
layouts. It also tests their reading of the configuration file.
@@ -62,8 +63,8 @@
cat.error("Message " + ++i);
root.error("Message " + i);
- cat.log(Priority.FATAL, "Message " + ++i); - root.log(Priority.FATAL, "Message " + i); + cat.log(Level.FATAL, "Message " + ++i); + root.log(Level.FATAL, "Message " + i);
Exception e = new Exception("Just testing"); cat.debug("Message " + ++i, e); @@ -78,14 +79,14 @@ cat.error("Message " + ++i, e); root.error("Message " + i, e);
- cat.log(Priority.FATAL, "Message " + ++i, e); - root.log(Priority.FATAL, "Message " + i, e); + cat.log(Level.FATAL, "Message " + ++i, e); + root.log(Level.FATAL, "Message " + i, e);
- root.setPriority(Priority.FATAL); + root.setLevel(Level.FATAL);
// It is always a good idea to call this method when exiting an // application. - Category.shutdown(); + LogManager.shutdown(); }
1.9 +2 -1 jakarta-log4j/src/java/org/apache/log4j/test/ShortSocketServer.java
Index: ShortSocketServer.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/ShortSocketServer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ShortSocketServer.java 24 Apr 2002 01:16:11 -0000 1.8
+++ ShortSocketServer.java 18 Mar 2003 13:33:30 -0000 1.9
@@ -6,6 +6,7 @@
import java.net.ServerSocket;
import org.apache.log4j.Category;
+import org.apache.log4j.LogManager;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.helpers.LogLog;
import org.apache.log4j.net.SocketNode;
@@ -35,7 +36,7 @@
Socket socket = serverSocket.accept();
LogLog.debug("Connected to client at " + socket.getInetAddress());
LogLog.debug("Starting new socket node.");
- SocketNode sn = new SocketNode(socket, Category.getDefaultHierarchy());
+ SocketNode sn = new SocketNode(socket, LogManager.getLoggerRepository());
Thread t = new Thread(sn);
t.start();
t.join();
1.6 +74 -35 jakarta-log4j/src/java/org/apache/log4j/xml/test/DOMTest.java
Index: DOMTest.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/test/DOMTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DOMTest.java 27 Jun 2001 21:34:41 -0000 1.5
+++ DOMTest.java 18 Mar 2003 13:33:31 -0000 1.6
@@ -1,79 +1,118 @@
/*
- * 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.APL 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.xml.test;
-import org.apache.log4j.xml.DOMConfigurator; import org.apache.log4j.Category; +import org.apache.log4j.LogManager; import org.apache.log4j.Priority; +import org.apache.log4j.xml.DOMConfigurator; + + //import org.apache.log4j.xml.examples.ReportParserError; //import org.apache.xerces.parsers.DOMParser; //import java.io.FileInputStream; //import org.xml.sax.InputSource;
/** - @author Ceki Gülcü -*/ + * @author Ceki Gülcü + */ public class DOMTest { static Category cat = Category.getInstance(DOMTest.class.getName());
- - public - static - void main(String argv[]) { - - if(argv.length == 1) + public static void main(String[] argv) { + if (argv.length == 1) { init(argv[0]); - else + } else { Usage("Wrong number of arguments."); + }
test(); }
- static - void Usage(String msg) { + static void Usage(String msg) { System.err.println(msg); - System.err.println( "Usage: java " + DOMTest.class.getName() + - " configFile"); + System.err.println( + "Usage: java " + DOMTest.class.getName() + " configFile"); System.exit(1); } - - static - void init(String configFile) { + + static void init(String configFile) { DOMConfigurator.configure(configFile); }
- static - void test() { + static void test() { int i = -1; Category root = Category.getRoot(); - + cat.debug("Message " + ++i); - root.debug("Message " + i); + root.debug("Message " + i);
- cat.info ("Message " + ++i); - root.info("Message " + i); + cat.info("Message " + ++i); + root.info("Message " + i);
- cat.warn ("Message " + ++i); - root.warn("Message " + i); + cat.warn("Message " + ++i); + root.warn("Message " + i);
cat.error("Message " + ++i); root.error("Message " + i); - + cat.log(Priority.FATAL, "Message " + ++i); - root.log(Priority.FATAL, "Message " + i); - + root.log(Priority.FATAL, "Message " + i); + Exception e = new Exception("Just testing"); cat.debug("Message " + ++i, e); root.debug("Message " + i, e); - + cat.error("Message " + ++i, e); - root.error("Message " + i, e); + root.error("Message " + i, e);
- Category.shutdown(); + LogManager.shutdown(); } }
1.36 +280 -175 jakarta-log4j/src/java/org/apache/log4j/spi/LoggingEvent.java
Index: LoggingEvent.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/LoggingEvent.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- LoggingEvent.java 18 Feb 2003 19:58:09 -0000 1.35
+++ LoggingEvent.java 18 Mar 2003 13:33:31 -0000 1.36
@@ -1,181 +1,260 @@
/*
- * 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.spi;
import org.apache.log4j.*; - -import org.apache.log4j.helpers.LogLog; import org.apache.log4j.helpers.Loader; -import java.lang.reflect.Method; -import java.io.ObjectOutputStream; +import org.apache.log4j.helpers.LogLog; + import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import java.lang.reflect.Method; + import java.util.Hashtable;
+ // Contributors: Nelson Minar <[EMAIL PROTECTED]> // Wolf Siberski // Anders Kristensen <[EMAIL PROTECTED]>
/**
- The internal representation of logging events. When an affirmative
- decision is made to log then a <code>LoggingEvent</code> instance
- is created. This instance is passed around to the different log4j
- components.
-
- <p>This class is of concern to those wishing to extend log4j.
-
- @author Ceki Gülcü
- @author James P. Cakalic
-
- @since 0.8.2 */
+ * The internal representation of logging events. When an affirmative decision
+ * is made to log then a <code>LoggingEvent</code> instance is created. This
+ * instance is passed around to the different log4j components.
+ *
+ * <p>
+ * This class is of concern to those wishing to extend log4j.
+ * </p>
+ *
+ * @author Ceki Gülcü
+ * @author James P. Cakalic
+ *
+ * @since 0.8.2
+ */
public class LoggingEvent implements java.io.Serializable {
-
private static long startTime = System.currentTimeMillis();
- /** Fully qualified name of the calling category class. */
- transient public final String fqnOfCategoryClass;
+ // Serialization
+ static final long serialVersionUID = -868428216207166145L;
+ static final Integer[] PARAM_ARRAY = new Integer[1];
+ static final String TO_LEVEL = "toLevel";
+ static final Class[] TO_LEVEL_PARAMS = new Class[] { int.class };
+ static final Hashtable methodCache = new Hashtable(3); // use a tiny table
- /**
- * The category of the logging event. This field is not serialized
- * for performance reasons.
- *
- * <p>It is set by the LoggingEvent constructor or set by a remote
- * entity after deserialization.
+ /**
+ * Fully qualified name of the calling category class.
+ */
+ public final transient String fqnOfCategoryClass;
+
+ /**
+ * The category of the logging event. This field is not serialized for
+ * performance reasons.
*
- * @deprecated This field will be marked as private or be completely
- * removed in future releases. Please do not use it.
- * */
- transient private Category logger;
-
- /**
- * <p>The category (logger) name.
- *
- * @deprecated This field will be marked as private in future
- * releases. Please do not access it directly. Use the [EMAIL PROTECTED]
- * #getLoggerName} method instead.
-
- * */
- final public String categoryName;
-
- /**
- * Level of logging event. Level cannot be serializable because it
- * is a flyweight. Due to its special seralization it cannot be
- * declared final either.
- *
- * <p> This field should not be accessed directly. You shoud use the
- * [EMAIL PROTECTED] #getLevel} method instead.
+ * <p>
+ * It is set by the LoggingEvent constructor or set by a remote entity after
+ * deserialization.
+ * </p>
*
- * @deprecated This field will be marked as private in future
- * releases. Please do not access it directly. Use the [EMAIL PROTECTED]
+ * @deprecated This field will be marked as private or be completely removed
+ * in future releases. Please do not use it.
+ */
+ private transient Category logger;
+
+ /**
+ * <p>
+ * The category (logger) name.
+ * </p>
+ *
+ * @deprecated This field will be marked as private in future releases.
+ * Please do not access it directly. Use the [EMAIL PROTECTED]
+ * #getLoggerName} method instead.
+ */
+ public final String categoryName;
+
+ /**
+ * Level of logging event. Level cannot be serializable because it is a
+ * flyweight. Due to its special seralization it cannot be declared final
+ * either.
+ *
+ * <p>
+ * This field should not be accessed directly. You shoud use the [EMAIL PROTECTED]
* #getLevel} method instead.
- * */
- transient public Priority level;
+ * </p>
+ *
+ * @deprecated This field will be marked as private in future releases.
+ * Please do not access it directly. Use the [EMAIL PROTECTED] #getLevel}
+ * method instead.
+ */
+ public transient Priority level;
- /** The nested diagnostic context (NDC) of logging event. */ + /** + * The nested diagnostic context (NDC) of logging event. + */ private String ndc;
- /** The mapped diagnostic context (MDC) of logging event. */ + /** + * The mapped diagnostic context (MDC) of logging event. + */ private Hashtable mdcCopy;
- /** A map of String keys and String values. - @since 1.3 + /** + * A map of String keys and String values. + * + * @since 1.3 */ private Hashtable properties;
- /** Have we tried to do an NDC lookup? If we did, there is no need
- * to do it again. Note that its value is always false when
- * serialized. Thus, a receiving SocketNode will never use it's own
- * (incorrect) NDC. See also writeObject method. */
+ /**
+ * Have we tried to do an NDC lookup? If we did, there is no need to do it
+ * again. Note that its value is always false when serialized. Thus, a
+ * receiving SocketNode will never use it's own (incorrect) NDC. See also
+ * writeObject method.
+ */
private boolean ndcLookupRequired = true;
- /** Have we tried to do an MDC lookup? If we did, there is no need
- * to do it again. Note that its value is always false when
- * serialized. See also the getMDC and getMDCCopy methods. */
+ /**
+ * Have we tried to do an MDC lookup? If we did, there is no need to do it
+ * again. Note that its value is always false when serialized. See also
+ * the getMDC and getMDCCopy methods.
+ */
private boolean mdcCopyLookupRequired = true;
- /** The application supplied message of logging event. */ - transient private Object message; + /** + * The application supplied message of logging event. + */ + private transient Object message;
- /** The application supplied message rendered through the log4j - objet rendering mechanism.*/ + /** + * The application supplied message rendered through the log4j objet + * rendering mechanism. + */ private String renderedMessage;
- /** The name of thread in which this logging event was generated. */ + /** + * The name of thread in which this logging event was generated. + */ private String threadName;
- /** This - variable contains information about this event's throwable - */ + /** + * This variable contains information about this event's throwable + */ private ThrowableInformation throwableInfo;
- /** The number of milliseconds elapsed from 1/1/1970 until logging event
- was created. */
+ /**
+ * The number of milliseconds elapsed from 1/1/1970 until logging event was
+ * created.
+ */
public final long timeStamp;
- /** Location information for the caller. */
- private LocationInfo locationInfo;
-
- // Serialization
- static final long serialVersionUID = -868428216207166145L;
- static final Integer[] PARAM_ARRAY = new Integer[1];
- static final String TO_LEVEL = "toLevel";
- static final Class[] TO_LEVEL_PARAMS = new Class[] { int.class };
- static final Hashtable methodCache = new Hashtable(3); // use a tiny table
+ /**
+ * Location information for the caller.
+ */
+ private LocationInfo locationInfo;
/** - Instantiate a LoggingEvent from the supplied parameters. - - <p>Except [EMAIL PROTECTED] #timeStamp} all the other fields of - <code>LoggingEvent</code> are filled when actually needed. - <p> - @param category The category of this event. - @param level The level of this event. - @param message The message of this event. - @param throwable The throwable of this event. */ + * Instantiate a LoggingEvent from the supplied parameters. + * + * <p> + * Except [EMAIL PROTECTED] #timeStamp} all the other fields of + * <code>LoggingEvent</code> are filled when actually needed. + * </p> + * + * <p></p> + * + * @param category The category of this event. + * @param level The level of this event. + * @param message The message of this event. + * @param throwable The throwable of this event. + */ public LoggingEvent( - String fqnOfCategoryClass, - Category logger, - Priority priority, - Object message, - Throwable throwable) { + String fqnOfCategoryClass, Category logger, Priority priority, + Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = priority; this.message = message; + if (throwable != null) { this.throwableInfo = new ThrowableInformation(throwable); } + timeStamp = System.currentTimeMillis(); }
/** - Instantiate a LoggingEvent from the supplied parameters. - - <p>Except [EMAIL PROTECTED] #timeStamp} all the other fields of - <code>LoggingEvent</code> are filled when actually needed. - <p> - @param category The category of this event. - @param timeStamp the timestamp of this logging event - @param level The level of this event. - @param message The message of this event. - @param throwable The throwable of this event. */ + * Instantiate a LoggingEvent from the supplied parameters. + * + * <p> + * Except [EMAIL PROTECTED] #timeStamp} all the other fields of + * <code>LoggingEvent</code> are filled when actually needed. + * </p> + * + * <p></p> + * + * @param category The category of this event. + * @param timeStamp the timestamp of this logging event + * @param level The level of this event. + * @param message The message of this event. + * @param throwable The throwable of this event. + */ public LoggingEvent( - String fqnOfCategoryClass, - Category logger, - long timeStamp, - Priority priority, - Object message, - Throwable throwable) { + String fqnOfCategoryClass, Category logger, long timeStamp, + Priority priority, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = priority; this.message = message; + if (throwable != null) { this.throwableInfo = new ThrowableInformation(throwable); } @@ -184,40 +263,45 @@ }
/** - Set the location information for this logging event. The collected - information is cached for future use. + * Set the location information for this logging event. The collected + * information is cached for future use. */ public LocationInfo getLocationInformation() { if (locationInfo == null) { locationInfo = new LocationInfo(new Throwable(), fqnOfCategoryClass); } + return locationInfo; }
/** * Return the level of this event. Use this form instead of directly - * accessing the <code>level</code> field. */ + * accessing the <code>level</code> field. + */ public Level getLevel() { return (Level) level; }
/** * Return the name of the logger. Use this form instead of directly - * accessing the <code>categoryName</code> field. + * accessing the <code>categoryName</code> field. */ public String getLoggerName() { return categoryName; }
/** - Return the message for this logging event. - - <p>Before serialization, the returned object is the message - passed by the user to generate the logging event. After - serialization, the returned value equals the String form of the - message possibly after object rendering. - - @since 1.1 */ + * Return the message for this logging event. + * + * <p> + * Before serialization, the returned object is the message passed by the + * user to generate the logging event. After serialization, the returned + * value equals the String form of the message possibly after object + * rendering. + * </p> + * + * @since 1.1 + */ public Object getMessage() { if (message != null) { return message; @@ -227,76 +311,86 @@ }
/**
- * This method returns the NDC for this event. It will return the
- * correct content even if the event was generated in a different
- * thread or even on a different machine. The [EMAIL PROTECTED] NDC#get} method
- * should <em>never</em> be called directly. */
+ * This method returns the NDC for this event. It will return the correct
+ * content even if the event was generated in a different thread or even on
+ * a different machine. The [EMAIL PROTECTED] NDC#get} method should <em>never</em> be
+ * called directly.
+ */
public String getNDC() {
if (ndcLookupRequired) {
ndcLookupRequired = false;
ndc = NDC.get();
}
+
return ndc;
}
/**
- Returns the the context corresponding to the <code>key</code>
- parameter. If there is a local MDC copy, possibly because we are
- in a logging server or running inside AsyncAppender, then we
- search for the key in MDC copy, if a value is found it is
- returned. Otherwise, if the search in MDC copy returns a null
- result, then the current thread's <code>MDC</code> is used.
-
- <p>Note that <em>both</em> the local MDC copy and the current
- thread's MDC are searched.
-
- */
+ * Returns the the context corresponding to the <code>key</code> parameter.
+ * If there is a local MDC copy, possibly because we are in a logging
+ * server or running inside AsyncAppender, then we search for the key in
+ * MDC copy, if a value is found it is returned. Otherwise, if the search
+ * in MDC copy returns a null result, then the current thread's
+ * <code>MDC</code> is used.
+ *
+ * <p>
+ * Note that <em>both</em> the local MDC copy and the current thread's MDC
+ * are searched.
+ * </p>
+ */
public Object getMDC(String key) {
Object r;
+
// Note the mdcCopy is used if it exists. Otherwise we use the MDC
// that is associated with the thread.
if (mdcCopy != null) {
r = mdcCopy.get(key);
+
if (r != null) {
return r;
}
}
+
return MDC.get(key);
}
/**
- Obtain a copy of this thread's MDC prior to serialization or
- asynchronous logging.
- */
+ * Obtain a copy of this thread's MDC prior to serialization or asynchronous
+ * logging.
+ */
public void getMDCCopy() {
if (mdcCopyLookupRequired) {
mdcCopyLookupRequired = false;
+
// the clone call is required for asynchronous logging.
// See also bug #5932.
Hashtable t = (Hashtable) MDC.getContext();
+
if (t != null) {
mdcCopy = (Hashtable) t.clone();
}
}
}
-
+
/**
* Return a previously set property. The return value can be null.
+ *
* @since 1.3
- * */
+ */
public String getProperty(String key) {
- if(properties == null)
+ if (properties == null) {
return null;
- else
+ } else {
return (String) properties.get(key);
+ }
}
public String getRenderedMessage() { - if (renderedMessage == null && message != null) { - if (message instanceof String) + if ((renderedMessage == null) && (message != null)) { + if (message instanceof String) { renderedMessage = (String) message; - else { - LoggerRepository repository = logger.getHierarchy(); + } else { + LoggerRepository repository = logger.getLoggerRepository();
if (repository instanceof RendererSupport) { RendererSupport rs = (RendererSupport) repository; @@ -306,57 +400,67 @@ } } } + return renderedMessage; }
/** - Returns the time when the application started, in milliseconds - elapsed since 01.01.1970. */ + * Returns the time when the application started, in milliseconds elapsed + * since 01.01.1970. + */ public static long getStartTime() { return startTime; }
public String getThreadName() { - if (threadName == null) + if (threadName == null) { threadName = (Thread.currentThread()).getName(); + } + return threadName; }
/** - Returns the throwable information contained within this - event. May be <code>null</code> if there is no such information. - - <p>Note that the [EMAIL PROTECTED] Throwable} object contained within a - [EMAIL PROTECTED] ThrowableInformation} does not survive serialization. - - @since 1.1 */ + * Returns the throwable information contained within this event. May be + * <code>null</code> if there is no such information. + * + * <p> + * Note that the [EMAIL PROTECTED] Throwable} object contained within a [EMAIL PROTECTED] + * ThrowableInformation} does not survive serialization. + * </p> + * + * @since 1.1 + */ public ThrowableInformation getThrowableInformation() { return throwableInfo; }
/** - Return this event's throwable's string[] representaion. - */ + * Return this event's throwable's string[] representaion. + */ public String[] getThrowableStrRep() { - - if (throwableInfo == null) + if (throwableInfo == null) { return null; - else + } else { return throwableInfo.getThrowableStrRep(); + } }
private void readLevel(ObjectInputStream ois) throws java.io.IOException, ClassNotFoundException { - int p = ois.readInt(); + try { String className = (String) ois.readObject(); + if (className == null) { level = Level.toLevel(p); } else { Method m = (Method) methodCache.get(className); + if (m == null) { Class clazz = Loader.loadClass(className); + // Note that we use Class.getDeclaredMethod instead of // Class.getMethod. This assumes that the Level subclass // implements the toLevel(int) method which is a @@ -366,6 +470,7 @@ m = clazz.getDeclaredMethod(TO_LEVEL, TO_LEVEL_PARAMS); methodCache.put(className, m); } + PARAM_ARRAY[0] = new Integer(p); level = (Level) m.invoke(null, PARAM_ARRAY); } @@ -381,19 +486,20 @@ readLevel(ois);
// Make sure that no location info is available to Layouts - if (locationInfo == null) + if (locationInfo == null) { locationInfo = new LocationInfo(null, null); + } }
/** - * Set a string property using a key and a string value. - * since 1.3 + * Set a string property using a key and a string value. since 1.3 */ public void setProperty(String key, String value) { - if(properties == null) { + if (properties == null) { properties = new Hashtable(5); // create a small hashtable } - properties.put(key, value); + + properties.put(key, value); }
private void writeObject(ObjectOutputStream oos) throws java.io.IOException {
@@ -422,10 +528,10 @@
}
private void writeLevel(ObjectOutputStream oos) throws java.io.IOException {
-
oos.writeInt(level.toInt());
Class clazz = level.getClass(); + if (clazz == Level.class) { oos.writeObject(null); } else { @@ -435,5 +541,4 @@ oos.writeObject(clazz.getName()); } } - }
1.9 +127 -93 jakarta-log4j/src/java/org/apache/log4j/Appender.java
Index: Appender.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/Appender.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Appender.java 28 Sep 2001 13:37:48 -0000 1.8
+++ Appender.java 18 Mar 2003 13:33:31 -0000 1.9
@@ -1,132 +1,166 @@
/*
- * 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;
-import org.apache.log4j.spi.Filter; import org.apache.log4j.spi.ErrorHandler; +import org.apache.log4j.spi.Filter; import org.apache.log4j.spi.LoggingEvent;
-/** - Implement this interface for your own strategies for outputting log - statements.
- @author Ceki Gülcü -*/ +/** + * Implement this interface for your own strategies for outputting log + * statements. + * + * @author Ceki Gülcü + */ public interface Appender { - /** - Add a filter to the end of the filter list. - - @since 0.9.0 + * Add a filter to the end of the filter list. + * + * @since 0.9.0 */ void addFilter(Filter newFilter);
/**
- Returns the head Filter. The Filters are organized in a linked list
- and so all Filters on this Appender are available through the result.
-
- @return the head Filter or null, if no Filters are present
- @since 1.1
- */
- public
- Filter getFilter();
+ * Returns the head Filter. The Filters are organized in a linked list and
+ * so all Filters on this Appender are available through the result.
+ *
+ * @return the head Filter or null, if no Filters are present
+ *
+ * @since 1.1
+ */
+ public Filter getFilter();
/** - Clear the list of filters by removing all the filters in it. - - @since 0.9.0 + * Clear the list of filters by removing all the filters in it. + * + * @since 0.9.0 */ - public - void clearFilters(); + public void clearFilters();
/**
- Release any resources allocated within the appender such as file
- handles, network connections, etc.
-
- <p>It is a programming error to append to a closed appender.
+ * Release any resources allocated within the appender such as file handles,
+ * network connections, etc.
+ *
+ * <p>
+ * It is a programming error to append to a closed appender.
+ * </p>
+ *
+ * @since 0.8.4
+ */
+ public void close();
- @since 0.8.4
- */
- public
- void close();
-
/**
- Log in <code>Appender</code> specific way. When appropriate,
- Loggers will call the <code>doAppend</code> method of appender
- implementations in order to log. */
- public
- void doAppend(LoggingEvent event);
-
+ * Log in <code>Appender</code> specific way. When appropriate, Loggers will
+ * call the <code>doAppend</code> method of appender implementations in
+ * order to log.
+ */
+ public void doAppend(LoggingEvent event);
/**
- Get the name of this appender. The name uniquely identifies the
- appender. */
- public
- String getName();
-
+ * Get the name of this appender. The name uniquely identifies the appender.
+ */
+ public String getName();
/** - Set the [EMAIL PROTECTED] ErrorHandler} for this appender. - - @ since 0.9.0 + * Set the [EMAIL PROTECTED] ErrorHandler} for this appender. + * + * @since 0.9.0 */ - public - void setErrorHandler(ErrorHandler errorHandler); + public void setErrorHandler(ErrorHandler errorHandler);
/** - Returns the [EMAIL PROTECTED] ErrorHandler} for this appender. - - @since 1.1 + * Returns the [EMAIL PROTECTED] ErrorHandler} for this appender. + * + * @since 1.1 */ - public - ErrorHandler getErrorHandler(); + public ErrorHandler getErrorHandler();
/** - Set the [EMAIL PROTECTED] Layout} for this appender. - - @since 0.8.1 - */ - public - void setLayout(Layout layout); + * Set the [EMAIL PROTECTED] Layout} for this appender. + * + * @since 0.8.1 + */ + public void setLayout(Layout layout);
/** - Returns this appenders layout. - - @since 1.1 - */ - public - Layout getLayout(); - + * Returns this appenders layout. + * + * @since 1.1 + */ + public Layout getLayout();
/** - Set the name of this appender. The name is used by other - components to identify this appender. - - @since 0.8.1 - */ - public - void setName(String name); + * Set the name of this appender. The name is used by other components to + * identify this appender. + * + * @since 0.8.1 + */ + public void setName(String name);
/**
- Configurators call this method to determine if the appender
- requires a layout. If this method returns <code>true</code>,
- meaning that layout is required, then the configurator will
- configure an layout using the configuration information at its
- disposal. If this method returns <code>false</code>, meaning that
- a layout is not required, then layout configuration will be
- skipped even if there is available layout configuration
- information at the disposal of the configurator..
-
- <p>In the rather exceptional case, where the appender
- implementation admits a layout but can also work without it, then
- the appender should return <code>true</code>.
-
- @since 0.8.4 */
- public
- boolean requiresLayout();
+ * Configurators call this method to determine if the appender requires a
+ * layout. If this method returns <code>true</code>, meaning that layout is
+ * required, then the configurator will configure an layout using the
+ * configuration information at its disposal. If this method returns
+ * <code>false</code>, meaning that a layout is not required, then layout
+ * configuration will be skipped even if there is available layout
+ * configuration information at the disposal of the configurator..
+ *
+ * <p>
+ * In the rather exceptional case, where the appender implementation admits
+ * a layout but can also work without it, then the appender should return
+ * <code>true</code>.
+ * </p>
+ *
+ * @since 0.8.4
+ */
+ public boolean requiresLayout();
}
[cut to fit the 100 KB limit]
--
Ceki
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]