You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2021/12/23 16:25:18 UTC
[logging-log4j1] 01/01: This commit was manufactured by cvs2svn to create tag 'LEVEL_REPLACES_PRIORITY'.
This is an automated email from the ASF dual-hosted git repository.
rgoers pushed a commit to annotated tag LEVEL_REPLACES_PRIORITY
in repository https://gitbox.apache.org/repos/asf/logging-log4j1.git
commit a3bbe94c4714988ba9ac7bbb8b69cd3a2760d047
Author: No Author <de...@apache.org>
AuthorDate: Sun Sep 2 20:05:40 2001 +0000
This commit was manufactured by cvs2svn to create tag
'LEVEL_REPLACES_PRIORITY'.
git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/tags/LEVEL_REPLACES_PRIORITY@309282 13f79535-47bb-0310-9956-ffa450edef68
---
.cvsignore | 2 -
INSTALL | 124 --
LICENSE.APL | 48 -
LICENSE.txt | 48 -
Makefile | 9 -
build.bat | 35 -
build.sh | 38 -
build/.cvsignore | 1 -
build/build.xml | 413 ------
build/lib/ant.jar | Bin 295934 -> 0 bytes
build/lib/jaxp.jar | Bin 5537 -> 0 bytes
build/lib/parser.jar | Bin 136198 -> 0 bytes
build/manifest.mf | 8 -
build/package-list | 59 -
build/siteBuild.sh | 34 -
build/siteBuild.xml | 49 -
contribs/CONTENTS | 101 --
contribs/CekiGulcu/Transform.java | 203 ---
contribs/EirikLygre/DailyFileAppender1.java | 232 ----
contribs/EirikLygre/mail-2001-01-18 | 27 -
contribs/JamesHouse/LogTextPanel.java | 182 ---
contribs/JamesHouse/LogTextPanelExample.java | 116 --
contribs/JamesHouse/TextPanelAppender.java | 201 ---
contribs/JamesHouse/mail-2001-01-23 | 70 -
contribs/Jamie Tsao/JMSQueueAppender.java | 225 ----
contribs/Jamie Tsao/mail-2001-06-20 | 11 -
contribs/JimMoore/LoggingOutputStream.java | 201 ---
contribs/JimMoore/mail-2001-03-12T1326 | 39 -
contribs/JimMoore/mail-2001-03-12T1454 | 112 --
contribs/JimMoore/mail-2001-03-13T0646 | 214 ---
contribs/KevinSteppe/JDBCAppender.java | 331 -----
contribs/KevinSteppe/JDBCTest.java | 81 --
contribs/KevinSteppe/mail-2001-02-01 | 542 --------
contribs/KitchingSimon/DatagramStringAppender.java | 274 ----
contribs/KitchingSimon/DatagramStringWriter.java | 164 ---
.../KitchingSimon/SingleLineTracerPrintWriter.java | 57 -
contribs/KitchingSimon/logconfig.xml | 42 -
contribs/KitchingSimon/mail-2001-02-07 | 88 --
contribs/KitchingSimon/udpserver.pl | 67 -
contribs/LeosLiterak/TempFileAppender.java | 178 ---
contribs/LeosLiterak/mail | 41 -
contribs/MarkDouglas/Log.txt | 17 -
contribs/MarkDouglas/SocketNode2.java | 102 --
contribs/MarkDouglas/SocketServer2.java | 83 --
contribs/MarkDouglas/mail-2001-01-17 | 50 -
contribs/SvenReimers/gui/JListView.java | 355 -----
contribs/SvenReimers/gui/JTableAppender.java | 227 ----
contribs/SvenReimers/gui/Makefile | 28 -
contribs/SvenReimers/gui/TextPaneAppender.java | 345 -----
contribs/SvenReimers/gui/examples/Makefile | 26 -
.../gui/examples/TextPaneAppenderExample.java | 101 --
contribs/ThomasFenner/JDBCAppender.java | 589 ---------
contribs/ThomasFenner/JDBCConnectionHandler.java | 26 -
contribs/ThomasFenner/JDBCIDHandler.java | 23 -
contribs/ThomasFenner/JDBCLogger.java | 456 -------
contribs/ThomasFenner/Log4JTest.java | 255 ----
contribs/ThomasFenner/code_example1.java | 37 -
contribs/ThomasFenner/code_example2.java | 113 --
contribs/ThomasFenner/configfile_example.txt | 35 -
contribs/VolkerMentzner/HTTPRequestHandler.java | 59 -
contribs/VolkerMentzner/Log4jRequestHandler.java | 161 ---
contribs/VolkerMentzner/PluggableHTTPServer.java | 246 ----
contribs/VolkerMentzner/RootRequestHandler.java | 143 --
.../VolkerMentzner/UserDialogRequestHandler.java | 119 --
contribs/VolkerMentzner/mail-03-05-2001 | 24 -
docs/.cvsignore | 1 -
docs/FAQ.html | 717 -----------
docs/HISTORY | 1362 --------------------
docs/TODO | 69 -
docs/TROUBLESHOOT.html | 253 ----
docs/contactUs.html | 219 ----
docs/critique.html | 584 ---------
docs/critique2.html | 164 ---
docs/deepExtension.html | 735 -----------
docs/documentation.html | 205 ---
docs/download.html | 227 ----
docs/earlier.html | 170 ---
docs/history.html | 180 ---
docs/images/cyberlab15.gif | Bin 238 -> 0 bytes
docs/images/ecaward_finalist_logo.gif | Bin 3015 -> 0 bytes
docs/images/logo.jpg | Bin 8184 -> 0 bytes
docs/index.html | 197 ---
docs/manual.html | 1257 ------------------
docs/od.gif | Bin 5741 -> 0 bytes
docs/overview.html | 11 -
docs/praise.html | 266 ----
docs/proposal.html | 345 -----
icons/BlueFlag.gif | Bin 959 -> 0 bytes
icons/COPYRIGHT | 3 -
icons/GreenFlag.gif | Bin 955 -> 0 bytes
icons/RedFlag.gif | Bin 959 -> 0 bytes
make/.cvsignore | 1 -
make/Makefile | 9 -
make/README | 30 -
make/TUTORIAL | 159 ---
make/exercise/Makefile | 9 -
make/exercise/Makefile.clean | 10 -
make/exercise/Makefile.sol | 9 -
make/exercise/echo/Echo.java | 9 -
make/exercise/echo/Makefile | 11 -
make/exercise/echo/Makefile.sol | 11 -
make/exercise/echo/client/EchoClient.java | 44 -
make/exercise/echo/client/Makefile | 10 -
make/exercise/echo/client/Makefile.sol | 10 -
make/exercise/echo/server/EchoServer.java | 50 -
make/exercise/echo/server/Makefile | 10 -
make/exercise/echo/server/Makefile.sol | 10 -
make/exercise/goInit | 1 -
make/exercise/goSolution | 1 -
make/make.inc | 94 --
packaging/.functions | 40 -
packaging/install | 189 ---
packaging/package-list | 59 -
packaging/tarmake | 72 --
src/Makefile | 10 -
src/java/Makefile | 10 -
src/java/org/Makefile | 10 -
src/java/org/apache/Makefile | 10 -
src/xdocs/contactUs.xml | 88 --
src/xdocs/documentation.xml | 66 -
src/xdocs/download.xml | 111 --
src/xdocs/earlier.xml | 29 -
src/xdocs/history.xml | 50 -
src/xdocs/index.xml | 66 -
src/xdocs/stylesheets/project.xml | 105 --
125 files changed, 16655 deletions(-)
diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644
index a618cc2..0000000
--- a/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-goEnv*
-dist
\ No newline at end of file
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 61a3257..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,124 +0,0 @@
-
-===========
-Using log4j
-===========
-
-1) First untar or unzip the distribution file.
-
-2) Assuming you chose to extract the distribution in to the
- PATH_OF_YOUR_CHOICE, untarring the distribution file should create
- a jakarta-log4j-X.X directory, where X.X is the log4j version
- number, under PATH_OF_YOUR_CHOICE.
-
-
-3) Add PATH_OF_YOUR_CHOICE\jakarta-log4j-X.X\dist\classes to the CLASSPATH
- variable.
-
-4) You can now test your installation. To do this issue the command:
-
- java org.apache.log4j.test.Hello
-
- You should see log statements appearing on the console.
-
-5) Refer to the javadoc documentation and the user manual on how to
- include log statements in your own code.
-
-=========
-JAR files
-=========
-
-The log4j distribution comes with two jar files: log4j-core.jar and
-log4j.jar.
-
-The first jar file contains the classes you need to use the package to
-print to a file or the console. The second jar file, in addition to
-the code contained in the first file, contains classes to interact
-with a Syslog daemon and code to output/receive log statements using
-TCP sockets plus all sort of other goodies.
-
-Note: If you install log4j.jar you DO NOT NEED to install
-log4j-core.jar on your classpath.
-
-==================
-log4j dependencies
-==================
-
-
-The log4j distribution comes with pre-compiled classes. Log4j is based
-on JDK 1.1 with the following additional requirements:
-
- ---------------------
- Package org.log4j.xml
- ---------------------
-
- The DOMConfigurator is based on the DOM Level 1 API. The
- DOMConfigurator.configure(Element) method will work with any
- XML parser that will pass it a DOM tree.
-
- The DOMConfigurator.configure(String filename) method and its variants
- require a JAXP compatible XMLparser, for example the Apache Xerces
- parser. Compiling the DOMConfigurator requires the presence of a
- JAXP parser in the classpath.
-
- Log4j is shipped with jaxp.jar and parser.jar files under the
- build/lib/ directory.
-
- -------------------
- RollingFileAppender
- -------------------
-
- For rather involved reasons RollingFileAppender requires JDK 1.2
- or above. This will be fixed in future releases of log4j. If you
- need RollingFileAppender to run under JDK 1.1 then you can
- simply remove RollingFileAppenderBeanInfo.class from log4j.jar.
-
- ------------
- SMTPAppender
- ------------
-
- The SMTPAppender relies on the JavaMail API. It has been tested with
- JavaMail API version 1.2. The JavaMail API requires the
- JavaBeans Activation Framework package. You can download the JavaMail API at:
-
- http://java.sun.com/products/javamail/
-
- and the JavaBeans Activation Framework at:
-
- http://java.sun.com/beans/glasgow/jaf.html
-
- -----------
- JMSAppender
- -----------
-
- The JMSAppender requires the JMS API as well as JNDI. The JMS API
- is usually bundled with the products of the vendors listed under
-
- http://java.sun.com/products/jms/vendors.html
-
- -----------------------
- JUnit testing framework
- -----------------------
-
- Log4j uses the JUnit framework for internal unit testing. If you
- want to compile all log4j source code, then you will need
- JUnit. JUnit is available from:
-
- http://www.junit.org
-
-==============
-Building log4j
-==============
-
-Like most java appilicatios today, log4j relies on ANT as its build
-tool. ANT is availale from "http://jakarta.apache.org/ant/". ANT
-requires a build file called build.xml which is part of this
-distribution.
-
-Log4j is shipped with ant.jar file under the build/lib/ directory.
-
-Alternatively, you might wish to use the GNU-Make build/compile
-environment included with the package. In that case, you need to
-create a make.loc file in the make directory. See the files
-make/README and make/TUTORIAL for further details.
-
-In case of problems send an e-mail note to <lo...@jakarta.apache.org>.
diff --git a/LICENSE.APL b/LICENSE.APL
deleted file mode 100644
index 007db57..0000000
--- a/LICENSE.APL
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * ============================================================================
- * 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
- * apache@apache.org.
- *
- * 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/>.
- *
- */
diff --git a/LICENSE.txt b/LICENSE.txt
deleted file mode 100644
index 007db57..0000000
--- a/LICENSE.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * ============================================================================
- * 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
- * apache@apache.org.
- *
- * 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/>.
- *
- */
diff --git a/Makefile b/Makefile
deleted file mode 100644
index d21f020..0000000
--- a/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-
-PKG_DIR :=
-DEPTH :=.
-JSOURCES:=
-SUBDIRS :=src
-
-# include master-rule file
-include $(DEPTH)/make/make.inc
-
diff --git a/build.bat b/build.bat
deleted file mode 100755
index 8a658fd..0000000
--- a/build.bat
+++ /dev/null
@@ -1,35 +0,0 @@
-@echo off
-
-REM --------------------------------------------
-REM No need to edit anything past here
-REM --------------------------------------------
-set _BUILDFILE=%BUILDFILE%
-set BUILDFILE=build\build.xml
-
-:final
-
-set _CLASSPATH=%CLASSPATH%
-
-if "%JAVA_HOME%" == "" goto javahomeerror
-if exist %JAVA_HOME%\lib\tools.jar set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\tools.jar
-
-set CLASSPATH=%CLASSPATH%;build\lib\ant.jar;
-set CLASSPATH=%CLASSPATH%;build\lib\jaxp.jar;
-set CLASSPATH=%CLASSPATH%;build\lib\parser.jar;
-
-
-%JAVA_HOME%\bin\java.exe org.apache.tools.ant.Main -buildfile %BUILDFILE% %1 %2 %3 %4 %5 %6 %7 %8 %9
-
-goto end
-
-REM -----------ERROR-------------
-:javahomeerror
-echo "ERROR: JAVA_HOME not found in your environment."
-echo "Please, set the JAVA_HOME variable in your environment to match the"
-echo "location of the Java Virtual Machine you want to use."
-
-:end
-set BUILDFILE=%_BUILDFILE%
-set _BUILDFILE=
-set CLASSPATH=%_CLASSPATH%
-set _CLASSPATH=
diff --git a/build.sh b/build.sh
deleted file mode 100644
index d529c18..0000000
--- a/build.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-#--------------------------------------------
-# No need to edit anything past here
-#--------------------------------------------
-if test -z "${JAVA_HOME}" ; then
- echo "ERROR: JAVA_HOME not found in your environment."
- echo "Please, set the JAVA_HOME variable in your environment to match the"
- echo "location of the Java Virtual Machine you want to use."
- exit
-fi
-
-if test -f ${JAVA_HOME}/lib/tools.jar ; then
- CLASSPATH=${CLASSPATH}:${JAVA_HOME}/lib/tools.jar
-fi
-
-# convert the existing path to unix
-if [ "$OSTYPE" = "cygwin32" ] || [ "$OSTYPE" = "cygwin" ] ; then
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-ANT_JAR='build/lib/ant.jar'
-JAXP_JAR='build/lib/jaxp.jar'
-PARSER_JAR='build/lib/parser.jar'
-
-CLASSPATH=${CLASSPATH}:${ANT_JAR}
-CLASSPATH=${CLASSPATH}:${JAXP_JAR}
-CLASSPATH=${CLASSPATH}:${PARSER_JAR}
-
-# convert the unix path to windows
-if [ "$OSTYPE" = "cygwin32" ] || [ "$OSTYPE" = "cygwin" ] ; then
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-fi
-
-BUILDFILE=build/build.xml
-
-${JAVA_HOME}/bin/java -classpath ${CLASSPATH} org.apache.tools.ant.Main \
- -buildfile ${BUILDFILE} "$@"
diff --git a/build/.cvsignore b/build/.cvsignore
deleted file mode 100644
index 8c25bff..0000000
--- a/build/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-velocity.log
\ No newline at end of file
diff --git a/build/build.xml b/build/build.xml
deleted file mode 100644
index 5bb5381..0000000
--- a/build/build.xml
+++ /dev/null
@@ -1,413 +0,0 @@
-
-<!-- This file is an ANT build script. ANT is a Java based build tool. -->
-<!-- It is availale from http://jakarta.apache.org/ant/ -->
-
-
-<!-- ================================================================= -->
-<!-- NOTE: all directories are relative to jakarta-log4j/ -->
-<!-- the parent of build/ -->
-<!-- ================================================================= -->
-<project name="log4j" default="usage" basedir=".." >
-
- <property name="version" value="1.1.3"/>
-
- <!-- The base directory relative to which most targets are built -->
- <property name="base" value="."/>
-
- <!-- The directory where source files are stored. -->
- <property name="java.source.dir" value="src/java/"/>
-
- <!-- The directory where the package-list file is found, ./ or -->
- <!-- build/ -->
- <property name="packaging.dir" value="build"/>
-
- <!-- Destination for compiled files -->
- <property name="javac.dest" value="dist/classes"/>
-
- <!-- Destination for generated jar files -->
- <property name="jar.dest" value="dist/lib"/>
-
- <!-- Destination for documentation files generated or not -->
- <property name="docs" value="docs"/>
-
- <!-- Destination for javadoc generated files -->
- <property name="javadoc.dest" value="docs/api"/>
-
- <!-- Icons source directory. -->
- <property name="icons.source" value="icons"/>
-
- <!-- The stem where most log4j source code is located. -->
- <property name="stem" value="org/apache/log4j"/>
-
- <!-- Some targets needs a more precise stem. -->
- <property name="BSTEM" value="${java.source.dir}/${stem}"/>
-
- <!-- Original manifest.mf file before filtering. -->
- <property name="manifest.src" value="build/manifest.mf"/>
-
- <!-- Directory where release images go. -->
- <property name="dist.images" value="dist/images"/>
-
- <!-- Directory for temporary files. -->
- <property name="dist.tmp" value="dist/tmp"/>
-
-
- <target name="usage">
- <echo>
-
- These are the targets supported by this ANT build scpript:
-
- build - compile all project files, if a certain library is missing,
- then the compilation of its dependents are skipped.
-
- javadoc - build project javadoc files
-
- jar - build log4j-core and log4j jar files
-
- dist - will create a complete distribution in dist/
- </echo>
- </target>
-
- <target name="junitCheck">
- <available classname="junit.framework.TestCase" property="junit-present"/>
- </target>
- <target name="junit" depends="junitCheck" if="junit-present">
- <echo message="JUnit is present."/>
- </target>
-
- <target name="xercesCheck">
- <available classname="org.apache.xerces.parsers.DOMParser"
- property="xerces-present"/>
- <available classname="org.apache.xerces.parsers.DOMParser"
- property="jaxp-present"/>
- </target>
- <target name="xerces" depends="xercesCheck" if="xerces-present">
- <echo message="Xerces is present."/>
- </target>
-
- <target name="sunParserCheck">
- <available classname="com.sun.xml.parser.DocumentBuilderFactoryImpl"
- property="sunParser-present"/>
- <available classname="com.sun.xml.parser.DocumentBuilderFactoryImpl"
- property="jaxp-present"/>
- </target>
- <target name="sunParser" depends="sunParserCheck" if="sunParser-present">
- <echo message="Sun JAXP parser is present."/>
- </target>
-
-
- <target name="jmsCheck">
- <available classname="javax.jms.Message" property="jms-present"/>
- </target>
- <target name="jms" depends="jmsCheck" if="jms-present">
- <echo message="JMS is present."/>
- </target>
-
- <target name="jndiCheck">
- <available classname="javax.naming.Context" property="jndi-present"/>
- </target>
- <target name="jndi" depends="jndiCheck" if="jndi-present">
- <echo message="JNDI is present."/>
- </target>
-
- <target name="javamailCheck">
- <available classname="javax.mail.Message" property="javamail-present"/>
- </target>
- <target name="javamail" depends="javamailCheck" if="javamail-present">
- <echo message="JAVAMAIL is present."/>
- </target>
-
- <!-- ================================================================= -->
- <!-- Initialize variables -->
- <!-- NOTE: all directories are relative to jakarta-log4j/ -->
- <!-- ================================================================= -->
- <target name="init">
- <tstamp />
- </target>
-
- <target name="build" depends="init, build.core, build.xml, build.unitTests,
- build.javamail, build.jms"/>
-
- <target name="build.core" depends="init">
- <mkdir dir="${javac.dest}" />
- <javac srcdir="${java.source.dir}"
- destdir="${javac.dest}"
- includes="${stem}/**/*.java, ${stem}/xml/XMLLayout.java,"
- classpath="${classpath}"
- excludes="misc/*, **/UnitTest*.java,
- **/doc-files/*,
- ${stem}/xml/**,
- ${stem}/gui/**,
- ${stem}/net/SMTPAppender.java,
- ${stem}/net/JMS*.java,
- ${stem}/or/MessageRenderer.java,
- **/pending/**"
- debug="on"/>
- <rmic base="${javac.dest}"
- classname="org.apache.log4j.examples.NumberCruncherServer"
- />
- </target>
-
- <target name="build.unitTests" depends="init, junit" if="junit-present">
- <javac srcdir="${java.source.dir}"
- destdir="${javac.dest}"
- includes="**/UnitTest*.java"
- classpath="${classpath}"/>
- </target>
-
- <target name="build.xml" depends="init, xerces, sunParser" if="jaxp-present">
- <javac srcdir="${java.source.dir}"
- destdir="${javac.dest}"
- includes="${stem}/xml/**/*.java"
- excludes="${stem}/xml/examples/doc-files/**.java,
- ${stem}/xml/Transform.java"
- classpath="${classpath}"/>
- <copy file="${BSTEM}/xml/log4j.dtd"
- tofile="${javac.dest}/${stem}/xml/log4j.dtd" />
- </target>
-
- <target name="build.javamail" depends="init, javamail"
- if="javamail-present">
- <javac srcdir="${java.source.dir}"
- destdir="${javac.dest}"
- includes="${stem}/net/SMTPAppender.java"
- classpath="${classpath}"/>
- </target>
-
- <target name="build.jms" depends="init, jms, jndi" if="jms-present">
- <javac srcdir="${java.source.dir}"
- destdir="${javac.dest}"
- includes="${stem}/net/JMS*.java"
- classpath="${classpath}"/>
- </target>
-
-
- <!-- ================================================================= -->
- <!-- Remove all generated (compiled) class files. -->
- <!-- ================================================================= -->
- <target name="clean" depends="init">
- <delete dir="${javac.dest}/" />
- </target>
-
- <!-- ================================================================= -->
- <!-- Remove the temporary manifest file, actual work is done in the -->
- <!-- dependencies. -->
- <!-- ================================================================= -->
- <target name="jar" depends="log4j-core.jar, log4j.jar">
- <delete file="${jar.dest}/manifest.mf"/>
- </target>
-
- <target name="prejar" depends="build">
- <mkdir dir="${jar.dest}"/>
- <filter token="version" value="${version}" />
- <copy file="${manifest.src}" tofile="${jar.dest}/manifest.mf"
- filtering="true"/>
- </target>
-
-
- <!-- ================================================================= -->
- <!-- Create log4j-core.jar, exluding non-core files -->
- <!-- ================================================================= -->
-
- <target name="log4j-core.jar" depends="prejar">
- <delete file="${jar.dest}/log4j-core.jar"/>
- <jar jarfile="${jar.dest}/log4j-core.jar" basedir="${javac.dest}"
- includes="${stem}/*.class,
- ${stem}/helpers/*.class,
- ${stem}/spi/*.class,
- ${stem}/or/*.class,
- ${stem}/config/PropertySetter.class
- ${stem}/config/PropertySetterException.class"
-
- excludes="**/StressCategory*, **/TTCC*, **/SimpleLayout.*,
- ${stem}/DailyRollingFileAppender.class,
- ${stem}/CompositeRollingAppender.class,
- ${stem}/Rolling*.class,
- ${stem}/HTMLLayout.class,
- ${stem}/helpers/CountingQuietWriter.class,
- ${stem}/helpers/DateLayout.class,
- ${stem}/or/ThreadGroupRenderer.class,
- **/AsyncAppender.*, **/Dispatcher.*, **/BoundedFIFO.*,
- **/Syslog*, **/RelativeTimeDateFormat.*,
- ${stem}/gui/**/*.class,
- **/UnitTest*.class,
- ${stem}/or/MessageRenderer.class,
- ${stem}/spi/TriggeringEventEvaluator.class
- ${stem}/helpers/CyclicBuffer.class"
- manifest="${jar.dest}/manifest.mf"
- />
- </target>
-
- <!-- ================================================================= -->
- <!-- Create log4j.jar, excluding tests and other odds and ends. -->
- <!-- ================================================================= -->
- <target name="log4j.jar" depends="prejar">
- <delete file="${jar.dest}/log4j.jar"/>
- <jar jarfile="${jar.dest}/log4j.jar" basedir="${javac.dest}"
- includes="${stem}/*.class, ${stem}/xml/log4j.dtd,
- ${stem}/config/*.class,
- ${stem}/helpers/*.class,
- ${stem}/spi/*.class,
- ${stem}/net/*.class,
- ${stem}/varia/*.class,
- ${stem}/nt/*.class,
- ${stem}/xml/*.class,
- ${stem}/or/*.class,
- ${stem}/config/*.class,
- ${stem}/gui/TextPaneAppender.class"
- excludes="**/StressCategory*, **/UnitTest**"
- manifest="${jar.dest}/manifest.mf"
- />
- </target>
-
-
- <!-- ================================================================= -->
- <!-- This target builds the javadoc files. -->
- <!-- ================================================================= -->
- <target name="javadoc" depends="init">
-
- <mkdir dir="${javadoc.dest}" />
-
- <copy todir="${BSTEM}/examples/doc-files/">
- <fileset dir="${BSTEM}/examples/"
- includes="Sort.java, SortAlgo.java, Trivial.java, MyCategory.java,
- MyCategoryFactory.java, mycat.good, mycat.bad, factor.html,
- MyPatternLayout.java, MyPatternParser.java, sort2.lcf, sort3.lcf,
- NumberCruncherClient.java, NumberCruncherServer.java, sort1.lcf,
- NumberCruncher.java, factor.lcf, sort4.lcf"/>
- </copy>
-
- <copy todir="${BSTEM}/xml/examples/doc-files/" >
- <fileset dir="${BSTEM}/xml/examples/"
- includes="XMLSample.java, XCategory.java, XTest.java"/>
- </copy>
-
- <copy todir="${BSTEM}/xml/doc-files/" >
- <fileset dir="${BSTEM}/xml/" includes="log4j.dtd"/>
- <fileset dir="${BSTEM}/xml/test/" includes="*.xml"/>
- <fileset dir="${BSTEM}/xml/examples/"
- includes="sample*.xml, extension?.xml"/>
- </copy>
-
-
- <javadoc sourcepath="${java.source.dir}"
- destdir="${javadoc.dest}"
- packagenames="org.apache.log4j,
- org.apache.log4j.config,
- org.apache.log4j.examples,
- org.apache.log4j.examples.appserver,
- org.apache.log4j.helpers,
- org.apache.log4j.net,
- org.apache.log4j.nt,
- org.apache.log4j.or,
- org.apache.log4j.performance,
- org.apache.log4j.spi,
- org.apache.log4j.varia,
- org.apache.log4j.xml,
- org.apache.log4j.xml.examples"
- version="true"
- protected="true"
- author="true"
- use="true"
- overview="${docs}/overview.html"
- doctitle="log4j version ${version}<br>API Specification"
- windowtitle="Log4j Version ${version}"
- header="<b>Log4j ${version}</b>"
- bottom="Please <a href=http://lists.sourceforge.net/mailman/listinfo/log4j-announce><b>notify me</b></a> about new log4j releases. <hr>">
-
- <link offline="true"
- href="http://java.sun.com/products/jdk/1.2/docs/api"
- packageListLoc="${packaging.dir}"/>
- </javadoc>
- </target>
-
- <!-- ================================================================= -->
- <!-- Build a complete distribution. Results go to ${dist.images} -->
- <!-- ================================================================= -->
- <target name="dist" depends="init, clean, jar, javadoc">
-
- <delete verbose="true">
- <fileset dir=".">
- <patternset>
- <include name="**/*.bak"/>
- <include name="dist/velocity.log"/>
- <include name="${BSTEM}/**/temp*"/>
- <include name="${BSTEM}/performance/test"/>
- <include name="${BSTEM}/test/current.*"/>
- <include name="${BSTEM}/test/current.*"/>
- <include name="${BSTEM}/examples/test"/>
- <include name="${BSTEM}/test/logging.*"/>
- <include name="${BSTEM}/test/log4j.properties"/>
- <include name="{$BSTEM}/test/socket.lcf"/>
- <include name="${BSTEM}/test/file"/>
- <include name="${BSTEM}/test/output.*"/>
- <include name="${BSTEM}/nt/EventLogCategories.dbg"/>
- <include name="${BSTEM}/nt/*.h"/>
- <include name="${BSTEM}/nt/*.obj"/>
- <include name="${BSTEM}/nt/*.idb"/>
- <include name="${BSTEM}/nt/EventLogCategories.rc"/>
- <include name="${BSTEM}/nt/EventLogCategories.RES"/>
- <include name="${BSTEM}/nt/EventLogCategories.res"/>
- <include name="${BSTEM}/nt/MSG00001.bin"/>
- <include name="${BSTEM}/nt/NTEventLogAppender.lib"/>
- <include name="${BSTEM}/nt/NTEventLogAppender.exp"/>
- <include name="${BSTEM}/nt/vc50.idb"/>
- <include name="${BSTEM}/net/test/loop.log"/>
- <include name="${BSTEM}/net/test/loop.log.1"/>
- <include name="${jar.dest}/manifest.mf"/>
- <include name="${javac.dest}/*.class"/>
- </patternset>
- </fileset>
- </delete>
-
- <mkdir dir="${dist.images}" />
-
- <mkdir dir="${dist.tmp}/jakarta-log4j-${version}" />
-
- <copy todir="${dist.tmp}/jakarta-log4j-${version}">
- <fileset dir="${base}"
- includes="make/**,
- src/**,
- docs/**,
- Makefile,
- build/*, build.bat, build.sh,
- build/lib/*.jar,
- manifest.mf,
- INSTALL,
- LICENSE.APL,
- dist/lib/*.jar,
- org/**,
- icons/**,
- dist/classes/**,
- contribs/**"
- excludes="make/make.loc,
- **/*.bak, **/goEnv.bat,
- **/.#*"/>
- </copy>
-
-
- <fixcrlf srcdir="${dist.tmp}/jakarta-log4j-${version}"
- includes="build.sh" cr="remove"/>
- <fixcrlf srcdir="${dist.tmp}/jakarta-log4j-${version}"
- includes="build.bat" cr="add"/>
- <chmod dir="${dist.tmp}/jakarta-log4j-${version}"
- includes="build.sh" perm="+x"/>
-
- <tar tarfile="${dist.images}/jakarta-log4j-${version}.tar"
- basedir="${dist.tmp}"
- includes="jakarta-log4j-${version}/**" />
-
- <gzip src="${dist.images}/jakarta-log4j-${version}.tar"
- zipfile="${dist.images}/jakarta-log4j-${version}.tar.gz" />
-
- <zip zipfile="${dist.images}/jakarta-log4j-${version}.zip"
- basedir="${dist.tmp}"
- includes="jakarta-log4j-${version}/**" />
-
-
- <delete dir="${dist.tmp}" />
-
- </target>
-
-</project>
-
diff --git a/build/lib/ant.jar b/build/lib/ant.jar
deleted file mode 100644
index e4efab3..0000000
Binary files a/build/lib/ant.jar and /dev/null differ
diff --git a/build/lib/jaxp.jar b/build/lib/jaxp.jar
deleted file mode 100644
index 8a08809..0000000
Binary files a/build/lib/jaxp.jar and /dev/null differ
diff --git a/build/lib/parser.jar b/build/lib/parser.jar
deleted file mode 100644
index cd16d4c..0000000
Binary files a/build/lib/parser.jar and /dev/null differ
diff --git a/build/manifest.mf b/build/manifest.mf
deleted file mode 100644
index 2628376..0000000
--- a/build/manifest.mf
+++ /dev/null
@@ -1,8 +0,0 @@
-Manifest-version: 1.0
-
-Name: org/apache/log4j/
-Implementation-Title: log4j
-Implementation-Version: @version@
-Implementation-Vendor: "Apache Software Foundation"
-
-
diff --git a/build/package-list b/build/package-list
deleted file mode 100644
index 407d0d7..0000000
--- a/build/package-list
+++ /dev/null
@@ -1,59 +0,0 @@
-java.applet
-java.awt
-java.awt.color
-java.awt.datatransfer
-java.awt.dnd
-java.awt.event
-java.awt.font
-java.awt.geom
-java.awt.im
-java.awt.image
-java.awt.image.renderable
-java.awt.print
-java.beans
-java.beans.beancontext
-java.io
-java.lang
-java.lang.ref
-java.lang.reflect
-java.math
-java.net
-java.rmi
-java.rmi.activation
-java.rmi.dgc
-java.rmi.registry
-java.rmi.server
-java.security
-java.security.acl
-java.security.cert
-java.security.interfaces
-java.security.spec
-java.sql
-java.text
-java.util
-java.util.jar
-java.util.zip
-javax.accessibility
-javax.swing
-javax.swing.border
-javax.swing.colorchooser
-javax.swing.event
-javax.swing.filechooser
-javax.swing.plaf
-javax.swing.plaf.basic
-javax.swing.plaf.metal
-javax.swing.plaf.multi
-javax.swing.table
-javax.swing.text
-javax.swing.text.html
-javax.swing.text.html.parser
-javax.swing.text.rtf
-javax.swing.tree
-javax.swing.undo
-org.omg.CORBA
-org.omg.CORBA.DynAnyPackage
-org.omg.CORBA.ORBPackage
-org.omg.CORBA.portable
-org.omg.CORBA.TypeCodePackage
-org.omg.CosNaming
-org.omg.CosNaming.NamingContextPackage
diff --git a/build/siteBuild.sh b/build/siteBuild.sh
deleted file mode 100644
index d6707e7..0000000
--- a/build/siteBuild.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-
-if [ "$JAVA_HOME" = "" ] ; then
- echo You must set JAVA_HOME to point at your Java Development Kit directory
- exit 1
-fi
-
-# convert the existing path to unix
-if [ "$OSTYPE" = "cygwin32" ] || [ "$OSTYPE" = "cygwin" ] ; then
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-# Add in the jakarta-site2 library files
-for i in ../../jakarta-site2/lib/*.jar
-do
- CLASSPATH=$CLASSPATH:"$i"
-done
-
-
-# convert the unix path to windows
-if [ "$OSTYPE" = "cygwin32" ] || [ "$OSTYPE" = "cygwin" ] ; then
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-fi
-
-echo "CLASSPATH=$CLASSPATH"
-
-BUILDFILE=siteBuild.xml
-
-#echo $CLASSPATH
-
-java $ANT_OPTS -classpath "$CLASSPATH" org.apache.tools.ant.Main \
- -Dant.home=$ANT_HOME \
- -buildfile ${BUILDFILE} \
- "$@"
diff --git a/build/siteBuild.xml b/build/siteBuild.xml
deleted file mode 100644
index 5f9f844..0000000
--- a/build/siteBuild.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<project name="build-site" default="docs" basedir="..">
-
- <!-- Initialization properties -->
- <property name="project.name" value="log4j.site"/>
-
- <property name="docs.src" value="./src/xdocs"/>
- <property name="docs.dest" value="./docs"/>
-
- <target name="prepare">
- <available classname="org.apache.velocity.anakia.AnakiaTask"
- property="AnakiaTask.present"/>
- </target>
-
- <target depends="prepare" name="prepare-error" unless="AnakiaTask.present">
- <echo>
- AnakiaTask is not present! Please check to make sure that
- velocity.jar is in your classpath.
- </echo>
- </target>
-
- <target name="docs" depends="prepare-error" if="AnakiaTask.present">
- <taskdef name="anakia"
- classname="org.apache.velocity.anakia.AnakiaTask"/>
- <anakia basedir="${docs.src}" destdir="${docs.dest}/"
- extension=".html"
- style="site.vsl"
- projectFile="stylesheets/project.xml"
- excludes="**/stylesheets/**, empty.xml"
- includes="**/*.xml"
- lastModifiedCheck="true"
- templatePath="../jakarta-site2/xdocs/stylesheets">
- </anakia>
- <!--
- <copy todir="${docs.dest}/images" filtering="no">
- <fileset dir="${docs.src}/images">
- <include name="**/*.gif"/>
- <include name="**/*.jpeg"/>
- <include name="**/*.jpg"/>
- </fileset>
- </copy>
- In case we have CSS someday
- <copy todir="${docs.dest}" filtering="no">
- <fileset dir="${docs.src}">
- <include name="**/*.css"/>
- </fileset>
- </copy>
- -->
- </target>
-</project>
diff --git a/contribs/CONTENTS b/contribs/CONTENTS
deleted file mode 100644
index fdbd580..0000000
--- a/contribs/CONTENTS
+++ /dev/null
@@ -1,101 +0,0 @@
-
-----------------------------------------------------------------------
-WARNING: The contents of the contribs/ directory is not guaranteed to
-work properly. Some files might not even compile.
-----------------------------------------------------------------------
-
-Each directory corresponds to the name of an author containing his/her
-contributions.
-
-
-EirikLygre/
-==========
-
- DailyFileAppender1.java
-
- DailyFileAppender extends FileAppender to use filenames formatted with
- date/time information. The filename is recomputed every day at midnight.
- Note that the filename doesn't have to change every day, making it possible
- to have logfiles which are per-week or per-month.
-
-JamesHouse/
-==========
-
- LogTextPanel.java
- LogTextPanelExample.java
- TextPanelAppender.java
-
-JimMoore/
-========
-
- LoggingOutputStream.java
-
- Allows the user to divert System.out and System.err to log4j.
-
- WARNING: Be sure to read the included e-mails to understand the dangers of
- WARNING: redirecting the console to LoggingOutputStream.
-
-
-LeosLiterak/
-===========
-
- TempFileAppender.java
-
- TempFileAppender creates new unique file for each logging statement.
-
-MarkDouglas/
-===========
-
- SocketNode2.java
- SocketServer2.java
-
- Small changes to SocketServer and SockerNode to allow the client machine name
- to be displayed in the logging output. This is important for us as we are
- using a single logging server with several clients.
-
-KevinSteppe/
-===========
-
- JDBCAppender.java
- JDBCTest.java
-
-
-KitchingSimon/
-=============
-
- DatagramStringAppender.java
- DatagramStringWriter.java
- logconfig.xml
- SingleLineTracerPrintWriter.java
- udpserver.pl
-
- A set of files that implement an Appender which sends messages to a
- remote host/port via UDP (datagram). Message formatting is
- performed at the at the client end, mainly so that:
- (a) the UDP server application does not have to be in java
- (b) non-java clients can send messages to the same UDP server.
-
-ThomasFenner/
-============
-
- Yet one more JDBCAppender.
-
- JDBCAppender.java
- JDBCConnectionHandler.java
- JDBCIDHandler.java
- JDBCLogger.java
- Log4JTest.java
- code_example1.java
- code_example2.java
- configfile_example.txt
-
-Volker Mentzner/
-===============
-
- HTTPRequestHandler.java
- Log4jRequestHandler.java
- PluggableHTTPServer.java
- RootRequestHandler.java
- UserDialogRequestHandler.java
-
- Allows users to configure log4j at runtime using a web-browser.
\ No newline at end of file
diff --git a/contribs/CekiGulcu/Transform.java b/contribs/CekiGulcu/Transform.java
deleted file mode 100644
index 3a20b3e..0000000
--- a/contribs/CekiGulcu/Transform.java
+++ /dev/null
@@ -1,203 +0,0 @@
-
-package org.apache.log4j.xml;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.Layout;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.helpers.DateLayout;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.Attributes;
-import org.xml.sax.XMLReader;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.XMLReaderFactory;
-import org.xml.sax.SAXException;
-import org.apache.xerces.parsers.SAXParser;
-
-import org.apache.trax.Processor;
-import org.apache.trax.TemplatesBuilder;
-import org.apache.trax.Templates;
-import org.apache.trax.Transformer;
-import org.apache.trax.Result;
-import org.apache.trax.ProcessorException;
-import org.apache.trax.ProcessorFactoryException;
-import org.apache.trax.TransformException;
-
-
-import org.apache.serialize.SerializerFactory;
-import org.apache.serialize.Serializer;
-import org.apache.serialize.OutputFormat;
-import org.xml.sax.helpers.AttributesImpl;
-
-
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-
-public class Transform {
-
- public static void main(String[] args) throws Exception {
- PropertyConfigurator.disableAll();
- PropertyConfigurator.configure("x.lcf");
-
- // I. Instantiate a stylesheet processor.
- Processor processor = Processor.newInstance("xslt");
-
- // II. Process the stylesheet. producing a Templates object.
-
- // Get the XMLReader.
- XMLReader reader = XMLReaderFactory.createXMLReader();
-
- // Set the ContentHandler.
- TemplatesBuilder templatesBuilder = processor.getTemplatesBuilder();
- reader.setContentHandler(templatesBuilder);
-
- // Set the ContentHandler to also function as a LexicalHandler, which
- // includes "lexical" (e.g., comments and CDATA) events. The Xalan
- // TemplatesBuilder -- org.apache.xalan.processor.StylesheetHandler -- is
- // also a LexicalHandler).
- if(templatesBuilder instanceof LexicalHandler) {
- reader.setProperty("http://xml.org/sax/properties/lexical-handler",
- templatesBuilder);
- }
-
- // Parse the stylesheet.
- reader.parse(args[0]);
-
- //Get the Templates object from the ContentHandler.
- Templates templates = templatesBuilder.getTemplates();
-
- // III. Use the Templates object to instantiate a Transformer.
- Transformer transformer = templates.newTransformer();
-
- // IV. Perform the transformation.
-
- // Set up the ContentHandler for the output.
- FileOutputStream fos = new FileOutputStream(args[2]);
- Result result = new Result(fos);
- Serializer serializer = SerializerFactory.getSerializer("xml");
- serializer.setOutputStream(fos);
-
- transformer.setContentHandler(serializer.asContentHandler());
-
- // Set up the ContentHandler for the input.
- org.xml.sax.ContentHandler chandler = transformer.getInputContentHandler();
- DC dc = new DC(chandler);
- reader.setContentHandler(dc);
- if(chandler instanceof LexicalHandler) {
- reader.setProperty("http://xml.org/sax/properties/lexical-handler",
- chandler);
- } else {
- reader.setProperty("http://xml.org/sax/properties/lexical-handler",
- null);
- }
-
- // Parse the XML input document. The input ContentHandler and
- // output ContentHandler work in separate threads to optimize
- // performance.
- reader.parse(args[1]);
- }
-}
-
- class DC implements ContentHandler {
-
- static Category cat = Category.getInstance("DC");
-
- ContentHandler chandler;
-
- DC(ContentHandler chandler) {
- this.chandler = chandler;
- }
-
-
- public
- void characters(char[] ch, int start, int length)
- throws org.xml.sax.SAXException {
- cat.debug("characters: ["+new String(ch, start, length)+ "] called");
- chandler.characters(ch, start, length);
-
- }
-
- public
- void endDocument() throws org.xml.sax.SAXException {
- cat.debug("endDocument called.");
- chandler.endDocument();
-
- }
-
- public
- void endElement(String namespaceURI, String localName, String qName)
- throws org.xml.sax.SAXException {
- cat.debug("endElement("+namespaceURI+", "+localName+", "+qName+") called");
- chandler.endElement(namespaceURI, localName, qName);
- }
-
- public
- void endPrefixMapping(String prefix) throws org.xml.sax.SAXException {
- cat.debug("endPrefixMapping("+prefix+") called");
- chandler.endPrefixMapping(prefix);
- }
-
- public
- void ignorableWhitespace(char[] ch, int start, int length)
- throws org.xml.sax.SAXException {
- cat.debug("ignorableWhitespace called");
- chandler.ignorableWhitespace(ch, start, length);
- }
-
- public
- void processingInstruction(java.lang.String target, java.lang.String data)
- throws org.xml.sax.SAXException {
- cat.debug("processingInstruction called");
- chandler.processingInstruction(target, data);
- }
-
- public
- void setDocumentLocator(Locator locator) {
- cat.debug("setDocumentLocator called");
- chandler.setDocumentLocator(locator);
- }
-
- public
- void skippedEntity(String name) throws org.xml.sax.SAXException {
- cat.debug("skippedEntity("+name+") called");
- chandler.skippedEntity(name);
- }
-
- public
- void startDocument() throws org.xml.sax.SAXException {
- cat.debug("startDocument called");
- chandler.startDocument();
- }
-
- public
- void startElement(String namespaceURI, String localName, String qName,
- Attributes atts) throws org.xml.sax.SAXException {
- cat.debug("startElement("+namespaceURI+", "+localName+", "+qName+")called");
-
- if("log4j:event".equals(qName)) {
- cat.debug("-------------");
- if(atts instanceof org.xml.sax.helpers.AttributesImpl) {
- AttributesImpl ai = (AttributesImpl) atts;
- int i = atts.getIndex("timestamp");
- ai.setValue(i, "hello");
- }
- String ts = atts.getValue("timestamp");
- cat.debug("New timestamp is " + ts);
- }
- chandler.startElement(namespaceURI, localName, qName, atts);
- }
-
- public
- void startPrefixMapping(String prefix, String uri)
- throws org.xml.sax.SAXException {
- cat.debug("startPrefixMapping("+prefix+", "+uri+") called");
- chandler.startPrefixMapping(prefix, uri);
- }
-
-
-}
-
diff --git a/contribs/EirikLygre/DailyFileAppender1.java b/contribs/EirikLygre/DailyFileAppender1.java
deleted file mode 100644
index e724377..0000000
--- a/contribs/EirikLygre/DailyFileAppender1.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * 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. */
-
-
-
-package org.apache.log4j;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.io.FileWriter;
-import java.io.File;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.helpers.QuietWriter;
-import org.apache.log4j.helpers.CountingQuietWriter;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.ErrorCode;
-
-/**
- DailyFileAppender extends FileAppender to use filenames formatted with
- date/time information. The filename is recomputed every day at midnight.
- Note that the filename doesn't have to change every day, making it possible
- to have logfiles which are per-week or per-month.
-
- The appender computes the proper filename using the formats specified in
- <a href="http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html">
- java.text.SimpleDateFormat</a>. The format requires that most static text is
- enclosed in single quotes, which are removed. The examples below show how
- quotes are used to embed static information in the format.
-
- Sample filenames:
-
-<code>
- Filename pattern Filename
- "'/logs/trace-'yyyy-MM-dd'.log'" /logs/trace-2000-12-31.log
- "'/logs/trace-'yyyy-ww'.log'" /logs/trace-2000-52.log
-</code>
-
- @author <a HREF="mailto:eirik.lygre@evita.no">Eirik Lygre</a>
-*/
-public class DailyFileAppender extends FileAppender {
-
- /**
- A string constant used in naming the option for setting the
- filename pattern. Current value of this string constant is
- <strong>FileNamePattern</strong>.
- */
- static final public String FILE_NAME_PATTERN_OPTION = "FilePattern";
-
- /**
- The filename pattern
- */
- private String fileNamePattern = null;
-
- /**
- The actual formatted filename that is currently being written to
- */
- private String currentFileName = null;
-
- /**
- The timestamp when we shall next recompute the filename
- */
- private long nextFilenameComputingMillis = System.currentTimeMillis () - 1;
-
- /**
- The default constructor does no longer set a default layout nor a
- default output target. */
- public
- DailyFileAppender() {
- }
-
- /**
- Instantiate a RollingFileAppender and open the file designated by
- <code>filename</code>. The opened filename will become the ouput
- destination for this appender.
-
- <p>If the <code>append</code> parameter is true, the file will be
- appended to. Otherwise, the file desginated by
- <code>filename</code> will be truncated before being opened.
- */
- public DailyFileAppender (Layout layout,String filename,boolean append) throws IOException {
- super(layout, filename, append);
- }
-
- /**
- Instantiate a FileAppender and open the file designated by
- <code>filename</code>. The opened filename will become the output
- destination for this appender.
-
- <p>The file will be appended to. */
- public DailyFileAppender (Layout layout,String filename) throws IOException {
- super(layout, filename);
- }
-
- /**
- Set the current output file.
-
- The function will compute a new filename, and open a new file only
- when the name has changed.
-
- The function is automatically called once a day, to allow for
- daily files -- the purpose of this class.
- */
-
- public
- synchronized
- void setFile(String fileName, boolean append) throws IOException {
-
- /* Compute filename, but only if fileNamePattern is specified */
- if (fileNamePattern == null) {
- errorHandler.error("Missing file pattern (" + FILE_NAME_PATTERN_OPTION + ") in setFile().");
- return;
- }
-
- Date now = new Date();
-
- fileName = new SimpleDateFormat(fileNamePattern).format (now);
- if (fileName.equals(currentFileName))
- return;
-
- /* Set up next filename checkpoint */
- DailyFileAppenderCalendar c = new DailyFileAppenderCalendar();
- c.rollToNextDay ();
- nextFilenameComputingMillis = c.getTimeInMillis ();
-
- currentFileName = fileName;
-
- super.setFile(fileName, append);
- }
-
- /**
- This method differentiates RollingFileAppender from its super
- class.
-
- */
- protected
- void subAppend(LoggingEvent event) {
-
- if (System.currentTimeMillis () >= nextFilenameComputingMillis) {
- try {
- setFile (super.fileName, super.fileAppend);
- }
- catch(IOException e) {
- System.err.println("setFile(null, false) call failed.");
- e.printStackTrace();
- }
- }
-
- super.subAppend(event);
- }
-
- /**
- Retuns the option names for this component, namely {@link
- #FILE_NAME_PATTERN_OPTION} in
- addition to the options of {@link FileAppender#getOptionStrings
- FileAppender}.
- */
- public
- String[] getOptionStrings() {
-
- return OptionConverter.concatanateArrays(super.getOptionStrings(),
- new String[] {FILE_NAME_PATTERN_OPTION});
- }
-
- /**
- Set the options for the appender
- */
- public
- void setOption(String key, String value) {
- super.setOption(key, value);
- if(key.equalsIgnoreCase(FILE_NAME_PATTERN_OPTION)) {
- fileNamePattern = value;
- }
- }
-
- /**
- If the a value for {@link #FILE_OPTION} is non-null, then {@link
- #setFile} is called with the values of {@link #FILE_OPTION} and
- {@link #APPEND_OPTION}.
-
- @since 0.8.1 */
- public
- void activateOptions() {
- try {
- setFile(null, super.fileAppend);
- }
- catch(java.io.IOException e) {
- errorHandler.error("setFile(null,"+fileAppend+") call failed.",
- e, ErrorCode.FILE_OPEN_FAILURE);
- }
- }
-}
-
-/**
- DailyFileAppenderCalendar is a helper class to DailyFileAppender. Using
- this class, it is easy to compute and access the next Millis()
-
- It subclasses the standard
- <a href="http://java.sun.com/j2se/1.3/docs/api/java/text/GregorianCalendar.html">
- java.util.GregorianCalendar</a>-object, to allow access to the protected
- function getTimeInMillis(), which it then exports.
-
- @author <a HREF="mailto:eirik.lygre@evita.no">Eirik Lygre</a>
-*/
-class DailyFileAppenderCalendar extends java.util.GregorianCalendar
-{
- /**
- Returns the current time in Millis
- */
- public long getTimeInMillis() {
- return super.getTimeInMillis();
- }
-
- /**
- Roll the date to the next hour, with minute, second and millisecond
- set to zero.
- */
- public void rollToNextDay () {
- this.add(java.util.Calendar.DATE, 0);
- this.add(java.util.Calendar.HOUR, 0);
- this.set(java.util.Calendar.MINUTE, 0);
- this.set(java.util.Calendar.SECOND, 0);
- this.set(java.util.Calendar.MILLISECOND, 0);
- }
-}
\ No newline at end of file
diff --git a/contribs/EirikLygre/mail-2001-01-18 b/contribs/EirikLygre/mail-2001-01-18
deleted file mode 100644
index 98ed56e..0000000
--- a/contribs/EirikLygre/mail-2001-01-18
+++ /dev/null
@@ -1,27 +0,0 @@
-Delivered-To: urba-cgu@urbanet.ch
-To: Ceki Gulcu <cg...@urbanet.ch>
-From: Eirik_Lygre/evita/no%EVITA@evita.no
-Subject: Re: Suggestion for new appender "DailyFileAppender"
-Date: Thu, 18 Jan 2001 20:18:27 +0100
-X-MIMETrack: Serialize by Router on domino1/evita/no(Release 5.0.5 |September 22, 2000) at
- 18.01.2001 20:18:30
-
-
-
-This version subclasses GregorianCalendar, to get access to the
-millis-variable used in the Calendar-classes (it is protected).
-
-
-What do you think?
-
-
-Eirik
-
-
-++++++++++
-Eirik Lygre
-eirik.lygre@evita.no
-e-vita as, Stortorvet 3, Oslo
-Mobil: (+47) 905 66476
-Fax: (+47) 23 35 70 51
- DailyFileAppender1.jav
\ No newline at end of file
diff --git a/contribs/JamesHouse/LogTextPanel.java b/contribs/JamesHouse/LogTextPanel.java
deleted file mode 100644
index db59e3d..0000000
--- a/contribs/JamesHouse/LogTextPanel.java
+++ /dev/null
@@ -1,182 +0,0 @@
-package org.apache.log4j.gui;
-
-
-/**
- * Title:
- * Description:
- * Copyright: Copyright (c) 2001
- * Company:
- * @author
- * @version 1.0
- */
-
-import java.awt.Color;
-import java.awt.Image;
-import java.awt.Toolkit;
-import java.awt.BorderLayout;
-
-import javax.swing.*;
-import javax.swing.text.StyledDocument;
-import javax.swing.text.SimpleAttributeSet;
-import javax.swing.text.MutableAttributeSet;
-import javax.swing.text.StyleConstants;
-
-import java.util.Hashtable;
-import java.util.StringTokenizer;
-import java.util.Enumeration;
-import java.util.ArrayList;
-
-import org.apache.log4j.*;
-
-public class LogTextPanel extends JPanel {
-
- private JScrollBar scrollBar;
- private JTextPane textPane;
- private JCheckBox cbxTail;
- private StyledDocument doc;
-
- private Hashtable fontAttributes;
-
- private int eventBufferMaxSize = 10000;
- private ArrayList eventBuffer = new ArrayList(eventBufferMaxSize);
- private int eventViewIndex = 0;
-
- public LogTextPanel() {
- constructComponents();
- createDefaultFontAttributes();
- }
-
- private void constructComponents() {
- // setup the panel's additional components...
- this.setLayout(new BorderLayout());
-
- cbxTail = new JCheckBox();
- cbxTail.setSelected(true);
- cbxTail.setText("Tail log events");
-
- JPanel bottomPanel = new JPanel();
- bottomPanel.add(cbxTail, null);
-
- textPane = new JTextPane();
- textPane.setEditable(false);
- textPane.setText("");
- doc = textPane.getStyledDocument();
-
- scrollBar = new JScrollBar(JScrollBar.VERTICAL);
-
- this.add(bottomPanel, BorderLayout.SOUTH);
- this.add(scrollBar, BorderLayout.EAST);
- this.add(textPane, BorderLayout.CENTER);
- }
-
- public
- void setTextBackground(Color color) {
- textPane.setBackground(color);
- }
-
- public
- void setTextBackground(String v) {
- textPane.setBackground(parseColor(v));
- }
-
- private void createDefaultFontAttributes() {
- Priority[] prio = Priority.getAllPossiblePriorities();
-
- fontAttributes = new Hashtable();
- for (int i=0; i<prio.length;i++) {
- MutableAttributeSet att = new SimpleAttributeSet();
- fontAttributes.put(prio[i], att);
- //StyleConstants.setFontSize(att,11);
- }
-
- setTextColor(Priority.FATAL, Color.red);
- setTextColor(Priority.ERROR, Color.magenta);
- setTextColor(Priority.WARN, Color.orange);
- setTextColor(Priority.INFO, Color.blue);
- setTextColor(Priority.DEBUG, Color.black);
- }
-
- private
- Color parseColor (String v) {
- StringTokenizer st = new StringTokenizer(v,",");
- int val[] = {255,255,255,255};
- int i=0;
- while (st.hasMoreTokens()) {
- val[i]=Integer.parseInt(st.nextToken());
- i++;
- }
- return new Color(val[0],val[1],val[2],val[3]);
- }
-
- void setTextColor(Priority p, String v) {
- StyleConstants.setForeground(
- (MutableAttributeSet)fontAttributes.get(p),parseColor(v));
- }
-
- void setTextColor(Priority p, Color c) {
- StyleConstants.setForeground(
- (MutableAttributeSet)fontAttributes.get(p),c);
- }
-
- void setTextFontSize(int size) {
- Enumeration e = fontAttributes.elements();
- while (e.hasMoreElements()) {
- StyleConstants.setFontSize((MutableAttributeSet)e.nextElement(),size);
- }
- return;
- }
-
- void setTextFontName(String name) {
- Enumeration e = fontAttributes.elements();
- while (e.hasMoreElements()) {
- StyleConstants.setFontFamily((MutableAttributeSet)e.nextElement(),name);
- }
- return;
- }
-
- void setEventBufferSize(int bufferSize) {
- eventBufferMaxSize = bufferSize;
- }
-
- void newEvents(EventBufferElement[] evts) {
-
- if((eventBuffer.size() + evts.length) >= eventBufferMaxSize) {
- for(int i=0; i < evts.length; i++) {
- eventBuffer.remove(0);
- }
- eventViewIndex -= evts.length;
- if(eventViewIndex < 0)
- eventViewIndex = 0;
- }
- for(int i=0; i < evts.length; i++)
- eventBuffer.add(evts[i]);
-
- if((eventBuffer.size() > maxR) && cbxTail.isSelected()) {
- eventViewIndex = (eventBuffer.size() - maxR);
- }
-
- // only redraw if new line is visible...
- if((maxR < 0) || (eventBuffer.size() >= eventViewIndex && eventBuffer.size() <= (eventViewIndex + maxR)))
- drawText();
- }
-
- int maxR = -1;
-
- void drawText() {
- if(maxR < 0)
- maxR = textPane.getHeight() / textPane.getFontMetrics(textPane.getFont()).getHeight();
- try {
- doc.remove(0, doc.getLength());
- } catch(Exception e) { e.printStackTrace(); }
-
- for(int i=eventViewIndex; (i < eventBuffer.size()) && (i < (eventViewIndex + maxR)); i++) {
- EventBufferElement evt = (EventBufferElement)eventBuffer.get(i);
-
- try {
- doc.insertString(doc.getLength(), evt.text, (MutableAttributeSet)fontAttributes.get(evt.prio));
- } catch(Exception e) { e.printStackTrace(); }
- }
- }
-
-
-}
\ No newline at end of file
diff --git a/contribs/JamesHouse/LogTextPanelExample.java b/contribs/JamesHouse/LogTextPanelExample.java
deleted file mode 100644
index 74f1c3f..0000000
--- a/contribs/JamesHouse/LogTextPanelExample.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.apache.log4j.gui.examples;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.*;
-
-import org.apache.log4j.*;
-import org.apache.log4j.gui.TextPanelAppender;
-
-public class LogTextPanelExample {
- boolean packFrame = false;
-
- String catName = "dum.cat.name";
-
- public LogTextPanelExample() {
-
- // setup the logging
- TextPanelAppender tpa = new TextPanelAppender(new PatternLayout("%-5p %d [%t]: %m%n"), "logTextPanel");
- tpa.setThreshold(Priority.DEBUG);
- Category cat = Category.getInstance(catName);
- cat.addAppender(tpa);
-
- LogFrame frame = new LogFrame(tpa);
- frame.validate();
-
- //Center the frame (window), and show it
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension frameSize = frame.getSize();
- if (frameSize.height > screenSize.height) {
- frameSize.height = screenSize.height;
- }
- if (frameSize.width > screenSize.width) {
- frameSize.width = screenSize.width;
- }
- frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
- frame.setVisible(true);
- }
-
- /**Main method*/
- public static void main(String[] args) {
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- }
- catch(Exception e) {
- e.printStackTrace();
- }
- LogTextPanelExample foo = new LogTextPanelExample();
- new LogTextPanelExampleGenThread(foo.catName);
- }
-}
-
-class LogFrame extends JFrame {
-
- public LogFrame(TextPanelAppender tpa) {
- enableEvents(AWTEvent.WINDOW_EVENT_MASK);
- JPanel contentPane = (JPanel) this.getContentPane();
- contentPane.setLayout(new BorderLayout());
- this.setSize(new Dimension(600, 400));
- this.setTitle("LogTextPanel Example");
- contentPane.add(tpa.getLogTextPanel(), BorderLayout.CENTER);
- }
-
- // exit when window is closed
- protected void processWindowEvent(WindowEvent e) {
- super.processWindowEvent(e);
- if (e.getID() == WindowEvent.WINDOW_CLOSING) {
- System.exit(0);
- }
- }
-}
-
-class LogTextPanelExampleGenThread extends Thread {
-
- String catName;
-
- public LogTextPanelExampleGenThread(String catName) {
- this.catName = catName;
- this.setPriority(Thread.NORM_PRIORITY - 1);
- this.start();
- }
-
- public void run() {
- Category cat = Category.getInstance(catName);
- int cnt = 0;
- while(true) {
- cnt++;
- int randEvt = (int)(Math.random() * 125);
- if(randEvt < 3)
- cat.fatal("{" + cnt + "} Something screwed up bad.");
- else if(randEvt < 10)
- cat.error("{" + cnt + "} An error occured while trying to delete all of your files.");
- else if(randEvt < 25)
- cat.warn("{" + cnt + "} It seems as if your hard disk is getting full.");
- else if(randEvt < 55)
- cat.info("{" + cnt + "} It is now time for tea.");
- else if(randEvt < 65)
- cat.debug("{" + cnt + "} Something bad is happening on line 565 of com.foo.Crap");
- else if(randEvt < 75)
- cat.debug("{" + cnt + "} Input value for xe343dd is not equal to xe39dfd!");
- else if(randEvt < 85)
- cat.debug("{" + cnt + "} Successfully reached line 2312 of com.foo.Goo");
- else if(randEvt < 105)
- cat.debug("{" + cnt + "} Here is some extra handy debugging information for you.");
- else if(randEvt < 115)
- cat.debug("{" + cnt + "} The file you are about to write to is not open.");
- else if(randEvt < 125)
- cat.debug("{" + cnt + "} The input value to the method was <null>.");
-
- try {
- Thread.sleep(10);
- }
- catch(Exception e) {}
-
- }
- }
-}
\ No newline at end of file
diff --git a/contribs/JamesHouse/TextPanelAppender.java b/contribs/JamesHouse/TextPanelAppender.java
deleted file mode 100644
index c4d45bc..0000000
--- a/contribs/JamesHouse/TextPanelAppender.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package org.apache.log4j.gui;
-
-
-import java.awt.Color;
-import java.awt.Image;
-import java.awt.Toolkit;
-import java.io.*;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.StringTokenizer;
-import java.util.Hashtable;
-import java.util.ArrayList;
-
-import javax.swing.JPanel;
-
-import org.apache.log4j.*;
-
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.helpers.Loader;
-import org.apache.log4j.helpers.QuietWriter;
-import org.apache.log4j.helpers.TracerPrintWriter;
-import org.apache.log4j.helpers.OptionConverter;
-
-
-/**
- *
- * @author James House
- */
-
-public class TextPanelAppender extends AppenderSkeleton {
-
- TracerPrintWriter tp;
- StringWriter sw;
- QuietWriter qw;
- LogTextPanel logTextPanel;
- LogPublishingThread logPublisher;
-
- final String COLOR_OPTION_FATAL = "Color.Fatal";
- final String COLOR_OPTION_ERROR = "Color.Error";
- final String COLOR_OPTION_WARN = "Color.Warn";
- final String COLOR_OPTION_INFO = "Color.Info";
- final String COLOR_OPTION_DEBUG = "Color.Debug";
- final String COLOR_OPTION_BACKGROUND = "Color.Background";
- final String FONT_NAME_OPTION = "Font.Name";
- final String FONT_SIZE_OPTION = "Font.Size";
- final String EVENT_BUFFER_SIZE_OPTION = "EventBuffer.Size";
-
- public TextPanelAppender(Layout layout, String name) {
- this.layout = layout;
- this.name = name;
- this.sw = new StringWriter();
- this.qw = new QuietWriter(sw, errorHandler);
- this.tp = new TracerPrintWriter(qw);
- setLogTextPanel(new LogTextPanel());
- logPublisher = new LogPublishingThread(logTextPanel, Priority.ERROR, 500);
- //logPublisher = new LogPublishingThread(logTextPanel, null, 500);
- }
-
- public
- void close() {
- }
-
- public void append(LoggingEvent event) {
-
- String text = this.layout.format(event);
-
- // Print Stacktrace
- // Quick Hack maybe there is a better/faster way?
- if (event.throwable!=null) {
- event.throwable.printStackTrace(tp);
- for (int i=0; i< sw.getBuffer().length(); i++) {
- if (sw.getBuffer().charAt(i)=='\t')
- sw.getBuffer().replace(i,i+1," ");
- }
- text += sw.toString();
- sw.getBuffer().delete(0,sw.getBuffer().length());
- }
- else
- if(!text.endsWith("\n"))
- text += "\n";
-
- logPublisher.publishEvent(event.priority, text);
- }
-
- public
- JPanel getLogTextPanel() {
- return logTextPanel;
- }
-
- public
- String[] getOptionStrings() {
- return new String[] { COLOR_OPTION_FATAL, COLOR_OPTION_ERROR,
- COLOR_OPTION_WARN, COLOR_OPTION_INFO, COLOR_OPTION_DEBUG,
- COLOR_OPTION_BACKGROUND, FONT_NAME_OPTION, FONT_SIZE_OPTION};
- }
-
-
- public
- void setName(String name) {
- this.name = name;
- }
-
- protected
- void setLogTextPanel(LogTextPanel logTextPanel) {
- this.logTextPanel = logTextPanel;
- logTextPanel.setTextBackground(Color.white);
- }
-
- public
- void setOption(String option, String value) {
- if (option.equalsIgnoreCase(COLOR_OPTION_FATAL))
- logTextPanel.setTextColor(Priority.FATAL,value);
- if (option.equalsIgnoreCase(COLOR_OPTION_ERROR))
- logTextPanel.setTextColor(Priority.ERROR,value);
- if (option.equalsIgnoreCase(COLOR_OPTION_WARN))
- logTextPanel.setTextColor(Priority.WARN,value);
- if (option.equalsIgnoreCase(COLOR_OPTION_INFO))
- logTextPanel.setTextColor(Priority.INFO,value);
- if (option.equalsIgnoreCase(COLOR_OPTION_DEBUG))
- logTextPanel.setTextColor(Priority.DEBUG,value);
- if (option.equalsIgnoreCase(COLOR_OPTION_BACKGROUND))
- logTextPanel.setTextBackground(value);
- if (option.equalsIgnoreCase(FONT_SIZE_OPTION))
- logTextPanel.setTextFontSize(Integer.parseInt(value));
- if (option.equalsIgnoreCase(FONT_NAME_OPTION))
- logTextPanel.setTextFontName(value);
- if (option.equalsIgnoreCase(EVENT_BUFFER_SIZE_OPTION))
- logTextPanel.setEventBufferSize(Integer.parseInt(value));
- return;
- }
-
- public
- boolean requiresLayout() {
- return true;
- }
-
-
-
- class LogPublishingThread extends Thread {
-
- LogTextPanel logTextPanel;
- ArrayList evts;
- Priority triggerPrio;
- long pubInterval;
-
- public LogPublishingThread(LogTextPanel logTextPanel, Priority triggerPrio, long pubInterval) {
- this.logTextPanel = logTextPanel;
- this.evts = new ArrayList(1000);
- this.triggerPrio = triggerPrio;
- this.pubInterval = pubInterval;
- //this.setPriority(Thread.NORM_PRIORITY - 1);
- this.start();
- }
-
- public void run() {
- while(true) {
- synchronized(evts) {
- try {
- evts.wait(pubInterval);
- }
- catch(InterruptedException e) {}
-
- logTextPanel.newEvents((EventBufferElement[])evts.toArray(new EventBufferElement[evts.size()]));
-
- evts.clear();
- }
- }
-
- }
-
- public void publishEvent(Priority prio, String text) {
- synchronized(evts) {
- evts.add(new EventBufferElement(prio, text));
- if(triggerPrio != null && prio.isGreaterOrEqual(triggerPrio))
- evts.notify();
- }
- }
- }
-
-} // TextPaneAppender
-
-class EventBufferElement {
-
- public String text;
- public Priority prio;
- public int numLines;
-
- EventBufferElement(Priority prio, String text) {
- this.prio = prio;
- this.text = text;
- numLines = 1;
- int pos = pos = text.indexOf('\n', 0);
- int len = text.length() - 1;
-
- while( (pos > 0) && (pos < len) )
- numLines++;
- pos = text.indexOf('\n', pos + 1);
- }
-}
-
-
diff --git a/contribs/JamesHouse/mail-2001-01-23 b/contribs/JamesHouse/mail-2001-01-23
deleted file mode 100644
index 0356f40..0000000
--- a/contribs/JamesHouse/mail-2001-01-23
+++ /dev/null
@@ -1,70 +0,0 @@
-Delivered-To: urba-cgu@urbanet.ch
-From: James House <ja...@medibuy.com>
-To: Ceki Gulcu <cg...@urbanet.ch>
-Subject: RE: Buffering issues
-Date: Tue, 23 Jan 2001 11:38:30 -0800
-X-Mailer: Internet Mail Service (5.5.2650.21)
-
-
-
-Ceki,
-
-
-Most of the "speed" issues can be easily solved, as demonstrated in
-the new versions of the files that are attached, and as described
-here:
-
-
-The "drawing" of the panel is time consuming. And let's face it: we
-will never build a swing component that can re-draw itself thousands
-of times per second - nor could the human eye keep up with that anyway
-(60-ish redraws per second is the limit of what most humans can
-perceive).
-
-
-I think you'll agree that regardless of which choice of swing
-components, the issue of not being able to draw more than 100 times
-per second (if that) will be a constant.
-
-
-Possible solutions to wasting a lot of time redrawing are:
- * Redraw every N messages
- * Redraw every N milliseconds
- * Redraw when a message of a high priority is received
- * Only redraw if the changes (new messages) are visible (depending on
-scroll-bar position)
-
-
-
-I made some very small changes (which are some of what I outlined in
-the previous e-mail as things on the to-do list), and you should be
-able to see a great difference in performance.
-
-
-In general the changes are: Use a "queue" to asynchronously deliver
-the messages to the panel for updating, rather than having the calling
-thread (the one generating the log message) be responsible for
-re-drawing the panel - this frees up the thread to continue on without
-waiting for the logging mechanism. The "queue" has a thread that
-wakes up every N milliseconds, or when a message of a specified
-priority arrives. It then delivers all queued messages to the panel,
-which then redraws ONCE for the entire batch of queued messages IF the
-new messages are visible in the display.
-
-
-With the "tail" mechanism turned on (so that any new set of messages
-forces a redraw, because the last message is always visible), the
-panel can now log about a thousand messages in 1 second. With tail
-turned off (so that redraw is only required if the panel is showing
-the space the new messages will be printed), it can receive over a
-100,000 messages in just a few seconds. Also, most of the flicker is
-already eliminated.
-
-
-Again, everything in the code is really "roughed in" - just there to
-give the general idea, not necessarily to do things in the best way -
-but I really feel that this kind of solution is what you'll have to
-end up with in the long term.
-
-
-James
diff --git a/contribs/Jamie Tsao/JMSQueueAppender.java b/contribs/Jamie Tsao/JMSQueueAppender.java
deleted file mode 100644
index aa475ef..0000000
--- a/contribs/Jamie Tsao/JMSQueueAppender.java
+++ /dev/null
@@ -1,225 +0,0 @@
-
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.ErrorCode;
-import org.apache.log4j.helpers.LogLog;
-
-import java.util.Hashtable;
-import java.util.Properties;
-import javax.jms.*;
-import javax.naming.InitialContext;
-import javax.naming.Context;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
-/**
- * A Simple JMS (P2P) Queue Appender.
- *
- * @author Ceki Gülcü
- * @author Jamie Tsao
-*/
-public class JMSQueueAppender extends AppenderSkeleton {
-
- protected QueueConnection queueConnection;
- protected QueueSession queueSession;
- protected QueueSender queueSender;
- protected Queue queue;
-
- String initialContextFactory;
- String providerUrl;
- String queueBindingName;
- String queueConnectionFactoryBindingName;
-
- public
- JMSQueueAppender() {
- }
-
-
- /**
- * The <b>InitialContextFactory</b> option takes a string value.
- * Its value, along with the <b>ProviderUrl</b> option will be used
- * to get the InitialContext.
- */
- public void setInitialContextFactory(String initialContextFactory) {
- this.initialContextFactory = initialContextFactory;
- }
-
- /**
- * Returns the value of the <b>InitialContextFactory</b> option.
- */
- public String getInitialContextFactory() {
- return initialContextFactory;
- }
-
- /**
- * The <b>ProviderUrl</b> option takes a string value.
- * Its value, along with the <b>InitialContextFactory</b> option will be used
- * to get the InitialContext.
- */
- public void setProviderUrl(String providerUrl) {
- this.providerUrl = providerUrl;
- }
-
- /**
- * Returns the value of the <b>ProviderUrl</b> option.
- */
- public String getProviderUrl() {
- return providerUrl;
- }
-
- /**
- * The <b>QueueConnectionFactoryBindingName</b> option takes a
- * string value. Its value will be used to lookup the appropriate
- * <code>QueueConnectionFactory</code> from the JNDI context.
- */
- public void setQueueConnectionFactoryBindingName(String queueConnectionFactoryBindingName) {
- this.queueConnectionFactoryBindingName = queueConnectionFactoryBindingName;
- }
-
- /**
- * Returns the value of the <b>QueueConnectionFactoryBindingName</b> option.
- */
- public String getQueueConnectionFactoryBindingName() {
- return queueConnectionFactoryBindingName;
- }
-
- /**
- * The <b>QueueBindingName</b> option takes a
- * string value. Its value will be used to lookup the appropriate
- * destination <code>Queue</code> from the JNDI context.
- */
- public void setQueueBindingName(String queueBindingName) {
- this.queueBindingName = queueBindingName;
- }
-
- /**
- Returns the value of the <b>QueueBindingName</b> option.
- */
- public String getQueueBindingName() {
- return queueBindingName;
- }
-
-
- /**
- * Overriding this method to activate the options for this class
- * i.e. Looking up the Connection factory ...
- */
- public void activateOptions() {
-
- QueueConnectionFactory queueConnectionFactory;
-
- try {
-
- Context ctx = getInitialContext();
- queueConnectionFactory = (QueueConnectionFactory) ctx.lookup(queueConnectionFactoryBindingName);
- queueConnection = queueConnectionFactory.createQueueConnection();
-
- queueSession = queueConnection.createQueueSession(false,
- Session.AUTO_ACKNOWLEDGE);
-
- Queue queue = (Queue) ctx.lookup(queueBindingName);
- queueSender = queueSession.createSender(queue);
-
- queueConnection.start();
-
- ctx.close();
-
- } catch(Exception e) {
- errorHandler.error("Error while activating options for appender named ["+name+
- "].", e, ErrorCode.GENERIC_FAILURE);
- }
- }
-
- protected InitialContext getInitialContext() throws NamingException {
- try {
- Hashtable ht = new Hashtable();
-
- //Populate property hashtable with data to retrieve the context.
- ht.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
- ht.put(Context.PROVIDER_URL, providerUrl);
-
- return (new InitialContext(ht));
-
- } catch (NamingException ne) {
- LogLog.error("Could not get initial context with ["+initialContextFactory + "] and [" + providerUrl + "].");
- throw ne;
- }
- }
-
-
- protected boolean checkEntryConditions() {
-
- String fail = null;
-
- if(this.queueConnection == null) {
- fail = "No QueueConnection";
- } else if(this.queueSession == null) {
- fail = "No QueueSession";
- } else if(this.queueSender == null) {
- fail = "No QueueSender";
- }
-
- if(fail != null) {
- errorHandler.error(fail +" for JMSQueueAppender named ["+name+"].");
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Close this JMSQueueAppender. Closing releases all resources used by the
- * appender. A closed appender cannot be re-opened.
- */
- public synchronized // avoid concurrent append and close operations
- void close() {
-
- if(this.closed)
- return;
-
- LogLog.debug("Closing appender ["+name+"].");
- this.closed = true;
-
- try {
- if(queueSession != null)
- queueSession.close();
- if(queueConnection != null)
- queueConnection.close();
- } catch(Exception e) {
- LogLog.error("Error while closing JMSQueueAppender ["+name+"].", e);
- }
-
- // Help garbage collection
- queueSender = null;
- queueSession = null;
- queueConnection = null;
- }
-
- /**
- * This method called by {@link AppenderSkeleton#doAppend} method to
- * do most of the real appending work. The LoggingEvent will be
- * be wrapped in an ObjectMessage to be put on the JMS queue.
- */
- public void append(LoggingEvent event) {
-
- if(!checkEntryConditions()) {
- return;
- }
-
- try {
-
- ObjectMessage msg = queueSession.createObjectMessage();
- msg.setObject(event);
- queueSender.send(msg);
-
- } catch(Exception e) {
- errorHandler.error("Could not send message in JMSQueueAppender ["+name+"].", e,
- ErrorCode.GENERIC_FAILURE);
- }
- }
-
- public boolean requiresLayout() {
- return false;
- }
-}
\ No newline at end of file
diff --git a/contribs/Jamie Tsao/mail-2001-06-20 b/contribs/Jamie Tsao/mail-2001-06-20
deleted file mode 100644
index 9ddbb50..0000000
--- a/contribs/Jamie Tsao/mail-2001-06-20
+++ /dev/null
@@ -1,11 +0,0 @@
-Hi,
-
-I have written a JMSQueueAppender that essentially logs to a JMS Queue
-(Point 2 Point). The JMSAppender currently packaged with log4j logs to
-a JMS Topic (I would rename it JMSTopicAppender). I also made it so
-that the InitialContextFactory and ProviderUrl are configurable appender
-options. I would like to submit this to Apache.
-
-Thanks,
-
-Jamie Tsao
\ No newline at end of file
diff --git a/contribs/JimMoore/LoggingOutputStream.java b/contribs/JimMoore/LoggingOutputStream.java
deleted file mode 100644
index 053779f..0000000
--- a/contribs/JimMoore/LoggingOutputStream.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * 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.
- */
-
-
-import java.io.*;
-import org.apache.log4j.*;
-
-
-/**
- * An OutputStream that flushes out to a Category.<p>
- *
- * Note that no data is written out to the Category until the stream is
- * flushed or closed.<p>
- *
- * Example:<pre>
- * // make sure everything sent to System.err is logged
- * System.setErr(new PrintStream(new LoggingOutputStream(Category.getRoot(), Priority.WARN), true));
- *
- * // make sure everything sent to System.out is also logged
- * System.setOut(new PrintStream(new LoggingOutputStream(Category.getRoot(), Priority.INFO), true));
- * </pre>
- *
- * @author <a href="mailto://Jim.Moore@rocketmail.com">Jim Moore</a>
- * @see Category
- */
-public class LoggingOutputStream extends OutputStream {
- protected static final String LINE_SEPERATOR = System.getProperty("line.separator");
-
-
- /**
- * Used to maintain the contract of {@link #close()}.
- */
- protected boolean hasBeenClosed = false;
-
- /**
- * The internal buffer where data is stored.
- */
- protected byte[] buf;
-
- /**
- * The number of valid bytes in the buffer. This value is always
- * in the range <tt>0</tt> through <tt>buf.length</tt>; elements
- * <tt>buf[0]</tt> through <tt>buf[count-1]</tt> contain valid
- * byte data.
- */
- protected int count;
-
-
- /**
- * Remembers the size of the buffer for speed.
- */
- private int bufLength;
-
- /**
- * The default number of bytes in the buffer. =2048
- */
- public static final int DEFAULT_BUFFER_LENGTH = 2048;
-
-
- /**
- * The category to write to.
- */
- protected Category category;
-
- /**
- * The priority to use when writing to the Category.
- */
- protected Priority priority;
-
-
- private LoggingOutputStream() {
- // illegal
- }
-
-
- /**
- * Creates the LoggingOutputStream to flush to the given Category.
- *
- * @param cat the Category to write to
- *
- * @param priority the Priority to use when writing to the Category
- *
- * @exception IllegalArgumentException
- * if cat == null or priority == null
- */
- public LoggingOutputStream(Category cat, Priority priority)
- throws IllegalArgumentException {
- if (cat == null) {
- throw new IllegalArgumentException("cat == null");
- }
- if (priority == null) {
- throw new IllegalArgumentException("priority == null");
- }
-
- this.priority = priority;
- category = cat;
- bufLength = DEFAULT_BUFFER_LENGTH;
- buf = new byte[DEFAULT_BUFFER_LENGTH];
- count = 0;
- }
-
-
- /**
- * Closes this output stream and releases any system resources
- * associated with this stream. The general contract of <code>close</code>
- * is that it closes the output stream. A closed stream cannot perform
- * output operations and cannot be reopened.
- */
- public void close() {
- flush();
- hasBeenClosed = true;
- }
-
-
- /**
- * Writes the specified byte to this output stream. The general
- * contract for <code>write</code> is that one byte is written
- * to the output stream. The byte to be written is the eight
- * low-order bits of the argument <code>b</code>. The 24
- * high-order bits of <code>b</code> are ignored.
- *
- * @param b the <code>byte</code> to write
- *
- * @exception IOException
- * if an I/O error occurs. In particular,
- * an <code>IOException</code> may be thrown if the
- * output stream has been closed.
- */
- public void write(final int b) throws IOException {
- if (hasBeenClosed) {
- throw new IOException("The stream has been closed.");
- }
-
- // don't log nulls
- if (b == 0) {
- return;
- }
-
- // would this be writing past the buffer?
- if (count == bufLength) {
- // grow the buffer
- final int newBufLength = bufLength+DEFAULT_BUFFER_LENGTH;
- final byte[] newBuf = new byte[newBufLength];
-
- System.arraycopy(buf, 0, newBuf, 0, bufLength);
-
- buf = newBuf;
- bufLength = newBufLength;
- }
-
- buf[count] = (byte)b;
- count++;
- }
-
-
- /**
- * Flushes this output stream and forces any buffered output bytes
- * to be written out. The general contract of <code>flush</code> is
- * that calling it is an indication that, if any bytes previously
- * written have been buffered by the implementation of the output
- * stream, such bytes should immediately be written to their
- * intended destination.
- */
- public void flush() {
- if (count == 0) {
- return;
- }
-
- // don't print out blank lines; flushing from PrintStream puts out these
- if (count == LINE_SEPERATOR.length()) {
- if ( ((char)buf[0]) == LINE_SEPERATOR.charAt(0) &&
- ( ( count == 1 ) || // <- Unix & Mac, -> Windows
- ( (count == 2) && ((char)buf[1]) == LINE_SEPERATOR.charAt(1) ) ) ) {
- reset();
- return;
- }
- }
-
- final byte[] theBytes = new byte[count];
-
- System.arraycopy(buf, 0, theBytes, 0, count);
-
- category.log(priority, new String(theBytes));
-
- reset();
- }
-
-
- private void reset() {
- // not resetting the buffer -- assuming that if it grew that it
- // will likely grow similarly again
- count = 0;
- }
-
-}
-
diff --git a/contribs/JimMoore/mail-2001-03-12T1326 b/contribs/JimMoore/mail-2001-03-12T1326
deleted file mode 100644
index 52a88c7..0000000
--- a/contribs/JimMoore/mail-2001-03-12T1326
+++ /dev/null
@@ -1,39 +0,0 @@
-Copied from:
-http://www.mail-archive.com/log4j-user@jakarta.apache.org/msg00430.html
-
---------------------------------------------------------------------------------
-diverting System.stderr/stdout into log4j
---------------------------------------------------------------------------------
-
-From: Joseph Panico
-Subject: diverting System.stderr/stdout into log4j
-Date: Mon, 12 Mar 2001 13:26:41 -0800
-
---------------------------------------------------------------------------------
-
-Folks,
-
-We use a number of third-party packages that do stderr.print... at various
-random places in their code. I'm finding it quite useful to divert these
-messages into our log4j heirarchy. I do this by replacing stderr/stdout with
-my own PrintStreams that log the lines to a special log4j Category-- as
-suggested on this list a while back. The only fly-in-the-ointment with this
-scheme is LogLog. If there is a problem with log4j such that it cannot log
-for some reason, then log4j internals use LogLog to attempt to print an
-error message. This obviously leads to an infinite recursion. Has anyone
-else been bothered by this? Would it make sense to add interface to LogLog
-which would set the PrintStream it uses to log its error messages to?
-
-thanks for any ideas
-
-joe
-
-_________________________________________________________________
-Get your FREE download of MSN Explorer at http://explorer.msn.com
-
-
----------------------------------------------------------------------
-To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
-For additional commands, e-mail: log4j-user-help@jakarta.apache.org
-
-
diff --git a/contribs/JimMoore/mail-2001-03-12T1454 b/contribs/JimMoore/mail-2001-03-12T1454
deleted file mode 100644
index 1a81e53..0000000
--- a/contribs/JimMoore/mail-2001-03-12T1454
+++ /dev/null
@@ -1,112 +0,0 @@
-
-Copied from:
-http://www.mail-archive.com/log4j-user@jakarta.apache.org/msg00433.html
-
---------------------------------------------------------------------------------
-RE: diverting System.stderr/stdout into log4j
---------------------------------------------------------------------------------
-
-From: Jim Moore
-Subject: RE: diverting System.stderr/stdout into log4j
-Date: Mon, 12 Mar 2001 14:54:13 -0800
-
---------------------------------------------------------------------------------
-
-It doesn't. I haven't worried about it, since log4j doesn't contain any
-bugs and therefore it would never happen... :)
-
-Probably the best way to handle it is to add a
-LogLog.setPrintStream(PrintStream) method, so you can do something like:
-
-// remember STDERR
-PrintStream se = System.err;
-
-// make sure everything sent to System.err is logged
-System.setErr(new PrintStream(new LoggingOutputStream(Category.getRoot(),
- Priority.WARN), true));
-
-// make sure everything sent to System.out is also logged
-System.setOut(new PrintStream(new LoggingOutputStream(Category.getRoot(),
- Priority.INFO), true));
-
-// prevent infinate recursion in LogLog
-LogLog.setPrintStream(se);
-
-
-I can't think of any other way to do it in the current version besides
-getting extremely kludgey by checking the stack to see if it's being called
-from LogLog and logging out the the "real" STDERR then in the
-LoggingOutputStream. It can be done on the theory that LogLog wouldn't be
-called very often, but still...
-
--Jim Moore
-
-
------Original Message-----
-From: Ceki G�lc� [mailto:cgu@qos.ch]
-Sent: Monday, March 12, 2001 5:15 PM
-To: LOG4J Users Mailing List
-Subject: RE: diverting System.stderr/stdout into log4j
-
-
-Jim, Joseph,
-
-Here is a link containing Jim's code:
-
-http://marc.theaimsgroup.com/?l=log4j-user&m=98097669218571&w=2
-
-How does this code handle the infinite recursion problem mentioned by
-Joseph? Ceki
-
-At 17:03 12.03.2001 -0500, Jim Moore wrote:
->Go to the mailing list archives (theAimsGroup.com is the best) and search
->for the thread with the subject of "Capturing System.err"
->
->-Jim Moore
->"I think so, Brain; but if we gave peas a chance, won't the lima beans get
->jealous?" - Pinky
->
->
->-----Original Message-----
->From: Joseph Panico [mailto:joe_panico@hotmail.com]
->Sent: Monday, March 12, 2001 4:43 PM
->To: log4j-user@jakarta.apache.org
->Subject: diverting System.stderr/stdout into log4j
->
->
->Folks,
->
->We use a number of third-party packages that do stderr.print... at various
->random places in their code. I'm finding it quite useful to divert these
->messages into our log4j heirarchy. I do this by replacing stderr/stdout
-with
->
->my own PrintStreams that log the lines to a special log4j Category-- as
->suggested on this list a while back. The only fly-in-the-ointment with this
-
->scheme is LogLog. If there is a problem with log4j such that it cannot log
->for some reason, then log4j internals use LogLog to attempt to print an
->error message. This obviously leads to an infinite recursion. Has anyone
->else been bothered by this? Would it make sense to add interface to LogLog
->which would set the PrintStream it uses to log its error messages to?
->
->thanks for any ideas
->
->joe
-
-I hope to see you at my ApacheCon 2001 presentation
-entitled "Log4j, A Logging Package for Java".
-
-See http://ApacheCon.Com/2001/US/ for more details.
-
-----
-Ceki G�lc� Web: http://qos.ch
-av. de Rumine 5 email: cgu@qos.ch (preferred)
-CH-1005 Lausanne ceki_gulcu@yahoo.com
-Switzerland Tel: ++41 21 351 23 15
-
----------------------------------------------------------------------
-To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
-For additional commands, e-mail: log4j-user-help@jakarta.apache.org
-
-
diff --git a/contribs/JimMoore/mail-2001-03-13T0646 b/contribs/JimMoore/mail-2001-03-13T0646
deleted file mode 100644
index 9b7d019..0000000
--- a/contribs/JimMoore/mail-2001-03-13T0646
+++ /dev/null
@@ -1,214 +0,0 @@
-
-Copied from
-http://www.mail-archive.com/log4j-user@jakarta.apache.org/msg00445.html
-
---------------------------------------------------------------------------------
-RE: diverting System.stderr/stdout into log4j
---------------------------------------------------------------------------------
-
-From: Michael Smith
-Subject: RE: diverting System.stderr/stdout into log4j
-Date: Tue, 13 Mar 2001 06:46:04 -0800
-
---------------------------------------------------------------------------------
-
-There is another way!
-
-In LogLog, completely ignore System.err. Instead, use the following to get
-the standard error stream:
-
-PrintStream err =
- new PrintStream(new FileOutputStream(FileDescriptor.err));
-
-When you use System.setErr, it changes System.err, but not
-FileDescriptor.err, which maintains a descriptor for the original error
-stream.
-
-michael
-
-For a sample program to test this, see below:
-
-import java.io.*;
-
-public class Stderr {
-
- public static void main(String[] args) {
-
- // create a print stream to represent a redirect
- PrintStream nonStandardErr =
- new PrintStream(new ByteArrayOutputStream());
-
- // Redirect standard out and standard err
- System.setOut(nonStandardErr);
- System.setErr(nonStandardErr);
-
- // attempt to print something
- System.err.println("You should *not* see this on the console!");
-
- // the stuff that would appear in LogLog
- PrintStream logLogOut =
- new PrintStream(new FileOutputStream(FileDescriptor.err));
-
- // attempt to print something
- logLogOut.println("You *should* see this on the console!");
- }
-}
-
-
-
-> -----Original Message-----
-> From: Ceki G�lc� [mailto:cgu@qos.ch]
-> Sent: Monday, March 12, 2001 7:18 PM
-> To: LOG4J Users Mailing List
-> Subject: RE: diverting System.stderr/stdout into log4j
->
->
->
-> Hate to follow up on myself, but the System.setErr method
-> reassigns the System.err variable. This can be deduced without
-> experimentation because the user calls the System.err variable
-> directly to print to the console, whatever it might be. Thus, the
-> reference itself must change to allow the System.err variable to
-> point to the new target stream.
->
-> The funny part is that the err variable is declared 'public
-> final' in the JDK source code. The setErr method makes a call to
-> setErr0 which is declared as being 'native'. It looks like the
-> native part is circumventing the JDK restrictions. I find this
-> quite entertaining. Ceki
->
-> At 00:58 13.03.2001 +0100, Ceki G�lc� wrote:
->
-> >Running the risk of disappointing you here, although not full of
-> bugs, log4j is not bug-free as bugs creep out regularly. They
-> just get corrected quickly before many people are affected by them.
-> >
-> >The PrintStream se = System.err; LogLog.setPrintStream(see);
-> combination is simple and rather bright. I initially overlooked
-> the PrintStream se = System.err; part, making me think that a
-> lot of code needed to be modified to cater for the redirected
-> console case. The remedy looked worse than the illness. My fears
-> are largely unfounded and the solution should work quite well if
-> one is careful.
-> >
-> >Regards, Ceki
-> >
-> >ps: I wonder if System.err always refers to the real STDERR or
-> if really gets reassigned with the setErr call. It's easy to find out...
-> >
-> >At 23:20 12.03.2001 +0000, Joseph Panico wrote:
-> >>Of course log4j is completely bug free, but that doesn't
-> preclude user error. For instance, I neglected to add appenders
-> in my config file (actually I intentionally left them out,
-> thinking that would simply turn off logging) and then log4j went
-> into an infinite loop. The setPrintStream makes sense to me.
-> >>
-> >>joe
-> >>
-> >>
-> >>>From: Jim Moore <ji...@veritas.com>
-> >>>Reply-To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
-> >>>To: 'LOG4J Users Mailing List' <lo...@jakarta.apache.org>
-> >>>Subject: RE: diverting System.stderr/stdout into log4j
-> >>>Date: Mon, 12 Mar 2001 18:10:37 -0500
-> >>>
-> >>>It doesn't. I haven't worried about it, since log4j doesn't
-> contain any
-> >>>bugs and therefore it would never happen... :)
-> >>>
-> >>>Probably the best way to handle it is to add a
-> >>>LogLog.setPrintStream(PrintStream) method, so you can do
-> something like:
-> >>>
-> >>>// remember STDERR
-> >>>PrintStream se = System.err;
-> >>>
-> >>>// make sure everything sent to System.err is logged
-> >>>System.setErr(new PrintStream(new
-> LoggingOutputStream(Category.getRoot(),
-> >>> Priority.WARN), true));
-> >>>
-> >>>// make sure everything sent to System.out is also logged
-> >>>System.setOut(new PrintStream(new
-> LoggingOutputStream(Category.getRoot(),
-> >>> Priority.INFO), true));
-> >>>
-> >>>// prevent infinate recursion in LogLog
-> >>>LogLog.setPrintStream(se);
-> >>>
-> >>>
-> >>>I can't think of any other way to do it in the current version besides
-> >>>getting extremely kludgey by checking the stack to see if it's
-> being called
-> >>>from LogLog and logging out the the "real" STDERR then in the
-> >>>LoggingOutputStream. It can be done on the theory that LogLog
-> wouldn't be
-> >>>called very often, but still...
-> >>>
-> >>>-Jim Moore
-> >>>
-> >>>
-> >>>-----Original Message-----
-> >>>From: Ceki G�lc� [mailto:cgu@qos.ch]
-> >>>Sent: Monday, March 12, 2001 5:15 PM
-> >>>To: LOG4J Users Mailing List
-> >>>Subject: RE: diverting System.stderr/stdout into log4j
-> >>>
-> >>>
-> >>>Jim, Joseph,
-> >>>
-> >>>Here is a link containing Jim's code:
-> >>>
-> >>>http://marc.theaimsgroup.com/?l=log4j-user&m=98097669218571&w=2
-> >>>
-> >>>How does this code handle the infinite recursion problem mentioned by
-> >>>Joseph? Ceki
-> >>>
-> >>>At 17:03 12.03.2001 -0500, Jim Moore wrote:
-> >>>>Go to the mailing list archives (theAimsGroup.com is the
-> best) and search
-> >>>>for the thread with the subject of "Capturing System.err"
-> >>>>
-> >>>>-Jim Moore
-> >>>>"I think so, Brain; but if we gave peas a chance, won't the
-> lima beans get
-> >>>>jealous?" - Pinky
-> >>>>
-> >>>>
-> >>>>-----Original Message-----
-> >>>>From: Joseph Panico [mailto:joe_panico@hotmail.com]
-> >>>>Sent: Monday, March 12, 2001 4:43 PM
-> >>>>To: log4j-user@jakarta.apache.org
-> >>>>Subject: diverting System.stderr/stdout into log4j
-> >>>>
-> >>>>
-> >>>>Folks,
-> >>>>
-> >>>>We use a number of third-party packages that do
-> stderr.print... at various
-> >>>>random places in their code. I'm finding it quite useful to
-> divert these
-> >>>>messages into our log4j heirarchy. I do this by replacing
-> stderr/stdout
-> >>>with
-> >>>>
-> >>>>my own PrintStreams that log the lines to a special log4j
-> Category-- as
-> >>>>suggested on this list a while back. The only
-> fly-in-the-ointment with this
-> >>>
-> >>>>scheme is LogLog. If there is a problem with log4j such that
-> it cannot log
-> >>>>for some reason, then log4j internals use LogLog to attempt
-> to print an
-> >>>>error message. This obviously leads to an infinite recursion.
-> Has anyone
-> >>>>else been bothered by this? Would it make sense to add
-> interface to LogLog
-> >>>>which would set the PrintStream it uses to log its error messages to?
-> >>>>
-> >>>>thanks for any ideas
-> >>>>
-> >>>>joe
-
-
diff --git a/contribs/KevinSteppe/JDBCAppender.java b/contribs/KevinSteppe/JDBCAppender.java
deleted file mode 100644
index 76e9f13..0000000
--- a/contribs/KevinSteppe/JDBCAppender.java
+++ /dev/null
@@ -1,331 +0,0 @@
-package org.apache.log4j.varia;
-
-
-
-import org.apache.log4j.*;
-import org.apache.log4j.spi.*;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.helpers.OptionConverter;
-
-
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-
-
-import java.sql.DriverManager;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.sql.SQLException;
-
-
-
-/**
- * This JDBCAppender is intended to provide a convinent base clas or
- * default class for sending log messages to a database.
- *
- * Each append call adds to an ArrayList buffer. When the buffer is filled
- * (set by the BUFFER_OPTION or setBufferSize(int buffer), default is 1) each
- * log event is placed in a sql statement (configurable) and executed.
- *
- * BufferSize, db URL, User, & Password are configurable options in
- * the standard Log4J methods.
- *
- * DB driver is also configurable -- setting the DRIVER_OPTION
- * automaticaly loads the driver The SQL_OPTION sets the SQL statement
- * to be used for logging -- by default all the conversion patterns in
- * PatternLayout can be used inside of the statement. (see the test
- * cases for examples) if a layout is explicitely attached it's output
- * will replace the first instance of "%m" in the SQL statement.
- * Overriding the getSQL method allows more explicit control of the
- * statement used for logging.
- *
- *
- * For use as a base class:
- *
- * Override executeSQL(String sql) to modify connection/statement
- * behavior The default implementation creates a new connection
- * from the Driver for every statement.
- *
- * Override getSQL(LoggingEvent event) to produce specialized or
- * dynamic statements The default uses the sql option value
- *
- *
- * @author: Kevin Steppe (ksteppe@pacbell.net)
-*/
-
-
-public class JDBCAppender extends org.apache.log4j.AppenderSkeleton
- implements org.apache.log4j.Appender {
-
-
- public static final String URL_OPTION = "URL";
- public static final String USER_OPTION = "User";
- public static final String PASSWORD_OPTION = "Password";
- public static final String BUFFER_OPTION = "Buffer";
- public static final String DRIVER_OPTION = "Driver";
- public static final String SQL_OPTION = "Sql";
-
-
- protected String databaseURL = "jdbc:odbc:myDB";
- protected String databaseUser = "me";
- protected String databasePassword = "mypassword";
- protected String databaseDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
-
-
- protected PatternLayout sqlLayout = null;
- protected String sqlStatement = "";
-
-
- protected int bufferSize = 1;
- protected List buffer;
-
-
- public JDBCAppender() {
- super();
- buffer = new ArrayList();
- }
-
-
- /**
- * Adds the event to the buffer. When full the buffer is flushed.
- */
- public void append(LoggingEvent event) {
- buffer.add(event);
-
-
- if (buffer.size() >= bufferSize)
- flushBuffer();
- }
-
-
- /**
- * Sets options as per the 1.0 version of Log4J option setting.
- * all cases are forwarded to the appropriate JavaBeans Introspection set
-method.
- * @deprecated
- */
- public void setOption(String key, String value) {
- super.setOption(key, value);
-
-
- key = key.trim();
- value = value.trim();
-
-
- if(key == null || value == null)
- return;
-
-
- if (key.equalsIgnoreCase(URL_OPTION))
- setURL(value);
- else if (key.equalsIgnoreCase(USER_OPTION))
- setUser(value);
- else if (key.equalsIgnoreCase(PASSWORD_OPTION))
- setPassword(value);
- else if (key.equalsIgnoreCase(BUFFER_OPTION))
- setBufferSize(Integer.parseInt(value));
- else if (key.equalsIgnoreCase(DRIVER_OPTION))
- setDriver(value);
- else if (key.equalsIgnoreCase(SQL_OPTION))
- setSql(value);
- }
-
-
- /** @deprecated */
- public String[] getOptionStrings() {
- return OptionConverter.concatanateArrays(super.getOptionStrings(),
- new String[] {URL_OPTION, USER_OPTION, PASSWORD_OPTION, BUFFER_OPTION,
-DRIVER_OPTION});
- }
-
-
- /**
- * By default getSQL formats the event into the provided statement using
- * PatternLayout style conversion characters. In fact, it uses an internal
- * PatternLayout object to do this.
- *
- * If a separate layout has been attached to the appender then the first
- * instance of "%m" in the sql statement will be replaced with the output
- * from that layout's format(LoggingEvent) method.
- *
- *
- * Overriding this provides direct access to the LoggingEvent
- * when constructing the logging statement.
- *
- * In hind-sight I should have given this a more different name from the
-setSql, getSql
- * property methods.
- */
- protected String getSQL(LoggingEvent event) {
- if (getLayout() != null) {
- String msg = this.layout.format(event);
- String _sql = getSql();
- return _sql.substring(0, _sql.indexOf("%m")) + msg +
-_sql.substring(_sql.indexOf("%m") + 2, _sql.length());
- } else
- return sqlLayout.format(event);
-
-
- }
-
-
-
- /**
- * By default this method creates a new connection for each
- * statement executed.
- *
- * Override this to provide an alertnate method of getting
- * connections (such as caching). One method to fix this is to open
- * connections at the start of flushBuffer() and close them at the
- * end. I use a connection pool outside of JDBCAppender which is
- * accessed in an override of this method.
- * */
- protected void executeSQL(String sql) throws SQLException {
- Connection con = null;
- Statement stmt = null;
-
-
- try {
- if (!DriverManager.getDrivers().hasMoreElements())
- setDriver(databaseDriver);
-
-
- con = DriverManager.getConnection(databaseURL, databaseUser,
- databasePassword);
- stmt = con.createStatement();
- stmt.executeUpdate(sql);
- } catch (SQLException e) {
- if (con != null)
- con.close();
- if (stmt != null)
- stmt.close();
- throw e;
- }
- stmt.close();
- con.close();
- }
-
-
- /**
- * loops through the buffer of LoggingEvents, gets a
- * sql string from getSQL() and sends it to
- * executeSQL()
- */
- public void flushBuffer() {
- //Do the actual logging
- for (Iterator i = buffer.iterator(); i.hasNext();) {
- try {
- String sql = getSQL((LoggingEvent)i.next());
- executeSQL(sql);
- }
- catch (SQLException e) {
- errorHandler.error("Failed to excute sql", e,
- ErrorCode.FLUSH_FAILURE);
- }
- }
- buffer.clear();
- }
-
-
- /** closes the appender, flushing the buffer first */
- public void close() {
- flushBuffer();
- this.closed = true;
- }
-
-
- /** closes the appender before disposal */
- public void finalize() {
- close();
- }
-
-
- /**
- * JDBCAppender has a built in layout.
- * a separate layout can be attached if needed.
- */
- public boolean requiresLayout() {
- return false;
- }
-
-
- public void setSql(String s) {
- sqlStatement = s;
- if (getLayout() == null) {
- if (sqlLayout == null)
- sqlLayout = new PatternLayout(s);
- else
- sqlLayout.setConversionPattern(s);
- }
- }
-
-
- public String getSql() {
- return sqlStatement;
- }
-
-
- public void setUser(String user) {
- databaseUser = user;
- }
-
-
- public void setURL(String url) {
- databaseURL = url;
- }
-
-
- public void setPassword(String password) {
- databasePassword = password;
- }
-
-
- public void setBufferSize(int buffer) {
- bufferSize = buffer;
- }
-
-
- public String getUser() {
- return databaseUser;
- }
-
-
- public String getURL() {
- return databaseURL;
- }
-
-
- public String getPassword() {
- return databasePassword;
- }
-
-
- public int getBufferSize() {
- return bufferSize;
- }
-
-
- public void setDriver(String driverClass) {
- databaseDriver = driverClass;
- try {
- Class.forName(databaseDriver);
- } catch (Exception e) {
- errorHandler.error("Failed to load driver", e,
- ErrorCode.GENERIC_FAILURE);
- }
- }
-
-
- /**
- * Returns whatever driver JDBCAppender was last told to load.
- * If a driver was loaded elsewhere in the program this may not
- * be meaningful.
- */
- public String getDriver() {
- return databaseDriver;
- }
-}
-
diff --git a/contribs/KevinSteppe/JDBCTest.java b/contribs/KevinSteppe/JDBCTest.java
deleted file mode 100644
index 70ee1ab..0000000
--- a/contribs/KevinSteppe/JDBCTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.apache.log4j.varia.test;
-
-
-import org.apache.log4j.varia.JDBCAppender;
-import org.apache.log4j.*;
-
-
-public class JDBCTest
-{
- public static void main (String argv[])
- {
- try {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- System.out.println(e.toString());
- }
-
-
- Category rootLog = Category.getRoot();
- Layout layout = new PatternLayout("%p [%t] %c - %m%n");
- JDBCAppender appender = new JDBCAppender();
- appender.setLayout(layout);
- appender.setOption(JDBCAppender.URL_OPTION, "jdbc:odbc:someDB");
-
-
- appender.setOption(JDBCAppender.USER_OPTION, "auser");
- appender.setOption(JDBCAppender.PASSWORD_OPTION, "thepassword");
-
-
-
- rootLog.addAppender(appender);
-
-
- try {
- Category log = Category.getInstance("main");
- log.debug("Debug 1");
- Thread.sleep(500);
- log.info("info 1");
- Thread.sleep(500);
- log.warn("warn 1");
- Thread.sleep(500);
- log.error("error 1");
- Thread.sleep(500);
- log.fatal("fatal 1");
- Thread.sleep(500);
-
-
- appender.setOption(JDBCAppender.BUFFER_OPTION, "5");
- log.debug("Debug 2");
- Thread.sleep(500);
- log.info("info 2");
- Thread.sleep(500);
- log.warn("warn 2");
- Thread.sleep(500);
- log.error("error 2");
- Thread.sleep(500);
- log.fatal("fatal 2");
- Thread.sleep(500);
-
-
- appender.setOption(JDBCAppender.BUFFER_OPTION, "2");
- appender.setThreshold(Priority.WARN);
- log.debug("Debug 3");
- Thread.sleep(500);
- log.info("info 3");
- Thread.sleep(500);
- log.warn("warn 3");
- Thread.sleep(500);
- log.error("error 3");
- Thread.sleep(500);
- log.fatal("fatal 3");
- }
- catch (InterruptedException e)
- {
- System.out.println("Interrupted");
- }
- }
-}
diff --git a/contribs/KevinSteppe/mail-2001-02-01 b/contribs/KevinSteppe/mail-2001-02-01
deleted file mode 100644
index 5024da8..0000000
--- a/contribs/KevinSteppe/mail-2001-02-01
+++ /dev/null
@@ -1,542 +0,0 @@
-Delivered-To: urba-cgu@urbanet.ch
-Mailing-List: contact log4j-user-help@jakarta.apache.org; run by ezmlm
-List-Post: <ma...@jakarta.apache.org>
-List-Help: <ma...@jakarta.apache.org>
-List-Unsubscribe: <ma...@jakarta.apache.org>
-List-Subscribe: <ma...@jakarta.apache.org>
-Reply-To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
-Delivered-To: mailing list log4j-user@jakarta.apache.org
-Date: Thu, 01 Feb 2001 14:26:34 -0800
-From: Kevin Steppe <ks...@pacbell.net>
-X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U)
-X-Accept-Language: en
-To: LOG4J Users Mailing List <lo...@jakarta.apache.org>
-Subject: JDBC Appender
-X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N
-
-
-Ok, here it is. Since there will be differences in database schemas and
-connection/execution methods, I wrote this with the intention that those
-parts would be overriden by subclasses (that's what I'm doing for my
-company), however it will work as is if you have a stored procedure
-spLog @msg. I'm sure there are optimizations which could be done.
-
-
-The code for org.apache.log4j.varia.JDBCAppender and
-org.apache.log4j.varia.test.JDBCTest follow and files attached. At the
-bottem is the SQL I used to test this on M$ SQL-Server.
-
-
-I help this proves useful,
-Kevin
-
-
-
-
-package org.apache.log4j.varia;
-
-
-import org.apache.log4j.*;
-import org.apache.log4j.spi.*;
-
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-
-import java.sql.DriverManager;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.sql.SQLException;
-
-
-/**
- * Contribution from MD Data Direct.
- *
- * Implements an ArrayList buffer before storing messages to the DB.
- * Override getSQL to fit your database schema (or implement spLog msg
-on your DB)
- * Override executeSQL to modify how DB connection and SQL execution is
-made.
- *
- * @author: Kevin Steppe
- */
-public class JDBCAppender extends org.apache.log4j.AppenderSkeleton
- implements org.apache.log4j.Appender
-{
- protected String databaseURL = "jdbc:odbc:myDB";
- protected String databaseUser = "me";
- protected String databasePassword = "mypassword";
-
-
- public static final String URL_OPTION = "URL";
- public static final String USER_OPTION = "User";
- public static final String PASSWORD_OPTION = "Password";
- public static final String BUFFER_OPTION = "Buffer";
- protected int bufferSize = 1;
- protected List buffer;
-
-
- public JDBCAppender()
- {
- super();
- buffer = new ArrayList();
- }
-
-
- public void append(LoggingEvent event)
- {
- buffer.add(event);
-
-
- if (buffer.size() >= bufferSize)
- flushBuffer();
- }
-
-
- public void close()
- {
- flushBuffer();
- this.closed = true;
- }
-
-
- public void setOption(String key, String value)
- {
- super.setOption(key, value);
-
-
- if (key.equalsIgnoreCase(URL_OPTION))
- databaseURL = value;
- else if (key.equalsIgnoreCase(USER_OPTION))
- databaseUser = value;
- else if (key.equalsIgnoreCase(PASSWORD_OPTION))
- databasePassword = value;
- else if (key.equalsIgnoreCase(BUFFER_OPTION))
- bufferSize = Integer.parseInt(value);
- }
-
-
- /**
- * Override this to create the SQL needed for your DB schema
- */
- protected String getSQL(LoggingEvent event)
- {
- String msg = this.layout.format(event);
- String sql = "spLog '" + msg + "'";
- return sql;
- }
-
-
- /**
- * Override this to provide an alertnate method of getting
-connections (such as caching)
- * This implementation creates a new connection and statement for
-every execution which
- * is very wastefull. One method to fix this is to open connections
-at the start of
- * flushBuffer() and close them at the end. MD Data uses a
-connection pool outside
- * of JDBCAppender which is accessed in the override of this method.
-
-
- */
- protected void executeSQL(String sql) throws SQLException
- {
- Connection con = null;
- Statement stmt = null;
-
-
- try {
- con = DriverManager.getConnection(databaseURL, databaseUser,
-databasePassword);
- stmt = con.createStatement();
- stmt.executeUpdate(sql);
- }
- catch (SQLException e)
- {
- if (con != null)
- con.close();
- if (stmt != null)
- stmt.close();
-
-
- throw e;
- }
- stmt.close();
- con.close();
- }
-
-
- public void flushBuffer()
- {
- //Do the actual logging
- for (Iterator i = buffer.iterator(); i.hasNext();)
- {
- try {
- String sql = getSQL((LoggingEvent)i.next());
- executeSQL(sql);
- }
- catch (SQLException e)
- {
- errorHandler.error("Failed to excute sql", e,
-ErrorCode.FLUSH_FAILURE);
- }
- }
- buffer.clear();
- }
-
-
- public void finalize()
- {
- close();
- }
-
-
- public boolean requiresLayout()
- {
- return true;
- }
-
-
-}
-
-
-
-package org.apache.log4j.varia.test;
-
-
-import org.apache.log4j.varia.JDBCAppender;
-import org.apache.log4j.*;
-
-
-public class JDBCTest
-{
- public static void main (String argv[])
- {
- try {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- System.out.println(e.toString());
- }
-
-
- Category rootLog = Category.getRoot();
- Layout layout = new PatternLayout("%p [%t] %c - %m%n");
- JDBCAppender appender = new JDBCAppender();
- appender.setLayout(layout);
- appender.setOption(JDBCAppender.URL_OPTION, "jdbc:odbc:someDB");
-
-
- appender.setOption(JDBCAppender.USER_OPTION, "auser");
- appender.setOption(JDBCAppender.PASSWORD_OPTION, "thepassword");
-
-
-
- rootLog.addAppender(appender);
-
-
- try {
- Category log = Category.getInstance("main");
- log.debug("Debug 1");
- Thread.sleep(500);
- log.info("info 1");
- Thread.sleep(500);
- log.warn("warn 1");
- Thread.sleep(500);
- log.error("error 1");
- Thread.sleep(500);
- log.fatal("fatal 1");
- Thread.sleep(500);
-
-
- appender.setOption(JDBCAppender.BUFFER_OPTION, "5");
- log.debug("Debug 2");
- Thread.sleep(500);
- log.info("info 2");
- Thread.sleep(500);
- log.warn("warn 2");
- Thread.sleep(500);
- log.error("error 2");
- Thread.sleep(500);
- log.fatal("fatal 2");
- Thread.sleep(500);
-
-
- appender.setOption(JDBCAppender.BUFFER_OPTION, "2");
- appender.setThreshold(Priority.WARN);
- log.debug("Debug 3");
- Thread.sleep(500);
- log.info("info 3");
- Thread.sleep(500);
- log.warn("warn 3");
- Thread.sleep(500);
- log.error("error 3");
- Thread.sleep(500);
- log.fatal("fatal 3");
- }
- catch (InterruptedException e)
- {
- System.out.println("Interrupted");
- }
- }
-}
-
-
-
-drop table JDBCAppenderTest
-go
-create table JDBCAppenderTest (EventID int identity, entrytime datetime,
-message varchar(255))
-
-
-drop procedure spLog
-go
-create procedure spLog (@msg varchar(255)) as
- insert into JDBCAppenderTest (message, entrytime) values (@msg,
-getdate())
-
-
-select * from JDBCAppenderTest
-
-
-
-drop table JDBCAppenderTest
-go
-create table JDBCAppenderTest (EventID int identity, entrytime datetime, message varchar(255))
-
-
-drop procedure spLog
-go
-create procedure spLog (@msg varchar(255)) as
- insert into JDBCAppenderTest (message, entrytime) values (@msg, getdate())
-
-
-select * from JDBCAppenderTest
-package org.apache.log4j.varia;
-
-
-import org.apache.log4j.*;
-import org.apache.log4j.spi.*;
-
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-
-import java.sql.DriverManager;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.sql.SQLException;
-
-
-/**
- * Contribution from MD Data Direct.
- *
- * Implements an ArrayList buffer before storing messages to the DB.
- * Override getSQL to fit your database schema (or implement spLog msg on your DB)
- * Override executeSQL to modify how DB connection and SQL execution is made.
- *
- * @author: Kevin Steppe
- */
-public class JDBCAppender extends org.apache.log4j.AppenderSkeleton
- implements org.apache.log4j.Appender
-{
- protected String databaseURL = "jdbc:odbc:myDB";
- protected String databaseUser = "me";
- protected String databasePassword = "mypassword";
-
- public static final String URL_OPTION = "URL";
- public static final String USER_OPTION = "User";
- public static final String PASSWORD_OPTION = "Password";
- public static final String BUFFER_OPTION = "Buffer";
- protected int bufferSize = 1;
- protected List buffer;
-
- public JDBCAppender()
- {
- super();
- buffer = new ArrayList();
- }
-
- public void append(LoggingEvent event)
- {
- buffer.add(event);
-
- if (buffer.size() >= bufferSize)
- flushBuffer();
- }
-
-
- public void close()
- {
- flushBuffer();
- this.closed = true;
- }
-
-
- public void setOption(String key, String value)
- {
- super.setOption(key, value);
-
- if (key.equalsIgnoreCase(URL_OPTION))
- databaseURL = value;
- else if (key.equalsIgnoreCase(USER_OPTION))
- databaseUser = value;
- else if (key.equalsIgnoreCase(PASSWORD_OPTION))
- databasePassword = value;
- else if (key.equalsIgnoreCase(BUFFER_OPTION))
- bufferSize = Integer.parseInt(value);
- }
-
-
- /**
- * Override this to create the SQL needed for your DB schema
- */
- protected String getSQL(LoggingEvent event)
- {
- String msg = this.layout.format(event);
- String sql = "spLog '" + msg + "'";
- System.out.println(sql); //DEBUG
- return sql;
- }
-
- /**
- * Override this to provide an alertnate method of getting connections (such as caching)
- * This implementation creates a new connection and statement for every execution which
- * is very wastefull. One method to fix this is to open connections at the start of
- * flushBuffer() and close them at the end. MD Data uses a connection pool outside
- * of JDBCAppender which is accessed in the override of this method.
- */
- protected void executeSQL(String sql) throws SQLException
- {
- Connection con = null;
- Statement stmt = null;
-
-
- try {
- con = DriverManager.getConnection(databaseURL, databaseUser, databasePassword);
- stmt = con.createStatement();
- stmt.executeUpdate(sql);
- }
- catch (SQLException e)
- {
- if (con != null)
- con.close();
- if (stmt != null)
- stmt.close();
-
- throw e;
- }
- stmt.close();
- con.close();
- }
-
- public void flushBuffer()
- {
- //Do the actual logging
- for (Iterator i = buffer.iterator(); i.hasNext();)
- {
- try {
- String sql = getSQL((LoggingEvent)i.next());
- executeSQL(sql);
- }
- catch (SQLException e)
- {
- errorHandler.error("Failed to excute sql", e, ErrorCode.FLUSH_FAILURE);
- }
- }
- buffer.clear();
- }
-
- public void finalize()
- {
- close();
- }
-
- public boolean requiresLayout()
- {
- return true;
- }
-
-
-}package org.apache.log4j.varia.test;
-
-
-import org.apache.log4j.varia.JDBCAppender;
-import org.apache.log4j.*;
-
-
-public class JDBCTest
-{
- public static void main (String argv[])
- {
- try {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- System.out.println(e.toString());
- }
-
- Category rootLog = Category.getRoot();
- Layout layout = new PatternLayout("%p [%t] %c - %m%n");
- JDBCAppender appender = new JDBCAppender();
- appender.setLayout(layout);
- appender.setOption(JDBCAppender.URL_OPTION, "jdbc:odbc:someDB");
- appender.setOption(JDBCAppender.USER_OPTION, "auser");
- appender.setOption(JDBCAppender.PASSWORD_OPTION, "thepassword");
-
- rootLog.addAppender(appender);
-
-
- try {
- Category log = Category.getInstance("main");
- log.debug("Debug 1");
- Thread.sleep(500);
- log.info("info 1");
- Thread.sleep(500);
- log.warn("warn 1");
- Thread.sleep(500);
- log.error("error 1");
- Thread.sleep(500);
- log.fatal("fatal 1");
- Thread.sleep(500);
-
- appender.setOption(JDBCAppender.BUFFER_OPTION, "5");
- log.debug("Debug 2");
- Thread.sleep(500);
- log.info("info 2");
- Thread.sleep(500);
- log.warn("warn 2");
- Thread.sleep(500);
- log.error("error 2");
- Thread.sleep(500);
- log.fatal("fatal 2");
- Thread.sleep(500);
-
-
- appender.setOption(JDBCAppender.BUFFER_OPTION, "2");
- appender.setThreshold(Priority.WARN);
- log.debug("Debug 3");
- Thread.sleep(500);
- log.info("info 3");
- Thread.sleep(500);
- log.warn("warn 3");
- Thread.sleep(500);
- log.error("error 3");
- Thread.sleep(500);
- log.fatal("fatal 3");
- }
- catch (InterruptedException e)
- {
- System.out.println("Interrupted");
- }
- }
-}
diff --git a/contribs/KitchingSimon/DatagramStringAppender.java b/contribs/KitchingSimon/DatagramStringAppender.java
deleted file mode 100644
index a532f96..0000000
--- a/contribs/KitchingSimon/DatagramStringAppender.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * 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. */
-
-package org.apache.log4j.net;
-
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.DatagramPacket;
-import java.net.UnknownHostException;
-import java.net.SocketException;
-
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.Category;
-import org.apache.log4j.Priority;
-import org.apache.log4j.Layout;
-
-import org.apache.log4j.helpers.SingleLineTracerPrintWriter;
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.helpers.QuietWriter;
-
-
-/**
- Use DatagramStringAppender to send log messages to a remote daemon
- which accepts Datagram (UDP) messages.
- <p>
- The benefits of UDP are that the client is guarunteed not to
- slow down if the network or remote log daemon is slow, and that
- no permanent TCP connection between client and server exists.
- <p>
- The disadvantages are that log messages can be lost if the network
- or remote daemon are under excessive load.
- <p>
- This class builts the final message string <b>before</b> sending
- the UDP packet, hence the "string" component in the class name. This
- means that the receiving application can be written in any language.
- The data is transmitted in whatever encoding is specified in the
- configuration file; this may be an 8-bit encoding (eg ISO-8859-1, also
- known as LATIN-1) or a larger encoding, eg UTF-16.
- <p>
- An alternative to building the message string within DatagramStringAppender
- would be to serialize & send the complete logging event object (perhaps
- such a class could be called a DatagramSerialAppender??). The
- receiving end could then be configured with appropriate Layout objects
- to generate the actual logged messages. This would ensure that the
- logging of messages from different sources is done in a consistent
- format, and give a central place to configure that format. It would ensure
- (by transmitting messages as unicode) that the receiving end could control
- the encoding in which the output is generated. It also would possibly allow
- he receiving end to use the full log4j flexibility to pass the event to
- different appenders at the receiving end, as the category information is
- retained, etc. However, this does require that the receiving end is in
- java, and that all clients of the logging daemon are java applications.
- In contrast, this DatagramStringAppender can send mesages to a log daemon
- that accepts messages from a variety of sources.
-
- @author Simon Kitching
- */
-public class DatagramStringAppender extends AppenderSkeleton {
-
- /**
- A string constant used in naming the option for setting the destination
- server for messages. Current value of this string constant is
- <b>DatagramHost</b>. */
- public static final String DATAGRAM_HOST_OPTION = "DatagramHost";
-
- /**
- A string constant used in naming the option for setting the destination
- port for messages. Current value of this string constant is
- <b>DatagramPort</b>. */
- public static final String DATAGRAM_PORT_OPTION = "DatagramPort";
-
- /**
- A string constant used in naming the option for setting the character
- encoding used when generating the log message. Current value of this
- string constant is <b>DatagramEncoding</b>. */
- public static final String DATAGRAM_ENCODING_OPTION = "DatagramEncoding";
-
- /**
- The default value for the "host" attribute, ie the machine to which
- messages are sent. Current value of this string constant is
- <b>localhost</b>. */
- public static final String DEFAULT_HOST = "localhost";
-
- /**
- The default value for the "port" attribute, ie the UDP port to which
- messages are sent. Current value of this integer constant is
- <b>8200</b>. This value was chosen for no particular reason. */
- public static final int DEFAULT_PORT = 8200;
-
- /**
- The default value for the "encoding" attribute, ie the way in which
- unicode message strings are converted into a stream of bytes before
- their transmission as a UDP packet. The current value of this constant
- is <b>null</b>, which means that the default platform encoding will
- be used. */
- public static final String DEFAULT_ENCODING = null;
-
- String host = DEFAULT_HOST;
- int port = DEFAULT_PORT;
- String encoding = DEFAULT_ENCODING;
-
- SingleLineTracerPrintWriter stp;
- QuietWriter qw;
-
- public
- DatagramStringAppender() {
- this.setDestination(DEFAULT_HOST, DEFAULT_PORT, DEFAULT_ENCODING);
- }
-
- public
- DatagramStringAppender(Layout layout) {
- this.setLayout(layout);
- this.setDestination(DEFAULT_HOST, DEFAULT_PORT, DEFAULT_ENCODING);
- }
-
- public
- DatagramStringAppender(Layout layout, String host, int port) {
- this.setLayout(layout);
- this.setDestination(host, port, DEFAULT_ENCODING);
- }
-
- public
- DatagramStringAppender(Layout layout, String host, int port, String encoding) {
- this.setLayout(layout);
- this.setDestination(host, port, encoding);
- }
-
- /**
- Release any resources held by this Appender
- */
- public
- void close() {
- closed = true;
- // A DatagramWriter is UDP based and needs no opening. Hence, it
- // can't be closed. We just unset the variables here.
- qw = null;
- stp = null;
- }
-
- public
- void append(LoggingEvent event) {
- if(!isAsSevereAsThreshold(event.priority))
- return;
-
- // We must not attempt to append if qw is null.
- if(qw == null) {
- errorHandler.error(
- "No host is set for DatagramStringAppender named \""
- + this.name + "\".");
- return;
- }
-
- String buffer = layout.format(event);
- qw.write(buffer);
-
- if(event.throwable != null)
- event.throwable.printStackTrace(stp);
- else if (event.throwableInformation != null) {
- // we must be the receiver of a serialized/deserialized LoggingEvent;
- // the event's throwable member is transient, ie becomes null when
- // deserialized, but that's ok because throwableInformation should
- // have the string equivalent of the same info (ie stack trace)
- qw.write(event.throwableInformation);
- }
- }
-
- /**
- Activate the options set via the setOption method.
-
- @see #setOption
- */
- public
- void activateOptions() {
- this.setDestination(this.host, this.port, this.encoding);
- }
-
- /**
- Returns the option names for this component, namely the string
- array consisting of {{@link #DATAGRAM_HOST_OPTION}, {@link
- #DATAGRAM_PORT_OPTION}, {@link #DATAGRAM_ENCODING_OPTION} */
- public
- String[] getOptionStrings() {
- return OptionConverter.concatanateArrays(super.getOptionStrings(),
- new String[] {
- DATAGRAM_HOST_OPTION,
- DATAGRAM_PORT_OPTION,
- DATAGRAM_ENCODING_OPTION});
- }
-
- /**
- The DatagramStringAppender requires a layout. Hence, this method return
- <code>true</code>.
-
- @since 0.8.4 */
- public
- boolean requiresLayout() {
- return true;
- }
-
- /**
- Set DatagramStringAppender specific parameters.
- <p>
- The recognized options are <b>DatagramHost</b>, <b>DatagramPort</b> and
- <b>DatagramEncoding</b>, i.e. the values of the string constants
- {@link #DATAGRAM_HOST_OPTION}, {@link #DATAGRAM_PORT_OPTION} and
- {@link #DATAGRAM_ENCODING_OPTION} respectively.
- <p>
- <dl>
- <p>
- <dt><b>DatagramHost</b>
- <dd>
- The name (or ip address) of the host machine where log output should go.
- If the DatagramHost is not set, then this appender will default to
- {@link #DEFAULT_HOST}.
- <p>
- <dt><b>DatagramPort</b>
- <dd>
- The UDP port number where log output should go. See {@link #DEFAULT_PORT}
- <p>
- <dt><b>DatagramEncoding</b>
- <dd>
- The ISO character encoding to be used when converting the Unicode
- message to a sequence of bytes within a UDP packet. If not defined, then
- the encoding defaults to the default platform encoding.
- </dl>
- */
- public
- void setOption(String option, String value) {
- if(value == null) return;
-
- super.setOption(option, value);
-
- if(option.equals(DATAGRAM_HOST_OPTION))
- {
- this.host = value;
- }
- else if(option.equals(DATAGRAM_PORT_OPTION))
- {
- this.port = OptionConverter.toInt(value, DEFAULT_PORT);
- }
- else if(option.equals(DATAGRAM_ENCODING_OPTION))
- {
- this.encoding = value;
- }
- }
-
- public
- void setDestination(String host, int port, String encoding) {
- if (host==null) {
- LogLog.error("setDestination: host is null");
- host = DEFAULT_HOST;
- }
-
- this.host = host;
- this.port = port;
- this.encoding = encoding;
-
- this.qw = new QuietWriter(
- new DatagramStringWriter(host, port, encoding),
- errorHandler);
- this.stp = new SingleLineTracerPrintWriter(qw);
- }
-
- public
- void setLayout(Layout layout) {
- this.layout = layout;
- }
-}
diff --git a/contribs/KitchingSimon/DatagramStringWriter.java b/contribs/KitchingSimon/DatagramStringWriter.java
deleted file mode 100644
index 9f7f6bc..0000000
--- a/contribs/KitchingSimon/DatagramStringWriter.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * 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.
- */
-
-package org.apache.log4j.net;
-
-import java.io.Writer;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.DatagramPacket;
-import java.net.UnknownHostException;
-import java.net.SocketException;
-import java.io.IOException;
-
-import org.apache.log4j.helpers.LogLog;
-
-/**
- * DatagramStringWriter is a wrapper around the java.net.DatagramSocket class
- * so that it behaves like a java.io.Writer.
- */
-public class DatagramStringWriter extends Writer {
-
- static final int SYSLOG_PORT = 514;
-
- private int port;
- private String host;
- private String encoding;
- private String prefix;
-
- private InetAddress address;
- private DatagramSocket ds;
-
- /**
- * This constructor assumes that it is sending to a remote syslog daemon
- * on the normal syslog port (514), and uses the default platform character
- * encoding when converting the message string to a byte sequence.
- */
- public
- DatagramStringWriter(String host) {
- this(host, SYSLOG_PORT, null, null);
- }
-
- /**
- * This constructor sends messages to the specified host and port, and
- * uses the default platform character encoding when converting the message
- * string to a byte sequence.
- */
- public
- DatagramStringWriter(String host, int port) {
- this(host, port, null, null);
- }
-
- /**
- * This constructor sends messages to the specified host and port, and
- * uses the specified character encoding when converting the message
- * string to a byte sequence.
- */
- public
- DatagramStringWriter(String host, int port, String encoding) {
- this(host, port, null, null);
- }
- /**
- * This constructor sends messages to the specified host and port, and
- * uses the specified character encoding when converting the message
- * string to a byte sequence; the specified prefix (which may be null)
- * is prepended to each message.
- */
- public
- DatagramStringWriter(String host, int port, String encoding, String prefix) {
- this.host = host;
- this.port = port;
- this.encoding = encoding;
- this.prefix = prefix;
-
- try {
- this.address = InetAddress.getByName(host);
- }
- catch (UnknownHostException e) {
- LogLog.error("Could not find " + host +
- ". All logging will FAIL.", e);
- }
-
- try {
- this.ds = new DatagramSocket();
- }
- catch (SocketException e) {
- e.printStackTrace();
- LogLog.error("Could not instantiate DatagramSocket to " + host +
- ". All logging will FAIL.", e);
- }
- }
-
-
- public
- void write(char[] buf, int off, int len) throws IOException {
- this.write(new String(buf, off, len));
- }
-
- public
- void write(String string) throws IOException {
- if (prefix != null) {
- string = prefix + string;
- }
-
- byte[] rawData;
- if (this.encoding == null)
- {
- // convert to byte sequence using platform's default encoding
- rawData = string.getBytes();
- }
- else
- {
- // convert to specified encoding - which may be sequence of
- // 8-bit chars, or multi-byte encodings like UTF-8 or UTF-16.
- // The receiving end had better be expecting whatever encoding
- // is used here on the sending end!
- rawData = string.getBytes(encoding);
- }
-
- DatagramPacket packet =
- new DatagramPacket(
- rawData,
- rawData.length,
- address,
- port);
-
- if(this.ds != null)
- {
- ds.send(packet);
- }
- else
- {
- LogLog.error(
- "write: failed to create DatagramPacket");
- }
- }
-
- public
- void flush() {}
-
- public
- void close() {}
-
- /**
- * Set a string to be prefixed to every message sent by this Writer.
- * For example, this method could be used to prepend a syslog
- * facility/priority code on the front of each message.
- * <p>
- * Note that this method is not synchronised, so should not be called in
- * a situation where other threads may be logging messages at the same
- * moment.
- * <p>
- * @param prefix may be a prefix string, or null which indicates no
- * prefix should be added.
- */
- public
- void setPrefix(String prefix){
- this.prefix = prefix;
- }
-}
diff --git a/contribs/KitchingSimon/SingleLineTracerPrintWriter.java b/contribs/KitchingSimon/SingleLineTracerPrintWriter.java
deleted file mode 100644
index c47e0b9..0000000
--- a/contribs/KitchingSimon/SingleLineTracerPrintWriter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * 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. */
-
-package org.apache.log4j.helpers;
-
-/**
- SingleLineTracerPrintWriter overrides the println function in
- TracerPrintWriter by replacing the TAB character with spaces.
- It also does not print the "\n".
- <p>
- The default format generated by TracerPrintWriter for exceptions
- prints on multiple lines, which does not interact well with some
- logging systems. On the other hand, a stack-trace on one line can be a
- mite difficult to read, so this class should only be used where really
- necessary :-)
- <p>
- For syslog daemons, tabs in messages are not friendly, hence the
- replacement of tabs by spaces here. It shouldn't do any harm to
- do this for all messages...
- <p>
- Perhaps it might be better to enhance TracerPrintWriter to have
- a configuration item for one-line or multi-line mode...
-*/
-public class SingleLineTracerPrintWriter extends TracerPrintWriter {
-
- static String TAB = " ";
-
- public SingleLineTracerPrintWriter(QuietWriter qWriter) {
- super(qWriter);
- }
-
- /**
- Make the first Exception line print properly by omitting the \n at the
- end.
- */
- public
- void println(Object o) {
- this.qWriter.write(o.toString());
- }
-
- // Note: the Char[] form is handled by the TracerPrinterWriter super
- // class
-
- /**
- Remove the first character from the string (usually a TAB) and do
- not print "\n"
- */
- public
- void println(String s) {
- // remove '^I' and replace it with 4 spaces
- this.qWriter.write(TAB+s.substring(1));
- }
-}
diff --git a/contribs/KitchingSimon/logconfig.xml b/contribs/KitchingSimon/logconfig.xml
deleted file mode 100644
index bc53733..0000000
--- a/contribs/KitchingSimon/logconfig.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<configuration configDebug="true">
-
- <appender name="STDOUT" class="org.apache.log4j.FileAppender">
- <param name="File" value="System.out" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern"
- value="aa:%p#%d#%c#%m%n"/>
- </layout>
- </appender>
-
- <appender name="UDPVENUS" class="org.apache.log4j.net.DatagramStringAppender">
- <param name="DatagramHost" value="Venus" />
- <param name="DatagramPort" value="8300" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern"
- value="%p#%d#%c#%m"/>
- </layout>
- <filter class="org.apache.log4j.filters.PriorityRangeFilter">
- <param name="PriorityMin" value="WARN" />
- </filter>
- </appender>
-
- <category name="org.apache.log4j.xml">
- <priority value="INFO" />
- </category>
-
- <category name="ch">
- <priority value ="DEBUG2" class="ch.orange.log.Priority"/>
- </category>
-
- <category name="script">
- <priority value ="DEBUG2" class="ch.orange.log.Priority"/>
- </category>
-
- <root>
- <priority value ="DEBUG2" class="ch.orange.log.Priority"/>
- <appender-ref ref="STDOUT" />
- <appender-ref ref="UDPVENUS" />
- </root>
-
-</configuration>
diff --git a/contribs/KitchingSimon/mail-2001-02-07 b/contribs/KitchingSimon/mail-2001-02-07
deleted file mode 100644
index 063e3ff..0000000
--- a/contribs/KitchingSimon/mail-2001-02-07
+++ /dev/null
@@ -1,88 +0,0 @@
-Delivered-To: urba-cgu@urbanet.ch
-Mailing-List: contact log4j-dev-help@jakarta.apache.org; run by ezmlm
-List-Post: <ma...@jakarta.apache.org>
-List-Help: <ma...@jakarta.apache.org>
-List-Unsubscribe: <ma...@jakarta.apache.org>
-List-Subscribe: <ma...@jakarta.apache.org>
-Reply-To: "LOG4J Developers Mailing List" <lo...@jakarta.apache.org>
-Delivered-To: mailing list log4j-dev@jakarta.apache.org
-From: Kitching Simon <Si...@orange.ch>
-To: "'log4j-dev@jakarta.apache.org'" <lo...@jakarta.apache.org>
-Subject: PATCH: New classes: DatagramStreamAppender & friends
-Date: Wed, 7 Feb 2001 12:41:54 +0100
-X-Mailer: Internet Mail Service (5.5.2650.21)
-X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N
-
-
-Hi log4j developers....
-
-
-Here, for your consideration, is a set of files that
-implement an Appender which sends messages
-to a remote host/port via UDP (datagram).
-
-
-There was brief discussion of this Appender on the
-log4j-user group, about a week ago. Ceki suggested
-that the Appender send serialized log event objects
-over UDP; while this approach has a number of
-advantages, I have decided to instead perform the
-message formatting at the client end, mainly so
-that:
-(a) the UDP server application does not have to be in java
-(b) non-java clients can send messages to the same UDP
- server.
-
-
-The appender has been named "DatagramStringAppender"
-to allow someone to write a serialization-based version at
-some later time, if desired, without any name confusion.
-------------------------------
-Notes:
-
-
-DatagramStringAppender is based on SyslogAppender, but
-with a fair number of changes.
-
-
-DatagramStringWriter is based on SyslogWriter, with a few changes.
-In particular, it takes an "encoding" parameter, so that the character
-encoding used can be specified, and a "port".
-
-
-SingleLineTracerPrintWriter is almost identical to
-SyslogTracerPrintWriter; just the name & some comments
-have changed. [I didn't want to call a class called SyslogXXX
-from the DatagramStreamAppender classes]
-------------------------------
-
-
-If this patch is accepted, then it may be worth rewriting SyslogAppender
-to use the DatagramStringWriter and SingleLineTracerPrintWriter
-classes. These classes should be compatible with SyslogAppender,
-as they implement the same functionality, or a superset of the
-Syslog functionality, and have more "general" names.
-------------------------------
- <<DatagramStringAppender.java>>
-
-
-
- <<DatagramStringWriter.java>>
-
-
- <<SingleLineTracerPrintWriter.java>>
-
-
---------------------------------
-And here's a simple perl UDP server, and an xml
-config file for testing the appender.
- <<logconfig.xml>>
-
-
- <<udpserver.pl>>
-
-
-Regards,
-
-
-Simon
diff --git a/contribs/KitchingSimon/udpserver.pl b/contribs/KitchingSimon/udpserver.pl
deleted file mode 100644
index 2f5f900..0000000
--- a/contribs/KitchingSimon/udpserver.pl
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/opt/perl5/bin/perl -w
-use strict;
-use Socket;
-use IO::Socket;
-use Sys::Hostname;
-
-main();
-exit(0);
-
-sub main()
-{
- my $MAX_MSG_SIZE = 16384; # 16KBytes should be enough...
-
- my $svrport = 8300;
- my $svriaddr = gethostbyname(hostname());
- my $svrproto = getprotobyname('udp');
- my $svrpaddr = sockaddr_in($svrport, $svriaddr);
-
- socket(SOCKET, PF_INET, SOCK_DGRAM, $svrproto) || die "socket: $!";
- bind(SOCKET, $svrpaddr) || die "bind: $!";
-
- my $rin = '';
- vec($rin, fileno(SOCKET), 1) = 1;
-
- # timeout after 10.0 seconds
- # at some time, I'm going to add signal handlers so that signals can be
- # sent to cause logfile rollover, or tidy exit...then the timeout will
- # come in useful..
-
- my $exit = 0;
- while (!$exit)
- {
- my $rout = $rin;
-
- # select(readvec, writevec, exceptionvec, timeout)
- # : returns # of selected filehandles, modifies
- # vector parameters so that set bits indicate
- # filehandles which are readable, writable or have
- # an exception state
-
- my $nSelected = select($rout, undef, undef, 10.0);
- if ($nSelected == 0)
- {
- # timedout : go back to start of loop
- next;
- }
-
- my $msgData = '';
- my $clientpaddr = recv(SOCKET, $msgData, $MAX_MSG_SIZE, 0);
- if (!$clientpaddr)
- {
- die "recv: $!";
- }
-
- my ($clientport, $clientiaddr) = sockaddr_in($clientpaddr);
- my $clienthost = gethostbyaddr($clientiaddr, AF_INET);
- if (!$clienthost)
- {
- # unable to determine name for client : show raw ip address
- $clienthost = inet_ntoa($clientiaddr);
- }
-
- print "$clienthost:$msgData\n";
- }
-}
-
-
diff --git a/contribs/LeosLiterak/TempFileAppender.java b/contribs/LeosLiterak/TempFileAppender.java
deleted file mode 100644
index 74fe216..0000000
--- a/contribs/LeosLiterak/TempFileAppender.java
+++ /dev/null
@@ -1,178 +0,0 @@
- package org.apache.log4j;
-
-import java.io.File;
-import java.io.Writer;
-import java.io.FileWriter;
-import java.io.BufferedWriter;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.ErrorHandler;
-
-/**
- TempFileAppender creates new unique file for each logging statement.
-
- @author <a HREF="mailto:leos.literak@12snap.com">Leos Literak</a>
- @author Ceki Gülcü
-
-*/
-public class TempFileAppender extends AppenderSkeleton {
-
- /**
- A string constant used in naming the option for setting the
- directory where the log files will be created. Current value
- of this string constant is <b>Path</b>. java.io.tmpdir directory
- will be used, if ommited.
- */
- static final public String PATH_OPTION = "Path";
-
- /**
- The default path is actual directory.
- */
- protected String path = null;
-
- /**
- A string constant used in naming the option for setting the
- prefix of the log files. It has to have at least 3 characters!
- Current value of this string constant is <b>Prefix</b>.
- */
- static final public String PREFIX_OPTION = "Prefix";
-
- /**
- The default path is actual directory.
- */
- protected String prefix = "l4j_";
-
- /**
- A string constant used in naming the option for setting the
- suffix of the log files. Current value of this string constant
- is <b>Suffix</b>.
- */
- static final public String SUFFIX_OPTION = "Suffix";
-
- /**
- The default path is actual directory.
- */
- protected String suffix = ".tmp";
-
- /**
- Default dir
- */
-
- protected File dir = null;
-
-
-
-
- /**
- The default constructor simply calls its parent's constructor.
- */
- public TempFileAppender() {
- super();
- }
-
- /**
- Retuns the option names for this component
- */
- public String[] getOptionStrings() {
- return OptionConverter.concatanateArrays(super.getOptionStrings(),
- new String[] {PATH_OPTION,PREFIX_OPTION,SUFFIX_OPTION});
- }
-
- /**
- Set TempFileAppender specific options.
-
- The recognized options are <b>Path</b>, <b>Prefix</b> and <b>Suffix</b>,
- i.e. the values of the string constants {@link #PATH_OPTION},
- {@link #PREFIX_OPTION} and respectively {@link #SUFFIX_OPTION}.
- The options of the super class {@link AppenderSkeleton} are also
- recognized.
- */
-
- public void setOption(String key, String value) {
- super.setOption(key, value);
- if(key.equalsIgnoreCase(PATH_OPTION)) {
- path = value;
- if(path==null) {
- errorHandler.error("Path cannot be empty!",null,0);
- }
-
- dir = new File(path);
- if(!(dir.exists() && dir.isDirectory() && dir.canWrite())) {
- errorHandler.error("Cannot write to directory " + path + "!",null,0);
- }
- }
- else if(key.equalsIgnoreCase(PREFIX_OPTION)) {
- if(value!=null && value.length()>=3) {
- prefix = value;
- } else {
- errorHandler.error("Prefix cannot be shorter than 3 characters!",
- null,0);
- }
- }
- else if(key.equalsIgnoreCase(SUFFIX_OPTION)) {
- if(value!=null && value.length()>=1) {
- suffix = value;
- } else {
- errorHandler.error("Suffix cannot be empty!",null,0);
- }
- }
- }
-
- /**
- This method is called by {@link AppenderSkeleton#doAppend}
- method.
-
- <p>Whenever this method is called, new unique file is created
- with specified prefix and suffix. The file is closed afterwards.
-
- <p>The format of the output will depend on this appender's
- layout.
-
- */
- public void append(LoggingEvent event) {
- if(!checkEntryConditions()) {
- return;
- }
- subAppend(event);
- }
-
- /**
- This method determines if there is a sense in attempting to append.
- */
- protected boolean checkEntryConditions() {
- return true;
- }
-
- /**
- This method does actual writing
- */
- protected void subAppend(LoggingEvent event) {
- try {
- File tmp = File.createTempFile(prefix,suffix,dir);
- Writer out = new BufferedWriter(new FileWriter(tmp));
- out.write(event.message);
- out.close();
- /* this Appender is not supposed to be used for logging of Exceptions */
- } catch (Exception e) {
- errorHandler.error("Error during creation of temporary File!",e,1);
- }
- }
-
- public boolean requiresLayout() {
- return false;
- }
-
- public void close() {
- /* nothing to do */
- }
-}
-/*
- * @author $Author$
- * @version $Revision$
- * @since $Date$
- *
- * $Log$
- * Revision 1.1 2001/04/20 17:38:31 ceki
- * Added LeosLiterak's TempFileAppender.java
- *
-*/
diff --git a/contribs/LeosLiterak/mail b/contribs/LeosLiterak/mail
deleted file mode 100644
index 072e7d9..0000000
--- a/contribs/LeosLiterak/mail
+++ /dev/null
@@ -1,41 +0,0 @@
-To: ceki@apache.org
-Subject: TempFileAppender
-
-
-Hi Ceki,
-
-
-I have created one small Appender, which puts each
-logging statement into separate file. We use it
-for storing incomming messages into second process'es
-spool directory. If you like it, please include it
-into Log4j with APL license.
-
-
-Usage:
-
-
-log4j.appender.A1=org.apache.log4j.TempFileAppender
-log4j.appender.A1.Path=spool_dir
-log4j.appender.A1.Prefix=out_
-log4j.appender.A1.Suffix=.msg
-
-
- Leo
-
------------------------------------------------------
-Leos Literak
-Software Engineer
-
-
-12snap s.r.o.
-Pstrossova 24
-110 00 Praha 1
-Czech Republic
-
-
-mobile: ?605-849-087
-phone: ?2-21-970-239
-fax: ?2-21-970-241
-e-mail: leos.literak@12snap.com
-
diff --git a/contribs/MarkDouglas/Log.txt b/contribs/MarkDouglas/Log.txt
deleted file mode 100644
index f773f53..0000000
--- a/contribs/MarkDouglas/Log.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-INFO ( Server:main ) systemsunion.LoggingServer.SocketServer2 - Connected to client at RDDSOWE2/129.153.78.195
-INFO ( Server:main ) systemsunion.LoggingServer.SocketServer2 - Starting new socket node.
-INFO ( Server:main ) systemsunion.LoggingServer.SocketServer2 - Waiting to accept a new client.
-INFO ( RDDSOWE2:main ) systemsunion.SSTS.system - ClosedownController: starting
-INFO ( Server:main ) systemsunion.LoggingServer.SocketServer2 - Connected to client at RDDSOWE2/129.153.78.195
-INFO ( Server:main ) systemsunion.LoggingServer.SocketServer2 - Starting new socket node.
-INFO ( Server:main ) systemsunion.LoggingServer.SocketServer2 - Waiting to accept a new client.
-INFO ( RDDSOWE2:main ) systemsunion.SSTS.system - ClosedownController: starting
-INFO ( RDDSOWE2:AWT-EventQueue-0) systemsunion.SSTS.components - Packing component Operator
-INFO ( RDDSOWE2:AWT-EventQueue-0) systemsunion.SSTS.components - Packing class file d:/SSDev/SSTS/components\Operator\Operator.class for component Operator
-INFO ( RDDSOWE2:AWT-EventQueue-0) systemsunion.SSTS.components - Packing class file d:/SSDev/SSTS/components\Operator\Operator.class for component Operator
-INFO ( RDDSOWE2:AWT-EventQueue-0) systemsunion.SSTS.components - Packing proxy class file d:/SSDev/SSTS/components\Operator\OperatorProxy.class for component Operator
-INFO ( RDDSOWE2:AWT-EventQueue-0) systemsunion.SSTS.components - Packing class file d:/SSDev/SSTS/components\Operator\OperatorProxy.class for component Operator
-INFO ( RDDSOWE2:AWT-EventQueue-0) systemsunion.SSTS.components - Packing test XML page file d:/SSDev/SSTS/components\Operator\Operator.XML for component Operator
-INFO ( RDDSOWE2:AWT-EventQueue-0) systemsunion.SSTS.components - Packing class file d:/SSDev/SSTS/components\Operator\Operator.XML for component Operator
-INFO ( RDDSOWE2:AWT-EventQueue-0) systemsunion.SSTS.components - Packing descriptor file d:/SSDev/SSTS/components\Operator\OperatorDeploymentDescriptor.XML for component Operator
-INFO ( RDDSOWE2:AWT-EventQueue-0) systemsunion.SSTS.components - Packing class file d:/SSDev/SSTS/components\Operator\OperatorDeploymentDescriptor.XML for component Operator
diff --git a/contribs/MarkDouglas/SocketNode2.java b/contribs/MarkDouglas/SocketNode2.java
deleted file mode 100644
index a868c92..0000000
--- a/contribs/MarkDouglas/SocketNode2.java
+++ /dev/null
@@ -1,102 +0,0 @@
-
-package com.systemsunion.LoggingServer;
-
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.ServerSocket;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
-
-import org.apache.log4j.Category;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.Priority;
-import org.apache.log4j.NDC;
-
-// Contributors: Moses Hohman <mm...@rainbow.uchicago.edu>
-
-/**
- Read {@link LoggingEvent} objects sent from a remote client using
- Sockets (TCP). These logging events are logged according to local
- policy, as if they were generated locally.
-
- <p>For example, the socket node might decide to log events to a
- local file and also resent them to a second socket node.
-
- @author Ceki Gülcü
-
- @since 0.8.4
-*/
-public class SocketNode2 implements Runnable {
-
- Socket socket;
- ObjectInputStream ois;
-
- static Category cat = Category.getInstance(SocketNode2.class.getName());
-
- public
- SocketNode2(Socket socket) {
- this.socket = socket;
- try {
- ois = new ObjectInputStream(socket.getInputStream());
- }
- catch(Exception e) {
- cat.error("Could not open ObjectInputStream to "+socket, e);
- }
- }
-
- //public
- //void finalize() {
- //System.err.println("-------------------------Finalize called");
- // System.err.flush();
- //}
-
- public void run() {
- LoggingEvent event;
- Category remoteCategory;
- String strClientName;
-
- // Get the client name.
- InetAddress addr = socket.getInetAddress();
- strClientName = addr.getHostName();
- if(strClientName == null || strClientName.length() == 0)
- {
- strClientName = addr.getHostAddress();
- }
-
- try {
- while(true) {
- event = (LoggingEvent) ois.readObject();
-
- if(event.ndc != null)
- {
- event.ndc = strClientName + ":" + event.ndc;
- }
- else
- {
- event.ndc = strClientName;
- }
-
- remoteCategory = Category.getInstance(event.categoryName);
- remoteCategory.callAppenders(event);
- }
- }
- catch(java.io.EOFException e) {
- cat.info("Caught java.io.EOFException will close conneciton.", e);
- }
- catch(java.net.SocketException e) {
- cat.info("Caught java.net.SocketException, will close conneciton.", e);
- }
- catch(Exception e) {
- cat.error("Unexpected exception. Closing conneciton.", e);
- }
-
- try {
- ois.close();
- }
- catch(Exception e) {
- cat.info("Could not close connection.", e);
- }
- }
-}
diff --git a/contribs/MarkDouglas/SocketServer2.java b/contribs/MarkDouglas/SocketServer2.java
deleted file mode 100644
index 97a5414..0000000
--- a/contribs/MarkDouglas/SocketServer2.java
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-package com.systemsunion.LoggingServer;
-
-import java.net.Socket;
-import java.net.ServerSocket;
-import java.io.IOException;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.NDC;
-
-/**
- A simple {@link SocketNode} based server.
-
- <pre>
- <b>Usage:</b> java org.apache.log4j.net.SocketServer port configFile
-
- where <em>port</em> is a part number where the server listens and
- <em>configFile</em> is a configuration file fed to the {@link
- PropertyConfigurator}.
- </pre>
-
-
-
-
-
- @author Ceki Gülcü
-
- @since 0.8.4 */
-
-public class SocketServer2 {
-
- static Category cat = Category.getInstance(SocketServer2.class.getName());
-
- static int port;
-
- public
- static
- void main(String argv[]) {
- if(argv.length == 2)
- init(argv[0], argv[1]);
- else
- usage("Wrong number of arguments.");
-
- try {
- cat.info("Listening on port " + port);
- ServerSocket serverSocket = new ServerSocket(port);
- while(true) {
- cat.info("Waiting to accept a new client.");
- Socket socket = serverSocket.accept();
- cat.info("Connected to client at " + socket.getInetAddress());
- cat.info("Starting new socket node.");
- new Thread(new SocketNode2(socket)).start();
- }
- }
- catch(Exception e) {
- e.printStackTrace();
- }
- }
-
-
- static
- void usage(String msg) {
- System.err.println(msg);
- System.err.println(
- "Usage: java " + SocketServer2.class.getName() + " port configFile");
- System.exit(1);
- }
-
- static
- void init(String portStr, String configFile) {
- try {
- port = Integer.parseInt(portStr);
- }
- catch(java.lang.NumberFormatException e) {
- e.printStackTrace();
- usage("Could not interpret port number ["+ portStr +"].");
- }
- PropertyConfigurator.configure(configFile);
- NDC.push("Server");
- }
-}
diff --git a/contribs/MarkDouglas/mail-2001-01-17 b/contribs/MarkDouglas/mail-2001-01-17
deleted file mode 100644
index 163dffc..0000000
--- a/contribs/MarkDouglas/mail-2001-01-17
+++ /dev/null
@@ -1,50 +0,0 @@
-Delivered-To: urba-cgu@urbanet.ch
-From: Mark Douglas <Ma...@systemsunion.com>
-To: "'cgu@urbanet.ch'" <cg...@urbanet.ch>
-Subject: Enhanced SocketServer and SocketNode classes
-Date: Wed, 17 Jan 2001 09:57:38 -0000
-X-Mailer: Internet Mail Service (5.5.2650.21)
-
-
-Hi Ceki,
-
-
-I have made small changes to SocketServer and SockerNode to allow the client
-machine name to be displayed in the logging output. This is important for
-us as we are using a single logging server with several clients.
-
-
-The new SocketServer2 and SocketNode2 classes (couldn't think of better
-names) prepends the NDC string with the clients Host Name (or IP address if
-the HostName can not be found). I thought the NDC string was a good place
-to add this information, but you may have a better place?
-
-
-I have created an NDC entry for the server such that server logging messages
-can easily be identified.
-
-
-I have included the two new source files plus a short example of the output.
-
-
-The output was generated with the following layout: %-6p (%9x:%-10t)
-%-40c{3} - %m%n
-
-
- <<Log.txt>> <<SocketNode2.java>> <<SocketServer2.java>>
-
-
-Note: I have changed the package names for the two classes to fit with our
-package names - sorry. Also, I find it difficult to follow the coding
-style, so again, sorry.
-
-
-If you think this may be useful to others, please feel free to include it as
-an addition in the next release or change the current SocketServer and
-SocketNode objects to include this new behaviour by default.
-
-
-Mark Douglas
-Systems Union Group plc
-
-
diff --git a/contribs/SvenReimers/gui/JListView.java b/contribs/SvenReimers/gui/JListView.java
deleted file mode 100644
index 42ce7ff..0000000
--- a/contribs/SvenReimers/gui/JListView.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * 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. */
-
-
-package org.apache.log4j.gui;
-
-import org.apache.log4j.helpers.CyclicBuffer;
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.Priority;
-import org.apache.log4j.Category;
-import org.apache.log4j.Layout;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.spi.LoggingEvent;
-
-import javax.swing.JList;
-import javax.swing.AbstractListModel;
-import javax.swing.JFrame;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextArea;
-import javax.swing.JScrollPane;
-import javax.swing.ListCellRenderer;
-import java.awt.Component;
-import java.awt.FlowLayout;
-import java.awt.GridLayout;
-import javax.swing.BoxLayout;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import java.awt.Container;
-import javax.swing.ImageIcon;
-import java.awt.Image;
-import java.awt.Toolkit;
-import java.net.URL;
-import java.awt.Rectangle;
-
-public class JListView extends JList {
-
-
- static Category cat = Category.getInstance(JListView.class.getName());
-
-
- //JListViewModel model;
- PatternLayout layout;
-
- static LoggingEvent proto = new LoggingEvent("x", cat, Priority.ERROR,
- "Message ", new Throwable());
-
- public
- JListView(JListViewModel model) {
- super(model);
- layout = new PatternLayout("%r %p %c [%t] - %m");
- //this.setModel(model);
- this.setCellRenderer(new MyCellRenderer());
- // setFixedCellWidth(10);
- //setFixedCellHeight(20);
-
- }
-
- public
- void add(LoggingEvent event) {
- ((JListViewModel)getModel()).add(event);
- }
-
- /*
- public
- Dimension getPreferredSize() {
- System.out.println("getPreferredSize() called");
- return super.getPreferredSize();
- }
-
-
- public
- int getScrollableUnitIncrement(Rectangle visibleRect, int orientation,
- int direction) {
- System.out.println("getScrollableUnitIncrement called with " + visibleRect +
- "orientation: "+orientation+", direction: "+direction);
- return super.getScrollableUnitIncrement(visibleRect, orientation,
- direction);
- }
-
- public
- int getScrollableBlockIncrement(Rectangle visibleRect, int orientation,
- int direction) {
- System.out.println("getScrollableBlockIncrement called with " +
- visibleRect + "orientation: "+orientation+
- ", direction: "+direction);
- return super.getScrollableBlockIncrement(visibleRect, orientation,
- direction);
- }
- */
-
- //public
- //boolean getScrollableTracksViewportWidth() {
- //System.out.println("getScrollableTracksViewportWidth called.");
- //return true;
- //boolean b = super.getScrollableTracksViewportWidth();
- //System.out.println("result is: "+b);
- //return b;
- //}
-
- //public
- //boolean getScrollableTracksViewportHeight() {
- // System.out.println("getScrollableTracksViewportHeight called.");
- // return true;
- //boolean b = super.getScrollableTracksViewportHeight();
- //System.out.println("result is: "+b);
- //return b;
- //}
-
- //public
- //int getFirstVisibleIndex() {
- //int r = getFirstVisibleIndex();
- // System.out.println("----------getFirstVisibleIndex called, result: "+r);
- //return r;
- //}
-
- //public
- //Object getPrototypeCellValue() {
- //return proto;
- //}
-
-
-
- static public void main(String[] args) {
-
- JFrame frame = new JFrame("JListView test");
- Container container = frame.getContentPane();
-
- JListView view = new JListView(new JListViewModel(Integer.parseInt(args[0])));
-
-
- JScrollPane sp = new JScrollPane(view);
- sp.setPreferredSize(new Dimension(250, 80));
-
- container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
- //container.add(view);
- container.add(sp);
-
- JButton b1 = new JButton("Add 1");
- JButton b10 = new JButton("Add 10");
- JButton b100 = new JButton("Add 100");
- JButton b1000 = new JButton("Add 1000");
- JButton b10000 = new JButton("Add 10000");
-
- JPanel panel = new JPanel(new GridLayout(0,1));
- container.add(panel);
-
- panel.add(b1);
- panel.add(b10);
- panel.add(b100);
- panel.add(b1000);
- panel.add(b10000);
-
-
- AddAction a1 = new AddAction(view, 1);
- AddAction a10 = new AddAction(view, 10);
- AddAction a100 = new AddAction(view, 100);
- AddAction a1000 = new AddAction(view, 1000);
- AddAction a10000 = new AddAction(view, 10000);
-
- b1.addActionListener(a1);
- b10.addActionListener(a10);
- b100.addActionListener(a100);
- b1000.addActionListener(a1000);
- b10000.addActionListener(a10000);
-
- frame.setVisible(true);
- frame.setSize(new Dimension(700,700));
-
- long before = System.currentTimeMillis();
-
- int RUN = 1000;
- int i = 0;
- while(i++ < RUN) {
- LoggingEvent event0 = new LoggingEvent("x", cat, Priority.ERROR,
- "Message "+i, null);
-
- Throwable t = new Exception("hello "+i);
- LoggingEvent event1 = new LoggingEvent("x", cat, Priority.ERROR,
- "Message "+i, t);
-
-
- if(i % 10 == 0) {
- event1.getThreadName();
- view.add(event1);
- } else {
- event0.getThreadName();
- view.add(event0);
- }
- }
-
- long after = System.currentTimeMillis();
- System.out.println("Time taken :"+ ((after-before)*1000/RUN));
-
- }
-
- class MyCellRenderer extends JTextArea implements ListCellRenderer {
-
- Object o = new Object();
- int i = 0;
- final ImageIcon longIcon = new ImageIcon("RedFlag.gif");
-
- public
- MyCellRenderer() {
- System.out.println("----------------------");
-
- }
-
-
-
- public
- int getTabSize() {
- return 2;
- }
-
- public Image loadIcon ( String path ) {
- Image img = null;
- try {
- URL url = ClassLoader.getSystemResource(path);
- img = (Image) (Toolkit.getDefaultToolkit()).getImage(url);
- } catch (Exception e) {
- System.out.println("Exception occured: " + e.getMessage() +
- " - " + e );
- }
- return (img);
- }
-
- public Component getListCellRendererComponent(JList list,
- Object value,
- int index, // cell index
- boolean isSelected,
- boolean cellHasFocus) {
-
- // System.out.println(o + " ============== " + i++);
- //LogLog.error("=======", new Exception());
- //setIcon(longIcon);
- if(value instanceof LoggingEvent) {
- LoggingEvent event = (LoggingEvent) value;
- String str = layout.format(event);
- String t = event.getThrowableInformation();
-
- if(t != null) {
- setText(str + Layout.LINE_SEP + t);
- } else {
- setText(str);
- }
-
- } else {
- setText(value.toString());
- }
-
-
- return this;
- }
- }
-}
-
-
-
-class JListViewModel extends AbstractListModel {
-
- CyclicBuffer cb;
-
- JListViewModel(int size) {
- cb = new CyclicBuffer(size);
- }
-
- public
- void add(LoggingEvent event) {
- //System.out.println("JListViewModel.add called");
- cb.add(event);
- int j = cb.length();
- fireContentsChanged(this, 0, j);
- }
-
-
-
- public
- Object getElementAt(int index) {
- return cb.get(index);
- }
-
- public
- int getSize() {
- return cb.length();
- }
-
-}
-
-class AddAction implements ActionListener {
-
- Thread t;
-
- static int counter = 0;
-
- public
- AddAction(JListView view, int burst) {
- this.t = new AddThread(view, burst);
- t.start();
- }
-
- public
- void actionPerformed(ActionEvent e) {
- System.out.println("Action occured");
- synchronized(t) {
- t.notify();
- }
- }
-
- class AddThread extends Thread {
- int burst;
- JListView view;
-
- Category cat = Category.getInstance("x");
-
- AddThread(JListView view, int burst) {
- super();
- this.burst = burst;
- this.view = view;
- setName("AddThread"+burst);
- }
-
- public
- void run() {
-
- while(true) {
- synchronized(this) {
- try {
- this.wait();
- } catch(Exception e) {
- }
- }
- for(int i = 0; i < burst; i++) {
- LoggingEvent event = new LoggingEvent("x", cat, Priority.DEBUG,
- "Message "+counter, null);
-
- event.getThreadName();
- if(counter % 50 == 0) {
- //event.throwable = new Exception("hello "+counter);
- }
- counter++;
- view.add(event);
- }
- }
- }
- }
-}
diff --git a/contribs/SvenReimers/gui/JTableAppender.java b/contribs/SvenReimers/gui/JTableAppender.java
deleted file mode 100644
index 3197a1d..0000000
--- a/contribs/SvenReimers/gui/JTableAppender.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * 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. */
-
-
-package org.apache.log4j.gui;
-
-import org.apache.log4j.helpers.CyclicBuffer;
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.Priority;
-import org.apache.log4j.Category;
-import org.apache.log4j.Layout;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.spi.LoggingEvent;
-
-import javax.swing.JList;
-import javax.swing.AbstractListModel;
-import javax.swing.JFrame;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JTable;
-import javax.swing.JTextArea;
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.JScrollPane;
-import javax.swing.ListCellRenderer;
-import java.awt.Component;
-import java.awt.FlowLayout;
-import javax.swing.BoxLayout;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import java.awt.Container;
-import javax.swing.ImageIcon;
-import java.awt.Image;
-import java.awt.Toolkit;
-import java.net.URL;
-import java.awt.Rectangle;
-
-public class JTableAppender extends JTable {
-
-
- static Category cat = Category.getInstance(JTableAppender.class.getName());
-
- PatternLayout layout;
-
- public
- JTableAppender() {
- layout = new PatternLayout("%r %p %c [%t] - %m");
- this.setDefaultRenderer(Object.class, new Renderer());
-
- }
-
- public
- void add(LoggingEvent event) {
- ((JTableAppenderModel)getModel()).add(event);
- }
-
- public
- Dimension getPreferredSize() {
- System.out.println("getPreferredSize() called");
- return super.getPreferredSize();
- }
-
- static public void main(String[] args) {
-
- JFrame frame = new JFrame("JListView test");
- Container container = frame.getContentPane();
-
- JTableAppender appender = new JTableAppender();
-
- JTableAppenderModel model = new
- JTableAppenderModel(Integer.parseInt(args[0]));
- appender.setModel(model);
- //appender.createDefaultColumnsFromModel();
-
-
- JScrollPane sp = new JScrollPane(appender);
- sp.setPreferredSize(new Dimension(250, 80));
-
- container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
- //container.add(view);
- container.add(sp);
-
- JButton button = new JButton("ADD");
- container.add(button);
-
-
- button.addActionListener(new JTableAddAction(appender));
-
- frame.setVisible(true);
- frame.setSize(new Dimension(700,700));
-
- long before = System.currentTimeMillis();
-
- int RUN = 10000;
- int i = 0;
- while(i++ < RUN) {
- LoggingEvent event = new LoggingEvent("x", cat, Priority.ERROR,
- "Message "+i, null);
- event.getThreadName();
- if(i % 10 == 0) {
- //event.throwable = new Exception("hello "+i);
- }
- appender.add(event);
- }
-
- long after = System.currentTimeMillis();
- System.out.println("Time taken :"+ ((after-before)*1000/RUN));
-
- }
-
- class Renderer extends JTextArea implements TableCellRenderer {
-
- Object o = new Object();
- int i = 0;
-
- public
- Renderer() {
- System.out.println("Render() called ----------------------");
- }
-
- public Component getTableCellRendererComponent(JTable table,
- Object value,
- boolean isSelected,
- boolean hasFocus,
- int row,
- int column) {
-
- System.out.println(o + " ============== " + i++);
- //LogLog.error("=======", new Exception());
- //setIcon(longIcon);
- if(value instanceof LoggingEvent) {
- LoggingEvent event = (LoggingEvent) value;
- String str = layout.format(event);
- String t = event.getThrowableInformation();
-
- if(t != null) {
- System.out.println("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
- setText(str + Layout.LINE_SEP + t);
- } else {
- setText(str);
- }
-
- } else {
- setText(value.toString());
- }
-
-
- return this;
- }
- }
-}
-
-
-
-class JTableAppenderModel extends AbstractTableModel {
-
- CyclicBuffer cb;
-
- JTableAppenderModel(int size) {
- cb = new CyclicBuffer(size);
- }
-
- public
- void add(LoggingEvent event) {
- //System.out.println("JListViewModel.add called");
- cb.add(event);
- int j = cb.length();
-
- fireTableDataChanged();
-
- }
- public
- int getColumnCount() {
- return 1;
- }
-
- public int getRowCount() {
- return cb.length();
- }
-
- //public
- //Class getColumnClass(int index) {
- // System.out.println("getColumnClass called " + index);
- // return LoggingEvent.class;
- //}
-
- public
- Object getValueAt(int row, int col) {
- return cb.get(row);
- }
-}
-
-
-class JTableAddAction implements ActionListener {
-
- int j;
- JTableAppender appender;
-
- Category cat = Category.getInstance("x");
-
- public
- JTableAddAction(JTableAppender appender) {
- this.appender = appender;
- j = 0;
- }
-
- public
- void actionPerformed(ActionEvent e) {
- System.out.println("Action occured");
-
- LoggingEvent event = new LoggingEvent("x", cat, Priority.DEBUG,
- "Message "+j, null);
-
- if(j % 5 == 0) {
- //event.throwable = new Exception("hello "+j);
- }
- j++;
- appender.add(event);
- }
-}
diff --git a/contribs/SvenReimers/gui/Makefile b/contribs/SvenReimers/gui/Makefile
deleted file mode 100644
index 5ab9d0e..0000000
--- a/contribs/SvenReimers/gui/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-
-PKG_DIR :=org/apache/log4j/gui
-DEPTH :=../../../../../..
-JSOURCES:= TextPaneAppender.java\
- JListView.java\
- JTableAppender.java\
-
-ifdef FULL
- JSOURCES:=$(JSOURCES)
-endif
-
-TSOURCES:=
-
-
-SUBDIRS := examples
-
-ifdef FULL
- SUBDIRS := $(SUBDIRS)
-endif
-
-# include master-rule file
-include $(DEPTH)/make/make.inc
-
-
-
-
-
-
diff --git a/contribs/SvenReimers/gui/TextPaneAppender.java b/contribs/SvenReimers/gui/TextPaneAppender.java
deleted file mode 100644
index 117c354..0000000
--- a/contribs/SvenReimers/gui/TextPaneAppender.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * 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. */
-
-package org.apache.log4j.gui;
-
-
-import java.awt.Color;
-import java.awt.Image;
-import java.awt.Toolkit;
-import java.io.*;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.StringTokenizer;
-import java.util.Hashtable;
-
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-import javax.swing.JTextPane;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.MutableAttributeSet;
-import javax.swing.text.SimpleAttributeSet;
-import javax.swing.text.StyleConstants;
-import javax.swing.text.StyledDocument;
-import javax.swing.text.TabSet;
-import javax.swing.text.TabStop;
-
-import org.apache.log4j.*;
-
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.helpers.Loader;
-import org.apache.log4j.helpers.QuietWriter;
-import org.apache.log4j.helpers.TracerPrintWriter;
-import org.apache.log4j.helpers.OptionConverter;
-
-
-/**
- * <b>Experimental</b> TextPaneAppender. <br>
- *
- *
- * Created: Sat Feb 26 18:50:27 2000 <br>
- *
- * @author Sven Reimers
- */
-
-public class TextPaneAppender extends AppenderSkeleton {
-
- JTextPane textpane;
- StyledDocument doc;
- TracerPrintWriter tp;
- StringWriter sw;
- QuietWriter qw;
- Hashtable attributes;
- Hashtable icons;
-
- private String label;
-
- private boolean fancy;
-
- final String LABEL_OPTION = "Label";
- final String COLOR_OPTION_FATAL = "Color.Emerg";
- final String COLOR_OPTION_ERROR = "Color.Error";
- final String COLOR_OPTION_WARN = "Color.Warn";
- final String COLOR_OPTION_INFO = "Color.Info";
- final String COLOR_OPTION_DEBUG = "Color.Debug";
- final String COLOR_OPTION_BACKGROUND = "Color.Background";
- final String FANCY_OPTION = "Fancy";
- final String FONT_NAME_OPTION = "Font.Name";
- final String FONT_SIZE_OPTION = "Font.Size";
-
- public static Image loadIcon ( String path ) {
- Image img = null;
- try {
- URL url = ClassLoader.getSystemResource(path);
- img = (Image) (Toolkit.getDefaultToolkit()).getImage(url);
- } catch (Exception e) {
- System.out.println("Exception occured: " + e.getMessage() +
- " - " + e );
- }
- return (img);
- }
-
- public TextPaneAppender(Layout layout, String name) {
- this();
- this.layout = layout;
- this.name = name;
- setTextPane(new JTextPane());
- createAttributes();
- createIcons();
- }
-
- public TextPaneAppender() {
- super();
- setTextPane(new JTextPane());
- createAttributes();
- createIcons();
- this.label="";
- this.sw = new StringWriter();
- this.qw = new QuietWriter(sw, errorHandler);
- this.tp = new TracerPrintWriter(qw);
- this.fancy =true;
- }
-
- public
- void close() {
-
- }
-
- private void createAttributes() {
- Priority prio[] = Priority.getAllPossiblePriorities();
-
- attributes = new Hashtable();
- for (int i=0; i<prio.length;i++) {
- MutableAttributeSet att = new SimpleAttributeSet();
- attributes.put(prio[i], att);
- StyleConstants.setFontSize(att,14);
- }
- StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.ERROR),Color.red);
- StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.WARN),Color.orange);
- StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.INFO),Color.gray);
- StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.DEBUG),Color.black);
- }
-
- private void createIcons() {
- Priority prio[] = Priority.getAllPossiblePriorities();
-
- icons = new Hashtable();
- for (int i=0; i<prio.length;i++) {
- if (prio[i].equals(Priority.FATAL))
- icons.put(prio[i],new ImageIcon(loadIcon("icons/RedFlag.gif")));
- if (prio[i].equals(Priority.ERROR))
- icons.put(prio[i],new ImageIcon(loadIcon("icons/RedFlag.gif")));
- if (prio[i].equals(Priority.WARN))
- icons.put(prio[i],new ImageIcon(loadIcon("icons/BlueFlag.gif")));
- if (prio[i].equals(Priority.INFO))
- icons.put(prio[i],new ImageIcon(loadIcon("icons/GreenFlag.gif")));
- if (prio[i].equals(Priority.DEBUG))
- icons.put(prio[i],new ImageIcon(loadIcon("icons/GreenFlag.gif")));
- }
- }
-
- public void append(LoggingEvent event) {
- String text = this.layout.format(event);
- String trace="";
- // Print Stacktrace
- // Quick Hack maybe there is a better/faster way?
- if (event.throwable!=null) {
- event.throwable.printStackTrace(tp);
- for (int i=0; i< sw.getBuffer().length(); i++) {
- if (sw.getBuffer().charAt(i)=='\t')
- sw.getBuffer().replace(i,i+1," ");
- }
- trace = sw.toString();
- sw.getBuffer().delete(0,sw.getBuffer().length());
- }
- try {
- if (fancy) {
- textpane.setEditable(true);
- textpane.insertIcon((ImageIcon)icons.get(event.priority));
- textpane.setEditable(false);
- }
- doc.insertString(doc.getLength(),text+trace,
- (MutableAttributeSet)attributes.get(event.priority));
- }
- catch (BadLocationException badex) {
- System.err.println(badex);
- }
- textpane.setCaretPosition(doc.getLength());
- }
-
- public
- JTextPane getTextPane() {
- return textpane;
- }
-
- private
- static
- Color parseColor (String v) {
- StringTokenizer st = new StringTokenizer(v,",");
- int val[] = {255,255,255,255};
- int i=0;
- while (st.hasMoreTokens()) {
- val[i]=Integer.parseInt(st.nextToken());
- i++;
- }
- return new Color(val[0],val[1],val[2],val[3]);
- }
-
- private
- static
- String colorToString(Color c) {
- // alpha component emitted only if not default (255)
- String res = ""+c.getRed()+","+c.getGreen()+","+c.getBlue();
- return c.getAlpha() >= 255 ? res : res + ","+c.getAlpha();
- }
-
- public
- void setLayout(Layout layout) {
- this.layout=layout;
- }
-
- public
- void setName(String name) {
- this.name = name;
- }
-
-
- public
- void setTextPane(JTextPane textpane) {
- this.textpane=textpane;
- textpane.setEditable(false);
- textpane.setBackground(Color.lightGray);
- this.doc=textpane.getStyledDocument();
- }
-
- private
- void setColor(Priority p, String v) {
- StyleConstants.setForeground(
- (MutableAttributeSet)attributes.get(p),parseColor(v));
- }
-
- private
- String getColor(Priority p) {
- Color c = StyleConstants.getForeground(
- (MutableAttributeSet)attributes.get(p));
- return c == null ? null : colorToString(c);
- }
-
- /////////////////////////////////////////////////////////////////////
- // option setters and getters
-
- public
- void setLabel(String label) {
- this.label = label;
- }
- public
- String getLabel() {
- return label;
- }
-
- public
- void setColorEmerg(String color) {
- setColor(Priority.FATAL, color);
- }
- public
- String getColorEmerg() {
- return getColor(Priority.FATAL);
- }
-
- public
- void setColorError(String color) {
- setColor(Priority.ERROR, color);
- }
- public
- String getColorError() {
- return getColor(Priority.ERROR);
- }
-
- public
- void setColorWarn(String color) {
- setColor(Priority.WARN, color);
- }
- public
- String getColorWarn() {
- return getColor(Priority.WARN);
- }
-
- public
- void setColorInfo(String color) {
- setColor(Priority.INFO, color);
- }
- public
- String getColorInfo() {
- return getColor(Priority.INFO);
- }
-
- public
- void setColorDebug(String color) {
- setColor(Priority.DEBUG, color);
- }
- public
- String getColorDebug() {
- return getColor(Priority.DEBUG);
- }
-
- public
- void setColorBackground(String color) {
- textpane.setBackground(parseColor(color));
- }
- public
- String getColorBackground() {
- return colorToString(textpane.getBackground());
- }
-
- public
- void setFancy(boolean fancy) {
- this.fancy = fancy;
- }
- public
- boolean getFancy() {
- return fancy;
- }
-
- public
- void setFontSize(int size) {
- Enumeration e = attributes.elements();
- while (e.hasMoreElements()) {
- StyleConstants.setFontSize((MutableAttributeSet)e.nextElement(),size);
- }
- return;
- }
-
- public
- int getFontSize() {
- AttributeSet attrSet = (AttributeSet) attributes.get(Priority.INFO);
- return StyleConstants.getFontSize(attrSet);
- }
-
- public
- void setFontName(String name) {
- Enumeration e = attributes.elements();
- while (e.hasMoreElements()) {
- StyleConstants.setFontFamily((MutableAttributeSet)e.nextElement(),name);
- }
- return;
- }
-
- public
- String getFontName() {
- AttributeSet attrSet = (AttributeSet) attributes.get(Priority.INFO);
- return StyleConstants.getFontFamily(attrSet);
- }
-
- public
- boolean requiresLayout() {
- return true;
- }
-} // TextPaneAppender
-
-
-
diff --git a/contribs/SvenReimers/gui/examples/Makefile b/contribs/SvenReimers/gui/examples/Makefile
deleted file mode 100644
index 9ab213f..0000000
--- a/contribs/SvenReimers/gui/examples/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-
-PKG_DIR :=org/apache/log4j/gui/examples
-DEPTH :=../../../../../../..
-JSOURCES:= TextPaneAppenderExample.java\
-
-ifdef FULL
- JSOURCES:=$(JSOURCES)
-endif
-
-TSOURCES:=
-
-
-SUBDIRS :=
-
-ifdef FULL
- SUBDIRS := $(SUBDIRS)
-endif
-
-# include master-rule file
-include $(DEPTH)/make/make.inc
-
-
-
-
-
-
diff --git a/contribs/SvenReimers/gui/examples/TextPaneAppenderExample.java b/contribs/SvenReimers/gui/examples/TextPaneAppenderExample.java
deleted file mode 100644
index 2c297fd..0000000
--- a/contribs/SvenReimers/gui/examples/TextPaneAppenderExample.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
- *
- * 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. */
-
-package org.apache.log4j.gui.examples;
-
-import java.awt.BorderLayout;
-import java.awt.event.*;
-import javax.swing.*;
-import org.apache.log4j.*;
-import org.apache.log4j.gui.*;
-
-
-
-public class TextPaneAppenderExample implements ActionListener {
-
- JFrame mainframe;
- ButtonGroup priorities;
- TextPaneAppender tpa;
- Category gui;
- Priority prio[];
- JTabbedPane logview;
-
-
- public TextPaneAppenderExample () {
- mainframe = new JFrame("Testing the TextPaneAppender...");
- mainframe.setSize(300,300);
- logview = new JTabbedPane();
- createLogger();
- createMenuBar();
- mainframe.setVisible(true);
- mainframe.getContentPane().add(logview);
- }
-
- public void createLogger() {
- tpa = new TextPaneAppender(new PatternLayout("%-5p %d [%t]: %m%n"),"Debug");
- logview.addTab("Events ...",new JScrollPane(tpa.getTextPane()));
- gui = Category.getInstance(this.getClass().getName());
- gui.addAppender(tpa);
- }
-
- public void createMenuBar() {
- JMenu file = new JMenu("File");
- JMenuItem exit = new JMenuItem("Exit");
- exit.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- System.exit(0);
- }
- });
- file.add(exit);
- JMenuBar mb = new JMenuBar();
- mb.add(file);
-
- JMenu logevent = new JMenu("LoggingEvents");
- JMenu selectprio = new JMenu("Priority");
-
- prio = Priority.getAllPossiblePriorities();
- JRadioButtonMenuItem priority[]= new JRadioButtonMenuItem[prio.length];
- priorities = new ButtonGroup();
-
- for (int i=0; i<prio.length;i++) {
- if (i==0)
- priority[i] = new JRadioButtonMenuItem(prio[i].toString(),true);
- else
- priority[i] = new JRadioButtonMenuItem(prio[i].toString());
- priority[i].setActionCommand(prio[i].toString());
- selectprio.add(priority[i]);
- priorities.add(priority[i]);
-
- }
-
- logevent.add(selectprio);
-
- JMenuItem lognow = new JMenuItem("LogIt!");
- lognow.addActionListener(this);
- logevent.add(lognow);
-
- mb.add(logevent);
-
- mainframe.setJMenuBar(mb);
-
- }
-
- public void actionPerformed(ActionEvent ae){
- String logtext = JOptionPane.showInputDialog("Text to log");
- if (logtext == null) logtext="NO Input";
- int i=0;
- String name = priorities.getSelection().getActionCommand();
- while (!prio[i].toString().equals(name))
- i=i+1;
- gui.log(prio[i],logtext);
- }
-
- static public void main(String args[]) {
- TextPaneAppenderExample tpex = new TextPaneAppenderExample();
- }
-
-}
diff --git a/contribs/ThomasFenner/JDBCAppender.java b/contribs/ThomasFenner/JDBCAppender.java
deleted file mode 100644
index d82bb20..0000000
--- a/contribs/ThomasFenner/JDBCAppender.java
+++ /dev/null
@@ -1,589 +0,0 @@
-
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
-*/
-
-package com.klopotek.utils.log;
-
-import java.sql.*;
-import java.util.*;
-import org.apache.log4j.*;
-import org.apache.log4j.helpers.*;
-import org.apache.log4j.spi.*;
-
-/**
-The JDBCAppender, writes messages into a database
-
-<p><b>The JDBCAppender is configurable at runtime by setting options in two alternatives : </b></p>
-<dir>
- <p><b>1. Use a configuration-file</b></p>
- <p>Define the options in a file (<A HREF="configfile_example.txt">example</A>) and call a <code>PropertyConfigurator.configure(filename)</code> in your code.</p>
- <p><b>2. Use the methods of JDBCAppender to do it</b></p>
- <p>Call <code>JDBCAppender::setOption(JDBCAppender.xxx_OPTION, String value)</code> to do it analogically without a configuration-file (<A HREF="code_example2.java">example</A>)</p>
-</dir>
-
-<p>All available options are defined as static String-constants in JDBCAppender named xxx_OPTION.</p>
-
-<p><b>Here is a description of all available options :</b></p>
-<dir>
- <p><b>1. Database-options to connect to the database</b></p>
- <p>- <b>URL_OPTION</b> : a database url of the form jdbc:subprotocol:subname</p>
- <p>- <b>USERNAME_OPTION</b> : the database user on whose behalf the connection is being made</p>
- <p>- <b>PASSWORD_OPTION</b> : the user's password</p>
-
- <p><b>2. Connector-option to specify your own JDBCConnectionHandler</b></p>
- <p>- <b>CONNECTOR_OPTION</b> : a classname which is implementing the JDBCConnectionHandler-interface</p>
- <p>This interface is used to get a customized connection.</p>
- <p>If in addition the database-options are given, these options will be used as arguments for the JDBCConnectionHandler-interface to get a connection.</p>
- <p>Else if no database-options are given, the JDBCConnectionHandler-interface is called without them.</p>
- <p>Else if this option is not defined, the database-options are required to open a connection by the JDBCAppender.</p>
-
- <p><b>3. SQL-option to specify a static sql-statement which will be performed with every occuring message-event</b></p>
- <p>- <b>SQL_OPTION</b> : a sql-statement which will be used to write to the database</p>
- <p>Use the variable <b>@MSG@</b> on a location in the statement, which has to be dynamically replaced by the message-text.</p>
- <p>If you give this option, the table-option and columns-option will be ignored !</p>
-
- <p><b>4. Table-option to specify a table contained by the database</b></p>
- <p>- <b>TABLE_OPTION</b> : the table in which the logging will be done</p>
-
- <p><b>5. Columns-option to describe the important columns of the table (Not nullable columns are mandatory to describe!)</b></p>
- <p>- <b>COLUMNS_OPTION</b> : a formatted list of column-descriptions</p>
- <p>Each column description consists of</p>
- <dir>
- <p>- the <b><i>name</i></b> of the column (required)</p>
- <p>- a <b><i>logtype</i></b> which is a static constant of class LogType (required)</p>
- <p>- and a <b><i>value</i></b> which depends by the LogType (optional/required, depending by logtype)</p>
- </dir>
- <p>Here is a description of the available logtypes of class <b>{@link LogType}</b> and how to handle the <b><i>value</i></b>:</p>
- <dir>
- <p>o <b>MSG</b> = a value will be ignored, the column will get the message. (One columns need to be of this type!)</p>
- <p>o <b>STATIC</b> = the value will be filled into the column with every logged message. (Ensure that the type of value can be casted into the sql-type of the column!)</p>
- <p>o <b>ID</b> = value must be a classname, which implements the JDBCIDHandler-interface.</p>
- <p>o <b>TIMESTAMP</b> = a value will be ignored, the column will be filled with a actually timestamp with every logged message.</p>
- <p>o <b>EMPTY</b> = a value will be ignored, the column will be ignored when writing to the database (Ensure to fill not nullable columns by a database trigger!)</p>
- </dir>
- <p>If there are more than one column to describe, the columns must be separated by a Tabulator-delimiter (unicode0008) !</p>
- <p>The arguments of a column-description must be separated by the delimiter '~' !</p>
- <p><i>(Example : name1~logtype1~value1 name2~logtype2~value2...)</i></p>
-
- <p><b>6. Layout-options to define the layout of the messages (optional)</b></p>
- <p>- <b>_</b> : the layout wont be set by a xxx_OPTION</p>
- <p>See the configuration-file and code examples below...</p>
- <p>The default is a layout of the class {@link org.apache.log4j.PatternLayout} with the pattern=%m which representate only the message.</p>
-
- <p><b>7. Buffer-option to define the size of the message-event-buffer (optional)</b></p>
- <p>- <b>BUFFER_OPTION</b> : define how many messages will be buffered until they will be updated to the database.</p>
- <p>The default is buffer=1, which will do a update with every happened message-event.</p>
-
- <p><b>8. Commit-option to define a auto-commitment</b></p>
- <p>- <b>COMMIT_OPTION</b> : define whether updated messages should be committed to the database (Y) or not (N).</p>
- <p>The default is commit=Y.</p>
-</dir>
-
-<p><b>The sequence of some options is important :</b></p>
-<dir>
- <p><b>1. Connector-option OR/AND Database-options</b></p>
- <p>Any database connection is required !</p>
- <p><b>2. (Table-option AND Columns-option) OR SQL-option</b></p>
- <p>Anything of that is required ! Whether where to write something OR what to write somewhere...;-)</p>
- <p><b>3. All other options can be set at any time...</b></p>
- <p>The other options are optional and have a default initialization, which can be customized.</p>
-</dir>
-
-<p><b>Here is a <b>configuration-file example</b>, which can be used as argument for the <b>PropertyConfigurator</b> : </b><A HREF="configfile_example.txt"> configfile_example.txt</A></p>
-
-<p><b>Here is a <b>code-example</b> to configure the JDBCAppender <b>with a configuration-file</b> : </b><A HREF="code_example1.java"> code_example1.java</A></p>
-
-<p><b>Here is a <b>another code-example</b> to configure the JDBCAppender <b>without a configuration-file</b> : </b><A HREF="code_example2.java"> code_example2.java</A></p>
-
-
-
-<p><b>Author : </b><A HREF="mailto:t.fenner@klopotek.de">Thomas Fenner</A></p>
-
-@since 1.0
-*/
-public class JDBCAppender extends AppenderSkeleton
-{
- /**
- A database-option to to set a database url of the form jdbc:subprotocol:subname.
- */
- public static final String URL_OPTION = "url";
-
- /**
- A database-option to set the database user on whose behalf the connection is being made.
- */
- public static final String USERNAME_OPTION = "username";
-
- /**
- A database-option to set the user's password.
- */
- public static final String PASSWORD_OPTION = "password";
-
- /**
- A table-option to specify a table contained by the database
- */
- public static final String TABLE_OPTION = "table";
-
- /**
- A connector-option to specify your own JDBCConnectionHandler
- */
- public static final String CONNECTOR_OPTION = "connector";
-
- /**
- A columns-option to describe the important columns of the table
- */
- public static final String COLUMNS_OPTION = "columns";
-
- /**
- A sql-option to specify a static sql-statement which will be performed with every occuring message-event
- */
- public static final String SQL_OPTION = "sql";
-
- /**
- A buffer-option to define the size of the message-event-buffer
- */
- public static final String BUFFER_OPTION = "buffer";
-
- /**
- A commit-option to define a auto-commitment
- */
- public static final String COMMIT_OPTION = "commit";
-
-
- //Variables to store the options values setted by setOption() :
- private String url = null;
- private String username = null;
- private String password = null;
- private String table = null;
- private String connection_class = null;
- private String sql = null;
- private boolean docommit = true;
- private int buffer_size = 1;
- private JDBCConnectionHandler connectionHandler = null;
-
- //This buffer stores message-events.
- //When the buffer_size is reached, the buffer will be flushed and the messages will updated to the database.
- private ArrayList buffer = new ArrayList();
-
- //Database-connection
- private Connection con = null;
-
- //This class encapsulate the logic which is necessary to log into a table
- private JDBCLogger jlogger = new JDBCLogger();
-
- //Flags :
- //A flag to indicate a established database connection
- private boolean connected = false;
- //A flag to indicate configuration status
- private boolean configured = false;
- //A flag to indicate that everything is ready to get append()-commands.
- private boolean ready = false;
-
- /**
- If program terminates close the database-connection and flush the buffer
- */
- public void finalize()
- {
- close();
- super.finalize();
- }
-
- /**
- Internal method. Returns a array of strings containing the available options which can be set with method setOption()
- */
- public String[] getOptionStrings()
- {
- // The sequence of options in this string is important, because setOption() is called this way ...
- return new String[]{CONNECTOR_OPTION, URL_OPTION, USERNAME_OPTION, PASSWORD_OPTION, SQL_OPTION, TABLE_OPTION, COLUMNS_OPTION, BUFFER_OPTION, COMMIT_OPTION};
- }
-
-
- /**
- Sets all necessary options
- */
- public void setOption(String _option, String _value)
- {
- _option = _option.trim();
- _value = _value.trim();
-
- if(_option == null || _value == null) return;
- if(_option.length() == 0 || _value.length() == 0) return;
-
- _value = _value.trim();
-
- if(_option.equals(CONNECTOR_OPTION))
- {
- if(!connected) connection_class = _value;
- }
- else if(_option.equals(URL_OPTION))
- {
- if(!connected) url = _value;
- }
- else if(_option.equals(USERNAME_OPTION))
- {
- if(!connected) username = _value;
- }
- else if(_option.equals(PASSWORD_OPTION))
- {
- if(!connected) password = _value;
- }
- else if(_option.equals(SQL_OPTION))
- {
- sql = _value;
- }
- else if(_option.equals(TABLE_OPTION))
- {
- if(sql != null) return;
- table = _value;
- }
- else if(_option.equals(COLUMNS_OPTION))
- {
- if(sql != null) return;
-
- String name = null;
- int logtype = -1;
- String value = null;
- String column = null;
- String arg = null;
- int num_args = 0;
- int num_columns = 0;
- StringTokenizer st_col;
- StringTokenizer st_arg;
-
- //Columns are TAB-separated
- st_col = new StringTokenizer(_value, " ");
-
- num_columns = st_col.countTokens();
-
- if(num_columns < 1)
- {
- errorHandler.error("JDBCAppender::setOption(), Invalid COLUMN_OPTION value : " + _value + " !");
- return;
- }
-
- for(int i=1; i<=num_columns; i++)
- {
- column = st_col.nextToken();
-
- //Arguments are ~-separated
- st_arg = new StringTokenizer(column, "~");
-
- num_args = st_arg.countTokens();
-
- if(num_args < 2)
- {
- errorHandler.error("JDBCAppender::setOption(), Invalid COLUMN_OPTION value : " + _value + " !");
- return;
- }
-
- for(int j=1; j<=num_args; j++)
- {
- arg = st_arg.nextToken();
-
- if(j == 1) name = arg;
- else if(j == 2)
- {
- try
- {
- logtype = Integer.parseInt(arg);
- }
- catch(Exception e)
- {
- logtype = LogType.parseLogType(arg);
- }
-
- if(!LogType.isLogType(logtype))
- {
- errorHandler.error("JDBCAppender::setOption(), Invalid COLUMN_OPTION LogType : " + arg + " !");
- return;
- }
- }
- else if(j == 3) value = arg;
- }
-
- if(!setLogType(name, logtype, value)) return;
- }
- }
- else if(_option.equals(BUFFER_OPTION))
- {
- try
- {
- buffer_size = Integer.parseInt(_value);
- }
- catch(Exception e)
- {
- errorHandler.error("JDBCAppender::setOption(), Invalid BUFFER_OPTION value : " + _value + " !");
- return;
- }
- }
- else if(_option.equals(COMMIT_OPTION))
- {
- docommit = _value.equals("Y");
- }
-
- if(_option.equals(SQL_OPTION) || _option.equals(TABLE_OPTION))
- {
- if(!configured) configure();
- }
- }
-
- /**
- Internal method. Returns true, you may define your own layout...
- */
- public boolean requiresLayout()
- {
- return true;
- }
-
-
- /**
- Internal method. Close the database connection & flush the buffer.
- */
- public void close()
- {
- flush_buffer();
- if(connection_class == null)
- {
- try{con.close();}catch(Exception e){errorHandler.error("JDBCAppender::close(), " + e);}
- }
- this.closed = true;
- }
-
-
- /**
- You have to call this function for all provided columns of your log-table !
- */
- public boolean setLogType(String _name, int _logtype, Object _value)
- {
- if(sql != null) return true;
-
- if(!configured)
- {
- if(!configure()) return false;
- }
-
- try
- {
- jlogger.setLogType(_name, _logtype, _value);
- }
- catch(Exception e)
- {
- errorHandler.error("JDBCAppender::setLogType(), " + e);
- return false;
- }
-
- return true;
- }
-
-
- /**
- Internal method. Appends the message to the database table.
- */
- public void append(LoggingEvent event)
- {
- if(!ready)
- {
- if(!ready())
- {
- errorHandler.error("JDBCAppender::append(), Not ready to append !");
- return;
- }
- }
-
- buffer.add(event);
-
- if(buffer.size() >= buffer_size) flush_buffer();
- }
-
-
- /**
- Internal method. Flushes the buffer.
- */
- public void flush_buffer()
- {
- try
- {
- int size = buffer.size();
-
- if(size < 1) return;
-
- for(int i=0; i<size; i++)
- {
- LoggingEvent event = (LoggingEvent)buffer.get(i);
-
- //Insert message into database
- jlogger.append(layout.format(event));
- }
-
- buffer.clear();
-
- if(docommit) con.commit();
- }
- catch(Exception e)
- {
- errorHandler.error("JDBCAppender::flush_buffer(), " + e + " : " + jlogger.getErrorMsg());
- try{con.rollback();} catch(Exception ex){}
- return;
- }
- }
-
-
- /**
- Internal method. Returns true, when the JDBCAppender is ready to append messages to the database, else false.
- */
- public boolean ready()
- {
- if(ready) return true;
-
- if(!configured) return false;
-
- ready = jlogger.ready();
-
- if(!ready){errorHandler.error(jlogger.getErrorMsg());}
-
- return ready;
- }
-
-
- /**
- Internal method. Connect to the database.
- */
- protected void connect() throws Exception
- {
- if(connected) return;
-
- try
- {
- if(connection_class == null)
- {
- if(url == null) throw new Exception("JDBCAppender::connect(), No URL defined.");
-
- if(username == null) throw new Exception("JDBCAppender::connect(), No USERNAME defined.");
-
- if(password == null) throw new Exception("JDBCAppender::connect(), No PASSWORD defined.");
-
- connectionHandler = new DefaultConnectionHandler();
- }
- else
- {
- connectionHandler = (JDBCConnectionHandler)(Class.forName(connection_class).newInstance());
- }
-
- if(url != null && username != null && password != null)
- {
- con = connectionHandler.getConnection(url, username, password);
- }
- else
- {
- con = connectionHandler.getConnection();
- }
-
- if(con.isClosed())
- {
- throw new Exception("JDBCAppender::connect(), JDBCConnectionHandler returns no connected Connection !");
- }
- }
- catch(Exception e)
- {
- throw new Exception("JDBCAppender::connect(), " + e);
- }
-
- connected = true;
- }
-
- /**
- Internal method. Configures for appending...
- */
- protected boolean configure()
- {
- if(configured) return true;
-
- if(!connected)
- {
- if((connection_class == null) && (url == null || username == null || password == null))
- {
- errorHandler.error("JDBCAppender::configure(), Missing database-options or connector-option !");
- return false;
- }
-
- try
- {
- connect();
- }
- catch(Exception e)
- {
- connection_class = null;
- url = null;
- errorHandler.error("JDBCAppender::configure(), " + e);
- return false;
- }
- }
-
- if(sql == null && table == null)
- {
- errorHandler.error("JDBCAppender::configure(), No SQL_OPTION or TABLE_OPTION given !");
- return false;
- }
-
- if(!jlogger.isConfigured())
- {
- try
- {
- jlogger.setConnection(con);
-
- if(sql == null)
- {
- jlogger.configureTable(table);
- }
- else jlogger.configureSQL(sql);
- }
- catch(Exception e)
- {
- errorHandler.error("JDBCAppender::configure(), " + e);
- return false;
- }
- }
-
- //Default Message-Layout
- if(layout == null)
- {
- layout = new PatternLayout("%m");
- }
-
- configured = true;
-
- return true;
- }
-}
-
-/**
-This is a default JDBCConnectionHandler used by JDBCAppender
-*/
-class DefaultConnectionHandler implements JDBCConnectionHandler
-{
- Connection con = null;
-
- public Connection getConnection()
- {
- return con;
- }
-
- public Connection getConnection(String _url, String _username, String _password)
- {
- try
- {
- if(con != null && !con.isClosed()) con.close();
- con = DriverManager.getConnection(_url, _username, _password);
- con.setAutoCommit(false);
- }
- catch(Exception e){}
-
- return con;
- }
-}
-
-
-
-
-
-
diff --git a/contribs/ThomasFenner/JDBCConnectionHandler.java b/contribs/ThomasFenner/JDBCConnectionHandler.java
deleted file mode 100644
index 535007c..0000000
--- a/contribs/ThomasFenner/JDBCConnectionHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
-*/
-
-package com.klopotek.utils.log;
-
-import java.sql.*;
-
-
-/**
-This interface has to be implemented for your own database-connection-handling and its used in class JDBCLogger.
-
-<p><b>Author : </b><A HREF="mailto:t.fenner@klopotek.de">Thomas Fenner</A></p>
-
-@since 1.0
-*/
-public interface JDBCConnectionHandler
-{
- /**Get a connection*/
- Connection getConnection();
- /**Get a defined connection*/
- Connection getConnection(String _url, String _username, String _password);
-}
-
-
diff --git a/contribs/ThomasFenner/JDBCIDHandler.java b/contribs/ThomasFenner/JDBCIDHandler.java
deleted file mode 100644
index 2135f57..0000000
--- a/contribs/ThomasFenner/JDBCIDHandler.java
+++ /dev/null
@@ -1,23 +0,0 @@
-
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
-*/
-
-package com.klopotek.utils.log;
-
-
-/**
-This interface has to be implemented to provide ID-columns with unique IDs and its used in class JDBCLogger.
-
-<p><b>Author : </b><A HREF="mailto:t.fenner@klopotek.de">Thomas Fenner</A></p>
-
-@since 1.0
-*/
-public interface JDBCIDHandler
-{
- /**Get a unique ID*/
- Object getID();
-}
-
-
-
diff --git a/contribs/ThomasFenner/JDBCLogger.java b/contribs/ThomasFenner/JDBCLogger.java
deleted file mode 100644
index ef8bc93..0000000
--- a/contribs/ThomasFenner/JDBCLogger.java
+++ /dev/null
@@ -1,456 +0,0 @@
-
-/*
- * Copyright (C) The Apache Software Foundation. All rights reserved.
-*/
-
-package com.klopotek.utils.log;
-
-import java.sql.*;
-import java.util.*;
-import org.apache.log4j.*;
-import org.apache.log4j.helpers.*;
-import org.apache.log4j.spi.*;
-
-
-/**
-This class encapsulate the logic which is necessary to log into a table.
-Used by JDBCAppender
-
-<p><b>Author : </b><A HREF="mailto:t.fenner@klopotek.de">Thomas Fenner</A></p>
-
-@since 1.0
-*/
-public class JDBCLogger
-{
- //All columns of the log-table
- private ArrayList logcols = null;
- //Only columns which will be provided by logging
- private String column_list = null;
- //Number of all columns
- private int num = 0;
- //Status for successful execution of method configure()
- private boolean isconfigured = false;
- //Status for ready to do logging with method append()
- private boolean ready = false;
- //This message will be filled with a error-string when method ready() failes, and can be got by calling getMsg()
- private String errormsg = "";
-
- private Connection con = null;
- private Statement stmt = null;
- private ResultSet rs = null;
- private String table = null;
-
- //Variables for static SQL-statement logging
- private String sql = null;
- private String new_sql = null;
- private String new_sql_part1 = null;
- private String new_sql_part2 = null;
- private static final String msg_wildcard = "@MSG@";
- private int msg_wildcard_pos = 0;
-
- /**
- Writes a message into the database table.
- Throws an exception, if an database-error occurs !
- */
- public void append(String _msg) throws Exception
- {
- if(!ready) if(!ready()) throw new Exception("JDBCLogger::append(), Not ready to append !");
-
- if(sql != null)
- {
- appendSQL(_msg);
- return;
- }
-
- LogColumn logcol;
-
- rs.moveToInsertRow();
-
- for(int i=0; i<num; i++)
- {
- logcol = (LogColumn)logcols.get(i);
-
- if(logcol.logtype == LogType.MSG)
- {
- rs.updateObject(logcol.name, _msg);
- }
- else if(logcol.logtype == LogType.ID)
- {
- rs.updateObject(logcol.name, logcol.idhandler.getID());
- }
- else if(logcol.logtype == LogType.STATIC)
- {
- rs.updateObject(logcol.name, logcol.value);
- }
- else if(logcol.logtype == LogType.TIMESTAMP)
- {
- rs.updateObject(logcol.name, new Timestamp((new java.util.Date()).getTime()));
- }
- }
-
- rs.insertRow();
- }
-
- /**
- Writes a message into the database using a given sql-statement.
- Throws an exception, if an database-error occurs !
- */
- public void appendSQL(String _msg) throws Exception
- {
- if(!ready) if(!ready()) throw new Exception("JDBCLogger::appendSQL(), Not ready to append !");
-
- if(sql == null) throw new Exception("JDBCLogger::appendSQL(), No SQL-Statement configured !");
-
- if(msg_wildcard_pos > 0)
- {
- new_sql = new_sql_part1 + _msg + new_sql_part2;
- }
- else new_sql = sql;
-
- try
- {
- stmt.executeUpdate(new_sql);
- }
- catch(Exception e)
- {
- errormsg = new_sql;
- throw e;
- }
- }
-
-
- /**
- Configures this class, by reading in the structure of the log-table
- Throws an exception, if an database-error occurs !
- */
- public void configureTable(String _table) throws Exception
- {
- if(isconfigured) return;
-
- //Fill logcols with META-informations of the table-columns
- stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
- rs = stmt.executeQuery("SELECT * FROM " + _table + " WHERE 1 = 2");
-
- LogColumn logcol;
-
- ResultSetMetaData rsmd = rs.getMetaData();
-
- num = rsmd.getColumnCount();
-
- logcols = new ArrayList(num);
-
- for(int i=1; i<=num; i++)
- {
- logcol = new LogColumn();
- logcol.name = rsmd.getColumnName(i).toUpperCase();
- logcol.type = rsmd.getColumnTypeName(i);
- logcol.nullable = (rsmd.isNullable(i) == rsmd.columnNullable);
- logcol.isWritable = rsmd.isWritable(i);
- if(!logcol.isWritable) logcol.ignore = true;
- logcols.add(logcol);
- }
-
- table = _table;
-
- isconfigured = true;
- }
-
- /**
- Configures this class, by storing and parsing the given sql-statement.
- Throws an exception, if somethings wrong !
- */
- public void configureSQL(String _sql) throws Exception
- {
- if(isconfigured) return;
-
- if(!isConnected()) throw new Exception("JDBCLogger::configureSQL(), Not connected to database !");
-
- if(_sql == null || _sql.trim().equals("")) throw new Exception("JDBCLogger::configureSQL(), Invalid SQL-Statement !");
-
- sql = _sql.trim();
-
- stmt = con.createStatement();
-
- msg_wildcard_pos = sql.indexOf(msg_wildcard);
-
- if(msg_wildcard_pos > 0)
- {
- new_sql_part1 = sql.substring(0, msg_wildcard_pos-1) + "'";
- //between the message...
- new_sql_part2 = "'" + sql.substring(msg_wildcard_pos+msg_wildcard.length());
- }
-
- isconfigured = true;
- }
-
- /**
- Sets a connection. Throws an exception, if the connection is not open !
- */
- public void setConnection(Connection _con) throws Exception
- {
- con = _con;
-
- if(!isConnected()) throw new Exception("JDBCLogger::setConnection(), Given connection isnt connected to database !");
- }
-
-
- /**
- Sets a columns logtype (LogTypes) and value, which depends on that logtype.
- Throws an exception, if the given arguments arent correct !
- */
- public void setLogType(String _name, int _logtype, Object _value) throws Exception
- {
- if(!isconfigured) throw new Exception("JDBCLogger::setLogType(), Not configured !");
-
- //setLogType() makes only sense for further configuration of configureTable()
- if(sql != null) return;
-
- _name = _name.toUpperCase();
-
- if(_name == null || !(_name.trim().length() > 0)) throw new Exception("JDBCLogger::setLogType(), Missing argument name !");
- if(!LogType.isLogType(_logtype)) throw new Exception("JDBCLogger::setLogType(), Invalid logtype '" + _logtype + "' !");
- if((_logtype != LogType.MSG && _logtype != LogType.EMPTY) && _value == null) throw new Exception("JDBCLogger::setLogType(), Missing argument value !");
-
- LogColumn logcol;
-
- for(int i=0; i<num; i++)
- {
- logcol = (LogColumn)logcols.get(i);
-
- if(logcol.name.equals(_name))
- {
- if(!logcol.isWritable) throw new Exception("JDBCLogger::setLogType(), Column " + _name + " is not writeable !");
-
- //Column gets the message
- if(_logtype == LogType.MSG)
- {
- logcol.logtype = _logtype;
- return;
- }
- //Column will be provided by JDBCIDHandler::getID()
- else if(_logtype == LogType.ID)
- {
- logcol.logtype = _logtype;
-
- try
- {
- //Try to cast directly Object to JDBCIDHandler
- logcol.idhandler = (JDBCIDHandler)_value;
- }
- catch(Exception e)
- {
- try
- {
- //Assuming _value is of class string which contains the classname of a JDBCIDHandler
- logcol.idhandler = (JDBCIDHandler)(Class.forName((String)_value).newInstance());
- }
- catch(Exception e2)
- {
- throw new Exception("JDBCLogger::setLogType(), Cannot cast value of class " + _value.getClass() + " to class JDBCIDHandler !");
- }
- }
-
- return;
- }
-
- //Column will be statically defined with Object _value
- else if(_logtype == LogType.STATIC)
- {
- logcol.logtype = _logtype;
- logcol.value = _value;
- return;
- }
-
- //Column will be provided with a actually timestamp
- else if(_logtype == LogType.TIMESTAMP)
- {
- logcol.logtype = _logtype;
- return;
- }
-
- //Column will be fully ignored during process.
- //If this column is not nullable, the column has to be filled by a database trigger,
- //else a database error occurs !
- //Columns which are not nullable, but should be not filled, must be explicit assigned with LogType.EMPTY,
- //else a value is required !
- else if(_logtype == LogType.EMPTY)
- {
- logcol.logtype = _logtype;
- logcol.ignore = true;
- return;
- }
- }
- }
- }
-
-
- /**
- Return true, if this class is ready to append(), else false.
- When not ready, a reason-String is stored in the instance-variable msg.
- */
- public boolean ready()
- {
- if(ready) return true;
-
- if(!isconfigured){ errormsg = "Not ready to append ! Call configure() first !"; return false;}
-
- //No need to doing the whole rest...
- if(sql != null)
- {
- ready = true;
- return true;
- }
-
- boolean msgcol_defined = false;
-
- LogColumn logcol;
-
- for(int i=0; i<num; i++)
- {
- logcol = (LogColumn)logcols.get(i);
-
- if(logcol.ignore || !logcol.isWritable) continue;
- if(!logcol.nullable && logcol.logtype == LogType.EMPTY)
- {
- errormsg = "Not ready to append ! Column " + logcol.name + " is not nullable, and must be specified by setLogType() !";
- return false;
- }
- if(logcol.logtype == LogType.ID && logcol.idhandler == null)
- {
- errormsg = "Not ready to append ! Column " + logcol.name + " is specified as an ID-column, and a JDBCIDHandler has to be set !";
- return false;
- }
- else if(logcol.logtype == LogType.STATIC && logcol.value == null)
- {
- errormsg = "Not ready to append ! Column " + logcol.name + " is specified as a static field, and a value has to be set !";
- return false;
- }
- else if(logcol.logtype == LogType.MSG) msgcol_defined = true;
- }
-
- if(!msgcol_defined) return false;
-
- //create the column_list
- for(int i=0; i<num; i++)
- {
- logcol = (LogColumn)logcols.get(i);
-
- if(logcol.ignore || !logcol.isWritable) continue;
-
- if(logcol.logtype != LogType.EMPTY)
- {
- if(column_list == null)
- {
- column_list = logcol.name;
- }
- else column_list += ", " + logcol.name;
- }
- }
-
- try
- {
- rs = stmt.executeQuery("SELECT " + column_list + " FROM " + table + " WHERE 1 = 2");
- }
- catch(Exception e)
- {
- errormsg = "Not ready to append ! Cannot select columns '" + column_list + "' of table " + table + " !";
- return false;
- }
-
- ready = true;
-
- return true;
- }
-
- /**
- Return true, if this class is configured, else false.
- */
- public boolean isConfigured(){ return isconfigured;}
-
- /**
- Return true, if this connection is open, else false.
- */
- public boolean isConnected()
- {
- try
- {
- return (con != null && !con.isClosed());
- }
- catch(Exception e){return false;}
- }
-
- /**
- Return the internal error message stored in instance variable msg.
- */
- public String getErrorMsg(){String r = new String(errormsg); errormsg = null; return r;}
-}
-
-
-/**
-This class encapsulate all by class JDBCLogger needed data around a column
-*/
-class LogColumn
-{
- //column name
- String name = null;
- //column type
- String type = null;
- //not nullability means that this column is mandatory
- boolean nullable = false;
- //isWritable means that the column can be updated, else column is only readable
- boolean isWritable = false;
- //if ignore is true, this column will be ignored by building sql-statements.
- boolean ignore = false;
-
- //Must be filled for not nullable columns ! In other case it is optional.
- int logtype = LogType.EMPTY;
- Object value = null; //Generic storage for typewrapper-classes Long, String, etc...
- JDBCIDHandler idhandler = null;
-}
-
-
-/**
-This class contains all constants which are necessary to define a columns log-type.
-*/
-class LogType
-{
- //A column of this type will receive the message.
- public static final int MSG = 1;
-
- //A column of this type will be a unique identifier of the logged row.
- public static final int ID = 2;
-
- //A column of this type will contain a static, one-time-defined value.
- public static final int STATIC = 3;
-
- //A column of this type will be filled with an actual timestamp depending by the time the logging will be done.
- public static final int TIMESTAMP = 4;
-
- //A column of this type will contain no value and will not be included in logging insert-statement.
- //This could be a column which will be filled not by creation but otherwhere...
- public static final int EMPTY = 5;
-
-
- public static boolean isLogType(int _lt)
- {
- if(_lt == MSG || _lt == STATIC || _lt == ID || _lt == TIMESTAMP || _lt == EMPTY) return true;
-
- return false;
- }
-
- public static int parseLogType(String _lt)
- {
- if(_lt.equals("MSG")) return MSG;
- if(_lt.equals("ID")) return ID;
- if(_lt.equals("STATIC")) return STATIC;
- if(_lt.equals("TIMESTAMP")) return TIMESTAMP;
- if(_lt.equals("EMPTY")) return EMPTY;
-
- return -1;
- }
-}
-
-
-
-
-
diff --git a/contribs/ThomasFenner/Log4JTest.java b/contribs/ThomasFenner/Log4JTest.java
deleted file mode 100644
index d64e772..0000000
--- a/contribs/ThomasFenner/Log4JTest.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/**
-// Class JDBCAppender, writes messages into a database
-
-// The JDBCAppender is configurable at runtime in two alternatives :
-// 1. Configuration-file
-// Define the options in a file and call a PropertyConfigurator.configure(file)-method.
-// 2. method JDBCAppender::setOption(JDBCAppender.xxx_OPTION, String value)
-
-// The sequence of some options is important :
-// 1. Connector-option OR/AND Database-options
-// Any database connection is required !
-// 2. (Table-option AND Columns-option) OR SQL-option
-// Any statement is required !
-// 3. All other options can be set at any time...
-// The other options are optional and have a default initialization, which can be custumized.
-
-// All available options are defined as static String-constants in JDBCAppender named xxx_OPTION.
-
-// Here is a description of all available options :
-// 1. Database-options to connect to the database
-// - URL_OPTION : a database url of the form jdbc:subprotocol:subname
-// - USERNAME_OPTION : the database user on whose behalf the connection is being made
-// - PASSWORD_OPTION : the user's password
-//
-// 2. Connector-option to specify your own JDBCConnectionHandler
-// - CONNECTOR_OPTION : a classname which is implementing the JDBCConnectionHandler-interface
-// This interface is used to get a customized connection.
-// If in addition the database-options are given, these options will be used
-// for invocation of the JDBCConnectionHandler-interface to get a connection.
-// Else if no database-options are given, the JDBCConnectionHandler-interface is called without these options.
-//
-// 3. SQL-option to specify a static sql-statement which will be performed with every occuring message-event
-// - SQL_OPTION : a sql-statement which will be used to write to the database
-// If you give this option, the table-option and columns-option will be ignored !
-// Use the variable @MSG@ on that location in the statement, which has to be dynamically replaced by the message.
-//
-// 4. Table-option to specify one table contained by the database
-// - TABLE_OPTION : the table in which the logging will be done
-//
-// 5. Columns-option to describe the important columns of the table (Not nullable columns are mandatory to describe!)
-// - COLUMNS_OPTION : a formatted list of column-descriptions
-// Each column description consists of
-// - the name of the column (required)
-// - a logtype which is a static constant of class LogType (required)
-// - and a value which depends by the LogType (optional/required, depending by logtype)
-// Here is a description of the available logtypes of class LogType :
-// o MSG = a value will be ignored, the column will get the message. (One columns need to be of this type!)
-// o STATIC = the value will be filled into the column with every logged message. (Ensure that the type of value can be casted into the sql-type of the column!)
-// o ID = value must be a classname, which implements the JDBCIDHandler-interface.
-// o TIMESTAMP = a value will be ignored, the column will be filled with a actually timestamp with every logged message.
-// o EMPTY = a value will be ignored, the column will be ignored when writing to the database (Ensure to fill not nullable columns by a database trigger!)
-// If there are more than one column to describe, the columns must be separated by a TAB-delimiter (' ') !
-// The arguments of a column-description must be separated by the delimiter '~' !
-// (Example : name1~logtype1~value1 name2~logtype2~value2...)
-//
-// 6. Layout-options to define the layout of the messages (optional)
-// - the layout wont be set by a xxx_OPTION
-// Configuration-file : see at the following configuration-file example
-// JDBCAppender::setOption() : see at the following code example
-// The default is a layout of class org.apache.log4j.PatternLayout with ConversionPattern=%m
-//
-// 7. Buffer-option to define the size of the message-event-buffer (optional)
-// - BUFFER_OPTION : define how many messages will be buffered until they will be updated to the database.
-// The default is a update on every message (buffer=1=no buffer).
-//
-// 8. Commit-option to define a auto-commitment
-// - COMMIT_OPTION : define whether updated messages should be committed to the database (Y) or not (N).
-// The default is a commit on every buffer-flush.
-
-
-// Here is a Configuration-file example, which can be used with the PropertyConfigurator :
-//
-// Declare a appender variable named JDBC
-log4j.rootCategory=JDBC
-
-// JDBC is a class of JDBCAppender, which writes messages into a database
-log4j.appender.JDBC=JDBCAppender
-
-// 1. Database-options to connect to the database
-log4j.appender.JDBC.url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))
-log4j.appender.JDBC.username=mex_pr_dev60
-log4j.appender.JDBC.password=mex_pr_dev60
-
-// 2. Connector-option to specify your own JDBCConnectionHandler
-log4j.appender.JDBC.connector=MyConnectionHandler
-
-// 3. SQL-option to specify a static sql-statement which will be performed with every occuring message-event
-log4j.appender.JDBC.sql=INSERT INTO LOGTEST (id, msg, created_on, created_by) VALUES (1, @MSG@, sysdate, 'me')
-
-// 4. Table-option to specify one table contained by the database
-log4j.appender.JDBC.table=logtest
-
-// 5. Columns-option to describe the important columns of the table (Not nullable columns are mandatory to describe!)
-log4j.appender.JDBC.columns=id_seq~EMPTY id~ID~MyIDHandler msg~MSG created_on~TIMESTAMP created_by~STATIC~Thomas Fenner (t.fenner@klopotek.de)
-
-// 6. Layout-options to define the layout of the messages (optional)
-log4j.appender.JDBC.layout=org.apache.log4j.PatternLayout
-log4j.appender.JDBC.layout.ConversionPattern=%m
-
-// 7. Buffer-option to define the size of the message-event-buffer (optional)
-log4j.appender.JDBC.buffer=1
-
-// 8. Commit-option to define a auto-commitment
-log4j.appender.JDBC.commit=Y
-*/
-
-// Here is a code example to configure the JDBCAppender with a configuration-file :
-
-import org.apache.log4j.*;
-import java.sql.*;
-import java.lang.*;
-import java.util.*;
-
-public class Log4JTest
-{
- // Create a category instance for this class
- static Category cat = Category.getInstance(Log4JTest.class.getName());
-
- public static void main(String[] args)
- {
- // Ensure to have all necessary drivers installed !
- try
- {
- Driver d = (Driver)(Class.forName("oracle.jdbc.driver.OracleDriver").newInstance());
- DriverManager.registerDriver(d);
- }
- catch(Exception e){}
-
- // Set the priority which messages have to be logged
- cat.setPriority(Priority.INFO);
-
- // Configuration with configuration-file
- PropertyConfigurator.configure("log4jtestprops.txt");
-
- // These messages with Priority >= setted priority will be logged to the database.
- cat.debug("debug"); //this not, because Priority DEBUG is less than INFO
- cat.info("info");
- cat.error("error");
- cat.fatal("fatal");
- }
-}
-
-// Here is a code example to configure the JDBCAppender without a configuration-file :
-/*
-import org.apache.log4j.*;
-import java.sql.*;
-import java.lang.*;
-import java.util.*;
-
-public class Log4JTest
-{
- // Create a category instance for this class
- static Category cat = Category.getInstance(Log4JTest.class.getName());
-
- public static void main(String[] args)
- {
- // A JDBCIDHandler
- MyIDHandler idhandler = new MyIDHandler();
-
- // Ensure to have all necessary drivers installed !
- try
- {
- Driver d = (Driver)(Class.forName("oracle.jdbc.driver.OracleDriver").newInstance());
- DriverManager.registerDriver(d);
- }
- catch(Exception e){}
-
- // Set the priority which messages have to be logged
- cat.setPriority(Priority.DEBUG);
-
- // Create a new instance of JDBCAppender
- JDBCAppender ja = new JDBCAppender();
-
- // Set options with method setOption()
- ja.setOption(JDBCAppender.CONNECTOR_OPTION, "MyConnectionHandler");
- ja.setOption(JDBCAppender.URL_OPTION, "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))");
- ja.setOption(JDBCAppender.USERNAME_OPTION, "mex_pr_dev60");
- ja.setOption(JDBCAppender.PASSWORD_OPTION, "mex_pr_dev60");
-
- ja.setOption(JDBCAppender.TABLE_OPTION, "logtest");
-
- // There are two ways to setup the column-descriptions :
- // 1. Use the the method setOption(JDBCAppender.COLUMNS_OPTION, column-description)
- //ja.setOption(JDBCAppender.COLUMNS_OPTION, "id_seq~EMPTY id~ID~MyIDHandler msg~MSG created_on~TIMESTAMP created_by~STATIC~:-) Thomas Fenner (t.fenner@klopotek.de)");
- // 2. Use the better way of coding with method setLogType(String columnname, int LogType.xxx, Object xxx)
- ja.setLogType("id_seq", LogType.EMPTY, "");
- ja.setLogType("id", LogType.ID, idhandler);
- ja.setLogType("msg", LogType.MSG, "");
- ja.setLogType("created_on", LogType.TIMESTAMP, "");
- ja.setLogType("created_by", LogType.STATIC, "FEN");
-
- // If you just want to perform a static sql-statement, forget about the table- and columns-options,
- // and use this one :
- //ja.setOption(JDBCAppender.SQL_OPTION, "INSERT INTO LOGTEST (id, msg, created_on, created_by) VALUES (1, @MSG@, sysdate, 'me')");
-
- // other options
- //ja.setOption(JDBCAppender.BUFFER_OPTION, "1");
- //ja.setOption(JDBCAppender.COMMIT_OPTION, "Y");
-
- // Define a layout
- //ja.setLayout(new PatternLayout("%m"));
-
- // Add the appender to a category
- cat.addAppender(ja);
-
- // These messages with Priority >= setted priority will be logged to the database.
- cat.debug("debug");
- cat.info("info");
- cat.error("error");
- cat.fatal("fatal");
- }
-}
-*/
-
-// Implement a sample JDBCConnectionHandler
-class MyConnectionHandler implements JDBCConnectionHandler
-{
- Connection con = null;
- //Default connection
- String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))";
- String username = "mex_pr_dev60";
- String password = "mex_pr_dev60";
-
- public Connection getConnection()
- {
- return getConnection(url, username, password);
- }
-
- public Connection getConnection(String _url, String _username, String _password)
- {
- try
- {
- if(con != null && !con.isClosed()) con.close();
- con = DriverManager.getConnection(_url, _username, _password);
- con.setAutoCommit(false);
- }
- catch(Exception e){}
-
- return con;
- }
-}
-
-
-// Implement a sample JDBCIDHandler
-class MyIDHandler implements JDBCIDHandler
-{
- private static long id = 0;
-
- public synchronized Object getID()
- {
- return new Long(++id);
- }
-}
-
-
diff --git a/contribs/ThomasFenner/code_example1.java b/contribs/ThomasFenner/code_example1.java
deleted file mode 100644
index d5e566d..0000000
--- a/contribs/ThomasFenner/code_example1.java
+++ /dev/null
@@ -1,37 +0,0 @@
-
-// Here is a code example to configure the JDBCAppender with a configuration-file
-
-import org.apache.log4j.*;
-import java.sql.*;
-import java.lang.*;
-import java.util.*;
-
-public class Log4JTest
-{
- // Create a category instance for this class
- static Category cat = Category.getInstance(Log4JTest.class.getName());
-
- public static void main(String[] args)
- {
- // Ensure to have all necessary drivers installed !
- try
- {
- Driver d = (Driver)(Class.forName("oracle.jdbc.driver.OracleDriver").newInstance());
- DriverManager.registerDriver(d);
- }
- catch(Exception e){}
-
- // Set the priority which messages have to be logged
- cat.setPriority(Priority.INFO);
-
- // Configuration with configuration-file
- PropertyConfigurator.configure("log4jtestprops.txt");
-
- // These messages with Priority >= setted priority will be logged to the database.
- cat.debug("debug"); //this not, because Priority DEBUG is less than INFO
- cat.info("info");
- cat.error("error");
- cat.fatal("fatal");
- }
-}
-
diff --git a/contribs/ThomasFenner/code_example2.java b/contribs/ThomasFenner/code_example2.java
deleted file mode 100644
index d799aaf..0000000
--- a/contribs/ThomasFenner/code_example2.java
+++ /dev/null
@@ -1,113 +0,0 @@
-
-// Here is a code example to configure the JDBCAppender without a configuration-file
-
-import org.apache.log4j.*;
-import java.sql.*;
-import java.lang.*;
-import java.util.*;
-
-public class Log4JTest
-{
- // Create a category instance for this class
- static Category cat = Category.getInstance(Log4JTest.class.getName());
-
- public static void main(String[] args)
- {
- // A JDBCIDHandler
- MyIDHandler idhandler = new MyIDHandler();
-
- // Ensure to have all necessary drivers installed !
- try
- {
- Driver d = (Driver)(Class.forName("oracle.jdbc.driver.OracleDriver").newInstance());
- DriverManager.registerDriver(d);
- }
- catch(Exception e){}
-
- // Set the priority which messages have to be logged
- cat.setPriority(Priority.DEBUG);
-
- // Create a new instance of JDBCAppender
- JDBCAppender ja = new JDBCAppender();
-
- // Set options with method setOption()
- ja.setOption(JDBCAppender.CONNECTOR_OPTION, "MyConnectionHandler");
- ja.setOption(JDBCAppender.URL_OPTION, "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))");
- ja.setOption(JDBCAppender.USERNAME_OPTION, "mex_pr_dev60");
- ja.setOption(JDBCAppender.PASSWORD_OPTION, "mex_pr_dev60");
-
- ja.setOption(JDBCAppender.TABLE_OPTION, "logtest");
-
- // There are two ways to setup the column-descriptions :
- // 1. Use the the method setOption(JDBCAppender.COLUMNS_OPTION, column-description)
- //ja.setOption(JDBCAppender.COLUMNS_OPTION, "id_seq~EMPTY id~ID~MyIDHandler msg~MSG created_on~TIMESTAMP created_by~STATIC~:-) Thomas Fenner (t.fenner@klopotek.de)");
-
- // 2. Use the better way of coding with method setLogType(String columnname, int LogType.xxx, Object xxx)
- ja.setLogType("id_seq", LogType.EMPTY, "");
- ja.setLogType("id", LogType.ID, idhandler);
- ja.setLogType("msg", LogType.MSG, "");
- ja.setLogType("created_on", LogType.TIMESTAMP, "");
- ja.setLogType("created_by", LogType.STATIC, "FEN");
-
- // If you just want to perform a static sql-statement, forget about the table- and columns-options,
- // and use this one :
- //ja.setOption(JDBCAppender.SQL_OPTION, "INSERT INTO LOGTEST (id, msg, created_on, created_by) VALUES (1, @MSG@, sysdate, 'me')");
-
- // other options
- //ja.setOption(JDBCAppender.BUFFER_OPTION, "1");
- //ja.setOption(JDBCAppender.COMMIT_OPTION, "Y");
-
- // Define a layout
- //ja.setLayout(new PatternLayout("%m"));
-
- // Add the appender to a category
- cat.addAppender(ja);
-
- // These messages with Priority >= setted priority will be logged to the database.
- cat.debug("debug");
- cat.info("info");
- cat.error("error");
- cat.fatal("fatal");
- }
-}
-
-// Implement a sample JDBCConnectionHandler
-class MyConnectionHandler implements JDBCConnectionHandler
-{
- Connection con = null;
- //Default connection
- String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))";
- String username = "mex_pr_dev60";
- String password = "mex_pr_dev60";
-
- public Connection getConnection()
- {
- return getConnection(url, username, password);
- }
-
- public Connection getConnection(String _url, String _username, String _password)
- {
- try
- {
- if(con != null && !con.isClosed()) con.close();
- con = DriverManager.getConnection(_url, _username, _password);
- con.setAutoCommit(false);
- }
- catch(Exception e){}
-
- return con;
- }
-}
-
-
-// Implement a sample JDBCIDHandler
-class MyIDHandler implements JDBCIDHandler
-{
- private static long id = 0;
-
- public synchronized Object getID()
- {
- return new Long(++id);
- }
-}
-
diff --git a/contribs/ThomasFenner/configfile_example.txt b/contribs/ThomasFenner/configfile_example.txt
deleted file mode 100644
index 466633a..0000000
--- a/contribs/ThomasFenner/configfile_example.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Here is a Configuration-file example, which can be used with the PropertyConfigurator :
-
-# Declare a appender variable named JDBC
-log4j.rootCategory=JDBC
-
-# JDBC is a class of JDBCAppender, which writes messages into a database
-log4j.appender.JDBC=JDBCAppender
-
-# 1. Database-options to connect to the database
-log4j.appender.JDBC.url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))
-log4j.appender.JDBC.username=mex_pr_dev60
-log4j.appender.JDBC.password=mex_pr_dev60
-
-# 2. Connector-option to specify your own JDBCConnectionHandler
-#log4j.appender.JDBC.connector=MyConnectionHandler
-
-# 3. SQL-option to specify a static sql-statement which will be performed with every occuring message-event
-#log4j.appender.JDBC.sql=INSERT INTO LOGTEST (id, msg, created_on, created_by) VALUES (1, @MSG@, sysdate, 'me')
-
-# 4. Table-option to specify one table contained by the database
-log4j.appender.JDBC.table=logtest
-
-# 5. Columns-option to describe the important columns of the table (Not nullable columns are mandatory to describe!)
-log4j.appender.JDBC.columns=id_seq~EMPTY id~ID~MyIDHandler msg~MSG created_on~TIMESTAMP created_by~STATIC~Thomas Fenner (t.fenner@klopotek.de)
-
-# 6. Layout-options to define the layout of the messages (optional)
-#log4j.appender.JDBC.layout=org.apache.log4j.PatternLayout
-#log4j.appender.JDBC.layout.ConversionPattern=%m
-
-# 7. Buffer-option to define the size of the message-event-buffer (optional)
-#log4j.appender.JDBC.buffer=1
-
-# 8. Commit-option to define a auto-commitment (optional)
-#log4j.appender.JDBC.commit=Y
-
diff --git a/contribs/VolkerMentzner/HTTPRequestHandler.java b/contribs/VolkerMentzner/HTTPRequestHandler.java
deleted file mode 100644
index 1c5bad7..0000000
--- a/contribs/VolkerMentzner/HTTPRequestHandler.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.psibt.framework.net;
-
-import java.io.*;
-import java.net.*;
-
-/**
- * This interface defines all methods that have to be implemented for a HTTPRequestHandler for the
- * PluggableHTTPServer.
- *
- * @author <a HREF="mailto:V.Mentzner@psi-bt.de">Volker Mentzner</a>
- */
-public interface HTTPRequestHandler {
-
- /**
- * Gets the title for html page
- */
- public String getTitle();
-
- /**
- * Sets the title for html page
- */
- public void setTitle(String title);
-
- /**
- * Gets the description for html page
- */
- public String getDescription();
-
- /**
- * Sets the description for html page
- */
- public void setDescription(String description);
-
- /**
- * Gets the virtual path in the HTTP server that ist handled in this HTTPRequestHandler.
- * So the root path handler will return "/" (without brackets) because it handles the path
- * "http://servername/" or a handler for "http://servername/somepath/" will return "/somepath/"
- * It is important to include the trailing "/" because all HTTPRequestHandler have to serve a path!
- */
- public String getHandledPath();
-
- /**
- * Sets the virtual path in the HTTP server that ist handled in this HTTPRequestHandler.
- * So set the path to "/" for the root path handler because it handles the path
- * "http://servername/" or set it to "/somepath/" for a handler for "http://servername/somepath/".
- * It is important to include the trailing "/" because all HTTPRequestHandler have to serve a path!
- */
- public void setHandledPath(String path);
-
- /**
- * Handles the given request and writes the reply to the given out-stream. Every handler has to check
- * the request for the right path info.
- *
- * @param request - client browser request
- * @param out - Out stream for sending data to client browser
- * @return if the request was handled by this handler : true, else : false
- */
- public boolean handleRequest(String request, Writer out);
-}
\ No newline at end of file
diff --git a/contribs/VolkerMentzner/Log4jRequestHandler.java b/contribs/VolkerMentzner/Log4jRequestHandler.java
deleted file mode 100644
index 7825dc6..0000000
--- a/contribs/VolkerMentzner/Log4jRequestHandler.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package com.psibt.framework.net;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import org.apache.log4j.*;
-
-/**
- * This class implements a RequestHandler for log4j configuration. It serves the "/log4j/" path
- * in the PluggableHTTPServer. If this path is requested a list of all current log4j categories
- * with their current priorities is created. All priority settings can be changed by the user
- * and can be submitted and taken over.
- *
- * @author <a HREF="mailto:V.Mentzner@psi-bt.de">Volker Mentzner</a>
- */
-public class Log4jRequestHandler extends RootRequestHandler {
-
- private Priority[] prios = Priority.getAllPossiblePriorities();
-
- /**
- * Creates a new Log4jRequestHandler object
- */
- public Log4jRequestHandler() {
- this.setTitle("log4j");
- this.setDescription("log4j configuration");
- this.setHandledPath("/log4j/");
- }
-
- /**
- * Handles the given request and writes the reply to the given out-stream.
- *
- * @param request - client browser request
- * @param out - Out stream for sending data to client browser
- * @return if the request was handled by this handler : true, else : false
- */
- public boolean handleRequest(String request, Writer out) {
- String path = "";
- String query = null;
- String name;
- try {
- // check request url
- URL url = new URL("http://localhost"+request);
- path = url.getPath();
- query = url.getQuery();
- if (path.startsWith(this.getHandledPath()) == false) {
- return false;
- }
-
- out.write("HTTP/1.0 200 OK\r\n");
- out.write("Content-type: text/html\r\n\r\n");
- out.write("<HTML><HEAD><TITLE>" + this.getTitle() + "</TITLE></HEAD>\r\n");
- out.write("<BODY><H1>log4j</H1>\r\n");
- out.write(this.getDescription() + "<br><br>\r\n");
-
- // handle a request with query
- if ((query != null) && (query.length() >= 0)) {
- StringTokenizer st = new StringTokenizer(query, "&");
- String cmd;
- String catname;
- String catval;
- int idx;
- while (st.hasMoreTokens()) {
- cmd = st.nextToken();
- idx = cmd.indexOf("=");
- catname = cmd.substring(0, idx);
- catval = cmd.substring(idx+1, cmd.length());
- if (catname.equalsIgnoreCase("root"))
- Category.getRoot().setPriority(Priority.toPriority(catval));
- else
- Category.getInstance(catname).setPriority(Priority.toPriority(catval));
- }
- }
-
- // output category information in a form with a simple table
- out.write("<form name=\"Formular\" ACTION=\""+this.getHandledPath()+"\" METHOD=\"PUT\">");
- out.write("<table cellpadding=4>\r\n");
- out.write(" <tr>\r\n");
- out.write(" <td><b>Category</b></td>\r\n");
- out.write(" <td><b>Priority</b></td>\r\n");
- out.write(" <td><b>Appender</b></td>\r\n");
- out.write(" </tr>\r\n");
-
- // output for root category
- Category cat = Category.getRoot();
- out.write(" <tr><td>root</td>\r\n");
- out.write(" <td>\r\n");
- out.write(" <select size=1 name=\""+ cat.getName() +"\">");
- for (int i = 0; i < prios.length; i++) {
- if (cat.getChainedPriority().toString().equals(prios[i].toString()))
- out.write("<option selected>"+prios[i].toString());
- else
- out.write("<option>"+prios[i].toString());
- }
- out.write("</select>\r\n");
- out.write(" </td>\r\n");
- out.write(" <td>\r\n");
- for (Enumeration apds = cat.getAllAppenders(); apds.hasMoreElements();) {
- Appender apd = (Appender)apds.nextElement();
- name = apd.getName();
- if (name == null)
- name = "<i>(no name)</i>";
- out.write(name);
- if (apd instanceof AppenderSkeleton) {
- try {
- AppenderSkeleton apskel = (AppenderSkeleton)apd;
- out.write(" [" + apskel.getThreshold().toString() + "]");
- } catch (Exception ex) {
- }
- }
- if (apds.hasMoreElements())
- out.write(", ");
- }
- out.write(" </td>\r\n");
- out.write(" </tr>\r\n");
-
- // output for all other categories
- for (Enumeration en = Category.getCurrentCategories(); en.hasMoreElements();) {
- cat = (Category)en.nextElement();
- out.write(" <tr>\r\n");
- out.write(" <td>" + cat.getName() + "</td>\r\n");
- out.write(" <td>\r\n");
- out.write(" <select size=1 name=\""+ cat.getName() +"\">");
- for (int i = 0; i < prios.length; i++) {
- if (cat.getChainedPriority().toString().equals(prios[i].toString()))
- out.write("<option selected>"+prios[i].toString());
- else
- out.write("<option>"+prios[i].toString());
- }
- out.write("</select>\r\n");
- out.write(" </td>\r\n");
- out.write(" <td>\r\n");
- for (Enumeration apds = cat.getAllAppenders(); apds.hasMoreElements();) {
- Appender apd = (Appender)apds.nextElement();
- name = apd.getName();
- if (name == null)
- name = "<i>(no name)</i>";
- out.write(name);
- if (apd instanceof AppenderSkeleton) {
- try {
- AppenderSkeleton apskel = (AppenderSkeleton)apd;
- out.write(" [" + apskel.getThreshold().toString() + "]");
- } catch (Exception ex) {
- }
- }
- if (apds.hasMoreElements())
- out.write(", ");
- }
- out.write(" </td>\r\n");
- out.write(" </tr>\r\n");
- }
- out.write("</table>\r\n");
- out.write("<input type=submit value=\"Submit\">");
- out.write("</form>");
- out.write("</BODY></HTML>\r\n");
- out.flush();
- return true;
- } catch (Exception ex) {
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/contribs/VolkerMentzner/PluggableHTTPServer.java b/contribs/VolkerMentzner/PluggableHTTPServer.java
deleted file mode 100644
index 25eb001..0000000
--- a/contribs/VolkerMentzner/PluggableHTTPServer.java
+++ /dev/null
@@ -1,246 +0,0 @@
-package com.psibt.framework.net;
-
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import org.apache.log4j.*;
-
-/**
- * This class implements a HTTP-server frame. All HTTP-requests are handled by HTTPRequestHandler
- * classes which implement the <code>HTTPRequestHandler</code> interface. Every RequestHandler has
- * to be registered in the PluggableHTTPServer with the <code>addRequestHandler</code> method.
- * A new thread is created for each connection to handle the request. If all reply data are sent
- * to the client the connection is closed and the thread ends.
- * An example how to use the PluggableHTTPServer class can be found in the <code>main</code> method
- * at the end of the source file.
- *
- * @author <a HREF="mailto:V.Mentzner@psi-bt.de">Volker Mentzner</a>
- */
-public class PluggableHTTPServer implements Runnable {
-
- public static final int DEFAULT_PORT = 80;
- static Category cat = Category.getInstance("PluggableHTTPServer");
- private int port;
- private Vector handler;
- private ServerSocket server;
-
- /**
- * Creates a new server object on the given TCP port.
- * If the port is occupied by another process a IOException (java.net.BindException) is thrown.
- *
- * @param port - TCP port number to listen on for requests
- */
- public PluggableHTTPServer(int port) throws IOException {
- this.port = port;
- this.handler = new Vector();
- cat.setPriority(Priority.ERROR);
- server = new ServerSocket(this.port);
- }
-
- /**
- * Creates a new server object on the default TCP port 80
- * If the port is occupied by another process a IOException (java.net.BindException) is thrown.
- */
- public PluggableHTTPServer() throws IOException {
- this(DEFAULT_PORT);
- }
-
- /**
- * Registers the given HTTPRequestHandler
- *
- * @param h - the HTTPRequestHandler to register
- */
- public void addRequestHandler(HTTPRequestHandler h) {
- handler.add(h);
- }
-
- /**
- * Unregisters the given HTTPRequestHandler
- *
- * @param h - the HTTPRequestHandler to unregister
- */
- public void removeRequestHandler(HTTPRequestHandler h) {
- handler.remove(h);
- }
-
- /**
- * Sends the HTTP message 404 - File Not Found
- * see RFC2616 for details
- *
- * @param out - Out stream for sending data to client browser
- */
- public static void replyNotFound(Writer out) {
- try {
- out.write("HTTP/1.0 404 Not Found\r\n");
- out.write("<HTML><HEAD><TITLE>Not Found</TITLE></HEAD>\r\n");
- out.write("<BODY><H1>Not Found</H1>\r\n");
- out.write("</BODY></HTML>\r\n");
- out.flush();
- } // end try
- catch (IOException e) {
- }
- }
-
- /**
- * Sends the HTTP message 405 - Method Not Allowed
- * see RFC2616 for details
- *
- * @param out - Out stream for sending data to client browser
- */
- public static void replyMethodNotAllowed(Writer out) {
- try {
- out.write("HTTP/1.1 405 Method Not Allowed\r\n");
- out.write("Allow: GET, PUT\r\n");
- out.write("<HTML><HEAD><TITLE>Method Not Allowed</TITLE></HEAD>\r\n");
- out.write("<BODY><H1>Method Not Allowed</H1>\r\n");
- out.write("</BODY></HTML>\r\n");
- out.flush();
- } // end try
- catch (IOException e) {
- }
- }
-
- /**
- * Creates the ReplyHTML data for the root page
- *
- * @param index - index of the RootRequestHandler
- */
- public void autoCreateRootPage(int index) {
- if (handler.get(index) instanceof RootRequestHandler) {
- RootRequestHandler r = (RootRequestHandler)handler.get(index);
- String html = "<HTML><HEAD><TITLE>"+r.getTitle()+"</TITLE></HEAD>\r\n";
- html = html + "<BODY><H1>"+r.getDescription()+"</H1>\r\n";
- for (int i = 0; i < handler.size(); i++) {
- html = html + "<a href=\"" + ((HTTPRequestHandler)handler.get(i)).getHandledPath();
- html = html + "\">" + ((HTTPRequestHandler)handler.get(i)).getDescription() + "</a><br>";
- }
- html = html + "</BODY></HTML>\r\n";
- r.setReplyHTML(html);
- }
- }
-
- /**
- * Main loop of the PluggableHTTPServer
- */
- public void run() {
- while (true) {
- try {
- Socket s = server.accept();
- Thread t = new ServerThread(s);
- t.start();
- }
- catch (IOException e) {
- }
- }
- }
-
- /**
- * This class handles the incomming connection for one request.
- */
- class ServerThread extends Thread {
-
- private Socket connection;
-
- ServerThread(Socket s) {
- this.connection = s;
- }
-
- /**
- * Serves the HTTP request.
- */
- public void run() {
- try {
- Writer out = new BufferedWriter(
- new OutputStreamWriter(
- connection.getOutputStream(), "ASCII"
- )
- );
- Reader in = new InputStreamReader(
- new BufferedInputStream(
- connection.getInputStream()
- )
- );
-
- // read the first line only; that's all we need
- StringBuffer req = new StringBuffer(80);
- while (true) {
- int c = in.read();
- if (c == '\r' || c == '\n' || c == -1) break;
- req.append((char) c);
- }
- String get = req.toString();
- cat.debug(get);
- StringTokenizer st = new StringTokenizer(get);
- String method = st.nextToken();
- String request = st.nextToken();
- String version = st.nextToken();
-
- if (method.equalsIgnoreCase("GET")) {
- boolean served = false;
- for (int i = 0; i < handler.size(); i++) {
- if (handler.get(i) instanceof HTTPRequestHandler) {
- if (((HTTPRequestHandler)handler.get(i)).handleRequest(request, out)) {
- served = true;
- break;
- }
- }
- }
- if (!served)
- PluggableHTTPServer.replyNotFound(out);
- }
- else {
- PluggableHTTPServer.replyMethodNotAllowed(out);
- }
- } // end try
- catch (IOException e) {
- }
- finally {
- try {
- if (connection != null) connection.close();
- }
- catch (IOException e) {}
- }
- } // end run
- } // end class ServerThread
-
- /**
- * Demo how to use the PluggableHTTPServer.
- */
- public static void main(String[] args) {
-
- int thePort;
-
- // create some logging stuff
- BasicConfigurator.configure();
- Category cat1 = Category.getInstance("cat1");
- cat1.addAppender(new org.apache.log4j.ConsoleAppender(new PatternLayout("%m%n")));
- Category cat2 = Category.getInstance("cat2");
- cat2.setPriority(Priority.INFO);
- cat2.addAppender(new org.apache.log4j.ConsoleAppender(new PatternLayout("%c - %m%n")));
-
- // set TCP port number
- try {
- thePort = Integer.parseInt(args[1]);
- }
- catch (Exception e) {
- thePort = PluggableHTTPServer.DEFAULT_PORT;
- }
-
- PluggableHTTPServer server = null;
- while (server == null) {
- try {
- server = new PluggableHTTPServer(thePort);
- server.addRequestHandler(new RootRequestHandler());
- server.addRequestHandler(new Log4jRequestHandler());
- server.addRequestHandler(new UserDialogRequestHandler());
- server.autoCreateRootPage(0);
- Thread t = new Thread(server);
- t.start();
- } catch (IOException e) {
- server = null;
- thePort++;
- }
- }
-
- } // end main
-}
diff --git a/contribs/VolkerMentzner/RootRequestHandler.java b/contribs/VolkerMentzner/RootRequestHandler.java
deleted file mode 100644
index b148327..0000000
--- a/contribs/VolkerMentzner/RootRequestHandler.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package com.psibt.framework.net;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-/**
- * This class implements a RequestHandler for the root path "/" in the PluggableHTTPServer.
- * A simple HTML message will be replied to the client.
- *
- * @author <a HREF="mailto:V.Mentzner@psi-bt.de">Volker Mentzner</a>
- */
-public class RootRequestHandler implements HTTPRequestHandler {
-
- private String title;
- private String description;
- private String handledPath;
- private String ReplyType = "Content-type: text/html\r\n\r\n";
- private String ReplyHTML = "<HTML><HEAD><TITLE>Root</TITLE></HEAD>\r\n"
- + "<BODY><H1>Root</H1>\r\n"
- + "</BODY></HTML>\r\n";
-
- /**
- * Creates a new RootRequestHandler object
- */
- public RootRequestHandler() {
- this.setTitle("root page");
- this.setDescription("root page");
- this.setHandledPath("/");
- }
-
- /**
- * Gets the content type of the reply HTTP message
- *
- * @return content type as String
- */
- public String getReplyType() {
- return this.ReplyType;
- }
-
- /**
- * Sets the content type of the reply HTTP message
- *
- * @param ReplyType - content type as String
- */
- public void setReplyType(String ReplyType) {
- this.ReplyType = ReplyType;
- }
-
- /**
- * Gets the HTML data of the reply HTTP message
- *
- * @return HTML message as String
- */
- public String getReplyHTML() {
- return this.ReplyHTML;
- }
-
- /**
- * Sets the HTML data of the reply HTTP message
- *
- * @param ReplyHTML - HTML message as String
- */
- public void setReplyHTML(String ReplyHTML) {
- this.ReplyHTML = ReplyHTML;
- }
-
- /**
- * Gets the title for html page
- */
- public String getTitle() {
- return this.title;
- }
-
- /**
- * Sets the title for html page
- */
- public void setTitle(String title) {
- this.title = title;
- }
-
- /**
- * Gets the description for html page
- */
- public String getDescription() {
- return this.description;
- }
-
- /**
- * Sets the description for html page
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * Gets the server path
- *
- * @return the server path
- */
- public String getHandledPath() {
- return this.handledPath;
- }
-
- /**
- * Sets the server path
- *
- * @param path - the server path
- */
- public void setHandledPath(String path) {
- this.handledPath = path;
- }
-
- /**
- * Handles the given request and writes the reply to the given out-stream.
- *
- * @param request - client browser request
- * @param out - Out stream for sending data to client browser
- * @return if the request was handled by this handler : true, else : false
- */
- public boolean handleRequest(String request, Writer out) {
- String path = "";
- String query = null;
- try {
- URL url = new URL("http://localhost"+request);
- path = url.getPath();
- query = url.getPath();
- if (path.equals(handledPath) == false) {
- return false;
- }
-
- out.write("HTTP/1.0 200 OK\r\n");
- if (ReplyType != null)
- out.write(ReplyType);
- if (ReplyHTML != null)
- out.write(ReplyHTML);
- out.flush();
- return true;
- } catch (Exception ex) {
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/contribs/VolkerMentzner/UserDialogRequestHandler.java b/contribs/VolkerMentzner/UserDialogRequestHandler.java
deleted file mode 100644
index 6b6205a..0000000
--- a/contribs/VolkerMentzner/UserDialogRequestHandler.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * Title: PSI Java Framework: UserDialogRequestHandler<p>
- * Copyright: PSI-BT AG<p>
- * History:
- * Date Author What's new
- * 16.04.2001 VMentzner Created
- */
-
-package com.psibt.framework.net;
-/**
- * This class implements a RequestHandler for the path "/userdialog/" in the PluggableHTTPServer.
- * A simple input form is presented in the browser where you can enter a message. This message will be sent
- * to the PluggableHTTPServer and shown in a JOptionPane MessageDialog.
- *
- * @author <a HREF="mailto:V.Mentzner@psi-bt.de">Volker Mentzner</a>
- */
-public class UserDialogRequestHandler extends RootRequestHandler {
-
- private Component parentComponent;
-
- /**
- * Creates a new UserDialogRequestHandler object
- */
- public UserDialogRequestHandler() {
- this(null);
- }
-
- /**
- * Creates a new UserDialogRequestHandler object with a parentComponent reference
- */
- public UserDialogRequestHandler(Component parentComponent) {
- this.setTitle("user dialog");
- this.setDescription("show user dialog");
- this.setHandledPath("/userdialog/");
- this.parentComponent = parentComponent;
- }
-
- /**
- * Handles the given request and writes the reply to the given out-stream.
- *
- * @param request - client browser request
- * @param out - Out stream for sending data to client browser
- * @return if the request was handled by this handler : true, else : false
- */
- public boolean handleRequest(String request, Writer out) {
- String path = "";
- String query = null;
- try {
- URL url = new URL("http://localhost"+request);
- path = url.getPath();
- query = url.getQuery();
- if (path.startsWith(this.getHandledPath()) == false) {
- return false;
- }
-
- out.write("HTTP/1.0 200 OK\r\n");
- out.write("Content-type: text/html\r\n\r\n");
- out.write("<HTML><HEAD><TITLE>" + this.getTitle() + "</TITLE></HEAD>\r\n");
- out.write("<BODY><H1>" + this.getDescription() + "</H1>\r\n");
- if ((query != null) && (query.length() >= 0)) {
- int idx = query.indexOf("=");
- String message = query.substring(idx+1, query.length());
- // replace '+' by space
- message = message.replace('+', ' ');
- // replace hex strings starting with '%' by their values
- idx = message.indexOf("%");
- while (idx >= 0) {
- String sl = message.substring(0, idx);
- String sm = message.substring(idx+1, idx+3);
- String sr = message.substring(idx+3, message.length());
- try {
- int i = Integer.parseInt(sm, 16);
- sm = String.valueOf((char)i);
- }
- catch (Exception ex) {
- sm = "";
- }
- message = sl + sm + sr;
- idx = message.indexOf("%");
- }
- // show message in a new thread
- if ((message != null) && (message.length() > 0)) {
- Thread t = new Thread(new DialogThread(parentComponent, message));
- t.start();
- }
- }
- out.write("<form name=\"Formular\" ACTION=\""+this.getHandledPath()+"+\" METHOD=\"PUT\">");
- out.write("<table>\r\n");
- out.write(" <tr><td>Send message to user</td></tr>\r\n");
- out.write(" <tr><td><textarea name=\"message\" rows=10 cols=50></textarea></td></tr>\r\n");
- out.write("</table>\r\n");
- out.write("<input type=submit value=\"Submit\">");
- out.write("</form>");
- out.write("</BODY></HTML>\r\n");
- out.flush();
- return true;
- } catch (Exception ex) {
- return false;
- }
- }
-
- /**
- * Internal class to start the user dialog in a new thread. This makes the RequestHandler return
- * immediatly
- */
- class DialogThread implements Runnable {
- private Component parentComponent;
- private String message;
-
- public DialogThread(Component parentComponent, String message) {
- this.parentComponent = parentComponent;
- this.message = message;
- }
-
- public void run() {
- JOptionPane.showMessageDialog(parentComponent, message);
- }
- }
-}
\ No newline at end of file
diff --git a/contribs/VolkerMentzner/mail-03-05-2001 b/contribs/VolkerMentzner/mail-03-05-2001
deleted file mode 100644
index 909d2c5..0000000
--- a/contribs/VolkerMentzner/mail-03-05-2001
+++ /dev/null
@@ -1,24 +0,0 @@
-Delivered-To: cgu@qos.ch
-From: "Mentzner, Volker" <V....@PSI-BT.de>
-To: "'cgu@qos.ch'" <cg...@qos.ch>
-Subject: Remote configuring log4j
-Date: Thu, 3 May 2001 08:10:25 +0200
-X-Mailer: Internet Mail Service (5.5.2653.19)
-
-Hi Ceki,
-
-I am using log4j in a GUI project. Working at the application I found
-it useful to remotely configure log4j with my favourite browser. This
-is reached by using a very small web server (PluggableHTTPServer) with
-extentions for tasks like configuring log4j. You can easily put this
-web server in an application, an example can be found in
-PluggableHTTPServer.main(). Maybe someone else can use this too, so I
-sent it to you to give it to the contrib dir if you like it.
-
-Regards
-
-
-Volker Mentzner
-
- <<pluggableServer.zip>>
-
diff --git a/docs/.cvsignore b/docs/.cvsignore
deleted file mode 100644
index 9e5bfb4..0000000
--- a/docs/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-api
\ No newline at end of file
diff --git a/docs/FAQ.html b/docs/FAQ.html
deleted file mode 100644
index a0e4748..0000000
--- a/docs/FAQ.html
+++ /dev/null
@@ -1,717 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html> <head>
-<title>log4j FAQ</title>
-</head>
-<body bgcolor=#FFFFFF>
-
-<h1 align=center>Frequently Asked Questions about log4j</h1>
-
-<h2 align=center>Ceki Gülcü
-<br>May 2001</h2>
-
-<ul>
-
-<li><p><a href=#whatIs>What is log4j?</a></p>
-
-<li><p><a href=#reliable>Is log4j a reliable logging system?</a></p>
-<li><p><a href=#prerequisites>What are the prerequisites for log4j?</a></p>
-<li><p><a href=#javadoc>Is there javadoc documentation for log4j?</a></p>
-<li><p><a href=#alternatives>What other logging packages are there?</a></p>
-<li><p><a HREF=#usageExample>Is there example code for using log4j?</a></p>
-<li><p><a href=#features>What are the features of log4j?</a></p>
-<li><p><a href=#thread-safety>Is log4j thread-safe?</a></p>
-<li><p><a href=#sample>What does log output look like?</a></p>
-<li><p><a href=#category>What are <em>Categories</em>?</a></p>
-<li><p><a href=#behavior>How can I change log behavior at runtime?</a></p>
-<li><p><a HREF=#reduce>How can I reduce the computational cost of
-debug and info statements?</a></p>
-<li><p><a HREF=#fastLogging>What is the fastest way of (not) logging?</a></p>
-<li><p><a HREF=#arrayDebug>What is the use of the <code>debug</code> method
-expecting a <code>String</code> array as one of its parameters?</a></p>
-
-<li><p><a href=#introCat>Why was the Category class introduced and how
-do I migrate from the previous String based implementation?</a></p>
-
-<li><p><a href=#namingCategories>Are there any suggested ways for naming
-categories?</a></p>
-
-<li><p><a href=#className>How do I get the fully-qualified name of a class in
-a static block?</a></p>
-
-<li><p><a href=#customLayouts>Can the log output format be
-customized?</a></p>
-
-<li><p><a href="#options">What are the configurable options for
-<code>ForBarAppender</code>?</a></p>
-
-
-<li><p><a href=#NDC>Can the outputs of multiple client request go to
-different log files?</a></p>
-
-
-<li><p><a href=#rm>Category instances seem to be create only. Why isn't
-there a method to remove category instances?</a></p>
-
-<li><p><a href=#filterByPriority>Is it possible to direct log output
-to different appenders by priority?</a></p>
-
-<li><p><a href=#many21>How do I get multiple processes to log to the
-same file?</a></p>
-
-<li><p><a href=#timestamp>If I have many process across multiple hosts
-(possibly across multiple timezones) logging to the same file using the
-method above, what happens to timestamps?</P>
-
-<LI><P><A HREF="#j2ee">Why can't Log4J find my properties file in a J2EE or WAR application?</P>
-<LI><P><A HREF="#configureandwatch">Is there a way to get Log4J to automatically reload a configuration file if it changes?</P>
-<LI><P><A HREF="#nteventlogproblems">What does the Windows NT Event Viewer complain about missing descriptions for my event messages
-when I use the NTEventLogAppender?</P>
-<LI><P><A HREF="#morenteventlogproblems">Why can't I map my category names to the categories that appear in the
-NT Event Log when I use the NTEventLogAppender?</p>
-<li><p><a href=#tax>Why should I donate my log4j extensions back to the
-project?</a></p>
-<li><p><a href=#help>What should I keep in mind when contributing code?</a></p>
-
-<li><p><a href=#bugCorrection>How fast do bugs in log4j get fixed?</a></p>
-
-<li><p><a href=#history>What is the history of log4j?</a></p>
-
-<li><p><a href=#bugs>How do I report bugs?</a></p>
-
-<li><p><a href=#download>Where can I find the latest distribution of log4j?</a></p>
-
-</ul>
-
-<hr>
-<p><a name=whatIs><h4 id="whatIs">What is log4j?</h4>
-
-log4j is a tool to help the programmer output log statements to a
-variety of output targets.
-
-<p>In case of problems with an application, it is helpful to enable
-logging so that the problem can be located. With log4j it is possible
-to enable logging at runtime without modifying the application binary.
-The log4j package is designed so that log statements can remain in
-<i>shipped</i> code without incurring a high performance cost. It
-follows that the speed of logging (or rather not logging) is capital.
-
-<p>At the same time, log output can be so voluminous that it quickly
-becomes overwhelming. One of the distinctive features of log4j is the
-notion of <i>hierarchical categories</i>. Using categories it is
-possible to selectively control which log statements are output at
-arbitrary granularity.
-
-<p>log4j is designed with two distinct goals in mind: speed and
-flexibility. There is a tight balance between these two
-requirements. I believe that log4j strikes the right balance.
-
-<a name=reliable><h4>Is log4j a reliable logging system?</h4>
-
-No. log4j is not reliable. It is a best-effort and <em>fail-stop</em>
-logging system.
-
-<p>By fail-stop, we mean that log4j will not throw unexpected
-exceptions at run-time potentially causing your application to
-crash. <b>If for any reason, log4j throws an uncaught exception,
-please send an email to the <a
-href="mailto:log4j-user@jakarta.apache.org">log4j-user@jakarta.apache.org</a>
-mailing list</b>. Uncaught exceptions are handled as serious bugs
-requiring immediate attention.
-
-
-<p>Moreover, log4j will not revert to System.out or System.err
-when its designated output stream is not opened, is not writable or
-becomes full. This avoids corrupting an otherwise working program by
-flooding the user's terminal because logging fails. However, log4j
-will output a single message to System.err indicating that logging can
-not be performed.
-
-<a name=prerequisites><h4>What are the prerequisites for log4j?</h4>
-
-<ul>
-
- <p><li>Log4j is JDK 1.1.x compatible.
-
- <p><li>The DOMConfigurator is based on the DOM Level 1 API. The
- DOMConfigurator.configure(Element) method will work with any XML
- parser that will pass it a DOM tree.
-
- <p>The DOMConfigurator.configure(String filename) method and its
- variants require a JAXP compatible XML parser, for example <a
- href="http://xml.apache.org/">Xerces</a> or Sun's
- parser. Compiling the DOMConfigurator requires the presence of a
- JAXP parser in the classpath.
-
- <p><li>The <code>org.apache.log4j.net.SMTPAppender</code> relies
- on the <a href="http://java.sun.com/products/javamail/">JavaMail
- API</a>. It has been tested with JavaMail API version 1.2. The
- JavaMail API requires the <a
- href="http://java.sun.com/beans/glasgow/jaf.html">JavaBeans
- Activation Framework</a> package.
-
- <p><li>The <code>org.apache.log4j.net.JMSAppender</code> requires
- the presence of the JMS API as well as JNDI.
-
-
- <p><li>log4j test code relies on the <a
- href="http://www.junit.org">JUnit</a> testing framework.
-
-</ul>
-
-<a name=usageExample><h4>Is there example code for using log4j?</h4>
-
-<p>There is a directory containing examples in
-<code>org/log4j/examples</code>. See also
-<code>org/log4j/xml/examples</code>.
-
-<a name=features><h4 id="">What are the features of log4j?</h4>
-
-<ul>
-
- <p><li>log4j is optimized for speed.
-
- <p><li>log4j is based on a named category hierarchy.
-
- <p><li>log4j is fail-stop but not reliable.
-
- <p><li>log4j is thread-safe.
-
- <p><li>log4j is not restricted to a predefined set of facilities.
-
- <p><li>Logging behavior can be set at runtime using a configuration
- file. Configuration files can be property files or in XML format.
-
- <p><li>log4j is designed to handle Java Exceptions from the start.
-
- <p><li>log4j can direct its output to a file, the console, an
- <code>java.io.OutputStream</code>, <code>java.io.Writer</code>,
- a remote server using TCP, a remote Unix Syslog daemon, to a
- remote listener using JMS, to the NT EventLog or even send e-mail.
-
- <p><li>log4j uses 5 priority levels, namely DEBUG, INFO, WARN, ERROR
- and FATAL.
-
- <p><li>The format of the log output can be easily changed by
- extending the Layout class.
-
- <p><li>The target of the log output as well as the writing strategy
- can be altered by implementations of the Appender interface.
-
- <p><li>log4j supports multiple output appenders per category.
-
- <p><li>log4j supports internationalization.
-
-</ul>
-
-<a name=thread-safety><h4 id="">Is log4j thread-safe?</h4>
-
-Yes, log4j is thread-safe.
-
-<a name=sample><h4 id="">What does log output look like?</h4>
-
-The log output can be customized in many ways. Moreover, one can completely
-override the output format by implementing one's own Layout.
-
-<p>Here is an example output using <em>PatternLayout</em> with
-the conversion pattern <b>"%r [%t] %-5p %c{2} %x - %m%n"</b>
-
-<pre>
-176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse order.
-225 [main] INFO examples.SortAlgo - Entered the sort method.
-262 [main] DEBUG SortAlgo.OUTER i=1 - Outer loop.
-276 [main] DEBUG SortAlgo.SWAP i=1 j=0 - Swapping intArray[0] = 1 and intArray[1] = 0
-290 [main] DEBUG SortAlgo.OUTER i=0 - Outer loop.
-304 [main] INFO SortAlgo.DUMP - Dump of interger array:
-317 [main] INFO SortAlgo.DUMP - Element [0] = 0
-331 [main] INFO SortAlgo.DUMP - Element [1] = 1
-343 [main] INFO examples.Sort - The next log statement should be an error message.
-346 [main] ERROR SortAlgo.DUMP - Tried to dump an uninitialized array.
- at org.log4j.examples.SortAlgo.dump(SortAlgo.java:58)
- at org.log4j.examples.Sort.main(Sort.java:64)
-467 [main] INFO examples.Sort - Exiting main method.
-</pre>
-
-<p>The first field is the number of milliseconds elapsed since the
-start of the program. The second field is the thread outputting the
-log statement. The third field is the priority of the log
-statement. The fourth field is the rightmost two components of the
-category making the log request. The fifth field (just before the '-')
-is the <em>nested diagnostic context</em> (NDC). Note the nested diagnostic
-context may be empty as in the first two statements. The text after
-the '-' is the message of the statement.
-
-<a name=category><h4 id="">What are <em>Categories</em>?</h4>
-
-The notion of categories lies at the heart of log4j. Categories define
-a hierarchy and give the programmer <em>run-time</em> control on which
-statements are printed or not.
-
-<p>Categories are assigned priorities. A log statement is printed
-depending on its priority <em>and</em> its category.
-
-<p>Make sure to read the <a href=manual.html>log4j manual</a>
-for more information.
-
-<a name=behavior><h4 id="">How can I change log behavior at runtime?</h4>
-
-<p>Log behavior can be set using configuration files which are parsed
-at runtime. Using configuration files the programmer can define
-categories and set their priorities.
-
-<p>The <code>PropertyConfigurator</code> defines a particular format
-of a configuration file. See also the
-<code>org.log4j.examples.Sort</code> example and associated
-configuration files.
-
-<p>Configuration files can be specified in XML. See
-<code>log4j.dtd</code> and
-<code>org.log4j.xml.DOMConfigurator</code> for more details.
-
-<p>See the various Layout and Appender components for specific
-configuration options.
-
-<p>In addition to configuration files, the user may disable all
-messages belonging to a set of priorities. See next item.
-
-<a name=reduce><h4 id="">How can I reduce the computational cost of
-debug and info statements?</h4>
-
-<p>For public releases of your code, calling the
-<code>BasicConfigurator.disable(pri)</code> method will disable
-all messages of priority <code>pri</code> and below.
-
-<p>In cases of problems with an application, technical support can
-re-enable logging by setting the <b>log4j.disableOverride</b> system
-property without changing the binary at the client's site.
-
-<a name=fastLogging><h4>What is the fastest way of (not) logging?</h4>
-
-<p> For some category <code>cat</code>, writing, <pre>
- cat.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
-</pre>
-
-<p>incurs the cost of constructing the message parameter, that is
-converting both integer <code>i</code> and <code>entry[i]</code> to a
-String, and concatenating intermediate strings. This, regardless of
-whether the message will be logged or not.
-
-<p>If you are worried about speed, then write
-<pre>
- if(cat.isDebugEnabled()) {
- cat.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
- }
-</pre>
-
-<p>This way you will not incur the cost of parameter construction if
-debugging is disabled for category <code>CAT</code>. On the other
-hand, if the category is debug enabled, you will incur the cost of
-evaluating whether the category is enabled or not, twice: once in
-<code>debugEnabled</code> and once in <code>debug</code>. This is an
-insignificant overhead since evaluating a category takes less than 1%
-of the time it takes to actually log a statement.
-
-<a name=arrayDebug><h4 id="">What is the use of the <code>debug</code>
-method expecting a <code>String</code> array as one of its parameters?</h4>
-
-This method no longer exists. Use the
-<code>Category.isDebugEnabled</code> method instead.
-
-<a name=introCat><h4>Why was the Category class introduced and how do
-I migrate from the previous String based implementation?</h4>
-
-<p>The reason was speed, speed, speed.
-
-<p>In the former implementation, when evaluating whether a category
-should be logged or not, we potentially computed a hash and performed
-an equality check multiple times, once for each higher ranking
-category. For example, if the category name was "x.y.z", we computed
-the hash of "x.y.z" and checked if it was already defined (costing an
-equality check). If not, we parsed "x.y.z" to discover that "x.y" was
-higher ranking, then computed the hash of "x.y" and checked whether it
-was defined (costing another equality check). So on, until a valid
-category was found or there were no possible categories left.
-
-<p>It turns out that for long strings, hash computations and an
-equality checks are computationally expensive operations.
-
-<p>The new Category class retains the flexibility of the former
-implementation and offers much much better performance. I would go as
-far as to claim that the performance cannot be improved upon without
-loosing functionality. <em>Please do not hesitate to debunk this
-assertion</em>. Contributions from <a
-href="mailto:Alex.Blewitt@ioshq.com">Alex Blewitt</a>, F. Hoering and
-M. Oestreicher were instrumental to these performance improvements.
-
-<p>The new syntax for defining a category is
-<pre>
- Category cat = Category.getInstance("x.y.z");
- cat.setPriority(Priority.DEBUG);
-</pre>
-
-<p>Previously, to achieve a similar effect, one had to write
-<pre>
- log.setCategory("x.y.z", "DEBUG"); // where log is an instance of Log
-</pre>
-
-<p>As of release 0.8.0, the syntax was further modified so
-that log statements (debug, info, ... methods) no longer need a log
-singleton but use a Category instance instead.
-
-<p>For some class <code>X</code> one previously wrote,
-<pre>
-package a.b.c;
-
-class X {
- static String cat = "a.b.c.X";
-
- void foo() {
- log.debug(cat, "Some foo message").
- ...
- }
-}
-</pre>
-
-This code needs to be modified as follows
-
-<pre>
-package a.b.c;
-
-import org.log4j.Category;
-
-class X {
- static Category cat = Category.getInstance("a.b.c.X");
-
- void foo() {
- cat.debug("Some foo message").
- ...
- }
-}
-</pre>
-
-<a name=namingCategories><h4>Are there any suggested ways for naming
-categories?</a></h4>
-
-<p>Yes, there are.
-
-<p>You can name categories by <strong>locality</strong>. It turns out
-that instantiating a category in each class, with the category name
-equal to the fully-qualified name of the class, is a useful and
-straightforward approach of defining categories. This approach has
-many benefits:
-
-<ul>
- <li>It is very simple to implement.
-
- <li>It is very simple to explain to new developers.
-
- <li>It automatically mirrors your application's own modular design.
-
- <li>It can be further refined at will.
-
- <li>Printing the category automatically gives information on the locality
- of the log statement.
-
-</ul>
-
-
-<p>However, this is not the only way for naming categories. A common
-alternative is to name categories by <strong>functional
-areas</strong>. For example, the "database" category, "RMI" category,
-"security" category, or the "XML" category.
-
-<p>You may choose to name categories by functionality and
-subcategorize by locality, as in "DATABASE.com.ibm.some.package.someClass" or
-"DATABASE.com.ibm.some.other.package.someOtherClass".
-
-<p><em>You are totally free in choosing the names of your
-categories.</em> The log4j package merely allows you to manage your
-names in a hierarchy. However, it is your responsibility to define
-this hierarchy.
-
-<p>Note by naming categories by locality one tends to name things by
-functionality, since in most cases the locality relates closely to
-functionality.
-
-<a name=className><h4>How do I get the fully-qualified name of a class
-in a static block?</a></h4>
-
-<p>You can easily retrieve the fully-qualified name of a class in a
-static block for class X, with the statement
-<code>X.class.getName()</code>. Note that <code>X</code> is the class
-name and not an instance. The <code>X.class</code> statement does
-<i>not</i> create a new instance of class <code>X</code>.
-
-<p>Here is the suggested usage template:
-
-<font color=BLUE><pre>
-package a.b.c;
-
-public class Foo {
- static Category cat = Category.getInstance(Foo.class.getName());
- ... other code
-
-}
-</pre></font>
-
-<a name=customLayouts><h4>Can the log output format be customized?</h4>
-
-<p>Yes. Since release 0.7.0, you can extend the <code>Layout</code>
-class to create you own customized log format. Appenders can be
-parameterized to use the layout of your choice.
-
-<a name=NDC><h4>Can the outputs of multiple client request go to
-different log files?</h4>
-
-Many developers are confronted with the problem of distinguishing the
-log output originating from the same class but different client
-requests. They come up with ingenious mechanisms to fan out the log
-output to different files. In most cases, this is not the right
-approach.
-
-<p>It is simpler to use a nested diagnostic context (NDC). Typically,
-one would <em>NDC.push()</em> client specific information, such as the
-client's hostname, ID or any other distinguishing information when
-starting to handle the client's request. Thereafter, log output will
-automatically include the nested diagnostic context so that you can
-distinguish logs from different client requests even if they are
-output to the same file.
-
-<p>See the <code>NDC</code> and the <code>PatternLayout</code> classes
-for more information. The <code>NumberCruncher</code> example shows
-how the NDC can be used to distinguish the log output from multiple
-clients even if they share the same log file.
-
-<p>For select applications, such as virtual hosting web-servers, the
-NDC solution is not sufficient. As of version 0.9.0, log4j supports
-multiple hierarchy trees. Thus, it is possible to log to different
-targets from the same category depending on the current context.
-
-<p><a name="#options"><h4>What are the configurable options for
-FooBarAppender?</h4>
-
-Log4j uses JavaBeans style configuration.
-
-<p>Thus, any setter method in <code>FooBarAppender</code> corresponds
-to a configurable option. For example, in <a
-href="api\org\apache\log4j\RollingFileAppender.html">RollingFileAppender</a>
-the <a
-href="api/org/apache/log4j/RollingFileAppender.html#setMaxBackupIndex(int)">setMaxBackupIndex(int
-maxBackups)</a> method corresponds to the <code>maxBackupIndex</code>
-option. The first letter of the option can be upper case, i.e.
-<code>MaxBackupIndex</code> and <code>maxBackupIndex</code> are
-equivalent but not <code>MAXBACKUPIndex</code> nor
-<code>mAXBackupIndex</code>.
-
-<p>Layouts options are also defined by their setter methods. Same goes
-for most other log4j components.
-
-<!-- ------------------------------------------------------------------ -->
-
-<p><a name=rm><h4>Category instances seem to be create only. Why isn't
-there a method to remove category instances?</h4>
-
-It is quite nontrivial to define the semantics of a "removed"
-category which is still referenced by the user.
-
-<p>Future releases <em>may</em> include a remove method in the
-Category class.
-
-<a name=filterByPriority><h4>Is it possible to direct log output to
-different appenders by priority?</h4>
-
-<p>Yes it is. Setting the <b>Threshold</b> option of any appender
-extending <a
-href="api/org/apache/log4j/AppenderSkeleton.html">AppenderSkeleton</a>,
-(most log4j appenders extend AppenderSkeleton) to filter out all log
-events with <em>lower</em> priority than the value of the threshold
-option.
-
-<p>For example, setting the threshold of an appender to DEBUG also
-allow INFO, WARN, ERROR and FATAL messages to log along with DEBUG
-messages. (DEBUG is the lowest priority). This is usually acceptable
-as there is little use for DEBUG messages without the surrounding
-INFO, WARN, ERROR and FATAL messages. Similarly, setting the threshold
-of an appender to ERROR will filter out DEBUG, INFO and ERROR messages
-but not FATAL messages.
-
-<p>This policy usually best encapsulates what the user actually wants
-to do, as opposed to her mind-projected solution.
-
-<p>See <a
-href="api/org/apache/log4j/examples/doc-files/sort4.lcf">sort4.lcf</a>
-for an example threshold configuration.
-
-<p>If you must filter events by exact priority match, then you can
-attach a <a
-href="api/org/apache/log4j/varia/PriorityMatchFilter.html">PriorityMatchFilter</a>
-to any appender to filter out logging events by exact priority match.
-
-
-<p><a name=many21><h4>How do I get multiple process to log to the same file?</h4></a>
-
-<p>You may have each process log to a
-<a href="api/org/apache/log4j/net/SocketAppender.html"><code>SocketAppender</code></a>.
-The receiving
-<a href="api/org/apache/log4j/net/SocketServer.html"><code>SocketServer</code></a>
-(or
-<a href="api/org/apache/log4j/net/SimpleSocketServer.html"><code>SimpleSocketServer</code></a>)
-can receive all the events and send them to a single
-log file.
-
-<p><a name=timestamp><h4>If I have many processes across multiple hosts
-(possibly across multiple timezones) logging to the same file using the
-method above, what happens to timestamps?</h4>
-
-<p>The timestamp is created when the logging event is created. That is
-so say, when the <code>debug</code>, <code>info</code>, <code>warn</code>,
-<code>error</code> or <code>fatal</code> method is invoked.
-This is unaffected by the time at which they may arrive at a remote
-socket server. Since the timestamps are stored in UTC format inside
-the event, they all appear in the same timezone as the host creating the
-logfile. Since the clocks of various machines may not be synchronized,
-this may account for time interval inconsistencies between events generated
-on different hosts.
-
-<p>While this is the intended behavior, it only recently became so due to
-a bug discovery between version 1.0.4 and 1.1b1. Versions 1.0.4 and before
-had their timestamp regenerated in the converter. In this case the timestamps
-seen in the log file would all appear in order, generated at the time they
-arrived at the log server host according to its local clock.
-
-<p><a name=j2ee><h4>Why can't Log4J find my properties file in a J2EE or WAR application?</h4>
-The short answer: the Log4J classes and the properties file are not within the scope of the same
-classloader.<P>
-The long answer (and what to do about it):
-J2EE or Servlet containers utilize Java's class loading system. Sun changed the way classloading
-works with the release of Java 2. In Java 2, classloaders are arranged in a hierarchial parent-child
-relationship. When a child classloader needs to find a class or a resource, it first delegates the request
-to the parent. Under no circumstances does it delegate the classloading to a child.
-<P>
-Earlier releases of Log4J only used the default <CODE>Class.forName()</code> mechanism for loading classes.
-Beginning with Java 2, the preferred method for loading classes is:
-<BLOCKQUOTE>
-<CODE>Thread.currentThread().getContextClassLoader().loadClass()</CODE>
-</BLOCKQUOTE>
-Resources are handled in the same manner. See the documentation for <CODE>java.lang.ClassLoader</CODE> for more details. The most
-recent versions of Log4J use the Java 2 method for loading classes.
-<P>
-So, if you're having problems, try loading the class or resource yourself. If you can't find it, neither will Log4J. ;)
-<P><A NAME=configureandwatch><H4>Is there a way to get Log4J to automatically reload a configuration file if it changes?</H4>
-<P>Yes. Both the DOMConfigurator and the PropertyConfigurator support automatic reloading through the <CODE>configureAndWatch</CODE> APIs.
-See the API documentation for more details.
-
-<P><A NAME=nteventlogproblems><H4>What does the Windows NT Event Viewer complain about missing descriptions for my event messages when I use the NTEventLogAppender?</H4>
-<P>The NT Event Viewer relies on <I>message resource</I> DLLs to properly view an event message. The NTEventLogAppender.dll contains these message
-resources, but that DLL must be copied to %SYSTEMROOT%\SYSTEM32 for it to work properly.
-
-
-<P><A NAME=morenteventlogproblems><H4>Why can't I map my category names to the categories that appear in the NT Event Log when I use the NTEventLogAppender?</H4>
-<P>Unfotunately, the category names are hardcoded within the message resource DLL (see previous question about NTEventLogAppender), so there isn't any easy way to
-override those dynamically... in fact, I don't think it's possible to do it, as you'd have to modify the DLL resources for every application. Since
-most native applications don't use the Category column anyway...
-
-<p><a name=tax><h4>Why should I donate my extensions to log4j back to the
-project?</h4>
-
-Contrary to the GNU Public License (GPL) the Apache Software License
-does not make any claims over your extensions. By extensions, we mean
-totally new code that invokes existing log4j classes. <em>You are free
-to do whatever you wish with your proprietary log4j extensions.</em>
-In particular, you may choose to never release your extensions to the
-wider public.
-
-<p>We are very careful not to change the log4j client API so that
-newer log4j releases are backward compatible with previous
-versions. We are a lot less scrupulous with the internal log4j
-API. Thus, if your extension is designed to work with log4j version
-<code>n</code>, then when log4j release version <code>n+1</code> comes
-out, you will probably need to adapt your proprietary extensions to
-the new release.
-
-Thus, you will be forced to spend precious resources in order to keep
-up with log4j changes. This is commonly referred to as the
-"stupid-tax." By donating the code and making it part of the standard
-distribution, you save yourself the unnecessary maintenance work.
-
-<p>If your extensions are useful then someone will eventually write an
-extension providing the same or very similar functionality. Your
-development effort will be wasted.
-
-<p>Unless the proprietary log4j extension is business critical, there
-is little reason for not donating your extensions back to the project.
-
-<a name=help><h4>What should I keep in mind when contributing
-code?</h4>
-
-<ol>
- <li>Stick to the existing indentation style even if you hate it.
-
- <p>Alternating between indentation styles makes it hard to
- understand the source code. Make it hard on yourself but easier
- on others. Log4j follows the <a
- href=http://java.sun.com/docs/codeconv/>Code Conventions for
- the JavaTM Programming Language</a>.
-
- <p><li>Make every effort to stick to the JDK 1.1 API.
-
- <p>One of the important advantages of log4j is its compatibility with
- JDK 1.1.x.
-
- <p><li><b>Thoroughly test your code.</b>
-
- <p>There is nothing more irritating than finding the bugs
- in debugging (i.e. logging) code.
-
- <p><li>Keep it simple, small and fast.
-
- <p>It's all about the application not about logging.
-
- <p><li>Identify yourself as the contributor at the top of the
- relevant file.
-
- <p><li>Take responsibility for your code.
-
- <p>Authoring software is like parenting. It takes many
- years to raise a child.
-
- <p><li>Did I mention sticking with the indentation style?
-
-</ol>
-
-<a name=bugCorrection><h4>How fast do bugs in log4j get fixed?</h4>
-
-<p>Rather than wait for the next release to be ready, we get bug fixes
-out of the door as soon as possible. Moreover, once a bug is found or
-reported, it is treated as <em>fire in the house</em>. All other
-activities stop until the bug is fixed.
-
-<p>Consequently, confirmed bugs are fixed after a short period
-following the initial bug report.
-
-<a name=history><h4>What is the history of log4j?</h4>
-
-The first ancestor of log4j was written for the <a
-href="http://www.semper.org">SEMPER</a> project. Jose-Luis Abad-Peiro
-wrote the initial 30 liner version that was picked up by Ceki
-Gülcü and enhanced by Andreas Fleuti. Michael Steiner,
-N. Asokan, Ceki Gülcü proposed category/priority based
-evaluation which has remained conceptually the same since 1996.
-
-<a name=bugs><h4 id="bugs">How do I report bugs?</h4>
-
-Report bugs using the <a
-href=http://nagoya.apache.org/bugzilla>Apache Bug Database</a>.
-
-<p>Please specify the version of log4j you are using. It is helpful to
-include log configurations files if any, plus source code. A short
-example reproducing the problem is very much appreciated.
-
-<a name=download><h4>Where can I find the latest distribution of log4j?</h4>
-
-<p>The log4j project is hosted at <a
-href="http://jakarta.apache.org/log4j/">http://jakarta.apache.org/log4j/</a>.
-<p>
-<hr>
-
-
-</body> </html>
diff --git a/docs/HISTORY b/docs/HISTORY
deleted file mode 100644
index fcc12c8..0000000
--- a/docs/HISTORY
+++ /dev/null
@@ -1,1362 +0,0 @@
-
-
- [*] Changes that are 100% compatible with existing client code.
- [**] Changes that requiring little or no modification to existing
- client code.
- [***] Changes requiring important modifications to existing client code.
-
- ??, 2001
-
- - Release of version 1.2alpha_0
-
- - The Category.assert method has been replaced by
- Category.assertLog. This change was mecessary because assert is a
- language reserved word in JDK 1.4. [**]
-
- - Added event reporting capability to the Hierachy class.
-
- - Added new system property "log4j.configuratorClass". This property
- allows the user to specify the custom configurator at the default
- initialization phase. This property replaces the previous
- interpretation of the reference part of "log4j.configuration"
- as the custom configurator class. This interpretation was sometimes
- erroneous and caused headaches. [*]
-
- - Introduced the Mapped Diagnostic Context or MDC class. This class
- is similar to the NDC except that the diagnistic context is based
- on a map instead of a stack. Moreover the MDC is automatically
- inherited by child threads under JDK 1.2 and above.
-
- - Corrected a performance bug in the NDC class as observed by Dan Milstein. [*]
-
- - Removed deprecated methods setOptions and getOptionStrings defined
- in the org.apache.log4j.spi.OptionHandler interface. This interface
- is implemented by most log4j appenders and layouts. In particular,
- all appenders and layouts shipped with log4j contain these
- deprecated methods. They have become totally redundant after we
- moved to JavaBeans style configuration in log4j 1.1.
-
- - Added supports java.io.Reader objects in the method doConfigure(),
- instead of only InputStream. Thanks to Mark Womack for submitting
- the relevant patch. [*]
-
-
- June 19, 2001
-
- - Release of version 1.1.3
-
- - Added a missing namespace declaration in the log4j:configuration
- element in log4j.dtd. The missing declaration caused the new
- generation of namespace aware parsers to barf when parsing log4j
- configuration files. [*]
-
- - Reduced the size of log4j-core.jar to 78KB. [*]
-
- - Minor documentation changes. [*]
-
- June 7, 2001
-
- - Release of version 1.1.2
-
- - Corrected a problem with the static initializer of the Category
- class which would use the wrong class loader to search for the
- default configuration file. The associated search algorithm has
- been also simplified. Nevertheless, the preferred method to specify
- the automatic configuration file is by setting the
- log4j.configuration system property. [*]
-
- - Documentation improvements. Added a new section to the manual
- explaining the default initialization procedure [*]
-
- - Enhancements to the org.apache.log4j.examples.appserver package. [*]
-
- - Corrected a bug in the way the NTEventLogAppender printed
- exceptions. [*]
-
- May 20, 2001
-
- - Release of version 1.1.1.
-
- - Added missing custom priority support in PropertyConfigurator. [*]
-
- - Made a number of fields protected instead of default access in
- SMTPAppender. [*]
-
- May 19, 2001
-
- - Release of version 1.1.
-
- - This release has the same code as 1.1b7. It differs only in a few minor
- documentation changes.
-
- May 9, 2001
-
- - Release of version 1.1b7
-
- - Made BasicConfigurator disable methods static as they were in log4j
- 1.0.4. Thanks to Francisco Marin for reporting the bug. [*]
-
- - Corrected a two related deadlock problems introduced while fixing
- bug 1505. Thanks to joelr@viair.com for reporting the problem. [*]
-
- - The configureAndWatch methods in Configurators did not close the
- configuration file, preventing its editing. See bug 1686. [*]
-
- - In DOMConfigurator.setParameter special character conversion now
- precedes variable substitution. This change was suggested by Steven
- Velez. The vast majority of users should be oblivious to it. [*]
-
- - The TextPaneAppender is no longer maintained and has been
- removed. It is still available under the contribs/
- directory. This change has been discussed in the log4j mailing
- lists and no one objected to the removal of the TextPaneAppender
- class.
-
- April 26, 2001
-
- - Release of version 1.1b6
-
- - Aaron Greenhouse from Carnegie Mellon SCS found a series of
- multi-threading related bugs in Category and AsyncAppender. See bug
- ids 1505 and 1507 in our bug database for exemplary bug
- reports. They are worth the detour. [*]
-
- - InvalidJarIndexException is only available in JDK 1.3. Referring
- to this exception type caused log4j 1.1b5 to break on earlier JDKs.
- We now avoid referring to it. [*]
-
- - Added PriorityRangeFilter by Simon Kitching. See the Threshold
- option in AppenderSkeleton for a more convenient alternative. [*]
-
- April 22, 2001
-
- - Release of version 1.1b5
-
- - In HTMLLayout, the Title option sets the HTML document
- title (<title>...<title>). [*]
-
- - Corrected an important performance bug in LocationInfo. Hein Couwet
- and kr@it-practice.dk have independently identified the bug. This is
- yet another example of the difference made by the number of eyeballs
- studying source code. [*]
-
- - Corrected the incorrect value returned by LocationInfo.getClassName
- method when running under IBM Visual Age. Thanks to Mathias
- Rupprecht for supplying the relevant patch. [*]
-
- - Corrected a bug where the build.sh file in the distribution would be in
- DOS CRLF format. Thanks to ma.darche@free.fr for reporting the
- problem. [*]
-
- - Corrected InvalidJarIndexException thrown in applets while
- searching for the default log4j configuration file. Thanks to
- Michael Lundahl for reporting this bug. [*]
-
- - Added missing PropertySetterException class to log4j-core.jar.
- Thanks to ma.darche@free.fr for reporting this bug. [*]
-
- April 20, 2001
-
- - Release of version 1.1b4
-
- - Mathias Bogaert observed that in version 1.1b3 the search algorithm
- for the resource used in automatic log4j configuration was
- different than in 1.0.x. Beta4 uses a more powerful mechanism which
- is also compatible with 1.0.x. [*]
-
- - Paul Glezen correctly observed that if log4j is deployed in a
- client/server mode where multiple log4j clients log to a log4j
- server, all hosts must be upgraded to version 1.1 in one go because
- the internal LoggingEvent class used in client/server communication
- changed in log4j 1.1.
-
- April 18, 2001
-
- - Release of version 1.1b3
-
- - Added a RollingFileAppenderBeanInfo class that fakes the
- maxFileSize JavaBeans property as a String type instead of a long.
- This allows us to resuscitate setMaxFileSize(long) method that was
- removed in 1.1b2 breaking 100% backward compatibility. This addition
- restores 100% backward compatibility. [*]
-
- April 18, 2001
-
- - Release of version 1.1b2
-
- - The directory structure has changed to better suit Jakarta
- conventions as follows:
-
- org/** --> src/java/org/**
- xdocs/** --> src/xdocs/**
-
- If you have a CVS checked out copy of log4j be sure to check out a
- fresh copy. [*]
-
- - Added a few jar files required at build time to build/lib so that
- it is now possible to compile log4j out of the box. [*]
-
- - Whenever a priority parameter is expected in a configuration file,
- one can now use a custom priority class. See OptionConverter.toPriority
- method for more information. Note that the <priority> element in
- log4j.dtd remains unaffected by this change. [*]
-
- - Added the setQuietMode(boolean) method to LogLog. In quiet mode
- LogLog will not output anything even in case of errors. [*]
-
- - Log4j components are now configured as JavaBeans. The setOption and
- getOptionString methods have been deprecated in OptionHandler
- interface which is implemented by most log4j components. [*]
-
- - The stack trace of a throwable passed in a logging statement is not
- parsed into a stack array which is serializable. This allows cascading of
- log4j servers to properly propagate throwable information. [*]
-
- - In XML configuration files, the <configuration> element has been
- deprecated and was replaced by the <log4j:configuration> element. [*]
-
- The following perl command can help to migrate:
-
- perl -p -i.bak -e "s/configuration/log4j:configuration/;" file1.xml .. fileN.xml
-
- - The "log4j.configDebug" system property has been replaced with the
- "log4j.debug" system property although it is still available.
- Similarly, the "configDebug" attribute has been deprecated and
- replaced with the "debug" attribute in log4j.dtd. [*]
-
-
- February 23, 2001
-
- - Release of version 1.1b1
-
- - Logging can now be disabled per Hierarchy. It can also be disabled
- using configuration files using the "disable" directive. The
- "disableOverride" directive takes precedence over the "disable"
- directive. As a result of this change the disable family of
- methods in BasicConfigurator has been deprecated and replaced by the same
- family of methods in the Hierarchy class. [*]
-
- - The FileAppender has been split into three parts: WriterAppender,
- ConsoleAppender and FileAppender. ConsoleAppender takes over the
- console logging functionality of FileAppender. As a result support
- for stream and console printing has been deprecated in FileAppender. [**]
-
- - The FileAppender now correctly outputs the header and footer of its
- layout. This problem was reported by too many users to list here. [*]
-
- - Appenders and Layouts now get to see the raw message object in
- LoggingEvent not just its rendered form. The access modifiers of
- some LoggingEvent fields were changed so that they can be accessed
- in less error-prone ways. Thanks to Jim Cakalic and Anders Kristens
- for their valuable advice. [*]
-
- - Added getLayout(), getErrorHandler(), and getFilter() to the
- Appender interface. [*]
-
- - Added getOption(key) method to the OptionHandler interface and modified
- implementations of it as appropriate. [*]
-
- - Added the much awaited DailyRollingFileAppender. [*]
-
- - The structure of the distribution changed somewhat. The log4j.jar
- files can be found under dist/. The javadoc directory has been
- moved to docs/api/. We are now totally dependent on ANT to perform
- all the steps involved in creating a release, including
- compilation, jar file creation, generation of the javadocs, and for
- the creation of the distribution tar and zip files. [*]
-
- - Removed org/apache/log4j/varia/ResilientFileAppender.java which was
- bogus to begin with. [*]
-
- - XMLLayout will now mark some output as <![CDATA[ .. ]]> so that it
- does not get interpreted by the XML parser. This was suggested by
- Mathias Bogaert like a long list of other fixes. [*]
-
- - Corrected a bug in CyclicBuffer.resize method that would not update the
- next insertion point. Thanks to Ole Bulbuk for accurately reporting
- the bug. [*]
-
- - The LoggingEvent class now supports serialization of priorities
- derived from the org.apache.log4j.Priority class. [*]
-
- - Improved the search method for finding the "log4j.properties" file in
- the static initializer of Category class. Thanks to Calvin Chan for
- supplying a better method. [*]
-
- - The code handling the FCQN (formerly instanceFQN) parameter was
- cleaned up. There is now a well-established and simple manner for
- sub-classes of Category (or wrapper classes) to define the FCQN
- variable: just define a static variable, say FCQN, consisting of
- the fully qualified class name of the subclass or wrapper, supply
- this variable as an argument to forcedLog method if and when
- the sub-class or wrapper invokes that method. [*]
-
- - Made the instanceFCQN an instance variable instead of a class
- static in Category.java. In related move, the Category constructor
- now takes an additional argument setting the instanceFCQN. This
- makes life less miserable for Category subclasses. [*]
-
- - Corrected a bug in the OptionConverter.instantiateByClassName
- method that would not return the defaultValue in case of error. Thanks
- to Matthieu Verbert for identifying this bug.
-
- - Corrected the missing stack trace in e-mails generated by the
- SMTPAppender when using certain Layouts. [*]
-
- - Updated the "Adding Conversion Characters to PatternLayout"
- document to reflect the latest changes to the code. Also added the
- org/apache/log4j/examples/appserver directory containing the
- associated example code. [*]
-
- - Added the BufferSize option to the AsyncAppender. [*]
-
- - Eliminated the SecurityExceptions thrown in Applets. Thanks Timur
- Zambalayev for reporting this bug. [*]
-
- - Fixed the erroneously thrown IOInterruptedException when the AsyncAppender
- was closed. Thanks to Tom Palmer for accurately reporting this bug. [*]
-
- January 12th, 2001
-
- - Release of version 1.0.4 (the 20th major release)
-
- - Corrected a serious bug in Hierarchy.java that would cause a
- NullPointerException depending on the order of instantiation of
- categories. Thanks to Wolfram Gewohn for reporting this bug. [*]
-
- - Corrected a bug in the getOptionsStrings method of SMTPAppender
- that omitted to mention the EvaluatorClass option. Thanks to Mark
- Balster for reporting this bug. [*]
-
- January 11th, 2001
-
- - Release of version 1.0.3 (the 20th major release)
-
- - Fixed a NullPointerException occurring in AsyncAppender after
- invoking Category.shutdown. Thanks to Frank-Olaf Lohmann for
- reporting this bug. [*]
-
- - Modified the OptionConverter.selectAndConfigure method to take an
- extra argument of type Hierarchy. This method is used internally
- and should not affect most users. [*/**]
-
- - Added the warn method to LogLog which is used internally by log4j
- to report on itself. [*]
-
- - Displaced a number of HTML files under the docs directory. The new
- structure is compatible with the jakarta site and results in a
- more consistent navigation experience. [*]
-
- - Made a few improvements in the javadocs. [*]
-
- January 11th, 2001
-
- - Release of version 1.0.2 (the 20th major release)
-
- - Added the missing build.inc file to the distribution. No code
- changed.
-
- January 10th, 2001
-
- - Release of version 1.0.1 (the 20th major release)
-
- - This version corrects some documentation and build script bugs;
- code has not changed.
-
- January 8th, 2001
-
- - Release of version 1.0 (the 20th major release)
-
- - Package hierarchy now starts at org.apache.log4j. [***]
-
- The following perl command can help in the transition:
-
- > perl -p -i.bak -e "s/org.log4j/org.apache.log4j/;" file1.java .. fileN.java
-
- - Added the fatal() family of methods to the Category
- class. Moreover, the EMERG priority has been removed from the
- Priority class. This priority has been replaced by the FATAL
- priority that is more widely accepted. This change will
- require EMERG log statements to be replaced by FATAL log
- statements. Assuming EMERG log statements are rare, this should
- have a small but bearable impact on existing client code.
-
- Moreover, the Unix Syslog priorities ALERT, CRIT and NOTICE are no
- longer recognized. Support for these priorities was minimal and
- few users should suffer from these changes. [**]
-
- - Removed the methods setRootPriority, getRootPriority as these
- methods were redundant and had been previously deprecated. [**]
-
- - Removed the DOM Level 2 dependency in DOMConfigurator. This makes
- log4j XML configurable using Sun's parser or Apache's Xerces. [*]
-
- - The static initializer of the Category class now takes the
- log4j.configuration system property to search for its configuration
- file. The type of the configurator used to parse the configuration
- file depends on the value of the log4j.configuration system
- property. [*]
-
- - Enhanced the PropertyConfigurator and DOMConfigurator to support
- customisation of independent Hierarchy instances. The
- org.apache.log4j.net.SocketServer has been enhanced to take
- advantage of this functionality. The old code of SocketServer has
- been moved to SimpleSocketServer. [**]
-
- - Enhanced the PropertyConfigurator to support variable substitution
- for all options *values* (but not keys!). [*]
-
- - Categories are now aware of the Hierarchy they are linked to. This
- will provide a basis for several performance enhancements planned
- for the future. [*]
-
- - Added support for object rendering. It is now possible to register
- an object renderer for a given object type. When the given object
- needs to be logged log4j will invoke the corresponding renderer to
- transform the object into a String.
-
- As a result of this enhancement, all the String forms of all the
- printing methods such as debug(String), info(String) have been
- removed as they are no longer necessary. This change should be
- backward compatible but requires recompilation of old client
- code. Thanks to Michael Smith for noting the recompilation
- requirement. [**]
-
- - Added support for user defined category factories in the
- PropertyConfigurator. Thus, it is now possible to configure log4j
- with a properties file and still use custom Category
- sub-classes. The DOMConfigurator had already a finer grain
- support. [*]
-
- - Added the SMTPAppender that in case of an error or fatal event
- sends an e-mail containing latest N logging events in its buffer,
- where N is chosen by the user. [*]
-
- - Added the method getInstance(Class) to the Category class. [*]
-
- - Corrected a bug in configureAndWatch method of configurators that
- would configure log4j only after an unnecessary delay. [*]
-
- November 30, 2000
-
- - Release of version 0.9.1 (the 19th public release)
-
... 7537 lines suppressed ...