diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index a618cc229c..0000000000 --- a/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -goEnv* -dist \ No newline at end of file diff --git a/BUILD-INFO.txt b/BUILD-INFO.txt new file mode 100644 index 0000000000..01310b7371 --- /dev/null +++ b/BUILD-INFO.txt @@ -0,0 +1,58 @@ +This is a detailed instruction to reproduce the log4j distribution +either to verify that the release is reproducable or to prepare +a hot-fix. + +Install VMWare Player or Workstation appropriate for machine. + +Download Ubuntu-6.06-1 desktop from http://www.vmware.com/vmtn/appliances/directory/ubuntu.html + +Launch Ubuntu 6.06-1 in VMWare Player (user name and password are ubuntu) + +Launch Synaptics Package Manager (System > Administration > Synaptic Package Manager), select all available repositories (Settings > Repositories), press Reload button to update list of available packages. Select the following packages for installation: Subversion, mingw32, sun-java6-jdk. Press Apply to install. Exit Synaptics. + +Download Maven-2.0.6 from http://maven.apache.org +Download JMX 1.2.1 Reference Implementation from + http://java.sun.com/products/JavaManagement/download.html +Download JMS 1.1 from http://java.sun.com/products/jms/docs.html +Unzip all in ~ + +Copy include/win32/jni_md.h from a Windows JDK to ~ + +From a command prompt: + +$ export JAVA_HOME=/usr/lib/jvm/java-6-sun +$ export PATH=$JAVA_HOME/bin:/home/ubuntu/maven-2.0.6/bin:$PATH +$ export JNI_WIN32_INCLUDE_DIR=/home/ubuntu +$ svn co https://svn.apache.org/repos/asf/logging/log4j/tags/v1_2_15 log4j +$ mvn install:install-file -DgroupId=com.sun.jdmk -DartifactId=jmxtools \ + -Dversion=1.2.1 -Dpackaging=jar -Dfile=~/jmx-1_2_1-bin/lib/jmxtools.jar +$ mvn install:install-file -DgroupId=com.sun.jmx -DartifactId=jmxri \ + -Dversion=1.2.1 -Dpackaging=jar -Dfile=~/jmx-1_2_1-bin/lib/jmxri.jar +$ mvn install:install-file -DgroupId=javax.jms -DartifactId=jms \ + -Dversion=1.1 -Dpackaging=jar -Dfile=~/jms1.1/lib/jms.jar +$ cd log4j +$ mvn site assembly:assembly + + +If you intended to deploy jars to the repo or update the site, +you need to copy your private keys for people.apache.org +over to ~/.ssh and update ~/maven-2.0.6/conf/settings.xml +to specify user name and key location. + + + logging.repo + USERNAME for people.apache.org + /home/ubuntu/.ssh/id_rsa + + + + logging.site + USERNAME for people.apache.org + /home/ubuntu/.ssh/id_rsa + + + +You should test your ssh connection to people.apache.org before +attempting a deployment like: + +$ ssh -l USERNAME people.apache.org diff --git a/INSTALL b/INSTALL index 75fd6db6a9..64e593b591 100644 --- a/INSTALL +++ b/INSTALL @@ -1,3 +1,18 @@ + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + =========== Using log4j @@ -7,12 +22,11 @@ Using log4j 2) Assuming you chose to extract the distribution in to the PATH_OF_YOUR_CHOICE, untarring the distribution file should create - a jakarta-log4j-VERSION directory, where VERSION is the log4j + a logging-log4j-VERSION directory, where VERSION is the log4j version number, under PATH_OF_YOUR_CHOICE. We will refer to the - directory PATH_OF_YOUR_CHOICE/jakarta-log4j-VERSION/ as $LOG4J_HOME/. + directory PATH_OF_YOUR_CHOICE/apache-log4j-VERSION/ as $LOG4J_HOME/. -3) Assuming you are using log4j version 1.2, add - $LOG4J_HOME/dist/lib/log4j-1.2.jar to your CLASSPATH, +3) Add $LOG4J_HOME/log4j-VERSION.jar to your CLASSPATH, 4) You can now test your installation by first compiling the following simple program. @@ -22,7 +36,7 @@ Using log4j public class Hello { - static Logger logger = Logger.getLogger(Hello.class); + private static final Logger logger = Logger.getLogger(Hello.class); public static @@ -48,80 +62,23 @@ JAR files ========= The log4j distribution comes with one jar file: log4j-VERSION.jar -under the $LOG4J_HOME/dist/lib/ directory. +under the LOG4J_HOME directory. This jar file contains all the class files of the log4j project, except test cases and classes from the "examples" and "org.apache.log4j.performance" packages. -================== -log4j dependencies -================== - -Log4j is based on JDK 1.1 with the following additional requirements: - - ---------------------------- - Package org.apache.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. - - ------------ - 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 version 3.7 for internal unit - testing. If you want to compile the source code in the tests/ - directory, 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. Required components from other projects are specified in -the build.properties and example of which is supplied in the -build.properties.sample file. + +log4j (as of 1.2.15) is built with Maven 2. To rebuild log4j-VERSION.jar, +place Maven 2 on the PATH and execute "mvn package". + In case of problems send an e-mail note to -log4j-user@jakarta.apache.org. Please do not directly e-mail any +log4j-user@logging.apache.org. Please do not directly e-mail any log4j developers. The answer to your question might be useful to other users. Moreover, there are many knowledgeable users on the log4j-user mailing lists who can quickly answer your questions. diff --git a/KEYS b/KEYS new file mode 100644 index 0000000000..d57054eca3 --- /dev/null +++ b/KEYS @@ -0,0 +1,93 @@ +This file contains the PGP&GPG keys of various Apache developers. +Please don't use them for email unless you have to. Their main +purpose is code signing. + +Apache users: pgp < KEYS +Apache developers: + (pgpk -ll && pgpk -xa ) >> this file. + or + (gpg --fingerprint --list-sigs + && gpg --armor --export ) >> this file. + +Apache developers: please ensure that your key is also available via the +PGP keyservers (such as pgpkeys.mit.edu). + + +Type bits /keyID Date User ID +pub 1024D/0C7C4F05 2005/06/10 Mark Dwayne Womack + Mark Dwayne Womack + +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: PGP Key Server 0.9.6 + +mQGiBEKqEj8RBADR8e9Xl0kFJqv8SspvDP8kUsivBxWVZz+HVKf0pL2wOie0LfsF +E0Y3dI7k0k8i8KXtWYmHY3dpJGLUaruqIRxPFen/No56Q7udlK5hj7vKEUb46krx +sLgik1s+WX8+61Yu5cLuGdqnfwRGuNV7uf3JF1Q78VXIyUlS4BFMXGtqjwCg//s6 +1m7N3p8AtIgma+U13rEkq9cEAJ6l9eEPgOdRx53nKkCgkVpDxxhpbg90STQ1s94f +rZIc+y5LN7FEERiQSiXvuzCwxiritiv+03sqdjYicxYZux+aladi0mHDIdgZkrAP +MrRJ+8AKs7jv+WXcyaJcja8h3IZLShszgUM6uCW4Wr8mzZ+ns/65ihe4A/jS/Gu+ +cD44A/9doNrvOnNXPD+N/R9ME3zS6FY8d5F6f8oxZOEsMll/AG1HhOR4yxOmZMOl ++ZTg9AacHWMtTkjbs6JkT6uA8+tU+txoYjofkaGcJgq/SQYen89ifXZXVkUMWjqL +ioUUKCsu4OQPnH5k3jCQp7DrkpDAgIBGZ5F3QGaYsrkVjxNoE7QnTWFyayBEd2F5 +bmUgV29tYWNrIDxtd29tYWNrQGFwYWNoZS5vcmc+iEYEEBECAAYFAkKwy1kACgkQ +vhbJXS4RQyKOYQCfddSBIMCd3kaFPvL90/piH/QIdIgAnRwG83V+KMRltnPRclDH +IcTI5unMiQBOBBARAgAOBQJCqhI/BAsDAgECGQEACgkQErKHWAx8TwWGeACgnN9d +jKDT2mjBKnApaDkMzmAaMvMAoKEcdBBCx62RPNIEBnxZ6zAxH244tC1NYXJrIER3 +YXluZSBXb21hY2sgPG1hcmt3b21hY2tAd29tYWNrbmV0LmNvbT6IRgQQEQIABgUC +QrDLXgAKCRC+FsldLhFDIgvLAJ9VsCFN6uBcObkb+UCN70ukHH5VWQCdEjPNvKCs +c4+FGbTTsEoabhoNhsuJAEsEEBECAAsFAkKqFqUECwMCAQAKCRASsodYDHxPBeU1 +AKDUIGqVzFZDXgK8PcLW8OlL2dXRmgCgwwxRkgpzuKNMnkphSZNend3VdJa5Ag0E +QqoSPxAIAPZCV7cIfwgXcqK61qlC8wXo+VMROU+28W65Szgg2gGnVqMU6Y9AVfPQ +B8bLQ6mUrfdMZIZJ+AyDvWXpF9Sh01D49Vlf3HZSTz09jdvOmeFXklnN/biudE/F +/Ha8g8VHMGHOfMlm/xX5u/2RXscBqtNbno2gpXI61Brwv0YAWCvl9Ij9WE5J280g +tJ3kkQc2azNsOA1FHQ98iLMcfFstjvbzySPAQ/ClWxiNjrtVjLhdONM0/XwXV0Oj +HRhs3jMhLLUq/zzhsSlAGBGNfISnCnLWhsQDGcgHKXrKlQzZlp+r0ApQmwJG0wg9 +ZqRdQZ+cfL2JSyIZJrqrol7DVekyCzsAAgIH/2A8l4YFI5dYs5ZV3OgspEh0Qa/N +qd/JiVWBdygI77zp9TEgUtFBPDItEjmJq8sgnao0Cd5d68l9c+PQJ1xr4fOpdug0 +YmYUgIaKutha3SSNRbD+T0WYmtTO5A4wxbsF3hYU7fvBJrt8gnO4tx6KAn/O2rRk +wPfNTZ1EdnKttZDM2Mz4OiK0SsQ9mS7zP+HPx3kzdl1Oj0Vk2tUElD1R1hVjLa/o +v5YgJCrwSD7RfCZAOEoPxXXN6StCqW1zT6HgcSR0clM5BC+ZyBJzczzD9I5+TrlH +d3ISaCOuP5NeYQdTsQ446bjiNk7LT25gNHF6U6WjmLQ3lXCz4kNoBG6fiOKIRgQY +EQIABgUCQqoSPwAKCRASsodYDHxPBQ7wAKD4DO0Se4+SvSqUKDfxhI0lJTgK0gCg +0lICv0KXT6PKyTndK+lr6K2AL4o= +=GKga +-----END PGP PUBLIC KEY BLOCK----- + + +pub 1024D/2E114322 2005-06-11 [expires: 2010-06-10] + Key fingerprint = A1A2 B554 6D43 31B2 A41E 1C07 BE16 C95D 2E11 4322 +uid Curt Arnold +sig 3 2E114322 2005-06-11 Curt Arnold +sub 2048g/209ECE57 2005-06-11 [expires: 2010-06-10] +sig 2E114322 2005-06-11 Curt Arnold + +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.3 (Darwin) + +mQGiBEKrSNQRBAC4J7udOBoC5+gVxBaPAbjXfnq12l5Pau1WD+UothePNGjI2hOp ++Rnzikk3ISgyrjiX3A8ScZYbu3iXvMpF4zknkGLdmerpf4Gz9xGeushwun+UFaFL +MX5u7LWJo9wDKzbcJJit1j/qGEg/HRp5fnVYCh0/l4dLansL60NhxtYdxwCguu2e +wZMZFroaiIXqnce7+cGDRq8D/2HgKGtEJHY3z8OtUqncWbW+RAQqdcT0Z+bMB8o6 +0UCHxUoJrFS1lA62qU3kcZ8ACPoh9xDW4X47EgNPELX81alymTI5FdqiDK7RIwzE +JlOH/8JJgC6eSwiUXJ0cOJwpMonitcpMLouxuURuPSpfE5b1mQ1gFzN5MBL8xlZQ +8IO6A/9qWwyWyQBoJud0RDIsVRosdoSBZtw9PHsURgsqfNsS2NXTWK4HjxExw1KO +AXmRlALfrH8yAShy/AyiUrwlKHG2WPTe6Etygjlr4dIxqTiCOoi+qv+H8SXW4Qy3 +SnyozJ2RlKoYG0oDTbVMsPhOFdytHjConDLL9vS14j4kN9zWB7QgQ3VydCBBcm5v +bGQgPGNhcm5vbGRAYXBhY2hlLm9yZz6IZAQTEQIAJAUCQqtI1AIbAwUJCWYBgAYL +CQgHAwIDFQIDAxYCAQIeAQIXgAAKCRC+FsldLhFDIs5CAJ9roOB39ithHoCLaDJx +l14efLwgNgCfcDBYutNX5W627kCeheDqhQbTqTi5Ag0EQqtJBRAIAN8maiGIO44S +dc9Ep3CAm0aXDeR8IQ/F253WcMQtkFBjeHEDd6/+EFT52vswMI6ZJDVV/A7pe4VM +XAdNutFmUG2gy9OJOu8gMuO3jTCLxUXyQYNF/RasOAQJgc7q1N5QgKtXVH2InQ21 +vHvlHM1fVe4rYDPr4JL2lZHe0P8kTzeQ7jI5pQnfYRJmS8I5AMQYFOiM48Pd7Sbs +Wu/rym7ikcmKUe6ZE59hSioneVP31CDMNRxCAQJVS1mZxTozsAEoh+cvmRjOD1Es +0iXvu6Sfe8+sLRL+7CNUZgixE1UFbdnNxuZGlG9qs0LGP7hDWijT1/Y4SHz4ovXx +k0oocmFtiLcAAwcIAMbY7K99hLAFVaU2ukxCSp1TNPcD+IB3gtpRieKaZvBn/LGe +CO+fNAogkw537lmpLk4nI+JiP/xWohyJ9lyEpW7yD4c9AHKNjqvEWD5Bhpnw4qKJ +ohQSVQwEeJRsftY4D0jCP9xbgPiq5woBzHWNok3BVaHqLK0fd0/+KygnT+k6cR22 +Mus9RsEisXk9Oj5lvC0miDOWof4vk2Ll8/H3xt4CXAr13n5Yj2632HolOHrFUQXT +gwc9v5CNIihOQMEiXFxHh743qbsUZktjxeYH7r8wSCV93/QQ4qELiWoUzndpkCRT +lEKenucAv6f5qqZqG7pVW8S48T99HwzwqgFX5VOITwQYEQIADwUCQqtJBQIbDAUJ +CWYBgAAKCRC+FsldLhFDIjnoAJ9ECOIrTH3adnVLOkHZnewyp2ssxwCgtLjlwZ7/ +4QtL3W5Id3nKxPFiI+c= +=9ut1 +-----END PGP PUBLIC KEY BLOCK----- diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..6279e5206d --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2005 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 007db57f8a..0000000000 --- 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 . - * - */ diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000000..0375732360 --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +Apache log4j +Copyright 2007 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/build.properties.sample b/build.properties.sample index 300f021c75..f346d4500a 100644 --- a/build.properties.sample +++ b/build.properties.sample @@ -1,22 +1,72 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + +# +# Providing a build.properties file is no longer +# necessary for an Ant build as long as one Maven build +# has previously been performed. +# + + +# base location of support directories +# +lib.home.dir=/java # The jaxp interface and a jaxp parser are required -# to build the DOMConfigurator -jaxp.home=/java/jaxp-1.1 -jaxp.jaxp.jar=${jaxp.home}/jaxp.jar -jaxp.parser.jar=${jaxp.home}/crimson.jar +# to build the DOMConfigurator. +# +# modern equivalent is xml-commons-apis.jar +# +jaxp.home=${lib.home.dir}/crimson-1.1.3 +jaxp.jaxp.jar=${jaxp.home}/crimson.jar # JavaMail API Required to build the SMTPAppender -javamail.jar=/java/javamail-1.2/mail.jar -activation.jar=/java/jaf-1.0.1/activation.jar +javamail.jar=${lib.home.dir}/javamail-1.3.2/mail.jar + +# and JavaBeans Activation Framework +# http://java.sun.com/products/javabeans/jaf/index.jsp +activation.jar=${lib.home.dir}/jaf-1.0.2/activation.jar # JMS interfaces are required to be on the classpath # in order to build the JMSAppender. -jms.jar=/java/JMQ1.1/lib/jms.jar +jms.jar=${lib.home.dir}/jms1.1/lib/jms.jar + +# Required to build the org.apache.log4j.jmx package. +jmx.home.dir=${lib.home.dir}/jmx-1_2_1-bin +jmx.jar=${jmx.home.dir}/lib/jmxri.jar +jmx-extra.jar=${jmx.home.dir}/lib/jmxtools.jar +jndi.jar=${lib.home.dir}/jndi-1_2_1/lib/jndi.jar -# Required to build the org.apace.log4j.jmx package. -jmx.jar=/java/jmx/lib/jmxri.jar -jmx-extra.jar=/java/jmx/lib/jmxtools.jar +# Required to run Checkstyle. Available from http://checkstyle.sf.net +checkstyle.jar=${lib.home.dir}/checkstyle-2.2/checkstyle-all-2.2.jar +# Velocity's Anakia task is used in the generation of the documentation +# download from http://jakarta.apache.org +velocity.jar=${lib.home.dir}/velocity-1.4/velocity-dep-1.4.jar +# Velocity's Anakia task requires JDOM, +# but Velocity 1.4 is not compatible with JDOM 1.0, but beta 8 works okay +# download for http://www.jdom.org/dist/binary/archive +jdom.jar=${lib.home.dir}/jdom-b8/build/jdom.jar +# +# CLIRR binary compatibility checker +# http://clirr.sourceforge.net +clirr-core.jar=${lib.home.dir}/clirr-0.6/clirr-core-0.6.jar +# bcel 5.1 will throw NullPointerExceptions +bcel.jar=${lib.home.dir}/bcel-5.2/bcel-5.2.jar diff --git a/build.xml b/build.xml index c730e8a744..7856a6940f 100644 --- a/build.xml +++ b/build.xml @@ -1,45 +1,83 @@ + - + - - - - - + + + + + + + + + - + - - + + + + + + + + + + + + + + - + - + + + + + + + - - @@ -53,14 +91,25 @@ - - - - + - + + + + + + + + + + + + + + + @@ -69,10 +118,11 @@ - + + @@ -86,7 +136,7 @@ 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. + then the compilation of its dependents are skipped. javadoc - build project javadoc files @@ -95,6 +145,9 @@ dist - will create a complete distribution in dist/ Setting the env variable NO_JAVADOC will build the distribution without running the javadoc target. + + release - will create a complete distribution in dist/ + using stricter settings for public distribution. @@ -109,11 +162,19 @@ - - - - - + + + + + + + + + + + + @@ -123,7 +184,8 @@ - + + @@ -139,9 +201,10 @@ - + - + + @@ -155,6 +218,9 @@ + + + + ${stem}/net/SMTPAppender.java, + ${stem}/net/JMS*.java, + ${stem}/jmx/*.java, + ${stem}/or/jms/*.java" + target="${javac.target}" + source="${javac.source}" + includeAntRuntime="${javac.includeAntRuntime}" + includeJavaRuntime="${javac.includeJavaRuntime}" + fork="${javac.fork}" + deprecation="${deprecation}" + debug="on"> + + + + + - + destdir="${javac.dest}" + includes="examples/**/*.java" + excludes="misc/*" + target="${javac.target}" + source="${javac.source}" + includeAntRuntime="${javac.includeAntRuntime}" + includeJavaRuntime="${javac.includeJavaRuntime}" + fork="${javac.fork}" + deprecation="${deprecation}" + debug="on"> + + + + + + + + + + + + + ${stem}/xml/Transform.java" + target="${javac.target}" + source="${javac.source}" + includeAntRuntime="${javac.includeAntRuntime}" + includeJavaRuntime="${javac.includeJavaRuntime}" + fork="${javac.fork}" + deprecation="${deprecation}" + classpath="${classpath}"> - + + destdir="${javac.dest}" + includes="${stem}/net/SMTPAppender.java" + target="${javac.target}" + source="${javac.source}" + includeAntRuntime="${javac.includeAntRuntime}" + includeJavaRuntime="${javac.includeJavaRuntime}" + fork="${javac.fork}" + deprecation="${deprecation}"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -251,7 +432,7 @@ + classpath="${checkstyle.jar}"/> + classpath="${javac.dest};${ant.home}/lib/crimson.jar"> @@ -278,46 +459,73 @@ - - - - - - - - + - + + - + + includes="${stem}/*.class, + ${stem}/xml/log4j.dtd, + ${stem}/config/*.class, + ${stem}/helpers/*.class, + ${stem}/spi/*.class, + ${stem}/net/*.class, + ${stem}/jdbc/*.class, + ${stem}/varia/*.class, + ${stem}/chainsaw/*.class, + ${stem}/lf5/**/*.class, + ${stem}/lf5/**/*.properties, + ${stem}/lf5/**/*.gif, + ${stem}/nt/*.class, + ${stem}/xml/*.class, + ${stem}/jmx/*.class, + ${stem}/or/*.class, + ${stem}/or/sax/*.class, + ${stem}/or/jms/*.class, + ${stem}/config/*.class" + excludes="**/UnitTest**"> + +
+ + + +
+
+ +
+
+ + + + + + + + + + + + + +
+ + + +
+
+ +
@@ -329,127 +537,329 @@ - - + destdir="${javadoc.dest}" + packagenames="org.apache.log4j, + org.apache.log4j.config, + org.apache.log4j.helpers, + org.apache.log4j.jmx, + org.apache.log4j.lf5, + org.apache.log4j.net, + org.apache.log4j.nt, + org.apache.log4j.or, + org.apache.log4j.jdbc, + org.apache.log4j.or.sax, + org.apache.log4j.or.jms, + org.apache.log4j.performance, + org.apache.log4j.spi, + org.apache.log4j.varia, + org.apache.log4j.chainsaw, + org.apache.log4j.xml, + org.apache.log4j.xml.examples" + version="true" + protected="true" + author="true" + use="true" + overview="${docs.dest}/overview.html" + doctitle="log4j version ${version}<br>API Specification" + windowtitle="Log4j Version ${version}" + header='<b>Log4j ${version}</b><!-- Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the 'License'); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +-->' + bottom="Copyright 2000-2007 Apache Software Foundation."> + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + clirr-core-${clirr.version}.jar not in maven repo. Run mvn clirr:check to download. + + + + bcel-${bcel.version}.jar not in maven repo. Run mvn clirr:check to download. + + + + log4j-${reference.version}.jar not in maven repo. Run mvn clirr:check to download. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - + + **/*.bak, **/goEnv.bat, + **/Makefile, **/goEnv.bat, + docs/pub-support/*, + ${dist.dir}/classes/org/**, + src/main/java/org/apache/log4j/test/**/*, + **/.#*, + **/*.o, **/*.res, **/*.h, **/EventLogCategories.rc"/> - - - - + includes="apache-log4j-${version}/**" + compression="gzip" /> - - - + includes="apache-log4j-${version}/**" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/build/.cvsignore b/build/.cvsignore deleted file mode 100644 index 8c25bff4e7..0000000000 --- a/build/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -velocity.log \ No newline at end of file diff --git a/build/manifest.mf b/build/manifest.mf deleted file mode 100644 index e576fed97c..0000000000 --- a/build/manifest.mf +++ /dev/null @@ -1,7 +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 407d0d79a5..0000000000 --- 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 d6707e7683..0000000000 --- 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 5f9f8442f7..0000000000 --- a/build/siteBuild.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - AnakiaTask is not present! Please check to make sure that - velocity.jar is in your classpath. - - - - - - - - - - diff --git a/contribs/CekiGulcu/AppenderTable.java b/contribs/CekiGulcu/AppenderTable.java index 3686327f87..fbb18f5aee 100644 --- a/contribs/CekiGulcu/AppenderTable.java +++ b/contribs/CekiGulcu/AppenderTable.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import org.apache.log4j.helpers.CyclicBuffer; diff --git a/contribs/CekiGulcu/Transform.java b/contribs/CekiGulcu/Transform.java index 3a20b3e789..dcd9c15396 100644 --- a/contribs/CekiGulcu/Transform.java +++ b/contribs/CekiGulcu/Transform.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.xml; diff --git a/contribs/EirikLygre/DailyFileAppender1.java b/contribs/EirikLygre/DailyFileAppender1.java index e72437747d..eb0a3d216c 100644 --- a/contribs/EirikLygre/DailyFileAppender1.java +++ b/contribs/EirikLygre/DailyFileAppender1.java @@ -1,9 +1,19 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/contribs/JamesHouse/LogTextPanel.java b/contribs/JamesHouse/LogTextPanel.java index db59e3d4c6..b8190ce6b7 100644 --- a/contribs/JamesHouse/LogTextPanel.java +++ b/contribs/JamesHouse/LogTextPanel.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.gui; diff --git a/contribs/JamesHouse/LogTextPanelExample.java b/contribs/JamesHouse/LogTextPanelExample.java index 74f1c3f6e1..c8898eec32 100644 --- a/contribs/JamesHouse/LogTextPanelExample.java +++ b/contribs/JamesHouse/LogTextPanelExample.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.gui.examples; import javax.swing.*; diff --git a/contribs/JamesHouse/TextPanelAppender.java b/contribs/JamesHouse/TextPanelAppender.java index c4d45bc1b8..bb46064935 100644 --- a/contribs/JamesHouse/TextPanelAppender.java +++ b/contribs/JamesHouse/TextPanelAppender.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.gui; diff --git a/contribs/Jamie Tsao/JMSQueueAppender.java b/contribs/Jamie Tsao/JMSQueueAppender.java index aa475efb25..9e762f5e29 100644 --- a/contribs/Jamie Tsao/JMSQueueAppender.java +++ b/contribs/Jamie Tsao/JMSQueueAppender.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.spi.LoggingEvent; diff --git a/contribs/JimMoore/LoggingOutputStream.java b/contribs/JimMoore/LoggingOutputStream.java index 053779f5d4..bc084b30db 100644 --- a/contribs/JimMoore/LoggingOutputStream.java +++ b/contribs/JimMoore/LoggingOutputStream.java @@ -1,9 +1,18 @@ /* - * 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. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ diff --git a/contribs/KevinSteppe/CompositeRollingAppender.java b/contribs/KevinSteppe/CompositeRollingAppender.java index 82f3709c52..3957f1658e 100644 --- a/contribs/KevinSteppe/CompositeRollingAppender.java +++ b/contribs/KevinSteppe/CompositeRollingAppender.java @@ -1,11 +1,20 @@ package org.apache.log4j; /* - * 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. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ import org.apache.log4j.RollingCalendar; diff --git a/contribs/KevinSteppe/JDBCTest.java b/contribs/KevinSteppe/JDBCTest.java index 70ee1abe15..8df3d18a23 100644 --- a/contribs/KevinSteppe/JDBCTest.java +++ b/contribs/KevinSteppe/JDBCTest.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.varia.test; diff --git a/contribs/KitchingSimon/DatagramStringAppender.java b/contribs/KitchingSimon/DatagramStringAppender.java index a532f9634c..f718580880 100644 --- a/contribs/KitchingSimon/DatagramStringAppender.java +++ b/contribs/KitchingSimon/DatagramStringAppender.java @@ -1,9 +1,19 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.net; diff --git a/contribs/KitchingSimon/DatagramStringWriter.java b/contribs/KitchingSimon/DatagramStringWriter.java index 9f7f6bc5a6..0120863999 100644 --- a/contribs/KitchingSimon/DatagramStringWriter.java +++ b/contribs/KitchingSimon/DatagramStringWriter.java @@ -1,9 +1,18 @@ /* - * 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. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.net; diff --git a/contribs/KitchingSimon/SingleLineTracerPrintWriter.java b/contribs/KitchingSimon/SingleLineTracerPrintWriter.java index c47e0b943a..50f8da24d1 100644 --- a/contribs/KitchingSimon/SingleLineTracerPrintWriter.java +++ b/contribs/KitchingSimon/SingleLineTracerPrintWriter.java @@ -1,9 +1,19 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.helpers; diff --git a/contribs/LeosLiterak/TempFileAppender.java b/contribs/LeosLiterak/TempFileAppender.java index 74fe216f56..0d8562a4af 100644 --- a/contribs/LeosLiterak/TempFileAppender.java +++ b/contribs/LeosLiterak/TempFileAppender.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; import java.io.File; @@ -172,7 +188,11 @@ public void close() { * @since $Date$ * * $Log$ + * Revision 1.1.2.1 2005/05/27 03:27:54 mwomack + * Fix for #35032. Added license header to .java files that did not already have a license. + * * Revision 1.1 2001/04/20 17:38:31 ceki + * * Added LeosLiterak's TempFileAppender.java * */ diff --git a/contribs/MarkDouglas/SocketNode2.java b/contribs/MarkDouglas/SocketNode2.java index a868c92691..60f63e755f 100644 --- a/contribs/MarkDouglas/SocketNode2.java +++ b/contribs/MarkDouglas/SocketNode2.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.systemsunion.LoggingServer; diff --git a/contribs/MarkDouglas/SocketServer2.java b/contribs/MarkDouglas/SocketServer2.java index 97a5414331..96caf0ea26 100644 --- a/contribs/MarkDouglas/SocketServer2.java +++ b/contribs/MarkDouglas/SocketServer2.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.systemsunion.LoggingServer; diff --git a/contribs/SvenReimers/gui/JListView.java b/contribs/SvenReimers/gui/JListView.java index 42ce7ff729..6a93ed08e6 100644 --- a/contribs/SvenReimers/gui/JListView.java +++ b/contribs/SvenReimers/gui/JListView.java @@ -1,9 +1,19 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.gui; diff --git a/contribs/SvenReimers/gui/JTableAppender.java b/contribs/SvenReimers/gui/JTableAppender.java index 3197a1dc55..32cc23ac83 100644 --- a/contribs/SvenReimers/gui/JTableAppender.java +++ b/contribs/SvenReimers/gui/JTableAppender.java @@ -1,9 +1,19 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.gui; diff --git a/contribs/SvenReimers/gui/TextPaneAppender.java b/contribs/SvenReimers/gui/TextPaneAppender.java index 117c354725..6b8fce523d 100644 --- a/contribs/SvenReimers/gui/TextPaneAppender.java +++ b/contribs/SvenReimers/gui/TextPaneAppender.java @@ -1,9 +1,19 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.gui; diff --git a/contribs/SvenReimers/gui/examples/TextPaneAppenderExample.java b/contribs/SvenReimers/gui/examples/TextPaneAppenderExample.java index 2c297fdd66..bd5f9d3a16 100644 --- a/contribs/SvenReimers/gui/examples/TextPaneAppenderExample.java +++ b/contribs/SvenReimers/gui/examples/TextPaneAppenderExample.java @@ -1,9 +1,19 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.gui.examples; diff --git a/contribs/ThomasFenner/JDBCAppender.java b/contribs/ThomasFenner/JDBCAppender.java index d82bb2023a..ac4808a599 100644 --- a/contribs/ThomasFenner/JDBCAppender.java +++ b/contribs/ThomasFenner/JDBCAppender.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* * Copyright (C) The Apache Software Foundation. All rights reserved. diff --git a/contribs/ThomasFenner/JDBCConnectionHandler.java b/contribs/ThomasFenner/JDBCConnectionHandler.java index 535007c26d..40bc1ab519 100644 --- a/contribs/ThomasFenner/JDBCConnectionHandler.java +++ b/contribs/ThomasFenner/JDBCConnectionHandler.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* * Copyright (C) The Apache Software Foundation. All rights reserved. diff --git a/contribs/ThomasFenner/JDBCIDHandler.java b/contribs/ThomasFenner/JDBCIDHandler.java index 2135f57707..cdb707e29c 100644 --- a/contribs/ThomasFenner/JDBCIDHandler.java +++ b/contribs/ThomasFenner/JDBCIDHandler.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* * Copyright (C) The Apache Software Foundation. All rights reserved. diff --git a/contribs/ThomasFenner/JDBCLogger.java b/contribs/ThomasFenner/JDBCLogger.java index ef8bc93990..e3c4f61534 100644 --- a/contribs/ThomasFenner/JDBCLogger.java +++ b/contribs/ThomasFenner/JDBCLogger.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* * Copyright (C) The Apache Software Foundation. All rights reserved. diff --git a/contribs/ThomasFenner/Log4JTest.java b/contribs/ThomasFenner/Log4JTest.java index d64e772fd4..d7bb30f720 100644 --- a/contribs/ThomasFenner/Log4JTest.java +++ b/contribs/ThomasFenner/Log4JTest.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /** // Class JDBCAppender, writes messages into a database diff --git a/contribs/ThomasFenner/code_example1.java b/contribs/ThomasFenner/code_example1.java index d5e566da1e..8d6f7d8c25 100644 --- a/contribs/ThomasFenner/code_example1.java +++ b/contribs/ThomasFenner/code_example1.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // Here is a code example to configure the JDBCAppender with a configuration-file diff --git a/contribs/ThomasFenner/code_example2.java b/contribs/ThomasFenner/code_example2.java index d799aaf357..40bb71d8c7 100644 --- a/contribs/ThomasFenner/code_example2.java +++ b/contribs/ThomasFenner/code_example2.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // Here is a code example to configure the JDBCAppender without a configuration-file diff --git a/contribs/VolkerMentzner/HTTPRequestHandler.java b/contribs/VolkerMentzner/HTTPRequestHandler.java index 1c5bad7423..d426e86867 100644 --- a/contribs/VolkerMentzner/HTTPRequestHandler.java +++ b/contribs/VolkerMentzner/HTTPRequestHandler.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.psibt.framework.net; import java.io.*; diff --git a/contribs/VolkerMentzner/Log4jRequestHandler.java b/contribs/VolkerMentzner/Log4jRequestHandler.java index 7825dc61cc..bf231a04d3 100644 --- a/contribs/VolkerMentzner/Log4jRequestHandler.java +++ b/contribs/VolkerMentzner/Log4jRequestHandler.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.psibt.framework.net; import java.io.*; diff --git a/contribs/VolkerMentzner/PluggableHTTPServer.java b/contribs/VolkerMentzner/PluggableHTTPServer.java index 25eb001d10..12aa063786 100644 --- a/contribs/VolkerMentzner/PluggableHTTPServer.java +++ b/contribs/VolkerMentzner/PluggableHTTPServer.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.psibt.framework.net; import java.net.*; diff --git a/contribs/VolkerMentzner/RootRequestHandler.java b/contribs/VolkerMentzner/RootRequestHandler.java index b1483276ef..121d39b0e3 100644 --- a/contribs/VolkerMentzner/RootRequestHandler.java +++ b/contribs/VolkerMentzner/RootRequestHandler.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.psibt.framework.net; import java.io.*; diff --git a/contribs/VolkerMentzner/UserDialogRequestHandler.java b/contribs/VolkerMentzner/UserDialogRequestHandler.java index 6b6205a5fb..4a5124dd8b 100644 --- a/contribs/VolkerMentzner/UserDialogRequestHandler.java +++ b/contribs/VolkerMentzner/UserDialogRequestHandler.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /** * Title: PSI Java Framework: UserDialogRequestHandler

* Copyright: PSI-BT AG

diff --git a/doap_log4j.rdf b/doap_log4j.rdf new file mode 100644 index 0000000000..5d4d5168b4 --- /dev/null +++ b/doap_log4j.rdf @@ -0,0 +1,51 @@ + + + + + + 2007-02-09 + + Apache log4j + + + Apache log4j provides logging services for Java. + + + + Java + + + + Apache log4j 1.2.14 + 2006-09-18 + 1.2.14 + + + + + + + + + + diff --git a/docs/.cvsignore b/docs/.cvsignore deleted file mode 100644 index 9e5bfb42d2..0000000000 --- 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 3b0b0dbd44..0000000000 --- a/docs/FAQ.html +++ /dev/null @@ -1,613 +0,0 @@ - - -log4j FAQ - - - -

-

Frequently Asked Questions about log4j

- -Ceki Gülcü and Chris Taylor -

May 2002

-
- - -
-

What is log4j?

- -log4j is a tool to help the programmer output log statements to a -variety of output targets. - -

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 -shipped code without incurring a high performance cost. It -follows that the speed of logging (or rather not logging) is capital. - -

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 hierarchical loggers. Using loggers it is -possible to selectively control which log statements are output at -arbitrary granularity. - -

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. - -

Is log4j a reliable logging system?

- -No. log4j is not reliable. It is a best-effort and fail-stop -logging system. - -

By fail-stop, we mean that log4j will not throw unexpected -exceptions at run-time potentially causing your application to -crash. If for any reason, log4j throws an uncaught exception, -please send an email to the log4j-user@jakarta.apache.org -mailing list. Uncaught exceptions are handled as serious bugs -requiring immediate attention. - - -

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. - -

What are the prerequisites for log4j?

- - - -

Is there example code for using log4j?

- -

See the examples/ directory. - -

What are the features of log4j?

- -
    - -

  • log4j is optimized for speed. - -

  • log4j is based on a named logger hierarchy. - -

  • log4j is fail-stop but not reliable. - -

  • log4j is thread-safe. - -

  • log4j is not restricted to a predefined set of facilities. - -

  • Logging behavior can be set at runtime using a configuration - file. Configuration files can be property files or in XML format. - -

  • log4j is designed to handle Java Exceptions from the start. - -

  • log4j can direct its output to a file, the console, an - java.io.OutputStream, java.io.Writer, - 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. - -

  • log4j uses 5 levels, namely DEBUG, INFO, WARN, ERROR and - FATAL. - -

  • The format of the log output can be easily changed by - extending the Layout class. - -

  • The target of the log output as well as the writing strategy - can be altered by implementations of the Appender interface. - -

  • log4j supports multiple output appenders per logger. - -

  • log4j supports internationalization. - -
- -

Is log4j thread-safe?

- -Yes, log4j is thread-safe. - -

What does log output look like?

- -The log output can be customized in many ways. Moreover, one can completely -override the output format by implementing one's own Layout. - -

Here is an example output using PatternLayout with -the conversion pattern "%r [%t] %-5p %c{2} %x - %m%n" - -

-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.
-
- -

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 level of the log -statement. The fourth field is the rightmost two components of the -logger making the log request. The fifth field (just before the '-') -is the nested diagnostic context (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. - -

What are Loggers?

- -Lggers lie at the heart of log4j. Loggers define a hierarchy and give -the programmer run-time control on which statements are -printed or not. - -

Loggers are assigned levels. A log statement is printed -depending on its level and its logger. - -

Make sure to read the log4j manual -for more information. - -

How can I change log behavior at runtime?

- -

Log behavior can be set using configuration files which are parsed -at runtime. Using configuration files the programmer can define -loggers and set their levels. - -

The PropertyConfigurator defines a particular format -of a configuration file. See also the examples/Sort.java -example and associated configuration files. - -

Configuration files can be specified in XML. See -log4j.dtd and -org.log4j.xml.DOMConfigurator for more details. - -

See the various Layout and Appender components for specific -configuration options. - -

In addition to configuration files, the user may disable all -messages belonging to a set of levels. See next item. - -

What is the fastest way of (not) logging?

- -

For some logger l, writing,

-  l.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
-
- -

incurs the cost of constructing the message parameter, that is -converting both integer i and entry[i] to a -String, and concatenating intermediate strings. This, regardless of -whether the message will be logged or not. - -

If you are worried about speed, then write -

-   if(l.isDebugEnabled()) {
-     l.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
-   }
-
- -

This way you will not incur the cost of parameter construction if -debugging is disabled for logger l. On the other -hand, if the logger is debug enabled, you will incur the cost of -evaluating whether the logger is enabled or not, twice: once in -debugEnabled and once in debug. This is an -insignificant overhead since evaluating a logger takes less than 1% -of the time it takes to actually log a statement. - -

Are there any suggested ways for naming -loggers?

- -

Yes, there are. - -

You can name loggers by locality. It turns out -that instantiating a logger in each class, with the logger name -equal to the fully-qualified name of the class, is a useful and -straightforward approach of defining loggers. This approach has -many benefits: - -

    -
  • It is very simple to implement. - -
  • It is very simple to explain to new developers. - -
  • It automatically mirrors your application's own modular design. - -
  • It can be further refined at will. - -
  • Printing the logger automatically gives information on the locality - of the log statement. - -
- - -

However, this is not the only way for naming loggers. A common -alternative is to name loggers by functional -areas. For example, the "database" logger, "RMI" logger, -"security" logger, or the "XML" logger. - -

You may choose to name loggers by functionality and -subcategorize by locality, as in "DATABASE.com.foo.some.package.someClass" or -"DATABASE.com.foo.some.other.package.someOtherClass". - -

You are totally free in choosing the names of your -loggers. The log4j package merely allows you to manage your -names in a hierarchy. However, it is your responsibility to define -this hierarchy. - -

Note by naming loggers by locality one tends to name things by -functionality, since in most cases the locality relates closely to -functionality. - -

How do I get the fully-qualified name of a class -in a static block?

- -

You can easily retrieve the fully-qualified name of a class in a -static block for class X, with the statement -X.class.getName(). Note that X is the class -name and not an instance. The X.class statement does -not create a new instance of class X. - -

Here is the suggested usage template: - -

-package a.b.c;
-
-public class Foo {
-  static Logger logger = Logger.getLogger(Foo.class);
-  ... other code
-
-}
-
- -

Can the log output format be customized?

- -

Yes. Since release 0.7.0, you can extend the Layout -class to create you own customized log format. Appenders can be -parameterized to use the layout of your choice. - -

Can the outputs of multiple client request go to -different log files?

- -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. - -

It is simpler to use a nested diagnostic context (NDC). Typically, -one would NDC.push() 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. - -

See the NDC and the PatternLayout classes -for more information. The NumberCruncher example shows -how the NDC can be used to distinguish the log output from multiple -clients even if they share the same log file. - -

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 logger depending on the current context. - -

What are the configurable options for -FooBarAppender?

- -Log4j uses JavaBeans style configuration. - -

Thus, any setter method in FooBarAppender corresponds -to a configurable option. For example, in RollingFileAppender -the setMaxBackupIndex(int -maxBackups) method corresponds to the maxBackupIndex -option. The first letter of the option can be upper case, i.e. -MaxBackupIndex and maxBackupIndex are -equivalent but not MAXBACKUPIndex nor -mAXBackupIndex. - -

Layouts options are also defined by their setter methods. Same goes -for most other log4j components. - - - -

Logger instances seem to be create only. Why isn't -there a method to remove logger instances?

- -It is quite nontrivial to define the semantics of a "removed" logger -which is still referenced by the user. Future releases may -include a remove method in the Logger class. - -

Is it possible to direct log output to -different appenders by level?

- -

Yes it is. Setting the Threshold option of any appender -extending AppenderSkeleton, -(most log4j appenders extend AppenderSkeleton) to filter out all log -events with lower level than the value of the threshold -option. - -

For example, setting the threshold of an appender to DEBUG also -allow INFO, WARN, ERROR and FATAL messages to log along with DEBUG -messages. 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 WARN messages but not ERROR or FATAL -messages. - -

This policy usually best encapsulates what the user actually wants -to do, as opposed to her mind-projected solution. - -

See sort4.lcf -for an example threshold configuration. - -

If you must filter events by exact level match, then you can -attach a LevelMatchFilter -to any appender to filter out logging events by exact level match. - - -

How do I get multiple process to log to the same file?

- -

You may have each process log to a -SocketAppender. -The receiving -SocketServer -(or -SimpleSocketServer) -can receive all the events and send them to a single -log file. - -

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?

- -

The timestamp is created when the logging event is created. That is -so say, when the debug, info, warn, -error or fatal 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. - -

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. - -

Why can't Log4J find my properties file in a J2EE -or WAR application?

- -The short answer: the Log4J classes and the properties file are not -within the scope of the same classloader.

- -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. - -

Log4J only uses the default Class.forName() mechanism -for loading classes. Resources are handled similarly. See the -documentation for java.lang.ClassLoader for more details. - -

So, if you're having problems, try loading the class or resource -yourself. If you can't find it, neither will Log4J. ;) - -

Is there a way to get Log4J to -automatically reload a configuration file if it changes?

- -

Yes. Both the DOMConfigurator and the PropertyConfigurator support -automatic reloading through the configureAndWatch APIs. -See the API documentation for more details. - -

What does the Windows NT Event -Viewer complain about missing descriptions for my event messages when -I use the NTEventLogAppender?

- -

The NT Event Viewer relies on message resource 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. - - -

Why can't I map my logger names -to the loggers that appear in the NT Event Log when I use the -NTEventLogAppender?

- -

Unfotunately, the logger 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 Logger column anyway... - -

Why should I donate my extensions to log4j back to the -project?

- -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. You are free -to do whatever you wish with your proprietary log4j extensions. -In particular, you may choose to never release your extensions to the -wider public. - -

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 -n, then when log4j release version n+1 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. - -

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. Unless the proprietary log4j -extension is business critical, there is little reason for not -donating your extensions back to the project. - -

What should I keep in mind when contributing -code?

- -
    - -
  1. Write a test case for your contribution. - -

    There is nothing more irritating than finding the bugs in - debugging (i.e. logging) code. Writing a test case takes some - effort but is crucial for a widely used library such as - log4j. Writing a test case will go a long way in earning you the - respect of fellow developers. See the tests/ directory for exiting - test cases. - -

  2. - - -

  3. Stick to the existing indentation style even if you hate it. - -

    Alternating between indentation styles makes it hard to - understand the source code. Make it hard on yourself but easier - on others. Log4j follows the Code Conventions for - the JavaTM Programming Language. - -

  4. Make every effort to stick to the JDK 1.1 API. - -

    One of the important advantages of log4j is its compatibility with - JDK 1.1.x. - -

  5. Keep it simple, small and fast. - -

    It's all about the application not about logging. - -

  6. Identify yourself as the contributor at the top of the - relevant file. - -

  7. Take responsibility for your code. - -

    Authoring software is like parenting. It takes many - years to raise a child. - -

  8. Did I mention sticking with the indentation style? - -

  9. Did I mention writing test cases? - -
- -

Where can I find the latest distribution of log4j?

- -

The log4j project is hosted at http://jakarta.apache.org/log4j/. -

-


- - - diff --git a/docs/HISTORY b/docs/HISTORY deleted file mode 100644 index 6f2a35a5eb..0000000000 --- a/docs/HISTORY +++ /dev/null @@ -1,1519 +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. - - May, 2002 - - - Release of version 1.2 - - - Fixed bug #8527. A closed TelnetAppender would continue waiting - for connections even if its ServerSocket was closed. This caused - the TelnetSocket to sit in a loop and complain about the closed - socket. [*] - - - AsyncAppender throws NullPointerException problem. The bug was actually in - AppenderSkeleton. See bug #5444 details. [*] - - - Added support for recursive variable substiuton as requested by - Eric Chastan. [*] - - - SocketNode now used a BufferedInputStream as suggested by Kok Chong - in bug report #3933. [*] - - - Fixed a problem with DailiyRollingAppender which would not - correctly compute the rollover period in certain timezones. See bug - report #7550. [*] - - - Fixed documentation bug #2726 in FAQ.html. [*] - - - In WriterAppender, fixed bug #2383 by adding a flush statement in the - writeFooter method. [*] - - - In XMLLayout, Fixed bug #7550 by escaping the method attribute. The - XMLLayout also outputs each item of a stack trace in a separate - line. [*] - - - Fixed bug #5932 as suggested by Heikki Linnakangas. The - LoggingEvent.getMDCCopy method now clones the MDC instead of just - referencing it. [*] - - (rc1) - - - The ANT build script was modified to use jar files specified in - the build.properties file instead of the CLASSPATH environment - variable. The build.properties file depends on local paths and is - supplied by the user. The build.properties.sample file is included - in the distribution. The build.sh and build.bat scripts have - been removed. This is the way many other jakarta projects build their - projects. The jar files in the dist/lib directory were also removed - since they are no longer used. [*] - - - The DOMConfigurator now interprets the string after the '#' - character in the value attribute within the element as - the fully qualified class name of a custom Level. This is consistent - with the way log4j handles "level" values in other places. The - class attribute is still honored. [*] - - - Added Oliver Burn's chainsaw tool to the core log4j - distribution. Visualisation and dynamic filtering of log events is - bound to be a very important area of activity in the future. [*] - - - Added the org.apache.log4j.jdbc.JDBCAppender which as the name - indicates sends events to a database using the JDBC API. Thanks to - Kevin Steppe for supplying the code. [*] - - - Added SocketHubAppender class as contributed by Mark Womack. This - appender sends LoggingEvent objects to a set of remote a log - servers. [*] - - - In the Category class, the getChainedPriority method has been - replaced with getEffectiveLevel method. [*] - - (beta4) - - - Replaced the custom class loading based on the thread context class - loader with a simple Class.forName() call. This solves two allied - but distinct problems encountered when using Ant with JUnit - although the bug is more general. In one instance of the - problem, log4j would throw java.lang.NoClassDefFoundError for - org/apache/log4j/AppenderSkeleton where log4j.jar and related - classes were clearly available to the Ant classloader. In another - incarnation, log4j would reject a custom appender claiming that it is - not assignable to a org.apache.log4j.Appender variable. This would - occur when log4j.jar was available to both the Ant classloader and the - system classloader. - - Thanks to Dave Herman for providing detailed scenarios exposing - the issues involved. See - http://forum.java.sun.com/thread.jsp?forum=38&thread=70946 - http://forum.java.sun.com/thread.jsp?forum=38&thread=70946#479697 - http://marc.theaimsgroup.com/?l=ant-user&m=101139178705895&w=2 - for more details. [*] - - - (beta3) - - - Fixed the complaints the compiler issued when using the - Logger.setLevel() methd. [*] - - - Incorporated the performance enhancements to ISO8601DateFormat and - AbsoluteTimeDateFormat classes submitted by Andrew Vajoczki. - - (beta2) - - - Source code written for log4j 1.1.3.jar will compile fine with - log4j 1.2X. However, code compiled for log4j 1.1.3 would previously - systematically throw "java.lang.NoSuchMethodError" runtime exceptions - when run with log4j 1.2 - prior to beta2. This problem has been - corrected in beta2. Pheew, that was a close one. [*] - - - Log4j 1.2 is now backward compatible in serialization of - LoggingEvents. For example, a 1.1.3 SocketAppedner can write to 1.2 - SocketServer. Similarly a 1.2 JMSAppender will work with 1.1.3 - JMSSink. This should ease the move to log4j 1.2, especially in - large deployments. [*] - - (alpha7) - - - The src/java/org/apache/log4j/examples/ directory moved under the - top-level directory as examples/. [*] - - - Fixed the ArrayIndexOutOfBoundsException that was thrown by - AsyncAppender if multiple threads were trying to log an event - containing an exception near simultaneously. Thanks to Thomas Tuft Muller - for reporting this bug. [*] - - (alpha1-alpha6) - - - Improved error reporting in DOMConfigurator. Thanks to Thomas Tuft - Muller for contributing the enhancement. [*] - - - Log4j is now configurable using JMX. JMX support is not of - production quality. [*] - - - Added support for different encodings in WriterAppender. Thanks to - Ben Sandee for submitting the relevant patch. [*] - - - Modified SMTPAppender to allow multiple email sessions. Thanks to - Jon Skeet for supplying the relevant patch. [*] - - - The CategoryFactory class has been replaced by the LoggerFactory - class. The makeNewCategoryInstance method has been renamed as - makeNewLoggerInstance. This change requires subclasses of Category - classes to be modified and recompiled. [**] - - - The Level class replaced the Priority class. Priority class now - extends Level to preserve backward compatibility. [*] - - - The Logger class replaced the Category class. Logger class - extends Category to preserve backward compatibility. We proudly - mark this change with a single star for 100% compatibility. [*] - - - The Category.assert method has been replaced by - Category.assertLog. This change was necessary because assert is a - language reserved word in JDK 1.4. [*/**] - - - 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. [**] - - - The disable(Level) methods in Hierarchy have been removed and been - replaced by threshold methods. [**] - - - Added buffered IO capability to FileAppender and subclasses. [*] - - - The location information (or stack information) was not correctly - transmitted by JMSAppender. [*] - - - Added event reporting capability to the Hierarchy 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 diagnostic 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 and independently by Ray Millard. [*] - - - Removed deprecated methods disable(Priority), disableAll, - disableDebug, disableInfo and enableAll in BasicConfigurator. [*] - - - Added supports java.io.Reader objects in the method doConfigure(), - instead of only InputStream. Thanks to Mark Womack for submitting - the relevant patch. [*] - - - Corrected the restart bug in DayliRollingFileAppender. Thanks to - Jim Moore for supplying 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>). [*] - - - 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) - - - Corrected a typo making NTEventLogAppender.dll register the wrong - category message file. Thanks to Peter Hayes for accurately - reporting this bug. [*] - - - The DOMConfigurator and PropertyConfigurator can now automatically - detect modified configuration files and re-read them. [*] - - - Added AsyncAppender which buffers log requests and serves them - at a later time. AsyncAppender can increase logging performance - tremendously if logging operations are interspersed with long - and blocking non CPU-intensive operations, typically I/O or network - access. For CPU intensive applications, using the AsyncAppender - will actualy degrade logging performance by 10 to 25 percent. [*] - - - The log4j.dtd has been modified to allow appenders to refer to - other appenders by IDREF. [*] - - - The DOMConfigurator has been modified to take advantage of ID/IDREF - attributes when referring to appenders. This change requires a - DOM Level-2 API compliant parser. DOM Level-2 java bindings are - available at - http://www.w3.org/TR/1999/WD-DOM-Level-2-19990923/java-binding.html. - - - Added the configure(String filename) method to DOMConfigurator. - This method requires the presence of a JAXP compatible parser. - - At this time, the only DOM2 and JAXP compatible parser seems to be - the Apache xerces parser. - - - Added the PriorityMatchFilter allowing filtering by exact priority - match. This was a common request by users. [*] - - - The configuration of a category is now an atomic operation. This - ensures that log requests are not lost while configuration is in - progress. Anders Kristensen was to first to observe the potential - problems in non-atomic configurations. [*] - - November 20th, 2000 - - - Release of version 0.9.0 (the 18th public release) - - - The "log4j" element has been renamed to "configuration" in the - log4j DTD. This change requires that log4j configuration files - written in XML be modified. Since the log4j element figures only - once in the XML file, this change should take little time. [**] - - - ResourceBundles are now category instance specific and no longer - class static. Moreover, like other properties resource bundles - are inherited from the category hierarchy. [**] - - - The jar files log4j.jar and log4j-full.jar now contain versioning - information in their respective manifest files. [*] - - - Corrected an inconsistency in the NTEventLogAppender which broke it. - - - Fixed a bug where configuration files were not parsed correctely - due to trailing spaces in option values as returned by - java.util.Properties. Trailing spaces are now removed from option - values. This bug was quite disconcerting because the - trailing spaces cannot be seen without careful examination of the - configuration file. [*] - - - Added the XMLLayout. - - The output of the XMLLayout consists of a series of log4j:event - elements. It does not output a complete XML file. The output is designed to - be included as an external entity to form a well-formed XML file. [*] - - - Added a new abstract class org.log4j.helpers.DateLayout. The TTCCLayout - now extends DateLayout. [*] - - - Corrected a rather subtle performance bug in the buffer management code - in PatternLayout. Thanks to Vladislav Dutov and Constantine - A. Plotnikov for for insisting on the correction of this bug. [*] - - - Created a new package called org.log4j.spi. This new package - holds classes that are hidden from the casual user but are needed - to extend log4j. [*] - - - Added org.log4j.varia.ExternallyRolledFileAppender to handle - externally triggered file rollovers. [*] - - - Added support for multiple hierarchy trees. [*] - - - PatternLayout can now be subclassed to support new conversion - patterns. [*] - - - Extended the DOMConfigurator and the log4j DTD to properly handle - sub-classing of Category and Priority classes. - - There have been also minor adjustments to other classes to handle - sub-classing. These changes should be invisible to users. - - All categories except the root category can be sub-classed and also - assigned priorities sub-classing org.log4j.Priority. - - The root category always exists and CANNOT be subclassed. - - The ProppertyConfigurator remains unchanged. Thus, it does not - handle extensions of the Category class. [*] - - - Added filter support in appenders. The DOMConfigurator and the - log4j.dtd have been enhanced to support filters. [*] - - - Added error handling support to appenders. The DOMConfigurator and the - log4j.dtd have been enhanced to support filters. [*] - - - Added support for correct interpretation of location information in - IBM's Visual Age environment. Thanks to Wolf Siberski for supplying - the relevant patch. [*] - - - Added getAdditivity method to Category. This feature was requested - by Constantin Mitran. (mitran at ecircle.de) [*] - - August 27, 2000 - - - Release of version 0.8.5b. - - - Corrected multiple bugs in default initialization code of - Category class. Thanks to Jeff Turner for identifying and supplying - corrective patches. [*] - - August 24, 2000 - - - Release of version 0.8.5a. - - - Added the %n conversion character to PatternLayout so that a line - separator can be specified in a platform independent way. [*] - - - In 0.8.5 internal Priority integer values were decoupled from the - Unix Syslog values. This broke SyslogAppedder. A new function - Priority.toSyslogInt is introduced to solve this bug. [*] - -Corrected a bug where the internal prtar tzvf iority integer - - August 23, 2000 - - - Release of version 0.8.5. - - - All log4j internal output is now prepended with the string - "log4j: ". This makes is easier to differentiate log4j internal - logs from messages output by other sources. [*] - - - Sub-classes of Category class must now specify their fully - qualified name when constructing logging events. This allows the %C - conversion specifier in PatternLayout to work properly even with - sub-classes or wrappers of Category. [*] - - - Added the method disableDebug to BasicConfigurator. This method - disables all print requests of debug priority regardless its - category. Similar methods disableInfo, disable, disableAll and - enableAll have also been added. Disable type methods can be - overriden by setting the log4j.disableOverride system property. - - Calling BasicConfigurator.disableInfo is equivalent to the now - deprecated flagAsShippedCode method. [*] - - - Given the above changes, the system property - log4j.shippedCodeFlagOverride is no longer honored. [**] - - - It is now possible to sub-class Category. The sub-classes may - continue to adhere to the category hierarchy. This was a frequently - requested feature. [*] - - - Corrected a problem with the additivity flag being ignored in - categories without appenders. This bug was discovered by Anders - Kristensen. [*] - - - Added a method BasicConfigurator.resetConfiguration to reset the - log4j environment. This method should be used sparingly. [*] - - - At the initialization of the Category class, the file - log4j.properties will now be searched from the search path used to - load classes. If the file can be found, then it is fed to the - PropertyConfigurator.configure(java.net.URL) method. [*] - - - Failing to access system properties within the static initializer - of BasicConfigurator class is no longer reported as an error but as - a debug message. Thanks to Gilles Schlienger for reporting this - problem with applets. [*] - - - Corrected a bug which caused infinite loops when using conversion - patterns with a single element, fortunately under very rare - circumstances. This bug was first reported by Igor Potraev, the - author of log4p. It was independently reported by Joe Haberl from - IBM Global Services. [*] - - - Added a mechanism to lazily remove references to dead threads in - the NDC class. Indeed, in previous versions calling NDC.pop within - a thread but forgetting to call to NDC.remove before exiting (that - thread) resulted in a memory leak. [*] - - - Corrected a huge memory leak in SocketAppender. This leak was due - to the ObjectOutputStream indefinitely holding a reference for each - written to the stream. Thanks to Dan MacDonald for very accurately - describing this bug. [*] - - - The log and l7dlog methods in Category no longer ignore the shipped - code flag. This bug was reported by Mario Schomburg. [*] - - - Added missing NDC information to LoggingEvent.writeObject - method. [*] - - - Corrected handling of SocketException in SocketNode. Thanks to - Gerald Gutierez (ggutierez@emobiledata.com) for reporting this and - the previous problem. [*] - - - Phased out custom shell scripts to build java documentation and jar - files in favor of Jakarta's ANT. It was becoming a nuisance to keep - the ANT build file in sync with the custom shell scripts. [*] - - - May 11, 2000 - - - Release of version 0.8.4d. - - - The NT EventViewer no longer complains about missing message 4096. - - - Minor corrections in documentation. - - - Added missing icons GIFs into the distribution. - - - SocketNode now attempts to close the socket when exiting. Thanks to - Moses Hohman (mmhohman@rainbow.uchicago.edu) for noting this. - - - Removed the com.ibm.log4j from the javadoc directory. This seems to - confuse VAJ. Thanks to Steve Ashcroft for reporting this problem. - - May 5, 2000 - - - Release of version 0.8.4c. - - - As a result of the infinite loop problem (see next item), added - over 800 new test cases to stress-test the code in CategoryFactory - class where category creation occurs. [*] - - - Under certain rare circumstances the Category.getInstance method - entered an infinite loop. Thanks to Mario Schomburg from IBM Global - Services / Hannover for identifying this problem and proposing a - patch. [*] - - - DOMConfigurator and the log4j.dtd were out of sync on the type of - the priority directive. As a result, priority directives all - defaulted to DEBUG. Thanks to Peter (petervt@users.sourceforge.net) - for accurately reporting this bug. [*] - - - Minor additions to the FAQ. [*] - - - Added the NumberCruncher example showing how the NDC class can be - used to distinguish output from different clients. [*] - - - Added the %x conversion specifier to the TTCC_CONVERSION_PATTERN in - the PatternLayout class. This is consistent expected output of - Trivial.java example. Thanks to Jerome (schrom@users.sourceforge.net) - for reporting this bug. [*] - - May 3, 2000 - - - Release of version 0.8.4b. - - - The value of the additivity option would not be parsed properly by - the ProperytConfigurator if the line containing the option - contained trailing spaces. [*] - - - Release of version 0.8.4a. - - - The localized logging methods (l7dlog) omitted priority based - evaluation and erroneously logged all requests. [*] - - May 1, 2000 - - - Release of version 0.8.4. - - - The close method was added to the Appender interface allowing - appender implementations to release any resources they may have - allocated. [*] - - - The package naming scheme of changed from "com.ibm.log4j.*" to - "org.log4j.*". The new naming reflects the open source nature of - the project and is consistent with the URL http://www.log4j.org. [***] - - - Added internationalization support. See the newly introduced l7dlog - methods in Category class. [*] - - - In the FileAppender, the File option now admits variable - substitution. For example, if "java.home" system property is set - to /home/xyz and the File option is given the value - "%{java.home}/test.log", then File option will be interpreted as - "/home/xyz/test.log". - - Thanks to Avy Sharell (sharell@online.fr) for contributing this - feature. [*] - - - SocketAppender is now officially part of the package. It is capable - of sending logging events to a remote SocketNode. The SocketNode - logs events according to server (local) policy. For example, a - client can log events to a local file and also send them to a - remote server (a SocketNode). This server can log the event to any - number of files, to the console, to any number of TextPaneAppenders - and even re-transmit the event to another server, and so forth. - - This paradigm is common in most logging systems, e.g. Syslog and NT - Event Log. Many thanks to Andrew Harrison for showing a way to - actually implement the paradigm. [*] - - - The Category.callAppenders method now accepts a LoggingEvent - instead of creating one itself. This was necessary to accommodate - events generated at a remote client. [*] - - - LoggingEvent class changed slightly to support remote logging. The - category field (a Category) has been replaced by the categoryName - field (a String). [*] - - April 14, 2000 - - Release of version 0.8.3b - - - Corrected a bug in Category.removeAppender(String) which would - never remove the desired appender. Thanks to Moses Hohman for - reporting this bug. - - Release of version 0.8.3a - - - Corrected a bug RollingFileAppender which would throw an uncaught - exception in case output file could not be opened for - writing. Thanks to Vinay Aggarwal for signaling this problem. - - April 13, 2000 - - - Release of version 0.8.3. - - - The log4j.override key defined in BasicConfigurator has been - renamed to log4j.shippedCodeFlagOverride. [**] - - - The getCurrentCategories method in the Category class would not - return the correct value. Thanks to Timothy Potter - (tpotter@agency.com) for reporting this problem. [*] - - - Appenders now admit a priority threshold as an option. All requests - with a priority lower than the appender's threshold priority are - ignored by the appender. [*] - - - Integrated Christopher Taylor's DOMConfigurator parsing XML - configuration files. [*] - - - The jar file log4j-net.jar has been replaced by log4j-full.jar. It - contains DOMConfigurator.class in addition to the com.ibm.log4j.net - package. [**] - - - Added support for the ANT build tool. Thanks to Christopher Taylor - for supplying the build.xml file. ANT is available form - http://jakarta.apache.org. [*] - - - FileAppender's File option now accepts the values "System.out" or - "System.err". If one these values is suppiled in a configuration - file then the output is directed to the corresponding stream. - Moreover, the default constructor of FileAppender no longer sets - System.out as an output target nor does it define a default - layout. [*] - - - Added caller class (C), caller file name (F), caller line number - (L), caller method name (M) conversion specifiers to the - PatternLayout class. - - The category conversion specifier now takes an optional precision - modifier allowing the user to control the number of right most - components in the category name that will be printed. - - Corrected a bug occuring when the caller file name and line number - information were unavilable due to JIT compilation. In that case, - the PatternLayout would not properly use the rest of the available - location information. [*] - - The above enhancements and bug-fixes originate from comments by - Nelson Minar (nelson@monkey.org). - - March 23, 2000 - - - Release of version 0.8.2. - - - The SimpleLayout and TTCCLayout are replaced by the PatternLayout - in the log4j.jar file to keep its size small. These two layouts are - still part of the package. - - - The PatternLayout class is introduced. This new layout is - configurable using a conversion pattern which is parsed at - runtime. This allows the user to choose the output layout without - writing any code and only at a marginal performance cost compared - to the dedicated layouts such as SimpleLayout and TTCCLayout. The - PatternLayout also allows the user to determine minimum and maximum - field lengths. - - The PatternLayout was written by Jim Cakalic - (jim_cakalic@na.biomerieux.com). [*] - - - All internal components now use LoggingEvent instances to specifiy - logging information. - - - Corrected a problem with a missing variable initialization in - SyslogAppender. This caused NullPinterException to be thrown when - logging exceptions. - - Added a default constructor to SyslogAppender. The lack of this - constructor caused PropertyConfigurator to throw a - java.lang.InstantiationException when the appender type was set to - be SyslogAppender. - - Thanks to Yves Bossel (ybossel@opengets.cl) for accurately - identifying these bugs. - - Modified some other related option handling code in - SyslogAppender. [*] - - - Made NDC.get public access instead of default access. Thanks to - Y. J. Chun (monac@softonnet.com) for reporting this problem. [*] - - - PropertyConfigurator now parses the additivity option for - categories. [*] - - - Corrected the value of the ADDITIVITY_PREFIX constant to match the - documented value, that is "log4j.additivity". [**] - - - Corrected a really bad bug where System.out would be closed when - PropertyConfigurator.configure was called. Thanks to Christopher - Taylor (cstaylor@pacbell.net) for tracking and reporting this bug. [*] - - - The PropertyConfiguator now prints debug messages if the flag - "log4j.configDebug" is defined in the configuration - file. Previously, only if the system property "log4j.configDebug" - was set would debug messages be printed. A question by Shawn - Kircher (skircher@vninet.com) induced this change. [*] - - - In AbsoluteTimeDateFormat, DateTimeDateFormat and ISO8601DateFormat - the separator between the seconds and milliseconds has been changed - to comma from full stop, in order to be compliant with ISO8601's - preferred sign. Thanks to Jim Cakalic - (jim_cakalic@na.biomerieux.com) for pointing out this discrepancy - with the standard. [*] - - - Corrected a bug where RollingFileAppender would not work - properly on Windows systems. Thanks to Heinz Richter - (heinz.richter@ecmwf.int) for noting this problem. - - February 19, 2000 - - - Release of version 0.8.1. - - - Core classes are now independent of the format of the options - file. Configurable core classes implement the OptionHandler - interface. OptionHandlers allows configurators to learn the - relevant option names. The configurator feeds option values to the - OptionHandler which configures itself. - - As a result of these changes, the Init class has been broken down - to two separate classes: the BasicConfigurator and the - PropertiesConfigurator. [**] - - An XML configurator for 0.8.0 has been already written by - Christopher Taylor (cstaylor@pacbell.net). - - - Added multiple appender support per category. The appenders follow - the category hierarchy, i.e. a child category inherits the - appenders of its parents. - - - Added an assert() method to the Category class. Steven Marcus - (srnm@awaretechnologies.com) requested this addition. [*] - - - Atomatic stack printing is no longer supported. This was an unused - and unreliable feature which unnecessarily complicated the - code. [*] - - - log4j now emits a single warning message when no appender to write to - could be found. This is typically the case when the user forgets - to configure the log4j environment. This change was suggested by - Jim Cakalic (jim_cakalic@na.biomerieux.com). [*] - - - RollingFileAppender adds file roll over capability--implemented by - Heinz Richter (heinz.richter@ecmwf.int). [*] - - - Corrected a bug where a java.lang.NoClassDefFoundError would be - thrown because com.ibm.log4j.helpers.SyslogTracerPrintWriter was - not included in log4j.jar. Thanks to Jim Cakalic (jim_cakalic@na.biomerieux.com) - for signaling this bug. [*] - - February 9, 2000 - - - Release of version 0.8.0. - - - There has been an important API changes. The Log, NOPLog and ILog - classes have been removed. Their functionality has been migrated to - the Category class. [***] - - In this release, instead of writing - - ILog.debug(CAT, "Some message."); - - one will write - - CAT.debug("Some message."); - - Arndt Schoenewald <arndt@ibm23093i821.mc.schoenewald.de> observed that - one could use the Category objects directly for logging. - - - It is no longer possible to instantiate Category objects directly. - Instead, one would use the factory method - Category.getInstance(String name). [***] - - There category instantiation code was moved to CateogryFactory - class. This class has package visibility and remains hidden from - the user. - - This stylistic improvement was suggested by Luke Blanshard - (luke@quiq.com). - - - The Init class offers methods to initialize the log4j - environment. The Init.flagAsShippedCode method replaces the NOPLog - class. - - - Changes in the documentation to reflect the API changes. - - - The NDC.cloneStack and inherit methods now tolerate null-stacks. [*] - - - January 29, 2000 - - - Release of version 0.7.5. - - - TTCCLayout now takes a java.text.DateFormat object as a - parameter. The task of formatting the date is delegated to this - object. - - Added four classes extending the java.text.DateFormat class. These - are RelativeTimeDateFormat, AbsoluteTimeDateFormat, - DateTimeDateFormat and ISO8601DateFormat classes. - - Thanks to Arndt Schoenewald <arndt@ibm23093i821.mc.schoenewald.de> - for suggesting the ISO8601 date format. - - These four classes can be parametrized with a particular - TimeZone. The TTCCLayout class now accepts a new configuration file - option called "TimeZone". - - These four DateFormats are less malleable than the - java.text.SimpleDateFormat but they are also much faster. - - As a consequence of these changes, the setRelativeTime, - setDatePrinting methods in TTCCLayout have been removed along with - the associated configuration file options RelativeTime, - DatePrinting and TimePrinting. [**] - - The current code is inspired by code contributed by - Heinz Richter (heinz.richter@ecmwf.int). - - - The Log.emerg method has been deprecated. If you use statements of - EMERG priority, please use the Log.log form instead. [**] - - - Added getDepth and setMaxdepth methods to the NDC class. This makes - it easier to manage the nested context depth especially when - callees push but forget to pop. - - - Moved the documentation in com/ibm/log4j/package.html to - com/ibm/log4j/overview.html. Many users were failing to read the - com/ibm/log4j/package.html description due to the unfortunate - layout of the text. Hopefully more people will read the package - overview in its present location. - - - Added the com.ibm.log4j.net package for doing remote logging using - TCP sockets. This is still experimental code. - - - Added new debug, .., emerg methods that do not require a category - parameter. They assume the "root" category, that is the decision to - whether print or not is made by comparing the statement's priority - with the default priority. [*] - -January 21, 2000 - - - Release of version 0.7.4. - - - Added a new ILog.init method accepting an Appender and a - configuration file as parameters. - - - FileAppender's setWriter and setFile methods where not instantiating - a new tracer. This caused stack traces to be lost! SyslogAppender - had a similar problem. [*] - - - The FileAppender and SyslogAppender where not calling the layout's - readConfig method to set layout specific options. Thanks to Heinz - Richter (heinz.richter@ecmwf.int) for reporting this bug. [*] - - - Corrected a bug in Log.log() method where the appender was always - called with Priority.DEBUG. Thanks to Oliver Boehm - (Oliver.Boehm@abaxx.de) for reporting this bug. [*] - -January 14, 2000 - - - Release of version 0.7.3. - - - Added Syslog compatibility. One can now choose (at runtime) between - remote syslog logging or file logging. [*] - - Syslog logging performance, although not appalling, is significantly - slower than file logging. - - - Priority class was enriched with the previously missing priorities - NOTICE, ALERT and CRIT. The internal constants were also aligned with - the syslog counterparts. [*] - - - Added the Log.log method to support the new priorities. [*] - - - TracerPrintWriter is now an independent class instead of being a - nested top-level class in Tracer. [*] - - - A number of writers, namely the SyslogWriter, SyslogQuietWriter, - SyslogTracerPrintWriter, were added to the helper package. [*] - - - Log.force method was removed. The various Appender.doAppend - implementations take over its functionality. [*] - - - FileAppender and SyslogAppender now use QuietWriter. QuietWriter is - a FilterWriter which hides exceptions and instead emits a single - warning message to System.err. [*] - - - The layout is now an initialization parameter to the appender - type. Previously, the layout and the appender where independent - parameters to the Log constructor. [**] - - - Many small improvements and corrections in the documentation. - Syslog related documentation remains sparse. - - - ILog.init() and ILog.init(String configFile) have been changed to - call ILog.init(,,,) with "com.ibm.log4j.Log.class" as the first - parameter. This makes it easier for people to get familiar with log4j. [**] - - - Added missing files to the make directory. These files are useful - for those wishing to use the log4j make environment. Thanks to "Lee - Hall" <LHall@JavaFoundry.com> for reporting this omission. [*] - - Until recently the make environment failed to compile RMI stubs in - a single run. This nagging problem has been corrected thanks to - help from Thomas Eirich (IBM Zurich Research Lab). - -January 4, 2000 - - - Release of version 0.7.2. - - - Some users have been rightly complaining about the verbosity - TTCCLayout's date output. The full date output is now shortened to - "dd MMM YYYY HH:mm:ss.SSS" for example, "06 Nov 1994 08:49:37.459" - In addition, users may now choose to print only time information, - as in "08:49:37.459". [*] - - - The package now uses Writer instead of OutputStream as its output - target. This makes the log4j code smaller and easier to - understand at the cost of a slight performance degradation. As a - result of this change a few method names in FileAppender class were - changed. [**] - - - Preliminary experiments with SyslogAppedner and SyslogLayout show - that syslog compatibility is not far away. The difficultly is - adding syslog compatibility without making radical changes to the - current log4j architecture. - - - Corrected a bug in the NOPLog.createInstance method which always - created a Log singleton even if the system property "log4j.logType" - was set to NOPLog. Thanks to Robert Gottofrey - (Robert.Gottofrey@wdr.com) for reporting this bug and the - associated test case. - - - Removed the inconsistent "Layout" configuration option in - Log.readConfig(). This change should be transparent to most - users. [*/**] - -December 20, 1999 - - - Release of version 0.7.1. - - - The LogCreationManager class has been removed. Its functionality - has been transfered to the createInstance and getInstance methods - in the Log and NOPLog classes. The new way of creating instances is - both simpler and less error prone although just as flexible. [**] - - As a result of these changes, the init family of methods in the - ILog class have been adjusted to the new way of creating the log - singleton. - - - The Appender interface has been introduced. The method of writing a - log statement into an output stream can now be varied by using a - different Appender. The new FileAppender offers the same - functionality that was previously part of the Log class. [**] - - - Changed the time format used in TTCCLayout to be of the form "Day, - dd MMM YYYY HH:mm:ss.SSS GMT" for example, "Sun, 06 Nov 1994 - 22:49:37.459 GMT". This format is almost the same as the format - specified in RFC 1123 and also the format recommended in RFC - 2616. The only difference is the additional milliseconds - information. [*] - - - The layout specific options were not read from the configuration - file due to a missing instruction. Many thanks to Vikram Sridharan - (Vikram.Sridharan@alysis.com) to patiently pointing out this - omission to an unbelieving maintainer. [*] - -December 16, 1999 - - - Release of version 0.7.0. - - - Version 0.7.0 and above will be distributed under the IBM Public - License (IPL). The IPL is an approved open source license (see - http://www.opensource.org/licenses/ for a list). It grants similar - rights to the previous ALPHAWORKS license agreement, in particular, - the right to redistribute and to modify the package. - - - The Log class can now be parameterized with a Layout object. - Layouts determine the format of what is printed, where as the Log - class decides when to print and to where. [**] - - As a result of this modularization, the CGULog and NOPCGULog - classes no longer exists. CGULog class has been replaced with the - TTCCLayout (Time Thread Context Category). This should make it - easier to create new log output formats. - - Some time in the near future, the Log class will be further broken - down to allow different strategies for writing to output streams. - - - Renamed com.ibm.util.log hierarchy to to com.ibm.log4j. I wanted to - do this for some time. I feel release 0.7.0 was the last - opportunity to do so. I am sorry for the the trouble caused by this - change. [**/***] - - - New NDC class. This class implements nested diagnostic contexts as - suggested by Neil Harrison in the article "Patterns for Logging - Diagnostic Messages" part of the book "Pattern Languages of Program - Design 3" edited by Martin et al. Nested diagnostic contexts is a - nifty feature that was missing up to now. [*] - - The StressNDC test class seems to break JDK 1.2.2 beta on AIX. On - Linux and NT using sun's JDK 1.2.2 it seem to work OK. In any case, - tests done with StressNDC and associated perl script seem to - indicate that the NDC class is bug-free. - - - Corrected a date formatting bug in CGULog class where on some - environments the wrong month was printed. Thanks to Christopher - Williams (Christopher_Williams@mail.northgrum.com) for signaling - this bug. Also changed the month format from a number to a three - letter abbreviation such as "Jan", "Feb", ..., "Dec". The new - format is unambiguous regardless of local date format. [*] - -December 8, 1999 - - - Release of version 0.6.2. - - - Clearer documentation with still much room for improvement. - - - Corrected a bug in the Tracer class which always used the Unix line - separator instead of the system specific separator. Thanks to - Vikram Sridharan (Vikram.Sridharan@alysis.com) for singaling this - bug. [*] - - - Corrected a runaway comment which gulped the CGULog.readConfig - method. [*] - - - Added the init family of methods to the ILog class to ease the - setup of a basic logging environment. Thanks to Mark Donszelmann - (Mark.Donszelmann@cern.ch) for this enhancement. [*] - - - Just an hour after releasing version 0.6.1 detected and corrected a - bug where the Tracer class would correctly print Exception stack - trace but not the type of the Exception. Replaced the - distribution on www.zurich.ibm.com without changing the version - number. I hope nobody is using the intermediary (and buggy) release - of 0.6.1. [*] - -November 16, 1999 - - - Release of log4j version 0.6.1. - - - Better documentation with still much room for improvement. - - - For consistence sake, added setDefaultPriority and - getDefaultPriority methods to the Category class and deprecated - setDefaultPriority in the Log.class. [**] - - - Corrected a major bug where if two categories were homonyms the - second instance would not be properly initialized. - - - Increased the speed of Exception logging from about 4000 - microseconds to about 1000. It seems that for some people Exception - logging is performance critical. Improved implementation is a - variant of Nocolai's (XNH@crisplant.com) implementation. [*] - -November 9, 1999 - - - Release of log4j 0.6.0 with incomplete documentation. - - - Added a stress test program to debug the new Category class. It - turns out that the test program was as hard to get right as the - Category class. Given the favorable results of the stress test I am - quite confident that the new class is now bug free. This assumption - has been proven to be wrong. See above. - - - Created a new class called Category to manipulate categories - instead of plain Strings. The new class is just as easy to use. - However, the evaluation of whether to log or not to log is at least - 10 times faster. The NOP class performance remain unaffected by the - change. (You can't improve on the performance of an empty function - call.) - - Many thanks to Alex Blewitt "Alex.Blewitt@ioshq.com" for his - valuable comments. He was the first to observe that finding Strings - in a hash table was an expensive operation. - - This change will require some recoding on your part. See the FAQ - for more details. [***] - - - Modified the force in Log and CGULog method to use a byte[] buffer - instead of a StringBuffer. The old code was clearer but the new one - is at least 25% faster. [*] - - - Added regression testing. - - - We now enforce a policy where the OutputStream set by - setOutputStream is a user managed resource whereas the OutputStream - opened using setLogFile is the Log class' responsibility. - - The setLogFile method now closes any previous OutputStream if only - if opened through setLogFile. If the previous OutputStream was - opened by the user and set through setOutputStream the previous - OutputStream is untouched. - - Similarly, setOutputStream will close any previous OutputStream if - and only if it was opened using setLogFile. - - - Added a new method logOutputStreamExists to the Log class allowing - the programmer to check if there is already an opened stream before - trying to set a new one. A stream can be opened as a byproduct of - reading the configuration file. - - - Changed the behavior of the (private) Log.Append method in case of - failure to write to the OutputStream. - - Previously, in case of failure, we reverted to System.err. Now, we - emit a warning message and discard all future log messages. The - new behavior is consistent with our current unreliable logging - semantics. The change prevents an otherwise functional program - from failing because the terminal is flooded with logging messages. - - - Renamed the iLog to ILog to remain consistent with our class naming - scheme. The initial intention was to add ILog and deprecate - iLog. However, I am running CVS on a fat16 partition, causing - serious problems when files differ only in case. - - - Corrected a bug where the LogFileName was not remembered. Thanks to - Jens for signaling this bug. - -October 28, 1999 - - - Release of log4j v0.5a - - - Now the programmer can choose to truncate the log file instead of - always appending to it. This functionality was first requested and - intially implemented by "Jens Uwe Pipka" jens.pipka@gmx.de. [*] - - - setLogFile now opens the requested file instead of having the - Append function open it later. Cleaned up some related code in the - Append function. Although nobody has requested it, there is still - no method to close the log file. This is harder to implement - reliably than it sounds. [*] - - - Simplified setLogOutputStream so that it does no longer return the - previously set OutputStream. [*] - -October 27, 1999 - - - Released log4j v0.5 - - - Joe Walker (joe@eireneh.com) observed that the - LogCreationManager.getSingleton mechanism was cumbersome. There is - now a new class iLog (indirect Log) which hides the need to call - getSingleton. Performance testing on my 233Mhz Thinkpad shows that - this indirection has small performance impact on non-logged calls - in the order of 40 nanoseconds. The impact on logged calls is - negligible. [*] - - - Added a jar file to the distribution. The jar file contains only - the files you would need to use log but not other classes needed - for testing nor examples. - - - Corrected a bug where CGUNOPLog was not integrated to the Makefile. - - - Added new public methods isDebugEnabled and isInfoEnabled to allow - programmers to check whether a debug/info statement will be logged - without incurring the cost of message parameter construction. This - addition was suggested by Luke Blanshard Luke@quiq.com. [*] - - - Renamed the private method evaluate to isEnabled. Also made it - final with no apparent speed gains. In addition, made the - Log.force method public. [*] - - - New syntactic sugar debug, ..., emerg, methods to log objects. [*] - - - Modified the interface to deal with Throwables and not just - Exceptions. My thanks to Luke Blanshard for signaling this "bug". [*] - - - Added more tests to the LogPerformance class. In particular, to - test the influence of indirect debug calls. - - - Added a "make" mini-tutorial for those who want to modify the code. - - - License updated to standard alphaWorks license allowing - modifications to source code. However, this license explicitly - requires that modifications be communicated back to alphaWorks. - -October 15, 1999 - - - Initial availability on alphaWorks. - -Refer to the FAQ for the lineage of the package. - - diff --git a/docs/TODO b/docs/TODO deleted file mode 100644 index 7fd2756501..0000000000 --- a/docs/TODO +++ /dev/null @@ -1,75 +0,0 @@ -TODO - - -- Add support for string options in SocketAppender - -- Add a properties file option to log4j:configure in XML. - -- Really quiet mode for LogLog. - -- Deprecate configure element in DTD. - -- Support for duplicate appender suppression in configurators. -- Clean up the association of renderers and hierarchies -- FailOverAppender - -- Graceful congiguration merging - -- Integrate tons of GUI code. -- JDBCAppender. -- Time based rolling. -- SSL logging. -- Authenticated logging. - - -ONGOING TASKS - -- Better test suite. -- Better documentation. - - -DONE - -- Add priority#priorityClass to Configurators -- log4j: namespace in DTD -- Mapped Diagnostic Contexts -- Allow the raw message object to be seen by Appenders and Layouts. -- Complete multiple hierachy support. -- JMSAppender. -- SMTPAppender. -- Automatic configuration file reloading. -- AsyncAppender. -- Written a short user manual. -- Added XMLLayout. -- In DOMConfigurator added support for sub-classes of Category - implementing OptionHandler interface. -- Added support for Filters and ErrorHandlers. -- Added support for multiple hierarchy trees. -- Added support for sub-classing of Category. -- Socket logging. -- Integration with NT event logging. -- File name option form environment. -- com.ibm.log4j to org.log4j package renaming. -- DOMConfigurator. -- PatternLayout replaces TTCCLayout and SimpleLayout. -- TTCCLayout customizable with any DateFormat. -- Better control over NDC stack. -- Act as UNIX syslog client. -- Make Priority intances flyweights. -- ILog.init methods with Layout argument, with Appender argument. -- Contexts a la Logging Pattern of N. Harrison. -- Improve catBag lookup speed with wrapper classes. -- Truncate functionality. -- ILog facade to LogCreationManager.getSingleton() -- JAR file -- New syntactic sugars to log objects and not strings. -- Exception --> Throwable - - - - - - - - - diff --git a/docs/TROUBLESHOOT.html b/docs/TROUBLESHOOT.html deleted file mode 100644 index 82590c2a60..0000000000 --- a/docs/TROUBLESHOOT.html +++ /dev/null @@ -1,301 +0,0 @@ -<html> -<head> -<title>Troubleshooting log4j - - - -

Log4j troubleshooting

- -

Ceki Gülcü Paul Glezen -
February 2002 -

- -
- -

Here is a list of commonly encountered problems when using log4j:

- - - -
- -

log4j tells me to initialize properly.

- - Logging output is written to a target by using an appender. If no - appenders are attached to a category nor to any of its ancestors, you - will get the following message when trying to log: -

- -
-log4j: No appenders could be found for category (some.category.name).
-log4j: Please initialize the log4j system properly.
-
- -

Log4j does not have a default logging target. - It is the user's responsibility to ensure that all - categories can inherit an appender. This can be easily - achieved by attaching an appender to the root category.

- - -

Duplicates in log4j output.

- -

The reason for observing duplicates in log4j output is - either due to having added the same appender multiple times - to the same category (typically root) or having added the - same appender to different categories ignoring the fact that - appenders are inherited cumulatively.

- -

log4j does not eliminate appender duplicates. In other - words, if you add the same appender to a category n - times, that appender will be invoked n times to - append to its target.

- -

A slightly different cause is adding different appenders - all sharing the same underlying output target to some - category. In the most common occurrence of this phenomenon, - the BasicConfigurator.configure() method is invoked multiple - times. Each time it is invoked, this method adds an appender - with a System.out target to the root - category.

- -

One other common mistake is to forget that appenders are - inherited cumulatively from the hierarchy. For example, if - you add an appender, say A, to the root - category, all other categories will inherit A - as an appender. Thus, if you add A to a - category, say C, then an enabled statement of - category C, will print to A twice, - once because A is in root and once because it - is in C.

- -

Options are not parsed correctly.

- -

The PropertyConfigurator relies on - java.util.Properties class to read in the - configuration file. This class preserves spaces in - options. For example,

- -
-fruit=orange  
-
-is returned as an option having the key "fruit" and the - value "orange ".

- -

The spaces in the value, i.e. "orange ", are due to - invisible spaces at the end of the example shown above. Thus, some of - the options might not be interpreted correctly due to trailing - spaces.

- -

Caller location information is printed as a "?" - character.

- - Location information is extracted automatically by the PatternLayout - conversion patterns %C, %F, %M and %L. However, some just-in-time - (JIT) compilers make it impossible to extract location information. It - is also possible that the compiler that generated the byte code may - have omitted the LineNumber table as is done by -O option of javac - and jikes.

- -

You can remedy this problem by disabling the JIT compiler and by - compiling the code without the -O option.

- -

In wrappers or subclasses of Category - -

Wrappers or subclasses of Category need supply their - fully qualified class name to the Category.log method or -to Category.forcedLog methods so that the caller location -information can be extracted correctly.

- -

This approach will work correctly in all cases except if - the class invoking the extended category instance has the - same prefix as the extended category class. For example, - calling an instance of com.foo.BarCategory - from the com.foo.BarCategoryTest class will - not yield the correct caller information. To circumvent - this "bug", either perform the tests from a class with a - different name or add a dot to the fully qualified name of - the extending class that you supply to - Category.log to - Category.forcedLog methods. For the - com.foo.BarCategory example, supply the - string "com.foo.BarCategory.".

- - -

ClassCastException when -instantiating a Category subclasses.

- -

This exception is thrown because log4j does not support -homonyms. For example, the following will systematically throw a -ClassCastException

- -
-  Category c1 = Category.getInstance("bad");
-  MyCategory c2 = (MyCategory) MyCategory.getInstance("bad");
-
- -where MyCategory is a subclass of -Category. The problem occurs because the second -getInstance invocation will retrieve the category created -in the fist invocation. This instance is a Category -object and cannot be cast to MyCategory.

- -

By default, the PropertyConfigurator will - create and configure - org.apache.log4j.Category objects. Thus, if - you try to instantiate a category subclass for an already - existing category, and try to cast it to the subclass - type, you will systematically get a - ClassCastException.

- -

To address this problem, the - PropertyConfigurator admits the - log4j.categoryFactory key. The value of this - key will be used as the factory to invoke when - instantiating Category objects. - -

The DOMConfigurator has a finer grain - method for setting the class of the category object to instantiate. - - - - -

Log4j class not found/defined

- -

Naturally you should check the classpath. But you should also -be aware of the presence of multiple classloaders in the JVM: -

    -
  1. the bootstrap classloader -
  2. the extension classloader -
  3. the application classloader -
-

If you place log4j.jar in the jre/lib/ext directory -but place user-defined extensions to log4j in the application -classloader classpath, log4j configurators will not find them. - -

Servlet, JSP and EJB containers inside of application servers -usually have their own special classloaders in addition to the -three mentioned above. While this provides for a greater -degree of separation for different webapps, EJB containers and the -application server runtime itself, it can provide headaches to the -uninitiated. - -

Classloaders are usually hierarchically related. The bootstrap -loader forms the root with the extension loader as its child. The -application loader is the child of the extension loader and it's -this "app loader" that we use by default when we write standalone -Java programs. - -

Upon receiving a class load request, the classloader usually -delegates it to the parent before attempting to service the request. -This allows the bootstrap and extension loaders to deliver any classes -that are part of the JDK or its extensions. Only after this delegation -fails will the classloader attempt to find the class itself. Note that -classloaders do not delegate requests to children. - -

Application servers often use the application loader for its runtime -classes and create separate classloaders for its webapp and EJB -containers. These additional classloaders may descend directly -from the app server's runtime classloader. If log4j is placed in the -classpath of a webapp classloader, another webapp classloader will not -necessarily see it. EJBs wouldn't see it either. If log4j is intended -to be made available to all objects participating in the app server, it -should be included in the classpath of a classloader high enough in the -classloader hierarchy to be seen by all classloaders. - -

A good article on classloaders with examples using IBM's WebSphere -application server can be found -here -in PDF format. - -

I cannot log to syslogd under linux.

- -If you are trying to log to the Unix syslog under Linux using the SyslogAppender, -then the Linux syslog daemon must be configured to accept log input -from the network. Otherwise, you will get an IOException: -connection refused. - -

This can be done by adding the -r option when starting -the daemon. Or more precisely: - -

    -
  1. Login as the root user -
  2. Edit file /etc/rc/init.d/syslog -
    -case "$1" in
    -  start)
    -        echo -n "Starting system logger: "
    -        daemon syslogd -r
    -
    - -
  3. /etc/rc/init.d/syslog restart - -
- -

log4j:WARN No such property [xyz] in some.appender.or.layout

- -

If during log4j configuration you get a warning about an inexistent -property, then you have probably misspelled a property or entered a -truly unrecognized property for the component you are trying to -configure in the configuration file. - -

Log4j version 1.0 did not complain about unrecognized properties -whereas log4j version 1.1 and later do complain. - - - - - - diff --git a/docs/critique.html b/docs/critique.html deleted file mode 100644 index 55c2d704f6..0000000000 --- a/docs/critique.html +++ /dev/null @@ -1,294 +0,0 @@ - - - - -JSR47 vs. log4j - - - - -

-

JSR47 vs. log4j

-
- -
-

I consider it quite distasteful to criticize other people's work, -especially in public. However, since the logging API included in JDK -1.4 will be considered by many as the "standard", I feel compelled to -react. I am not alone in my criticism of JSR47, Greg Davis has his own -set of comments. - -

The JDK 1.4 logging API is a result of the JSR47 -effort, led by Graham Hamilton. - -

Before delving into the details, some historical perspective is in -order. I am the founder of the log4j project. I participated in the -specification of the JSR47 API, although not as an expert. In 1999, I -was still working for IBM and could not join the experts group because -big blue had already Chris Barlock as a member in the JSR47 experts -group. Chris is the author of IBM's -logging toolkit for Java. - -

On the surface, his toolkit has heavily influenced the JSR47 -API. In particular, the two share the same basic components, namely -loggers, levels, handlers and formatters. In log4j, these components -are called categories, priorities, appenders and layouts -respectively. Pairwise, they are identical in purpose. As such, the -terms logger and category, level and priority, handler and appender, -formatter and layout will be used interchangeably in the remainder of -this document. - -

Even after a casual review it should be apparent that the log4j and -JSR47 APIs are very similar. For one, they are the only -logging APIs which are based on a named hierarchy. If you understand -one API, then understanding the concepts of the other should be a -breeze. There are differences however. - -

On Parents and Children

- -

In JSR47, a parent logger knows about its children but not the -other way around. Children do not have links to their parent. For -example, the logger named "foo" knows about -"foo.bar1" and "foo.bar2". However, -"foo.bar1" has no links to its parent "foo". - -

In log4j, it is exactly the other way around. A log4j category -contains a link to its parent but a parent does not have links to its -children. - -

At first glance, this might look like a mundane implementation -detail but it is actually quite fundamental. - -

    -

  1. Configuration order matters - -

    In JSR47, when you set the level of a logger, say -wombat, JSR47 traverses the tree below -wombat. In other words, the levels for all the loggers -descending from wombat are overwritten. This can be a -very expensive operation for large trees. In particular, for the most -common case where one sets the level of the root logger. However, -performance is not the point I am trying to make. - -

    In log4j, changing the priority of a category involves the change -of a single field. Children categories dynamically inherit the -priority of their parent by traversing the hierarchy tree upwards. - -

    It follows that with JSR47 if you configure the level for logger -"foo.bar1" before configuring the level for "foo", then the latter -instruction will overwrite the first exactly as if the first -instruction for configuring "foo.bar1" had never -existed. Configuration order dependence is not a show stopper but -it is something that will bite you time and again. - -

    In contrast, in log4j categories can be configured in any -order. You never have to worry about configuration order. - -

  2. Limited inheritance - -

    In JSR47, a logger does not walk the hierarchy to inherit its level -but possesses a copy of it. - -

    Unfortunately, in the JSR47 API, handlers cannot be inherited -because it would be prohibitively expensive to let each logger to -contain a distinct Vector of all inherited handlers, especially in -large trees. - -

    To circumvent this problem by JSR47 defines global handlers. A -logger logs to global handlers and to the handlers attached to itself -directly. It does not inherit any handlers from the -hierarchy. - -

    In log4j, appenders are inherited additively from the hierarchy. A -category will log to the appenders attached to itself as well as the -appenders attached to its ancestors. This might not seem like much -until the day you need handler inheritance; probably a week after you -decide to adopt a logging API. - -

    Similarly, in log4j resource bundles are inherited from the -hierarchy. In JSR47, a resource bundle must be attached to -each logger individually. There is no resource bundle inheritance in -JSR47. In practice, this means that you have to choose between -internationalization and the benefits of the named logger -hierarchy. It's one or the other. This limitation is particularly -surprising because support for internationalization is advocated as -one of the primary advantages of the JSR47 API. - -

- -

Bogus Levels

- -

JSR 47 defines the levels ALL, SEVERE, -WARNING, INFO, CONFIG, -FINE, FINER, FINEST and -OFF. Experience shows that the levels ALL -and OFF are never needed. The SEVERE and -CONFIG levels are unique to JSR47. - -

Having three debugging levels FINE, -FINER, FINEST could seem like a good -idea. However, you will soon discover that even when by yourself, it -is hard to decide when to use which level. It is plain impossible in -groups. - -

Log4j in contrast has a limited but self-evident set of priorities: -FATAL, ERROR, WARN, -INFO and DEBUG. - -

Both JSR47 and log4j allow the user to extend the set of -priorities. Log4j supports subclasses of priorities in configuration -files as well as across the wire. JSR47 does not. - -

Limited functionality

- -

Log4j has appenders capable of logging to the console, to files, to -Unix Syslog daemons, to Microsoft NT EventLoggers, remote servers, to -JMS channels, automatically generate email etc. It can roll log files -by size or date and log asynchronously. - -

JSR47 can log to the console, to files, to sockets and to a memory -buffer. - -

Log4j has an extensible and powerful layout called the -PatternLayout. JSR47 offers the much weaker -SimpleFormatter as an alternative. - -

Log4j supports configuration through property files as well as XML -documents. JSR47 currently admits only property files. Moreover, the -language of JSR47 configuration files is very weak. In particular, you -can only configure one instance of a given handler class. This -means that you can log to just one file at a time. - -

Other differences

- -

There are many other details in which log4j differs from -JSR47. Even if the log4j core is small, the project contains a total -of over 30'000 lines of well-tested code. JSR47 contains about 5'000 -lines of code. - -

Log4j has been around for a number of years, enjoys the support of -five active developers (committers) and is being used in thousands of -projects. Our site gets over 500 downloads each and every day, and the -numbers are on the rise. Log4j has been ported to C++ and -Python. Companies are also offering commercial products extending -log4j. - -

Here is a short list of opensource projects or sites that are known -to use log4j. - -

- - -

By the way, log4j runs fine under JDK 1.1 and above. JSR 47 will -run under JDK 1.4 and only under JDK 1.4. Interestingly enough, no -package shipped with JDK 1.4 is using the JSR47 API. - -

Brian R. Gilstrap has re-written JSR47 API to -run under JDK 1.2 and 1.3. He has also published an article -in JavaWorld. This is all very promising but since -java.util.logging is under the java.* -namespace, when running under JDK 1.3, you will systematically -encounter: -

-Exception in thread "main" java.lang.ExceptionInInitializerError: java.lang.SecurityException: Prohibited package name: java.util.logging
-        at java.lang.ClassLoader.defineClass(ClassLoader.java:477)
-        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
-        at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
-        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
-        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
-        at java.security.AccessController.doPrivileged(Native Method)
-        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
-        at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
-        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
-        at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
-        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
-
- -

Jochen Hiller had observed this problem in early 2001 when he -implemented the JSR47 API by wrapping log4j. - -

Note that any third-party implementation using the -java.* or javax.* namespaces violates Sun's -trademark on Java. Without explicit permission from Sun, such software -remains under the threat of litigation. - -

Error Handling

- -In JSR 47 when an error occurs then either a -RunTimeException is thrown to the user or (in handlers -only) an internal field is set. In the first case, the -RunTimeException will cause your application to crash. In -the latter case, you can retrieve the last caught exception in the -handler by querying the getException method of that -handler. The former is totally unacceptable while the latter is -impractical. - -

In log4j, under no circumstances are exceptions thrown at the -user. However, all appenders have an associated -ErrorHandler. This ErrorHandler is invoked -by the appender whenever a handler-specific error occurs. By default, -log4j appenders are associated with an -OnlyOnceErrorHandler which emits a message on the console -for the first error in an appender and ignoring all following errors. - -

An ErrorHandler can implement an arbitrary error -handling policy. For example, after a failure to write to a database a -JDBCAppender can be redirected to fall back on a -FileAppender. This functionality is supported in XML -configuration files. You do not need to change a single line of client -code. - -

But again who cares about errors, right? - -

Performance

- -

Logging performance must be studied in three distinct cases: when -logging is turned off, when turned on but due to priority comparison -logic not enabled, and when actually logging. Please refer to the log4j manual for a more detailed -discussion of logging performance. - -

When logging is turned on, log4j will be about two to three times -slower to decide whether a log statement is enabled or not. This is -due to the dynamic nature of log4j which requires it to walk the -hierarchy. To give you an idea about the figures involved, under JDK -1.4 beta, we are talking about 90 nanoseconds instead of 30 -nanoseconds on a 800Mhz Intel processor. In other words, one -million disabled logging requests will cost under a second in both -environments. - -

In a shipped binary, you can turn off logging entirely and both -APIs will perform identically. Note that if one is not careful, the -cost of parameter construction before invoking a disabled log -statement will overwhelm any other performance consideration. -Regardless of the API you decide to use, logging statements should -never be placed in tight loops, for example, before or after an -element swap instruction in a sort algorithm. - -

In log4j, caller localization information is optional whereas in -JSR47 it is always extracted. Since the extraction of caller -localization is a very slow operation, in the common case where caller -information is not needed, log4j will log the same information 4 to -100 times faster. - - - - diff --git a/docs/deepExtension.html b/docs/deepExtension.html deleted file mode 100644 index 05e0eb7cbb..0000000000 --- a/docs/deepExtension.html +++ /dev/null @@ -1,735 +0,0 @@ - - -Extending Log4J - - - - -

-

Adding Conversion Characters to PatternLayout

- - "Paul Glezen" - - January 2001

-
- -
-

Abstract

- -

-This article describes a systematic way to extend the -log4j API to include -additional attributes formatted using the -PatternLayout -class. -

-


-

Contents

- -

-


-

Introduction

- -

-This article assumes familiarity with the log4j -User Manual. It builds on fundamental -classes described in both the User Manual and the -Javadoc API. To assist in illustrating the -concepts, a simple case study will be developed along side the -explanations. The resulting classes may be used as a template -for your own extensions. Condensed (i.e. statements compressed, -comments removed) snippets of the case study code -are included in this document. - -

The Case Study

-The case study was developed in a CORBA environment in which the -following information for each log entry was needed. The letters in -parenthesis represent the corresponding character to be used by the -PatternLayout -class for formatting. - -

-

    -
  • Host Name (h) - the IP address or hostname of the physical machine - on which the Category was running. -
  • Server Name (s) - The name of the application server process. In - this context, a server refers to a process that accepts requests - rather than referring to a machine. The term host refers to a - physical machine. Several servers may run on the same host. -
  • Component Name (b) - Rather than getting bogged down on what - constitutes a component, let's assume for the case study that a component - is a unit of software worth denoting in the logs. -
  • Version (v) - the version of the component from which the log entry - originated. -
-

-It seems odd to use "b" for the component name. Presently -PatternLayout -already defines both "C" and "c" for class name and category name respectively. - -

A Peek Under the Hood

-

-In principle, if the steps described below are followed closely, there is -not a need to understand how the extended classes will be used by log4j. -But sometimes software development can be entirely unprincipled. You may -wish to extend log4j in a different manner than describe here or you may -make a mistake that requires knowledge of what is really going on. (Heaven -forbid there be a mistake in this document). In any case, it doesn't hurt -to get an idea of what's going on. -

-The following describes a "typical" logging scenario in the un-extended log4j -case. -

-

    -
  1. Application code invokes a log request on a -Category -object. Let's say the info method was invoked. -

    -

  2. The first thing info does is to check if logging has -been turned off entirely for the info level. If so, it returns -immediately. We'll assume for this scenario that logging has not -been turned off for the info level. -

    -

  3. Next info compares the -Priority -level for this category against Priority.INFO. Assuming -the priority warrants logging the message, the category instantiates a -LoggingEvent -object populated with information available for logging. -

    -

  4. The Category instance passes the LoggingEvent -instance to all its -Appender -implementations. -

    -

  5. Most (but not all) Appender implementations should have -an associated subclass of -Layout. -The Layout subclass is passed the LoggingEvent -instance and returns the event's information formatted in a -String according to the configuration of the Layout. -

    -When the Layout subclass is -PatternLayout, -the format of the event's information is determined by a character sequence -similar to the C language library's printf routine. -PatternLayout delegates the parsing of this character sequence to a -PatternParser -instance. -

    -When the PatternLayout was constructed, it created a -PatternParser to tokenize the character sequence. Upon -recognizing a token, the PatternParser constructs an appropriate -PatternConverter -subclass, passing it formatting information from the token. Often the -PatternConverter subclasses are implemented as static inner -classes of PatternParser. The parse method of -the PatternParser returns a linked list of these -PatternConverter subclasses. -

    -

  6. PatternLayout.format() passes the LoggingEvent -to each PatternConverter subclass in the linked list. Each link -in the list selects a particular item from the LoggingEvent, -converts this item to a String in the proper format and appends -it to a StringBuffer. -

    -

  7. The format method returns the resulting String -to the Appender for output. -
-

-The above discussing involved most of the classes that we must extend or -implement. -

-

-

-


-

The Process

-Below are steps required to add additional attributes available -for logging by extending log4j. This will allow you to specify -their output formats in the same manner as those provided by the -PatternLayout class. The steps are numbered for -reference only. It makes no difference in which order they are -followed. -

-It's helpful if you know the attributes you wish to add and a -PatternLayout symbol for each one before you begin. Be -sure to consult the PatternLayout documentation to ensure -the symbols you select are not already in use. -

-Before we dig in, I should give the standard lecture on comments. -If the log4j library were not well documented, it would be useless -to everyone but the log4j creators; likewise with your extensions. -Much like eating vegetables and saving the environment, we all agree -commenting code properly should be done. Yet it is often sacrificed -for more immediate pleasures. We all write code faster without -comments; especially those pesky Javadoc comments. But the reality -is that the utility of undocumented code fades exponentially with time. -

-Since the log4j product comes with Javadoc comments together with -the documentation it produces, it makes sense to include Javadoc -comments in your extensions. By their very nature, logging tools -are strong candidates for reuse. They can only be independently -re-used if they are supported by strong documentation component. -

-This all having been said, I have elected to remove most comments from -examples in the interest of space rather than including them to serve -as a nagging reminder. The reader is referred to the case study source -code files for a Javadoc version and a -Javadoc website -for more information on Javadoc conventions. - -

1. Extending LoggingEvent

- -Extending the LoggingEvent class should be one of the -trivial steps. All that is needed in the extension is the addition -of public data members representing the new attributes and a new -constructor to populate them. -

- -
-
-import org.apache.log4j.Category;
-import org.apache.log4j.Priority;
-import org.apache.log4j.spi.LoggingEvent;
-
-public class AppServerLoggingEvent extends LoggingEvent
-                                   implements java.io.Serializable 
-{
-   public String hostname;
-   public String component;
-   public String server;
-   public String version;
-   
-   public AppServerLoggingEvent( String    fqnOfCategoryClass, 
-                                 AppServerCategory  category, 
-                                 Priority  priority, 
-                                 Object    message, 
-                                 Throwable throwable) 
-   {
-      super( fqnOfCategoryClass,
-             category,
-             priority,
-             message,
-             throwable );
-
-      hostname  = category.getHostname();
-      component = category.getComponent();
-      server    = category.getServer();
-      version   = category.getVersion();
-   }  
-}
-
-
-

-The constructor demonstrates that in most cases, the Category -subclass will contain most of the information necessary to populate -the attributes of the LoggingEvent subclass. Extensions -to LoggingEvent seem no more than a collection of strings -with a constructor. Most of the work is done by the super class. - -

2. Extending PatternLayout

- -Extending the PatternLayout class should be another -simple matter. The extension to PatternLayout should -differ from its parent only in the creation of a -PatternParser instance. The extended -PatternLayout should create an extended -PatternParser class. Fortunately, this task in -PatternLayout is encapsulated within a single method. -

-
-
-import org.apache.log4j.PatternParser;
-import org.apache.log4j.PatternLayout;
-
-public class AppServerPatternLayout extends PatternLayout 
-{
-   public AppServerPatternLayout() 
-   {
-      this(DEFAULT_CONVERSION_PATTERN);
-   }
-
-   public MyPatternLayout(String pattern) 
-   {
-      super(pattern);
-   }
-    
-   public PatternParser createPatternParser(String pattern) 
-   {
-      PatternParser result;
-      if ( pattern == null )
-         result = new AppserverPatternParser( DEFAULT_CONVERSION_PATTERN );
-      else
-         result = new AppServerPatternParser ( pattern );
-
-      return result;
-  }
-}
-
-
- -

3. Extend PatternParser and PatternConverter

- -Recall from our peek under the hood that the -PatternParser does much of its work in its -parse method. The PatternLayout object -instantiates a PatternParser object by passing it -the pattern string. The PatternLayout then invokes the -parse method of PatternParser to produce -a linked list of PatternConverter subclass instances. -It is this linked list of converters that is used to convert an -event instance into a string used by appenders. -

-Our job will be to subclass PatternParser to properly -interpret formatting characters we wish to add. Fortunately, -PatternParser has been designed so that only the one -step in the parsing process differing for each formatting character -has to be overridden. The grunt work of parsing is still performed -by the PatternParser.parse() method. Only the -PatternParser.finalizeConverter method has to be -overridden. This is the method that decides which -PatternConverter to create based on a formatting -character. -

-The extension to PatternParser, -AppServerPatternParser, is similar to its super class. -It uses -

    -
  • constants to identify the various formats -
  • a converter defined as private static inner-classes of - AppServerPatternParser. -
  • a finalizeConverter method which instantiates - the appropriate converter for a given format character. -
-

-AppServerPatternParser differs principally by -dedicating a separate converter type for each logging -attribute to be formatted. -Rather than placing switch logic in the converter, like its -parent class, each converter only converts one format character. -This means the decision of which converter subclass -to instantiate is made at layout instantiation time rather -than in a switch statement at logging time. -

-It also differs in that the format constants are characters -rather than integers. -

- -
-
-import org.apache.log4j.*;
-import org.apache.log4j.helpers.FormattingInfo;
-import org.apache.log4j.helpers.PatternConverter;
-import org.apache.log4j.helpers.PatternParser;
-import org.apache.log4j.spi.LoggingEvent;
-
-public class AppServerPatternParser extends PatternParser 
-{
-   static final char HOSTNAME_CHAR  = 'h';
-   static final char SERVER_CHAR    = 's';
-   static final char COMPONENT_CHAR = 'b';
-   static final char VERSION_CHAR   = 'v';
-
-   public AppServerPatternParser(String pattern) 
-   {
-      super(pattern);
-   }
-    
-   public void finalizeConverter(char formatChar) 
-   {
-      PatternConverter pc = null;
-      switch( formatChar )
-      {
-         case HOSTNAME_CHAR:
-            pc = new HostnamePatternConverter( formattingInfo );
-            currentLiteral.setLength(0);
-            addConverter( pc );
-            break;
-         case SERVER_CHAR:
-            pc = new ServerPatternConverter( formattingInfo );
-            currentLiteral.setLength(0);
-            addConverter( pc );
-            break;
-         case COMPONENT_CHAR:
-            pc = new ComponentPatternConverter( formattingInfo );
-            currentLiteral.setLength(0);
-            addConverter( pc );
-            break;
-         case VERSION_CHAR:
-            pc = new VersionPatternConverter( formattingInfo );
-            currentLiteral.setLength(0);
-            addConverter( pc );
-            break;
-         default:
-            super.finalizeConverter( formatChar );
-      }
-   }
-  
-   private static abstract class AppServerPatternConverter extends PatternConverter 
-   {
-      AppServerPatternConverter(FormattingInfo formattingInfo) 
-      {
-         super(formattingInfo);     
-      }
-
-      public String convert(LoggingEvent event) 
-      {
-         String result = null;
-         AppServerLoggingEvent appEvent = null;
-
-         if ( event instanceof AppServerLoggingEvent )
-         {
-            appEvent = (AppServerLoggingEvent) event;
-            result = convert( appEvent );
-         }
-         return result;
-      }
-
-      public abstract String convert( AppServerLoggingEvent event );
-   }
-
-   private static class HostnamePatternConverter extends AppServerPatternConverter
-   {
-      HostnamePatternConverter( FormattingInfo formatInfo )
-      {  super( formatInfo );  }
-
-      public String convert( AppServerLoggingEvent event )
-      {  return event.hostname;  }
-   }
-
-   private static class ServerPatternConverter extends AppServerPatternConverter
-   {
-      ServerPatternConverter( FormattingInfo formatInfo )
-      {  super( formatInfo );  }
-
-      public String convert( AppServerLoggingEvent event )
-      {  return event.server;  }
-   }
-
-   private static class ComponentPatternConverter extends AppServerPatternConverter
-   {
-      ComponentPatternConverter( FormattingInfo formatInfo )
-      {  super( formatInfo );  }
-
-      public String convert( AppServerLoggingEvent event )
-      {  return event.component;  }
-   }
-
-   private static class VersionPatternConverter extends AppServerPatternConverter
-   {
-      VersionPatternConverter( FormattingInfo formatInfo )
-      {  super( formatInfo );  }
-
-      public String convert( AppServerLoggingEvent event )
-      {  return event.version;  }
-   }
-}
-
-
-

-

4. Extending Category

-Extending Category and its factory will be more straight -forward than extending PatternParser and the converters. -The following tasks are involved in overridding -Category for our purposes. -

-

    -
  • Add fields corresponding to the new attributes with their - corresponding getters and setters. -

    -

  • Override the constructor to accept or acquire information - about new attributes. -

    -

  • Override the forcedLog method to ensure that a - correctly populated instance of - AppServerLoggingEvent is instantiated rather than - the default LoggingEvent. -

    -

  • Override the getInstance method to use our - CategoryFactory (described in the next step). This will - require that we hold a static reference to our factory and provide a - way to initialize it. -
-

-Most of the code below is standard getter/setter verbage which has been -somewhat abbreviated. The notable parts are in bold. We add five more -attributes to Category: the four new logging attributes -plus a static AppServerCategoryFactory reference. This is -pre-initialized to an instance with attributes set to null as a -precautionary measure. Otherwise the getInstance method -will result in a null pointer exception if invoked before the -setFactory method. -

-The getInstance method simply invokes its parent class -method that accepts a CategoryFactory reference in -addition to the category name. -

-The forcedLog method follows closely the corresponding -parent class method. The most important difference is the instantiation -of the AppServerLoggingEvent. A minor yet necessary -difference is the use of the getRendererMap() method rather -than accessing the data member directory as in Category. -Category can do this because the rendererMap -is package level accessible. -

-The setFactory method is provided to allow application code -to set the factory used in the getInstance method. -

- -
-
-import org.apache.log4j.Priority;
-import org.apache.log4j.Category;
-import org.apache.log4j.spi.CategoryFactory;
-import org.apache.log4j.spi.LoggingEvent;
-
-public class AppServerCategory extends Category
-{
-   protected String component;
-   protected String hostname;
-   protected String server;
-   protected String version;
-   private static CategoryFactory factory = 
-                  new AppServerCategoryFactory(null, null, null);
-
-   protected  AppServerCategory( String categoryName,
-                                 String hostname,
-                                 String server,
-                                 String component,
-                                 String version )
-   {
-      super( categoryName );
-      instanceFQN = "org.apache.log4j.examples.appserver.AppServerCategory";
-      
-      this.hostname  = hostname;
-      this.server    = server;
-      this.component = component;
-      this.version   = version;
-   }
-
-   public String getComponent()
-   { return (component == null ) ? "" : result; }
-
-   public String getHostname()
-   {  return ( hostname == null ) ? "" : hostname; }
-
-   public static Category getInstance(String name)
-   {
-      return Category.getInstance(name, factory);
-   }
-
-   public String getServer()
-   {  return ( server == null ) ? "" : server; }
-
-   public String getVersion()
-   {  return ( version == null ) ? "" : version; }
-
-   protected void forcedLog( String    fqn, 
-                             Priority  priority, 
-                             Object    message, 
-                             Throwable t) 
-   {
-      LoggingEvent event = new AppServerLoggingEvent(fqn, this, priority, message, t);
-      callAppenders( event );
-   }
-
-   public void setComponent(String componentName)
-   { component = componentName; }
-
-   public static void setFactory(CategoryFactory factory)
-   { AppServerCategory.factory = factory; }
-
-   public void setHostname(String hostname)
-   { this.hostname = hostname; }
-
-   public void setServer(String serverName)
-   { server = serverName; }
-
-   public void setVersion(String versionName)
-   { version = versionName; }
-}
-
-
-

- -

5. Extending CategoryFactory

- -The last step is to provide an implementation of the -CategoryFactory interface that will correctly -instantiate our AppServerCategory objects. It -will obtain the hostname of the machine on which it runs using the -java.net API. Aside from providing getters and -setters for the attributes introduced, the only method to -be implemented is the makeNewCategoryInstance. -

-Below is a snippet from AppServerCategoryFactory -with getters, setters and comments removed. -

- -
-
-import org.apache.log4j.Category;
-import org.apache.log4j.spi.CategoryFactory;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class AppServerCategoryFactory implements CategoryFactory
-{
-   protected String hostname;
-   protected String server;
-   protected String component;
-   protected String version;
-   protected ResourceBundle messageBundle;
-
-   protected  AppServerCategoryFactory( String serverName,
-                                        String componentName,
-                                        String versionName )
-   {
-      try
-      {
-         hostname = java.net.InetAddress.getLocalHost().getHostName();
-      }
-      catch ( java.net.UnknownHostException uhe )
-      {
-         System.err.println("Could not determine local hostname.");
-      }
-
-      server    = serverName;
-      component = componentName;
-      version   = versionName;
-   }
-
-   public Category makeNewCategoryInstance(String name)
-   {
-       Category result = new AppServerCategory( name, 
-                                                hostname, 
-                                                server, 
-                                                component, 
-                                                version);
-       return result;
-   }
-}
-
-
-

-


-

Usage

-We now arrive at how to use what we have created. We must remember to -initialize log4j by creating an instance of -AppServerCategoryFactory and passing it to -AppServerCategory. Once done, we can obtain a -AppServerCategoryInstance anytime by using the static -getInstance method of AppServerCategory. -This will ensure that AppServerLoggingEvent instances -are generated by the category logging methods. -

- -
-
-import org.apache.log4j.*;
-import org.apache.log4j.appserver.AppServerCategory;
-import org.apache.log4j.appserver.AppServerCategoryFactory;
-import org.apache.log4j.appserver.AppServerPatternLayout;
-
-public class test
-{
-   private static String formatString = 
-      "---------------------------------------------------%n" +
-      "Time:      %d%n" +
-      "Host:      %h%n" +
-      "Server:    %s%n" +
-      "Component: %b%n" +
-      "Version:   %v%n" +
-      "Priority:  %p%n" +
-      "Thread Id: %t%n" +
-      "Context:   %x%n" +
-      "Message:   %m%n";
-
-   public static void main(String[] args)
-   {
-      AppServerCategoryFactory factory;
-      factory = new AppServerCategoryFactory("MyServer", "MyComponent", "1.0");
-      AppServerCategory.setFactory( factory );
-      Category cat = AppServerCategory.getInstance("some.cat");
-
-      PatternLayout layout = new AppServerPatternLayout( formatString );
-      cat.addAppender( new FileAppender( layout, System.out) );
-
-      cat.debug("This is a debug statement.");
-      cat.info("This is an info statement.");
-      cat.warn("This is a warning statement.");
-      cat.error("This is an error statement.");
-      cat.fatal("This is a fatal statement.");
-   }
-}
-
-
-

Configurators

-There is one a word of caution concerning the use of configurators that -may create Category instances (such as - -PropertyConfigurator -and - -DOMConfigurator). Since these configurators do not -know about our extensions, any Category instances they -create will not be AppServerCategory instances. To -prevent this problem, any AppServerCategory that one -might want to be configured through a configurator should be -instantiated before the configure method is invoked. In this way, -the configurator will configure the AppServerCategory -that already exists rather than creating an instance of its super -class. -

-The consequence of a configurator creating the super class by -mistake is merely that the extra attributes will not appear in -the log output. All other attributes are conveyed properly. -

-


-

Further Enhancements

-There are some other directions in which this log4j extension -may be enhanced: -

-

    -
  1. The hostname attribute could incorportate a formatting convention - similar to that of class and category names whereby only a certain - number of the more significant components are displayed. But - whereas with class and category names, the most significant component - is on the right, with host names, it is on the left. -

    -

  2. Specifying a version number could be dangerous since programmers - are apt to change versions of the code without changing the - string constant in the code which specifies the version. Some - source control programs provide for insertion of a version number - into source. For those that don't, including the version number as - a constant is likely to lead to confusion later on. It would be - nice to see this short-coming addressed. - - diff --git a/docs/images/cyberlab15.gif b/docs/images/cyberlab15.gif deleted file mode 100644 index 1856324ba0..0000000000 Binary files a/docs/images/cyberlab15.gif and /dev/null differ diff --git a/docs/images/ecaward_finalist_logo.gif b/docs/images/ecaward_finalist_logo.gif deleted file mode 100644 index 220896b78d..0000000000 Binary files a/docs/images/ecaward_finalist_logo.gif and /dev/null differ diff --git a/docs/overview.html b/docs/overview.html deleted file mode 100644 index 40efccd27e..0000000000 --- a/docs/overview.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Short log4j introduction - - - -

    Make sure to read the user manual -in addition to this javadoc documentation. - - diff --git a/docs/praise.html b/docs/praise.html deleted file mode 100755 index e6d10d0e9b..0000000000 --- a/docs/praise.html +++ /dev/null @@ -1,266 +0,0 @@ - - -Praise from log4j users - - - -

    Praise from log4j users

    - -
    -Log4J was named as a finalist in the "Most Useful New or Revised Java API/Technology" -category, and Tomcat 3.2 was named as a finalist in the "Most Innovative Java Product" category. -
    -

    JavaWorld, April 2001 - -


    -

    Log4j is an incredibly well designed and functional logging tool. I -caught the religion last summer and with every project I work on, most -everyone agrees it's a must know/have tool. Previously I was using -another Java logging library developed internally within my company -which I liked. I had no desire to learn another but did so for the -sake of due diligence. Log4j has the following features which set it -apart from others I have seen. - -

    Highly configurable - the ability to configure the -properties of your loggers (called Categories in log4j) from within a -property file is indispensible. This allows you to change the -characteristics of your logging without changing code. You can change -the logging level, the format of the output and the output targets -very easily. One can also use XML files (though I haven't). - -

    Unobtrusive - I'm finishing a project where we started using another -logging tool. The log statements were clumsily long and required using -predefined constants that were hard to remember. When writing the -initial code, "System.out.println" was so much easier to type that -people did this for tracing with the best of intentions to place -legitimate logging in later. You know the story. It never -happened. Log4j statements are shorter than "System.out.println" -statements. This encourages people to actually use it rather than -simply agreeing to. - -

    Easy configuration - With just one statement, log4j will -configure itself with a set of defaults that are useful until you get -around to actually writing your property file, XML file or -whatever. Like the point just made before, this allows log4j to be -used at the outset of coding rather than having to wait because you -haven't considered how you wish logging to be configured. The -application code itself does not have to know how logging will be -configured. - -

    Performance Concerns - Since Java does not use pre-processor -macros, most Java tracing is always compiled into the code. That means -that the decision to compile is made at runtime. There are times when -performance is so paramount that even checking whether to log is a -concern. There are other extremes where other delays make this -insignificant so that the performance is easily sacrificed for the -increased amount of information logged (such as method name, class -name and line number in source code). The log4j javadoc documentation -explains which information elements are quickly logged and which may -compromise performance. It also includes benchmarks that demonstrate -how fast certain statements are logged for a few sample machine -configurations. - -

    Hierarchical Categories - This is highly useful in component -based development. Each component has its own set of logging -categories. When individually tested, the properties of these -categories may be set however the developer wishes. When combined with -other components, the categories inherit the properties determined by -the integrator of the components. One can selectively elevate logging -priorities on one component without affecting the other -components. This is useful when you need a detailed trace from just a -single component without crowding the trace file with messages from -other components. All this can be done with property files - no change -in the code is required. - -

    Easily specified output format - Some Java and OO purist -disagree with me on this, but allowing one to use printf-style output -format specification is powerful, convenient and compact. Log4j -provides a Layout class with this capability. Of course, for those who -wish, you may implement the Layout interface yourself with something -"more OO". Naturally, the printf-style pattern can be specified in a -property file. - -

    Customization - Like other loggers, log4j is interface-based -making it possible to extend. Log4j supplies useful implementations -that are extended easily without having to implement the interface -from scratch. -

    - -

    Paul Glezen (pglezen at atdial.net), December 3rd, 2000 - -


    -This Java package is probably one of the best and most reliable packages -around, and really helps development and maintenance of quality software. -Thanks to all contributors who have made such a good work. -
    - -

    Denis Balazuc (denis.balazuc at trader.com), December 8th, 2000 - -


    This is just a quick note of thanks for publishing -your article in Javaworld. Log4j is really easy to use. While I was -initially skeptical of the idea, code like this makes me a believer in -the concept of Open Source. -
    - -

    Paul Hyndman (PaulHyndman at mynd.com), November 29th, 2000 - -


    -I just recently became aware of log4j and am just now begining to use -it. I want to thank you and the rest of the log4j development team for -making this functionality available. You are providing an outstanding -service to the development community. Please pass my regards on to the -other team members. -
    - -

    Rich Coco (racoco at celoxnetworks.com), November 16th, 2000 - - - -


    - -Just thought I'd let you know that I am using your log4j as a part of -an e-commerce application (www.consumerd.com). I am using -the XML configuration classes and have to say that I am most -impressed. -
    - -

    Richard King (Richard.King at capgemini.co.uk), October 25th, 2000 - -


    - -You should see what we've used log4j for at work... I put together -this Servlet that can interpret SOAP messages and invoke little -"handlers". Logging is pervasive through out the system, and the -handler developers can "create" their own Categories dynamically using -the getInstance method of Category. - -

    It's funny when I get an email from someone at work who's using the -toolkit with a "it didn't work" question, and I ask them to check out -the log... due to the coolness of log4j, they can track down their -mistake immediately. - -

    -

    Christopher Taylor (cstaylor at pacbell.net), September 2nd, 2000 - -


    -I am using log4j for a project I am currently working on. The -simplicity and ease with which new appenders can be written makes it -one of the best logging systems I have ever used. -
    - -

    Manish Balsara (manishb at aumsoft.com) August 28th, 2000 - -


    -Thank you for writing this incredibly effective piece of software. You -have made my and my team's lives much easier. -
    - -

    Guy Nirpaz, Java Architect (guyn at tantian.com) August -14th, 2000 - -


    -Thank you so much for developing such a -sleek package. I think it's going to be a part of many of my projects in -the future :) -
    - -

    Alice Nakajima (alice.t.nakajima at saic.com) May 10th, -2000 - - -


    -Thank you very much for your great work on log4j, which is really -powerful and flexible logging system. Log4j is now playing an -important role in our project. -
    - -

    Zeng Qiang (zeng.qiang at europeloan.com) April 26th, 2000 - -


    -
    Thank you and your team giving us a excellent tool to -help us to develop our Java applications. After evaluation, our team -is ready to use log4j as our eCare product's diagnostic strategy. -

    Jianbo Wang (jiwang at Daleen.com) April -25th, 2000 - -


    -
    -Was trying to use the log4j tracer ... great job, by the way ! - -

    Actually I'm evaluating the log4j package for use in our commercial -projects. We have our own tracer package which is by far less -powerfull and less configurable than yours. -

    -

    Joerg Palmer (Joerg.Palmer at Compart.net) April 14th, 2000 - - -


    -
    -Hooray, log4j! It's now all over my current project, and my colleagues -were pleasantly surprised at the ease of debugging. I gave them my -jarfile, it didn't work, I said "oh, just change this configuration -file" and presto, logging to a file. They're happy. -
    -

    Nelson Minar CTO, Popular Power, Inc. (nelson at popularpower.com) April 14th, 2000 - -


    -
    -I really dig your log4j package... just started using it on our linux -and os390 boxes for the java servlets we run in websphere. Still -trying to get the hang of it properly, but what I do have working is -working great. (Not to mention your makefile tutorial which has -improved my life significantly! :-) -
    -

    Anthony (ant at sanlam.co.za) April 13th, 2000 - - -


    -
    -Thanks for providing log4j: it's a very useful package. -
    -

    Andrew Harris (Andrew.Harris at capgemini.co.uk) April 10th, 2000 - -


    -
    -I just started using log4j v.0.8.1. It is quite what I was looking for. -

    So here is my "THANK YOU" to all the contributors. -I think I'll join the club. -

    -

    Avy Sharell (asharell at club-internet.fr) March 8th, 2000 - - -


    -
    -I just wanted to thank you for log4j which is a great piece of software! - -

    We are using it in the FREE e-democracy project -http://www.thecouch.org/free/ to provide an effective security audit -trail in our electronic voting software. -

    -

    Jason Kitcat (jeep at thecouch.org) March 29th, 2000 - - -


    -
    -Thanks for making log4j available. -I like the changes in v0.8 and am using it in all my java projects. -
    -

    Steven Marcus (srnm at awaretechnologies.com) February 19th, 2000 - -


    -
    -First congratulation for your great job on the Log mechanism log4j, -it's really valuable. -
    -

    Sebastien Sahuc (ssahuc at imediation.com) January 4th, 2000 - - -


    Just a few remarks to your log4j Logging-Tool. First -of all, in my opinion, it is exactly what many Java programmers need: -A small but very useful tool complementing the debugger ;-) The logs -help me to debug results generated on a distant client.

    Jens Uwe Pipka (jens.pipka at gmx.de) October 25th, 1999 - -


    - diff --git a/examples/.cvsignore b/examples/.cvsignore deleted file mode 100644 index f590ca415d..0000000000 --- a/examples/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -doc-files \ No newline at end of file diff --git a/examples/MyPatternLayout.java b/examples/MyPatternLayout.java index eba1787c66..8cb563da8e 100644 --- a/examples/MyPatternLayout.java +++ b/examples/MyPatternLayout.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples; @@ -46,9 +56,9 @@ PatternParser createPatternParser(String pattern) { public static void main(String[] args) { Layout layout = new MyPatternLayout("[counter=%.10#] - %m%n"); - Category cat = Category.getInstance("some.cat"); - cat.addAppender(new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT)); - cat.debug("Hello, log"); - cat.info("Hello again..."); + Logger logger = Logger.getLogger("some.cat"); + logger.addAppender(new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT)); + logger.debug("Hello, log"); + logger.info("Hello again..."); } } diff --git a/examples/MyPatternParser.java b/examples/MyPatternParser.java index ea19c6af53..b65746bec8 100644 --- a/examples/MyPatternParser.java +++ b/examples/MyPatternParser.java @@ -1,13 +1,22 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples; -import org.apache.log4j.*; import org.apache.log4j.helpers.FormattingInfo; import org.apache.log4j.helpers.PatternConverter; import org.apache.log4j.helpers.PatternParser; diff --git a/examples/NumberCruncher.java b/examples/NumberCruncher.java index 3a6e85cec3..84ba303c28 100644 --- a/examples/NumberCruncher.java +++ b/examples/NumberCruncher.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples; diff --git a/examples/NumberCruncherClient.java b/examples/NumberCruncherClient.java index 0d6e96bb26..4f58271bc4 100644 --- a/examples/NumberCruncherClient.java +++ b/examples/NumberCruncherClient.java @@ -1,17 +1,24 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples; -import java.rmi.Remote; -import java.rmi.server.UnicastRemoteObject; import java.rmi.RemoteException; import java.rmi.Naming; -import java.util.Vector; import java.io.*; /** diff --git a/examples/NumberCruncherServer.java b/examples/NumberCruncherServer.java index d2eec74ee9..e981243d64 100644 --- a/examples/NumberCruncherServer.java +++ b/examples/NumberCruncherServer.java @@ -1,20 +1,28 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples; -import java.rmi.Remote; import java.rmi.server.UnicastRemoteObject; import java.rmi.RemoteException; import java.rmi.Naming; import java.util.Vector; - -import org.apache.log4j.Category; +import org.apache.log4j.Logger; import org.apache.log4j.NDC; import org.apache.log4j.PropertyConfigurator; @@ -52,10 +60,10 @@ */ public class NumberCruncherServer extends UnicastRemoteObject implements NumberCruncher { + private static final long serialVersionUID = 2626753561969426769L; - static Category cat = Category.getInstance( - NumberCruncherServer.class.getName()); + static Logger logger = Logger.getLogger(NumberCruncherServer.class); public NumberCruncherServer() throws RemoteException { @@ -66,7 +74,7 @@ int[] factor(int number) throws RemoteException { // The client's host is an important source of information. try { - NDC.push(this.getClientHost()); + NDC.push(getClientHost()); } catch(java.rmi.server.ServerNotActiveException e) { // we are being called from same VM @@ -79,7 +87,7 @@ int[] factor(int number) throws RemoteException { // contained in cookies. NDC.push(String.valueOf(number)); - cat.info("Beginning to factor."); + logger.info("Beginning to factor."); if(number <= 0) { throw new IllegalArgumentException(number+" is not a positive integer."); } @@ -93,10 +101,10 @@ else if(number == 1) // It is bad practice to place log requests within tight loops. // It is done here to show interleaved log output from // different requests. - cat.debug("Trying to see if " + i + " is a factor."); + logger.debug("Trying to see if " + i + " is a factor."); if((n % i) == 0) { - cat.info("Found factor "+i); + logger.info("Found factor "+i); factors.addElement(new Integer(i)); do { n /= i; @@ -108,7 +116,7 @@ else if(number == 1) } if(n != 1) { - cat.info("Found factor "+n); + logger.info("Found factor "+n); factors.addElement(new Integer(n)); } @@ -140,7 +148,7 @@ void usage(String msg) { public static void delay(int millis) { - try{Thread.currentThread().sleep(millis);} + try{Thread.sleep(millis);} catch(InterruptedException e) {} } @@ -153,10 +161,10 @@ public static void main(String[] args) { try { ncs = new NumberCruncherServer(); Naming.rebind("Factor", ncs); - cat.info("NumberCruncherServer bound and ready to serve."); + logger.info("NumberCruncherServer bound and ready to serve."); } catch(Exception e) { - cat.error("Could not bind NumberCruncherServer.", e); + logger.error("Could not bind NumberCruncherServer.", e); return; } NumberCruncherClient.loop(ncs); diff --git a/examples/Sort.java b/examples/Sort.java index a4a9ac8151..7b97225058 100644 --- a/examples/Sort.java +++ b/examples/Sort.java @@ -1,9 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples; import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.Logger; -import org.apache.log4j.Priority; /** Example code for log4j to viewed in conjunction with the {@link diff --git a/examples/SortAlgo.java b/examples/SortAlgo.java index a5a3f53e2f..dde9ce811c 100644 --- a/examples/SortAlgo.java +++ b/examples/SortAlgo.java @@ -1,7 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples; -import org.apache.log4j.Category; +import org.apache.log4j.Logger; import org.apache.log4j.NDC; /** @@ -16,11 +32,11 @@ public class SortAlgo { final static String className = SortAlgo.class.getName(); - final static Category CAT = Category.getInstance(className); - final static Category OUTER = Category.getInstance(className + ".OUTER"); - final static Category INNER = Category.getInstance(className + ".INNER"); - final static Category DUMP = Category.getInstance(className + ".DUMP"); - final static Category SWAP = Category.getInstance(className + ".SWAP"); + final static Logger LOG = Logger.getLogger(className); + final static Logger OUTER = Logger.getLogger(className + ".OUTER"); + final static Logger INNER = Logger.getLogger(className + ".INNER"); + final static Logger DUMP = Logger.getLogger(className + ".DUMP"); + final static Logger SWAP = Logger.getLogger(className + ".SWAP"); int[] intArray; @@ -29,7 +45,7 @@ public class SortAlgo { } void bubbleSort() { - CAT.info( "Entered the sort method."); + LOG.info( "Entered the sort method."); for(int i = intArray.length -1; i >= 0 ; i--) { NDC.push("i=" + i); diff --git a/examples/Trivial.java b/examples/Trivial.java index 0f97056295..99e9978125 100644 --- a/examples/Trivial.java +++ b/examples/Trivial.java @@ -1,8 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples; -import org.apache.log4j.Category; +import org.apache.log4j.Logger; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.NDC; @@ -33,31 +49,31 @@ */ public class Trivial { - static Category cat = Category.getInstance(Trivial.class.getName()); + static Logger logger = Logger.getLogger(Trivial.class); public static void main(String[] args) { BasicConfigurator.configure(); NDC.push("Client #45890"); - cat.info("Awake awake. Put on thy strength."); + logger.info("Awake awake. Put on thy strength."); Trivial.foo(); InnerTrivial.foo(); - cat.info("Exiting Trivial."); + logger.info("Exiting Trivial."); } static void foo() { NDC.push("DB"); - cat.debug("Now king David was old."); + logger.debug("Now king David was old."); NDC.pop(); } static class InnerTrivial { - static Category cat = Category.getInstance(InnerTrivial.class.getName()); + static Logger logger = Logger.getLogger(InnerTrivial.class); static void foo() { - cat.info("Entered foo."); + logger.info("Entered foo."); } } } diff --git a/examples/customLevel/XLevel.java b/examples/customLevel/XLevel.java index 2977aebe59..d4d1b902f3 100644 --- a/examples/customLevel/XLevel.java +++ b/examples/customLevel/XLevel.java @@ -1,8 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples.customLevel; import org.apache.log4j.Level; -import org.apache.log4j.Priority; /** @@ -11,6 +26,7 @@ */ public class XLevel extends Level { + private static final long serialVersionUID = 2626753561969426769L; static public final int TRACE_INT = Level.DEBUG_INT - 1; static public final int LETHAL_INT = Level.FATAL_INT + 1; diff --git a/examples/factor.html b/examples/factor.html index bf9f27ffd0..af593c7425 100644 --- a/examples/factor.html +++ b/examples/factor.html @@ -1,4 +1,21 @@ + diff --git a/examples/factor.lcf b/examples/factor.lcf index 3ad3607ba8..bc43ba0324 100644 --- a/examples/factor.lcf +++ b/examples/factor.lcf @@ -1,3 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# # For the general syntax of property based configuration files see the # documenation of org.apache.log4j.PropertyConfigurator. diff --git a/examples/lf5/InitUsingDefaultConfigurator/InitUsingDefaultConfigurator.java b/examples/lf5/InitUsingDefaultConfigurator/InitUsingDefaultConfigurator.java new file mode 100644 index 0000000000..1c54f3d733 --- /dev/null +++ b/examples/lf5/InitUsingDefaultConfigurator/InitUsingDefaultConfigurator.java @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package examples.lf5.InitUsingDefaultConfigurator; + +import org.apache.log4j.Logger; +import org.apache.log4j.NDC; +import org.apache.log4j.lf5.DefaultLF5Configurator; + +import java.io.IOException; + +/** + * This class is a simple example of how to configure the LogFactor5 + * logging window using the DefaultLF5Configurator. + * + * The DefaultLF5Configurator uses a default configuration file stored + * in the log4j.jar in order to provide a default configuration for + * the LF5Appender. + * + * @author Brent Sprecher + */ + +// Contributed by ThoughtWorks Inc. + +public class InitUsingDefaultConfigurator { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + private static Logger logger = + Logger.getLogger(InitUsingDefaultConfigurator.class); + + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + public static void main(String[] args) throws IOException { + // Configure the LF5Appender using the DefaultLF5Configurator. This + // will add the LF5Appender to the root of the Category tree. + DefaultLF5Configurator.configure(); + + // Add an NDC to demonstrate how NDC information is output. + NDC.push("#23856"); + // Log some information. + for (int i = 0; i < 10; i++) { + logger.debug("Hello, my name is Homer Simpson."); + logger.info("Mmmmmm .... Chocolate."); + logger.warn("Mmm...forbidden donut."); + } + // Clean up NDC + NDC.pop(); + NDC.remove(); + + NDC.push("Another NDC"); + // Log some information. + logger.fatal("Hello, my name is Bart Simpson."); + logger.error("Hi diddly ho good neighbour."); + // Clean up NDC + NDC.pop(); + NDC.remove(); + + // Call methods on both classes. + InitUsingDefaultConfigurator.foo(); + InnerInitUsingDefaultConfigurator.foo(); + + logger.info("Exiting InitUsingDefaultConfigurator."); + + } + + public static void foo() { + logger.debug("Entered foo in InitUsingDefaultConfigurator class"); + + NDC.push("#123456"); + logger.debug("Hello, my name is Marge Simpson."); + logger.info("D'oh!! A deer! A female deer."); + // Clean up NDC + NDC.pop(); + NDC.remove(); + } + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + + public static class InnerInitUsingDefaultConfigurator { + static Logger logger = + Logger.getLogger(InnerInitUsingDefaultConfigurator.class.getName()); + + static void foo() throws IOException { + // Configure the LF5Appender again. You can call + // DefaultLF5Configurator.configure() as often as you want + // without unexpected behavior. + DefaultLF5Configurator.configure(); + + logger.info("Entered foo in InnerInitUsingDefaultConfigurator class."); + } + } +} + + + + + diff --git a/examples/lf5/InitUsingLog4JProperties/InitUsingLog4JProperties.java b/examples/lf5/InitUsingLog4JProperties/InitUsingLog4JProperties.java new file mode 100644 index 0000000000..3e6fae23f9 --- /dev/null +++ b/examples/lf5/InitUsingLog4JProperties/InitUsingLog4JProperties.java @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package examples.lf5.InitUsingLog4JProperties; + +import org.apache.log4j.Logger; + +import java.io.IOException; + +/** + * This class is a simple example of how to use the LogFactor5 logging + * window. + * + * The LF5Appender is the primary class that enables logging to the + * LogFactor5 logging window. The simplest method of using this Appender + * is to add the following line to your log4j.properties file: + * + * log4j.appender.A1=org.apache.log4j.lf5.LF5Appender + * + * The log4j.properties file MUST be in you system classpath. If this file + * is in your system classpath, a static initializer in the Category class + * will load the file during class initialization. The LF5Appender will be + * added to the root category of the Category tree. + * + * Create a log4j.properties file and add this line to it, or add this line + * to your existing log4j.properties file. Run the example at the command line + * and explore the results! + * + * @author Brent Sprecher + */ + +// Contributed by ThoughtWorks Inc. + +public class InitUsingLog4JProperties { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + + private static Logger logger = + Logger.getLogger(InitUsingLog4JProperties.class); + + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + public static void main(String argv[]) { + // Add a bunch of logging statements ... + logger.debug("Hello, my name is Homer Simpson."); + logger.debug("Hello, my name is Lisa Simpson."); + logger.debug("Hello, my name is Marge Simpson."); + logger.debug("Hello, my name is Bart Simpson."); + logger.debug("Hello, my name is Maggie Simpson."); + + logger.info("We are the Simpsons!"); + logger.info("Mmmmmm .... Chocolate."); + logger.info("Homer likes chocolate"); + logger.info("Doh!"); + logger.info("We are the Simpsons!"); + + logger.warn("Bart: I am through with working! Working is for chumps!" + + "Homer: Son, I'm proud of you. I was twice your age before " + + "I figured that out."); + logger.warn("Mmm...forbidden donut."); + logger.warn("D'oh! A deer! A female deer!"); + logger.warn("Truly, yours is a butt that won't quit." + + "- Bart, writing as Woodrow to Ms. Krabappel."); + + logger.error("Dear Baby, Welcome to Dumpsville. Population: you."); + logger.error("Dear Baby, Welcome to Dumpsville. Population: you.", + new IOException("Dumpsville, USA")); + logger.error("Mr. Hutz, are you aware you're not wearing pants?"); + logger.error("Mr. Hutz, are you aware you're not wearing pants?", + new IllegalStateException("Error !!")); + + + logger.fatal("Eep."); + logger.fatal("Mmm...forbidden donut.", + new SecurityException("Fatal Exception")); + logger.fatal("D'oh! A deer! A female deer!"); + logger.fatal("Mmmmmm .... Chocolate.", + new SecurityException("Fatal Exception")); + } + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + +} diff --git a/examples/lf5/InitUsingLog4JProperties/log4j.properties b/examples/lf5/InitUsingLog4JProperties/log4j.properties new file mode 100644 index 0000000000..98b54b5ddf --- /dev/null +++ b/examples/lf5/InitUsingLog4JProperties/log4j.properties @@ -0,0 +1,17 @@ +# For the general syntax of property based configuration files see the +# documenation of org.apache.log4j.PropertyConfigurator. + +# The root category uses the appender called A1. Since no priority is +# specified, the root category assumes the default priority for root +# which is DEBUG in log4j. The root category is the only category that +# has a default priority. All other categories need not be assigned a +# priority in which case they inherit their priority from the +# hierarchy. + +log4j.rootCategory=, A1 + +# A1 is set to be a LF5Appender which outputs to a swing +# logging console. + +log4j.appender.A1=org.apache.log4j.lf5.LF5Appender +log4j.appender.A1.MaxNumberOfRecords=1000 diff --git a/examples/lf5/InitUsingMultipleAppenders/InitUsingMultipleAppenders.java b/examples/lf5/InitUsingMultipleAppenders/InitUsingMultipleAppenders.java new file mode 100644 index 0000000000..6aac063676 --- /dev/null +++ b/examples/lf5/InitUsingMultipleAppenders/InitUsingMultipleAppenders.java @@ -0,0 +1,146 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package examples.lf5.InitUsingMultipleAppenders; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; + +import java.io.IOException; +import java.net.URL; + +/** + * This example shows how to use LogFactor5 with other Log4J appenders + * (In this case the RollingFileAppender). + * + * The following lines can be added to the log4j.properties file or a + * standard Java properties file. + * + * # Two appenders are registered with the root of the Category tree. + * + * log4j.rootCategory=, A1, R + * + * # A1 is set to be a LF5Appender which outputs to a swing + * # logging console. + * + * log4j.appender.A1=org.apache.log4j.lf5.LF5Appender + * + * # R is the RollingFileAppender that outputs to a rolling log + * # file called rolling_log_file.log. + * + * log4j.appender.R=org.apache.log4j.RollingFileAppender + * log4j.appender.R.File=rolling_log_file.log + * + * log4j.appender.R.layout=org.apache.log4j.PatternLayout + * log4j.appender.R.layout.ConversionPattern=Date - %d{DATE}%nPriority + * - %p%nThread - %t%nCategory - %c%nLocation - %l%nMessage - %m%n%n + * log4j.appender.R.MaxFileSize=100KB + * log4j.appender.R.MaxBackupIndex=1 + * + * To make this example work, either run the InitUsingMultipleAppenders.bat + * file located in the examples folder or run it at the command line. If you + * are running the example at the command line, you must ensure that the + * example.properties file is in your classpath. + * + * @author Brent Sprecher + * @author Brad Marlborough + */ + +// Contributed by ThoughtWorks Inc. + +public class InitUsingMultipleAppenders { + + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + + private static Logger logger = + Logger.getLogger(InitUsingMultipleAppenders.class); + + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + public static void main(String argv[]) { + // Use a PropertyConfigurator to initialize from a property file. + String resource = + "/examples/lf5/InitUsingMultipleAppenders/example.properties"; + URL configFileResource = + InitUsingMultipleAppenders.class.getResource(resource); + PropertyConfigurator.configure(configFileResource); + + // Add a bunch of logging statements ... + logger.debug("Hello, my name is Homer Simpson."); + logger.debug("Hello, my name is Lisa Simpson."); + logger.debug("Hello, my name is Marge Simpson."); + logger.debug("Hello, my name is Bart Simpson."); + logger.debug("Hello, my name is Maggie Simpson."); + + logger.info("We are the Simpsons!"); + logger.info("Mmmmmm .... Chocolate."); + logger.info("Homer likes chocolate"); + logger.info("Doh!"); + logger.info("We are the Simpsons!"); + + logger.warn("Bart: I am through with working! Working is for chumps!" + + "Homer: Son, I'm proud of you. I was twice your age before " + + "I figured that out."); + logger.warn("Mmm...forbidden donut."); + logger.warn("D'oh! A deer! A female deer!"); + logger.warn("Truly, yours is a butt that won't quit." + + "- Bart, writing as Woodrow to Ms. Krabappel."); + + logger.error("Dear Baby, Welcome to Dumpsville. Population: you."); + logger.error("Dear Baby, Welcome to Dumpsville. Population: you.", + new IOException("Dumpsville, USA")); + logger.error("Mr. Hutz, are you aware you're not wearing pants?"); + logger.error("Mr. Hutz, are you aware you're not wearing pants?", + new IllegalStateException("Error !!")); + + + logger.fatal("Eep."); + logger.fatal("Mmm...forbidden donut.", + new SecurityException("Fatal Exception")); + logger.fatal("D'oh! A deer! A female deer!"); + logger.fatal("Mmmmmm .... Chocolate.", + new SecurityException("Fatal Exception")); + } + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + +} diff --git a/examples/lf5/InitUsingMultipleAppenders/example.properties b/examples/lf5/InitUsingMultipleAppenders/example.properties new file mode 100644 index 0000000000..ac1f374302 --- /dev/null +++ b/examples/lf5/InitUsingMultipleAppenders/example.properties @@ -0,0 +1,34 @@ +# For the general syntax of property based configuration files see the +# documenation of org.apache.log4j.PropertyConfigurator. + +# The root category uses two appenders called A1 and R. Since no priority is +# specified, the root category assumes the default priority for root +# which is DEBUG in log4j. The root category is the only category that +# has a default priority. All other categories need not be assigned a +# priority in which case they inherit their priority from the +# hierarchy. + +log4j.rootCategory=, A1, R + +# A1 is set to be a LF5Appender which outputs to a swing +# logging console. + +log4j.appender.A1=org.apache.log4j.lf5.LF5Appender + +# R is the RollingFileAppender that outputs to a rolling log +# file called rolling_log_file.log. + +log4j.appender.R=org.apache.log4j.RollingFileAppender +log4j.appender.R.File=rolling_log_file.log + +# Define a pattern layout for the file. +# For more information on conversion characters (i.e. d,p,t,c,l,m,n) +# please see the PatternLayout class of the Log4j API. + +log4j.appender.R.layout=org.apache.log4j.PatternLayout +log4j.appender.R.layout.ConversionPattern=[slf5s.start]%d{DATE}[slf5s.DATE]%n%p[slf5s.PRIORITY]%n%x[slf5s.NDC]%n%t[slf5s.THREAD]%n%c[slf5s.CATEGORY]%n%l[slf5s.LOCATION]%n%m[slf5s.MESSAGE]%n%n + +# Set the max size of the file and the number of backup files + +log4j.appender.R.MaxFileSize=100KB +log4j.appender.R.MaxBackupIndex=1 \ No newline at end of file diff --git a/examples/lf5/InitUsingPropertiesFile/InitUsingPropertiesFile.java b/examples/lf5/InitUsingPropertiesFile/InitUsingPropertiesFile.java new file mode 100644 index 0000000000..d1968ca3aa --- /dev/null +++ b/examples/lf5/InitUsingPropertiesFile/InitUsingPropertiesFile.java @@ -0,0 +1,125 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package examples.lf5.InitUsingPropertiesFile; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; + +import java.io.IOException; +import java.net.URL; + +/** + * This is another simple example of how to use the LogFactor5 + * logging console. + * + * The LF5Appender is the primary class that enables logging to the + * LogFactor5 logging window. If the following line is added to a properties + * file, the LF5Appender will be appended to the root category when + * the properties file is loaded: + * + * log4j.appender.A1=org.apache.log4j.lf5.LF5Appender + * + * To make this example work, you must ensure that the example.properties file + * is in your classpath.You can then run the example at the command line. + * + * @author Brent Sprecher + */ + +// Contributed by ThoughtWorks Inc. + +public class InitUsingPropertiesFile { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + + private static Logger logger = + Logger.getLogger(InitUsingPropertiesFile.class); + + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + public static void main(String argv[]) { + // Use a PropertyConfigurator to initialize from a property file. + String resource = + "/examples/lf5/InitUsingPropertiesFile/example.properties"; + URL configFileResource = + InitUsingPropertiesFile.class.getResource(resource); + PropertyConfigurator.configure(configFileResource); + + // Add a bunch of logging statements ... + logger.debug("Hello, my name is Homer Simpson."); + logger.debug("Hello, my name is Lisa Simpson."); + logger.debug("Hello, my name is Marge Simpson."); + logger.debug("Hello, my name is Bart Simpson."); + logger.debug("Hello, my name is Maggie Simpson."); + + logger.info("We are the Simpsons!"); + logger.info("Mmmmmm .... Chocolate."); + logger.info("Homer likes chocolate"); + logger.info("Doh!"); + logger.info("We are the Simpsons!"); + + logger.warn("Bart: I am through with working! Working is for chumps!" + + "Homer: Son, I'm proud of you. I was twice your age before " + + "I figured that out."); + logger.warn("Mmm...forbidden donut."); + logger.warn("D'oh! A deer! A female deer!"); + logger.warn("Truly, yours is a butt that won't quit." + + "- Bart, writing as Woodrow to Ms. Krabappel."); + + logger.error("Dear Baby, Welcome to Dumpsville. Population: you."); + logger.error("Dear Baby, Welcome to Dumpsville. Population: you.", + new IOException("Dumpsville, USA")); + logger.error("Mr. Hutz, are you aware you're not wearing pants?"); + logger.error("Mr. Hutz, are you aware you're not wearing pants?", + new IllegalStateException("Error !!")); + + + logger.fatal("Eep."); + logger.fatal("Mmm...forbidden donut.", + new SecurityException("Fatal Exception")); + logger.fatal("D'oh! A deer! A female deer!"); + logger.fatal("Mmmmmm .... Chocolate.", + new SecurityException("Fatal Exception")); + } + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + +} diff --git a/examples/lf5/InitUsingPropertiesFile/example.properties b/examples/lf5/InitUsingPropertiesFile/example.properties new file mode 100644 index 0000000000..ab421d3b3a --- /dev/null +++ b/examples/lf5/InitUsingPropertiesFile/example.properties @@ -0,0 +1,17 @@ +# For the general syntax of property based configuration files see the +# documenation of org.apache.log4j.PropertyConfigurator. + +# The root category uses the appender called A1. Since no priority is +# specified, the root category assumes the default priority for root +# which is DEBUG in log4j. The root category is the only category that +# has a default priority. All other categories need not be assigned a +# priority in which case they inherit their priority from the +# hierarchy. + +log4j.rootCategory=, A1 + +# A1 is set to be a LF5Appender which outputs to a swing +# logging console. + +log4j.appender.A1=org.apache.log4j.lf5.LF5Appender +log4j.appender.A1.MaxNumberOfRecords=700 diff --git a/examples/lf5/InitUsingXMLPropertiesFile/InitUsingXMLPropertiesFile.java b/examples/lf5/InitUsingXMLPropertiesFile/InitUsingXMLPropertiesFile.java new file mode 100644 index 0000000000..c02e8c7baa --- /dev/null +++ b/examples/lf5/InitUsingXMLPropertiesFile/InitUsingXMLPropertiesFile.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package examples.lf5.InitUsingXMLPropertiesFile; + +import org.apache.log4j.Logger; +import org.apache.log4j.xml.DOMConfigurator; + +import java.io.IOException; +import java.net.URL; + +/** + * This is another simple example of how to use the LogFactor5 + * logging console. + * + * To make this example work, ensure that the lf5.jar, lf5-license.jar + * and example.xml files are in your classpath. Once your classpath has + * been set up, you can run the example from the command line. + * + * @author Brent Sprecher + */ + +// Contributed by ThoughtWorks Inc. + +public class InitUsingXMLPropertiesFile { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + + private static Logger logger = + Logger.getLogger(InitUsingXMLPropertiesFile.class); + + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + public static void main(String argv[]) { + // Use a PropertyConfigurator to initialize from a property file. + String resource = + "/examples/lf5/InitUsingXMLPropertiesFile/example.xml"; + URL configFileResource = + InitUsingXMLPropertiesFile.class.getResource(resource); + DOMConfigurator.configure(configFileResource.getFile()); + + // Add a bunch of logging statements ... + logger.debug("Hello, my name is Homer Simpson."); + logger.debug("Hello, my name is Lisa Simpson."); + logger.debug("Hello, my name is Marge Simpson."); + logger.debug("Hello, my name is Bart Simpson."); + logger.debug("Hello, my name is Maggie Simpson."); + + logger.info("We are the Simpsons!"); + logger.info("Mmmmmm .... Chocolate."); + logger.info("Homer likes chocolate"); + logger.info("Doh!"); + logger.info("We are the Simpsons!"); + + logger.warn("Bart: I am through with working! Working is for chumps!" + + "Homer: Son, I'm proud of you. I was twice your age before " + + "I figured that out."); + logger.warn("Mmm...forbidden donut."); + logger.warn("D'oh! A deer! A female deer!"); + logger.warn("Truly, yours is a butt that won't quit." + + "- Bart, writing as Woodrow to Ms. Krabappel."); + + logger.error("Dear Baby, Welcome to Dumpsville. Population: you."); + logger.error("Dear Baby, Welcome to Dumpsville. Population: you.", + new IOException("Dumpsville, USA")); + logger.error("Mr. Hutz, are you aware you're not wearing pants?"); + logger.error("Mr. Hutz, are you aware you're not wearing pants?", + new IllegalStateException("Error !!")); + + + logger.fatal("Eep."); + logger.fatal("Mmm...forbidden donut.", + new SecurityException("Fatal Exception")); + logger.fatal("D'oh! A deer! A female deer!"); + logger.fatal("Mmmmmm .... Chocolate.", + new SecurityException("Fatal Exception")); + } + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + +} diff --git a/examples/lf5/InitUsingXMLPropertiesFile/example.xml b/examples/lf5/InitUsingXMLPropertiesFile/example.xml new file mode 100644 index 0000000000..d167c5f158 --- /dev/null +++ b/examples/lf5/InitUsingXMLPropertiesFile/example.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/lf5/OpeningLogFiles/sample.log b/examples/lf5/OpeningLogFiles/sample.log new file mode 100644 index 0000000000..1adbea56e8 --- /dev/null +++ b/examples/lf5/OpeningLogFiles/sample.log @@ -0,0 +1,184 @@ +[slf5s.start]26 Jul 2001 15:54:44,673[slf5s.DATE] +DEBUG[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:102)[slf5s.LOCATION] +Hello, my name is Homer Simpson.[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,743[slf5s.DATE] +DEBUG[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:103)[slf5s.LOCATION] +Hello, my name is Lisa Simpson.[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,743[slf5s.DATE] +DEBUG[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:104)[slf5s.LOCATION] +Hello, my name is Marge Simpson.[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,753[slf5s.DATE] +DEBUG[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:105)[slf5s.LOCATION] +Hello, my name is Bart Simpson.[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,793[slf5s.DATE] +DEBUG[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:106)[slf5s.LOCATION] +Hello, my name is Maggie Simpson.[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,793[slf5s.DATE] +INFO[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:108)[slf5s.LOCATION] +We are the Simpsons![slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,803[slf5s.DATE] +INFO[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:109)[slf5s.LOCATION] +Mmmmmm .... Chocolate.[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,803[slf5s.DATE] +INFO[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:110)[slf5s.LOCATION] +Homer likes chocolate[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,803[slf5s.DATE] +INFO[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:111)[slf5s.LOCATION] +Doh![slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,803[slf5s.DATE] +INFO[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:112)[slf5s.LOCATION] +We are the Simpsons![slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,803[slf5s.DATE] +WARN[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:114)[slf5s.LOCATION] +Bart: I am through with working! Working is for chumps!Homer: Son, I'm proud of you. I was twice your age before I figured that out.[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,803[slf5s.DATE] +WARN[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:117)[slf5s.LOCATION] +Mmm...forbidden donut.[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,803[slf5s.DATE] +WARN[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:118)[slf5s.LOCATION] +D'oh! A deer! A female deer![slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,803[slf5s.DATE] +WARN[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:119)[slf5s.LOCATION] +Truly, yours is a butt that won't quit.- Bart, writing as Woodrow to Ms. Krabappel.[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,803[slf5s.DATE] +ERROR[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:122)[slf5s.LOCATION] +Dear Baby, Welcome to Dumpsville. Population: you.[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,903[slf5s.DATE] +ERROR[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:123)[slf5s.LOCATION] +Dear Baby, Welcome to Dumpsville. Population: you.[slf5s.MESSAGE] + +java.io.IOException: Dumpsville, USA + at examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:123) +[slf5s.start]26 Jul 2001 15:54:44,903[slf5s.DATE] +ERROR[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:125)[slf5s.LOCATION] +Mr. Hutz, are you aware you're not wearing pants?[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:44,903[slf5s.DATE] +ERROR[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:126)[slf5s.LOCATION] +Mr. Hutz, are you aware you're not wearing pants?[slf5s.MESSAGE] + +java.lang.IllegalStateException: Error !! + at examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:126) +[slf5s.start]26 Jul 2001 15:54:44,903[slf5s.DATE] +FATAL[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:130)[slf5s.LOCATION] +Eep.[slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:45,063[slf5s.DATE] +FATAL[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:131)[slf5s.LOCATION] +Mmm...forbidden donut.[slf5s.MESSAGE] + +java.lang.SecurityException: Fatal Exception + at examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:131) +[slf5s.start]26 Jul 2001 15:54:45,063[slf5s.DATE] +FATAL[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:133)[slf5s.LOCATION] +D'oh! A deer! A female deer![slf5s.MESSAGE] + +[slf5s.start]26 Jul 2001 15:54:45,063[slf5s.DATE] +FATAL[slf5s.PRIORITY] +[slf5s.NDC] +main[slf5s.THREAD] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders[slf5s.CATEGORY] +examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:134)[slf5s.LOCATION] +Mmmmmm .... Chocolate.[slf5s.MESSAGE] + +java.lang.SecurityException: Fatal Exception + at examples.InitUsingMultipleAppenders.InitUsingMultipleAppenders.main(InitUsingMultipleAppenders.java:134) diff --git a/examples/lf5/UsingLogMonitorAdapter/CustomizedLogLevels.java b/examples/lf5/UsingLogMonitorAdapter/CustomizedLogLevels.java new file mode 100644 index 0000000000..b0e9942e74 --- /dev/null +++ b/examples/lf5/UsingLogMonitorAdapter/CustomizedLogLevels.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package examples.lf5.UsingLogMonitorAdapter; + +import org.apache.log4j.lf5.LogLevel; +import org.apache.log4j.lf5.util.LogMonitorAdapter; + +/** + * This class is a simple example of how use the LogMonitorAdapter to + * bypass the Log4JAppender and post LogRecords directly to the LogMonitor + * using customized LogLevels + * + * To make this example work, ensure that the lf5.jar and lf5-license.jar + * files are in your classpath, and then run the example at the command line. + * + * @author Richard Hurst + */ + +// Contributed by ThoughtWorks Inc. + +public class CustomizedLogLevels { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + public final static LogLevel LEVEL_ONE = new LogLevel("LEVEL 1", 1); + public final static LogLevel LEVEL_TWO = new LogLevel("LEVEL 2", 2); + public final static LogLevel LEVEL_THREE = new LogLevel("LEVEL 3", 3); + public final static LogLevel LEVEL_FOUR = new LogLevel("LEVEL 4", 4); + public final static LogLevel DEFAULT = new LogLevel("DEFAULT", 0); + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + private static LogMonitorAdapter _adapter; + + static { + // The first LogLevel in the Array will be used as the default LogLevel. + _adapter = LogMonitorAdapter.newInstance(new LogLevel[]{DEFAULT, LEVEL_ONE, + LEVEL_TWO, LEVEL_THREE, LEVEL_FOUR, LogLevel.FATAL}); + // if a different log level is to be used it can be specified as such + // _adapter.setDefaultLevel(LEVEL_THREE); + } + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + public static void main(String[] args) { + CustomizedLogLevels test = new CustomizedLogLevels(); + test.doMyBidding(); + } + + public void doMyBidding() { + // tell the LogMonitorAdapter which LogLevel is the severe Level if necessary + _adapter.setSevereLevel(LEVEL_ONE); + + String levels = this.getClass().getName(); + + // will used the default Level + _adapter.log(levels, "Using the customized LogLevels"); + + _adapter.log(levels, LEVEL_FOUR, "This is a test"); + _adapter.log(levels, LEVEL_THREE, "Hmmm fobidden doughnut"); + _adapter.log(levels, LEVEL_ONE, "Danger Danger Will Robinson", + new RuntimeException("DANGER"), "32"); + _adapter.log(levels, LEVEL_TWO, "Exit stage right->"); + _adapter.log(levels, LEVEL_FOUR, "What's up Doc?", + new NullPointerException("Unfortunate exception")); + + } + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- +} + + + + + diff --git a/examples/lf5/UsingLogMonitorAdapter/UsingLogMonitorAdapter.java b/examples/lf5/UsingLogMonitorAdapter/UsingLogMonitorAdapter.java new file mode 100644 index 0000000000..545bf3118f --- /dev/null +++ b/examples/lf5/UsingLogMonitorAdapter/UsingLogMonitorAdapter.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package examples.lf5.UsingLogMonitorAdapter; + +import org.apache.log4j.lf5.LogLevel; +import org.apache.log4j.lf5.util.LogMonitorAdapter; + +/** + * This class is a simple example of how use the LogMonitorAdapter to + * bypass the Log4JAppender and post LogRecords directly to the LogMonitor + * + * To make this example work, ensure that the lf5.jar and lf5-license.jar + * files are in your classpath, and then run the example at the command line. + * + * @author Richard Hurst + */ + +// Contributed by ThoughtWorks Inc. + +public class UsingLogMonitorAdapter { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + private static LogMonitorAdapter _adapter; + + static { + _adapter = LogMonitorAdapter.newInstance(LogMonitorAdapter.LOG4J_LOG_LEVELS); + } + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + public static void main(String[] args) { + UsingLogMonitorAdapter test = new UsingLogMonitorAdapter(); + test.doMyBidding(); + } + + public void doMyBidding() { + String logger = this.getClass().getName(); + + // will default to debug log level + _adapter.log(logger, "Doh this is a debugging"); + + _adapter.log(logger, LogLevel.INFO, "Hmmm fobidden doughnut"); + _adapter.log(logger, LogLevel.WARN, "Danger Danger Will Robinson", + new RuntimeException("DANGER"), "32"); + _adapter.log(logger, LogLevel.ERROR, "Exit stage right->"); + _adapter.log(logger, LogLevel.FATAL, "What's up Doc?", + new NullPointerException("Unfortunate exception")); + } + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- +} + + + + + diff --git a/examples/lf5/UsingSocketAppenders/UsingSocketAppenders.java b/examples/lf5/UsingSocketAppenders/UsingSocketAppenders.java new file mode 100644 index 0000000000..d22a2e0df5 --- /dev/null +++ b/examples/lf5/UsingSocketAppenders/UsingSocketAppenders.java @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package examples.lf5.UsingSocketAppenders; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; + +import java.io.IOException; +import java.net.URL; + +/** + * This is another simple example of how to use the LogFactor5 + * logging console. + * + * The LF5Appender is the primary class that enables logging to the + * LogFactor5 logging window. If the following line is added to a properties + * file, the LF5Appender will be appended to the root category when + * the properties file is loaded: + * + * log4j.appender.A1=org.apache.log4j.lf5.LF5Appender + * + * To make this example work, you must ensure that the example.properties file + * is in your classpath.You can then run the example at the command line. + * + * @author Brent Sprecher + */ + +// Contributed by ThoughtWorks Inc. + +public class UsingSocketAppenders { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + + private static Logger logger1 = + Logger.getLogger(UsingSocketAppenders.class); + private static Logger logger2 = + Logger.getLogger("TestClass.Subclass"); + private static Logger logger3 = + Logger.getLogger("TestClass.Subclass.Subclass"); + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + public static void main(String argv[]) { + // Use a PropertyConfigurator to initialize from a property file. + String resource = + "/examples/lf5/UsingSocketAppenders/socketclient.properties"; + URL configFileResource = + UsingSocketAppenders.class.getResource(resource); + PropertyConfigurator.configure(configFileResource); + + // Add a bunch of logging statements ... + logger1.debug("Hello, my name is Homer Simpson."); + logger1.debug("Hello, my name is Lisa Simpson."); + logger2.debug("Hello, my name is Marge Simpson."); + logger2.debug("Hello, my name is Bart Simpson."); + logger3.debug("Hello, my name is Maggie Simpson."); + + logger2.info("We are the Simpsons!"); + logger2.info("Mmmmmm .... Chocolate."); + logger3.info("Homer likes chocolate"); + logger3.info("Doh!"); + logger3.info("We are the Simpsons!"); + + logger1.warn("Bart: I am through with working! Working is for chumps!" + + "Homer: Son, I'm proud of you. I was twice your age before " + + "I figured that out."); + logger1.warn("Mmm...forbidden donut."); + logger1.warn("D'oh! A deer! A female deer!"); + logger1.warn("Truly, yours is a butt that won't quit." + + "- Bart, writing as Woodrow to Ms. Krabappel."); + + logger2.error("Dear Baby, Welcome to Dumpsville. Population: you."); + logger2.error("Dear Baby, Welcome to Dumpsville. Population: you.", + new IOException("Dumpsville, USA")); + logger3.error("Mr. Hutz, are you aware you're not wearing pants?"); + logger3.error("Mr. Hutz, are you aware you're not wearing pants?", + new IllegalStateException("Error !!")); + + + logger3.fatal("Eep."); + + logger3.fatal("Mmm...forbidden donut.", + new SecurityException("Fatal Exception ... ")); + + logger3.fatal("D'oh! A deer! A female deer!"); + logger2.fatal("Mmmmmm .... Chocolate.", + new SecurityException("Fatal Exception")); + + // Put the main thread is put to sleep for 5 seconds to allow the + // SocketServer to process all incoming messages before the Socket is + // closed. This is done to overcome some basic limitations with the + // way the SocketServer and SocketAppender classes manage sockets. + try { + Thread.sleep(5000); + } catch (InterruptedException ie) { + } + + } + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + +} diff --git a/examples/lf5/UsingSocketAppenders/socketclient.properties b/examples/lf5/UsingSocketAppenders/socketclient.properties new file mode 100644 index 0000000000..b0513655a1 --- /dev/null +++ b/examples/lf5/UsingSocketAppenders/socketclient.properties @@ -0,0 +1,18 @@ +# For the general syntax of property based configuration files see the +# documenation of org.apache.log4j.PropertyConfigurator. + +# The root category uses the appender called A1. Since no priority is +# specified, the root category assumes the default priority for root +# which is DEBUG in log4j. The root category is the only category that +# has a default priority. All other categories need not be assigned a +# priority in which case they inherit their priority from the +# hierarchy. + +log4j.rootCategory=, A1 + +# A1 is set to be a LF5Appender which outputs to a swing +# logging console. + +log4j.appender.A1=org.apache.log4j.net.SocketAppender +log4j.appender.A1.RemoteHost=localhost +log4j.appender.A1.Port=8887 diff --git a/examples/lf5/UsingSocketAppenders/socketserver.properties b/examples/lf5/UsingSocketAppenders/socketserver.properties new file mode 100644 index 0000000000..da14ac04ce --- /dev/null +++ b/examples/lf5/UsingSocketAppenders/socketserver.properties @@ -0,0 +1,19 @@ +# For the general syntax of property based configuration files see the +# documenation of org.apache.log4j.PropertyConfigurator. + +# The root category uses the appender called A1. Since no priority is +# specified, the root category assumes the default priority for root +# which is DEBUG in log4j. The root category is the only category that +# has a default priority. All other categories need not be assigned a +# priority in which case they inherit their priority from the +# hierarchy. + +#log4j.rootCategory=DEBUG, A1 +log4j.rootCategory=, A1 + +# A1 is set to be a LF5Appender which outputs to a swing +# logging console. + +#log4j.category.org.apache.log4j.net.SocketNode=DEBUG +log4j.appender.A1=org.apache.log4j.lf5.LF5Appender +log4j.appender.A1.MaxNumberOfRecords=700 \ No newline at end of file diff --git a/examples/lf5/index.html b/examples/lf5/index.html new file mode 100644 index 0000000000..9a39752b21 --- /dev/null +++ b/examples/lf5/index.html @@ -0,0 +1,11 @@ + + + + + + +

    See Examples + section in the LogFactor5 user guide. +

    + + diff --git a/examples/mycat.bad b/examples/mycat.bad index 86ef942ff8..27ceb9ea44 100644 --- a/examples/mycat.bad +++ b/examples/mycat.bad @@ -1,16 +1,32 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # The usual stuff. Note that A1 is configured in root not in "some.cat" -log4j.rootCategory=DEBUG, A1 +log4j.rootLogger=DEBUG, A1 log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%5p [%t] %c - %m%n # Set the priority of "some.cat" to TRACE (defined in -# org.apache.log4j.xml.examples.XPriority). This will actually have -# the side effect of instanciating a category object having the name -# "some.cat" this will cause a ClassCastException if the category -# object is cast as a MyCategory object. +# examples.customLevel.XLevel). This will actually have the side +# effect of instanciating a logger object having the name "some.cat" +# this will cause a ClassCastException if the logger object is cast +# as a MyLogger object. + +log4j.logger.some.cat=TRACE#examples.customLevel.XLevel + -log4j.category.some.cat=TRACE#org.apache.log4j.xml.examples.XPriority diff --git a/examples/mycat.good b/examples/mycat.good index 6d0813667e..76697fae7a 100644 --- a/examples/mycat.good +++ b/examples/mycat.good @@ -1,13 +1,29 @@ -# Setting the category factory to MyCategoryFactory solves the +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# Setting the logger factory to MyLoggerFactory solves the # ClassCastException problem encountered with the "mycat.bad" # configuration file. -log4j.categoryFactory=org.apache.log4j.examples.MyCategoryFactory +log4j.loggerFactory=examples.subclass.MyLoggerFactory # The usual stuff. Note that A1 is configured in root not in "some.cat" -log4j.rootCategory=DEBUG, A1 +log4j.rootLogger=DEBUG, A1 log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout @@ -15,10 +31,10 @@ log4j.appender.A1.layout.ConversionPattern=%5p [%t] %c - %m%n # Set the priority of "some.cat" to TRACE (defined in -# org.apache.log4j.xml.examples.XPriority). Since we specified -# MyCategoryFactory as the category factory, the following line willl -# also have the side effect of instanciating a MyCategory object -# having the name "some.cat". +# examples.customLevel.XLevel). Since we specified MyLoggerFactory as +# the logger factory, the following line willl also have the side +# effect of instanciating a MyLogger object having the name +# "some.cat". -log4j.category.some.cat=TRACE#org.apache.log4j.xml.examples.XPriority +log4j.logger.some.cat=TRACE#examples.customLevel.XLevel diff --git a/examples/package.html b/examples/package.html index def43d8851..944341b6fe 100644 --- a/examples/package.html +++ b/examples/package.html @@ -1,4 +1,21 @@ + diff --git a/examples/sort1.properties b/examples/sort1.properties index 77943f313a..5f676d357e 100644 --- a/examples/sort1.properties +++ b/examples/sort1.properties @@ -1,3 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + # An example log4j configuration file that outputs to System.out. The # output information consists of relative time, log level, thread # name, logger name, nested diagnostic context and the message in that diff --git a/examples/sort2.properties b/examples/sort2.properties index 1bacdb92dd..b55de06929 100644 --- a/examples/sort2.properties +++ b/examples/sort2.properties @@ -1,3 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + # An example log4j configuration file that outputs both to System.out # and a file named 'test'. diff --git a/examples/sort3.properties b/examples/sort3.properties index 906285f003..91b172dfab 100644 --- a/examples/sort3.properties +++ b/examples/sort3.properties @@ -1,3 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + # An example log4j configuration file that directs its logging output # to a SocketAppender. The SocketAppender is configuted to send its # output to a server running on the localhost port number 12345. diff --git a/examples/sort4.properties b/examples/sort4.properties index b4f02acebf..72d8a19f7e 100644 --- a/examples/sort4.properties +++ b/examples/sort4.properties @@ -1,3 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + # Attach appender A1 to root. Set root level to Level.DEBUG. log4j.rootLogger=DEBUG, A1 diff --git a/examples/subclass/MyLogger.java b/examples/subclass/MyLogger.java index e91c46f46d..d2368b03a2 100644 --- a/examples/subclass/MyLogger.java +++ b/examples/subclass/MyLogger.java @@ -1,18 +1,24 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples.subclass; import org.apache.log4j.*; -import org.apache.log4j.spi.LoggerFactory; -import org.apache.log4j.xml.DOMConfigurator; import examples.customLevel.XLevel; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.helpers.LogLog; /** A simple example showing logger subclassing. @@ -49,16 +55,6 @@ void debug(Object message) { super.log(FQCN, Level.DEBUG, message + " world.", null); } - /** - This method overrides {@link Logger#getInstance} by supplying - its own factory type as a parameter. - */ - public - static - Category getInstance(String name) { - return Logger.getLogger(name, myFactory); - } - /** This method overrides {@link Logger#getLogger} by supplying its own factory type as a parameter. diff --git a/examples/subclass/MyLoggerFactory.java b/examples/subclass/MyLoggerFactory.java index 51fc50e497..8f859a1121 100644 --- a/examples/subclass/MyLoggerFactory.java +++ b/examples/subclass/MyLoggerFactory.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples.subclass; diff --git a/examples/subclass/MyLoggerTest.java b/examples/subclass/MyLoggerTest.java index 4f1ffa18a4..6ea39f5d56 100644 --- a/examples/subclass/MyLoggerTest.java +++ b/examples/subclass/MyLoggerTest.java @@ -1,16 +1,24 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package examples.subclass; import org.apache.log4j.*; -import org.apache.log4j.spi.LoggerFactory; import org.apache.log4j.xml.DOMConfigurator; -import examples.customLevel.XLevel; import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.helpers.LogLog; @@ -58,7 +66,7 @@ else if(args.length == 1) { usage("Incorrect number of parameters."); } try { - MyLogger c = (MyLogger) MyLogger.getInstance("some.cat"); + MyLogger c = (MyLogger) MyLogger.getLogger("some.cat"); c.trace("Hello"); c.debug("Hello"); } catch(ClassCastException e) { diff --git a/packaging/.functions b/packaging/.functions deleted file mode 100644 index fe8eff28f0..0000000000 --- a/packaging/.functions +++ /dev/null @@ -1,40 +0,0 @@ -# +=============================================+ -# Strip the filename, retain the directory only.| -# +=============================================+ -function getShellScriptDirectory { - local dir - - dir=${0%/*} - - if [ "$dir" = "." ] - then - dir=$(pwd) - elif [ "${dir#/}" = "$dir" ] # dir does not start with a / - then - dir=$(pwd)/$dir - fi - echo $dir -} -# ============================================== -# Delete the file if exists -# ============================================== -function deleteFile { - if [ -e $1 ]; then - echo "Deleting file [$1]." - rm $1 - fi -} -# ============================================== -# Change extension of file if it exists -# ============================================== -function changeFileExtension { - filename=$1 - ext=$2 - #echo "File mame =$1, ext=$2" - if [ -e $filename ]; then - noext=${filename%.*} - echo "Renaming [$filename] to [$noext.$ext]." - mv $filename $noext.$ext - fi -} -# ============================================== diff --git a/packaging/install b/packaging/install deleted file mode 100644 index 41d1ae82f5..0000000000 --- a/packaging/install +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/bash - -# Usage: install [-j] [-h] -# -j: jar files only -# -h: do not update the history file - -# +=============================================+ -# Strip the filename, retain the directory only.| -# +=============================================+ -function getShellScriptDirectory { - local dir - - dir=${0%/*} - - if [ "$dir" = "." ] - then - dir=$(pwd) - elif [ "${dir#/}" = "$dir" ] # dir does not start with a / - then - dir=$(pwd)/$dir - fi - echo $dir -} -# ================================================== - -WWW_TARGET=~/ASF/dump -DISTRIB_TARGET=~/sf/temp -JAR_FULL=log4j.jar -JAR_CORE=log4j-core.jar - - -if [ -z "$ANT" ] -then - ANT=ant -fi - - -while getopts ":jh" opt; do - - case $opt in - j ) JAR_ONLY=true - ;; - h ) NO_HISTORY=true - ;; - \? ) echo "Usage: install [-j] [-h]" - echo " -j: jar files only" - echo " -h: do not update the history file" - exit; - esac -done - -# ================================================================= -function cleanUp { - echo "" -} -# ================================================================= - -pushd $PWD > /dev/null - -scriptDir=$(getShellScriptDirectory) -echo "Script directry is determined to be [$scriptDir]" - -echo "Sourcing ${scriptDir}/.functions" -. ${scriptDir}/.functions - -echo "Setting current dir to [${scriptDir}/..]" -cd ${scriptDir}/.. -PKG_DIR=$PWD - -# ${PKG_DIR##*/} returns the package name -PKG_NAME=${PKG_DIR##*/} - -# Package name is [$PKG_NAME] - -TGZ_FILE=${PKG_NAME}.tgz -ZIP_FILE=${PKG_NAME}.zip - -echo "Deleting \"core\" files." -find . -type f -name core -exec rm {} \; - -deleteFile $PKG_DIR/org/apache/log4j/performance/test -deleteFile $PKG_DIR/org/apache/log4j/test/temp -deleteFile $PKG_DIR/org/apache/log4j/test/temp.A1 -deleteFile $PKG_DIR/org/apache/log4j/test/temp.A2 -deleteFile $PKG_DIR/org/apache/log4j/test/temp.x -deleteFile $PKG_DIR/org/apache/log4j/test/temp.1 -deleteFile $PKG_DIR/org/apache/log4j/test/temp.2 -deleteFile $PKG_DIR/org/apache/log4j/test/temp.3 -deleteFile $PKG_DIR/org/apache/log4j/test/logging.lcf -deleteFile $PKG_DIR/org/apache/log4j/test/logging.cat -deleteFile $PKG_DIR/org/apache/log4j/test/current.reg -deleteFile $PKG_DIR/org/apache/log4j/test/current.reg.A1 -deleteFile $PKG_DIR/org/apache/log4j/test/current.reg.A2 -deleteFile $PKG_DIR/org/apache/log4j/test/log4j.properties -deleteFile $PKG_DIR/org/apache/log4j/test/socket.lcf -deleteFile $PKG_DIR/org/apache/log4j/test/file -deleteFile $PKG_DIR/org/apache/log4j/test/output.A1 - -deleteFile $PKG_DIR/org/apache/log4j/examples/test -deleteFile $PKG_DIR/org/apache/log4j/xml/test/output.A1 -deleteFile $PKG_DIR/org/apache/log4j/xml/test/output.A2 -deleteFile $PKG_DIR/org/apache/log4j/xml/test/temp.A1 -deleteFile $PKG_DIR/org/apache/log4j/xml/test/temp.A2 -deleteFile $PKG_DIR/org/apache/log4j/xml/test/current.reg -deleteFile $PKG_DIR/org/apache/log4j/nt/EventLogCategories.dbg -deleteFile $PKG_DIR/org/apache/log4j/nt/EventLogCategories.h -deleteFile $PKG_DIR/org/apache/log4j/nt/EventLogCategories.rc -deleteFile $PKG_DIR/org/apache/log4j/nt/EventLogCategories.RES -deleteFile $PKG_DIR/org/apache/log4j/nt/MSG00001.bin -deleteFile $PKG_DIR/org/apache/log4j/nt/NTEventLogAppender.lib -deleteFile $PKG_DIR/org/apache/log4j/nt/NTEventLogAppender.exp -deleteFile $PKG_DIR/org/apache/log4j/nt/vc50.idb -deleteFile $PKG_DIR/org/apache/log4j/net/test/loop.log -deleteFile $PKG_DIR/org/apache/log4j/net/test/loop.log.1 -deleteFile $PKG_DIR/classes/org/apache/log4j/UnitTestCategory.class -deleteFile $PKG_DIR/org/apache/log4j/varia/test/temp -deleteFile $PKG_DIR/org/apache/log4j/xml/test/temp - -echo "Cleaning \"classes\" directory." -find . -type d -path "./classes/exercise" -exec rm -r {} \; -find . -type d -path "./classes/make" -exec rm -r {} \; - -echo -n "Build stamp: " -date -u +"%Y-%m-%d %T %Z" - -echo "About to run ANT. Current directory is [$PWD]" -$ANT jar - -if [ "$?" != "0" ]; then - echo "jar failed! Exiting."; popd; exit 1 -fi - -if [ -n "$JAR_ONLY" ]; then - cleanUp - exit -fi - - - -# Run tramake -$scriptDir/tarmake - -if [ "$?" != "0" ]; then - echo "There was an error while running \"$scriptDir/tarmake\". Exiting." - exit 1 -fi - -if [ ! -s ../$TGZ_FILE ] -then - echo "../$TGZ_FILE does not exists in $PWD/.." - exit 1 -fi - - -echo "Moving $TGZ_FILE to $WWW_TARGET/" -mv ../$TGZ_FILE $WWW_TARGET/ -if [ "$?" != "0" ]; then - echo "There was an error moving ../$TGZ_FILE to $WWW_TARGET/" - exit 1 -fi - -echo "About to do ZIP processing in [$DISTRIB_TARGET]" - -# Clean up old copy of package in $DISTRIB_TARGET -cd $DISTRIB_TARGET -if [ -d $DISTRIB_TARGET/$PKG_NAME ]; then - echo; echo "Removing directory $DISTRIB_TARGET/$PKG_NAME" - rm -r $DISTRIB_TARGET/$PKG_NAME - if [ "$?" != "0" ]; then - echo "Could not remove $DISTRIB_TARGET/$PKG_NAME. Exiting."; exit 1 - fi -fi - -echo; echo "Untarring $WWW_TARGET/$TGZ_FILE in $PWD" -tar xzf $WWW_TARGET/$TGZ_FILE - -cd $DISTRIB_TARGET -echo; -if [ -e $WWW_TARGET/$ZIP_FILE ]; then - echo "Removing stale $WWW_TARGET/$ZIP_FILE" - rm $WWW_TARGET/$ZIP_FILE -fi -echo "Zipping $PKG_NAME in $DISTRIB_TARGET to $WWW_TARGET/$ZIP_FILE" -zip -y -9 -q -r $WWW_TARGET/$ZIP_FILE $PKG_NAME -if [ "$?" != "0" ]; then - echo "There was an error while zipping. Exiting."; exit 1 -fi - -cleanUp diff --git a/packaging/package-list b/packaging/package-list deleted file mode 100644 index 407d0d79a5..0000000000 --- a/packaging/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/packaging/tarmake b/packaging/tarmake deleted file mode 100644 index 39e6abf5de..0000000000 --- a/packaging/tarmake +++ /dev/null @@ -1,72 +0,0 @@ -# use v as argument for verbose tar output - -# Note: the ${pkg}.tgz file is output in $scriptDir/../.. - -#. .functions > /dev/null - -pushd $PWD > /dev/null - -scriptDir=$(getShellScriptDirectory) -echo "tarmake script directory found to be [$scriptDir]." - -tmp0=${scriptDir%/packaging} -pkg=${tmp0##/*/} -echo "Package version name found to be [$pkg]." - -cd $scriptDir/../.. - -echo "tarmake current directory is [$PWD]" - -if [ ! -s $pkg/packaging/package-list ] -then - echo "Could not find file \"package-list\" in directory $pkg/packaging." - echo "Current direcotry is [$PWD]." - exit 1 -fi - - -echo;echo "Making tar file $pkg.tgz in $PWD" -find $pkg -name "*CVS*" -o -name ".#*" -o -name "*~" -o -name \ - "*util.old*" -o -name "*misc*" -o -name TAGS -o -name "*.avaj" \ - -o -name make.loc -o -name "*pending*"\ - -o -path "*nt/Readme.txt" -o -name goEtags -o -name "JListView*" \ - -o -name "JTableAppender*" > $scriptDir/tar-exclude - -if [ $? -ne 0 ]; then - echo "Find failed with exit code $?."; exit 1; -fi -tar -cz${1}f ${pkg}.tgz -X $scriptDir/tar-exclude \ - $pkg/make/\ - $pkg/doc/\ - $pkg/xdocs/\ - $pkg/Makefile\ - $pkg/build.xml\ - $pkg/build.inc\ - $pkg/manifest.mf\ - $pkg/INSTALL\ - $pkg/LICENSE.APL\ - $pkg/*.jar\ - $pkg/org/ \ - $pkg/icons\ - $pkg/classes/ \ - $pkg/javadoc/ \ - $pkg/packaging/package-list \ - $pkg/packaging/.functions \ - $pkg/packaging/initialize \ - $pkg/packaging/install \ - $pkg/packaging/tarmake \ - - -if [ $? -ne 0 ]; then - echo "tar failed with exit code $?."; exit 1; -fi - -popd > /dev/null - -echo "tarmake successful." -exit 0 - - - - - diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000..78f6038e9d --- /dev/null +++ b/pom.xml @@ -0,0 +1,468 @@ + + + 4.0.0 + log4j + log4j + jar + Apache Log4j + 1.2.15-SNAPSHOT + + 1.2.15 + + Apache Log4j 1.2 + http://logging.apache.org:80/log4j/1.2/ + + Bugzilla + http://issues.apache.org/bugzilla/ + + + Gump + http://vmgump.apache.org/gump/public/logging-log4j-12/logging-log4j-12/index.html + + 1999 + + + log4j-user + log4j-user-subscribe@logging.apache.org + log4j-user-unsubscribe@logging.apache.org + log4j-user@logging.apache.org + http://mail-archives.apache.org/mod_mbox/logging-log4j-dev/ + + http://marc.info/?l=log4j-user + http://dir.gmane.org/gmane.comp.jakarta.log4j.user + + + + log4j-dev + log4j-dev-subscribe@logging.apache.org + log4j-dev-unsubscribe@logging.apache.org + log4j-dev@logging.apache.org + http://mail-archives.apache.org/mod_mbox/logging-log4j-dev/ + + http://marc.info/?l=log4j-dev + http://dir.gmane.org/gmane.comp.jakarta.log4j.devel + + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + scm:svn:http://svn.apache.org/repos/asf/logging/log4j/trunk + scm:svn:https://svn.apache.org/repos/asf/logging/log4j/trunk + http://svn.apache.org/viewcvs.cgi/logging/log4j/trunk + + + Apache Software Foundation + http://www.apache.org + + + + + maven-surefire-plugin + + tests + plain + pertest + true + + org/apache/log4j/LevelTest.java + org/apache/log4j/PriorityTest.java + org/apache/log4j/CategoryTest.java + org/apache/log4j/FileAppenderTest.java + org/apache/log4j/LogManagerTest.java + org/apache/log4j/helpers.LogLogTest.java + org/apache/log4j/LayoutTest.java + org/apache/log4j/helpers.DateLayoutTest.java + org/apache/log4j/TTCCLayoutTest.java + org/apache/log4j/xml.XMLLayoutTest.java + org/apache/log4j/HTMLLayoutTest.java + org/apache/log4j/PatternLayoutTest.java + org/apache/log4j/spi.LoggingEventTest.java + org/apache/log4j/spi.ThrowableInformationTest.java + org/apache/log4j/spi.LocationInfoTest.java + org/apache/log4j/PropertyConfiguratorTest.java + org/apache/log4j/MinimumTestCase.java + org/apache/log4j/LoggerTestCase.java + org/apache/log4j/PatternLayoutTestCase.java + org/apache/log4j/HierarchyThresholdTestCase.java + org/apache/log4j/xml/DOMTestCase.java + org/apache/log4j/xml/CustomLevelTestCase.java + org/apache/log4j/customLogger/XLoggerTestCase.java + + + org/apache/log4j/xml/XMLLayoutTestCase.java + org/apache/log4j/xml/AsyncAppenderTestCase.java + org/apache/log4j/varia/LevelMatchFilterTestCase.java + + + + org/apache/log4j/helpers/BoundedFIFOTestCase.java + org/apache/log4j/helpers/CyclicBufferTestCase.java + org/apache/log4j/helpers/PatternParserTestCase.java + org/apache/log4j/or/ORTestCase.java + org/apache/log4j/DRFATestCase.java + org/apache/log4j/RFATestCase.java + org/apache/log4j/varia/ERFATestCase.java + org/apache/log4j/net/SyslogAppenderTest + org/apache/log4j/nt/NTEventLogAppenderTest + org/apache/log4j/net/SocketAppenderTest + + + + + maven-compiler-plugin + + 1.2 + 1.1 + + + + maven-jar-plugin + + + + + org.apache.log4j + + log4j + ${project.version} + "Apache Software Foundation" + + + + + + + + maven-antrun-plugin + + + + process-classes + ntdll + + + + + + + + + + + + run + + + + + test-compile + mkdir_tests_output + + + + + + + run + + + + clean + rmdir_tests_output + + + + + + + run + + + + test + runAll + + + + + + + + + + + + run + + + + + site + untag-site + + + + + + + + + + + run + + + + post-site + post-site + + + + + + + run + + + + site-deploy + site-deploy + + + + + + + run + + + + + + ant + ant-nodeps + 1.6.5 + + + ant-contrib + ant-contrib + 1.0b2 + + + ant + ant-junit + 1.6.5 + + + junit + junit + 3.8.1 + test + + + sun.jdk + tools + 1.4.2 + system + ${tools.jar} + + + + + maven-assembly-plugin + + + src/assembly/bin.xml + + false + + + + + assembly + + + + + + maven-javadoc-plugin + + + + jar + javadoc + + + + + + maven-source-plugin + + + + jar + + + + + + + org.codehaus.mojo + clirr-maven-plugin + + 1.2.14 + + + + tests/src/java + + + tests/resources + + + + + + mac + + mac + + + ${java.home}/../Classes/classes.jar + + + + default + + true + + + ${java.home}/../lib/tools.jar + + + + + + java.net + https://maven-repository.dev.java.net/nonav/repository + legacy + + + + + javax.mail + mail + 1.4 + + + javax.jms + jms + 1.1 + + + com.sun.jdmk + jmxtools + 1.2.1 + + + com.sun.jmx + jmxri + 1.2.1 + + + oro + oro + 2.0.8 + test + + + junit + junit + 3.8.1 + test + + + + true + + + maven-project-info-reports-plugin + + + + scm + dependencies + cim + issue-tracking + mailing-list + license + + + + + + org.codehaus.mojo + jxr-maven-plugin + + + maven-release-plugin + + site-deploy + + + + maven-changes-plugin + + + + changes-report + + + + + %URL%/show_bug.cgi?id=%ISSUE% + + + + + + + logging.repo + scp://people.apache.org/www/people.apache.org/builds/logging/repo/ + + + logging.site + scp://localhost/${user.dir}/target/site-deploy + + + diff --git a/src/assembly/bin.xml b/src/assembly/bin.xml new file mode 100644 index 0000000000..4090576ec1 --- /dev/null +++ b/src/assembly/bin.xml @@ -0,0 +1,64 @@ + + + bin + + zip + tar.gz + + apache-log4j-${project.version} + true + + + + *.txt + *.sample + *.xml + INSTALL + KEYS + LICENSE + NOTICE + contribs/** + examples/** + src/assembly/** + src/changes/** + src/main/** + src/ntdll/** + src/performance/** + src/site/** + tests/README + tests/*.xml + tests/*.sample + tests/*.bat + tests/input/** + tests/resources/** + tests/src/** + tests/witness/** + + + + + + target/log4j-${project.version}.jar + + + target/NTEventLogAppender.dll + 0755 + + + diff --git a/src/changes/changes.xml b/src/changes/changes.xml new file mode 100644 index 0000000000..8cb9d278e9 --- /dev/null +++ b/src/changes/changes.xml @@ -0,0 +1,1762 @@ + + + + Apache log4j 1.2 + + + + + Notice to use UTF-8 or UTF-16 encoding added to XML and HTMLLayout javadoc. + XML and HTMLLayout do not always escape special characters. + Optionally render MDC content in XMLLayout + Typo in log4j.dtd concerning threshold. + ERFATestCase fails on some JDK's. + SocketNode can leak Sockets. + Migrate to Maven based build and documentation. + Prepare Maven release bundles. + Eclipse compiler warning cleanup. + JRockit VM and java-gcj fail unit tests. + SocketAppender does not use FallbackErrorHandler + Enhance DOMConfigurator to delegate unrecognized elements to configured object. + Add LoggingEvent accessors. + InstanceAlreadyExistsException using MBean. + Reduce first connection failure severity in SocketAppender + SyslogAppender does not limit packets to 1024 bytes. + SyslogAppender: Added "header" property which if set to true will cause the appender + to produce the HEADER part (timestamp and hostname) of the syslog packet. + Default value is false for compatibility with previous behavior. + SyslogAppender also now sends any header from the associated + layout when activateOptions is called or first logging event is sent and + any footer when the appender is closed. + SyslogAppender leaks descriptors + SyslogAppender assumes all lines start with tab + SyslogAppender does not limit packet size to 1024 bytes + + NTEventLogAppender: Updated NTEventLogAppender.dll which corrects missing event messages + and which should work with earlier releases of log4j. + NTEventLogAppender.dll also now supports registration and unregistration + using regsvr32. If replacing an existing copy of NTEventLogAppender, + use "regsvr32 NTDllEventLogAppender.dll" or manually remove the + HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Eventlog/Application/Log4J + registry key. + NTEventLogAppender.dll performs unnecessary code page conversion using code copied from book. + PropertyConfigurator.configure(URL) does not close resource stream. + In Turkish locale level "info" is not equivalent to "INFO" + Javadoc of PatternLayout should use %n in TTCC layout examples + Stacktraces of exceptions disappear occassionally + Incorrect message when specified custom level class does not implement toLevel + Warning when configuring inner-class logger + AsyncAppender in 1.2.14 DiscardSummary events create NullPointerExceptions in layouts + Add target to generate binary and source compatibility report + PropertyPrinter.printOptions breaking signature change in log4j 1.2.9 + RollingFileAppender may delete files during rollover + XMLConfiguration of loggerFactory does not work + SyslogAppender does not limit packet size to 1024 bytes + Update source per new ASF Header Policy. + DateLayoutTest fails if default Locale is not en_US. + Stacktrace may choke on null fields. + Add projects.apache.org project descriptor. + + + + Monitor deadlock in AsyncAppender. + AsyncAppender: Dispatcher should run at normal prio. + AsyncAppender wait forever when buffer is full. + Add non-blocking option for AsyncAppender. + Add SyslogPort option to SyslogAppender. + Add cc and bcc addresses to SMTPAppender. + Add password authentication to SMTPAppender. + NullPointerException in org.apache.log4j.NDC.get. + org.apache.log4j.lf5.util.DateFormatManager.setTimeZone assignment error. + Monthly logs not generated at midnight with DailyRollingFileAppender. + PatternLayout specifier %r is not consistent with documentation. + Space after log level causes default level to be used. + Bad patterns in ISO8601DateFormat and DateTimeDateFormat. + SyslogAppender throws NullPointerException upon misconfiguration. + FallbackErrorHandler throws NullPointerException if no loggers are set. + Bad documentation for WriterAppender.encoding. + NTEventLogAppender not build, tested and placed in distribution. + SMTPAppender does not output newlines between stack trace lines. + SMTPAppender will not run within sandbox. + MDC with SMTPAppender doesn't work. + Misspelling in HierarchyDynamicMBean. + Additivity not exported by PropertyPrinter. + RollingFileAppender, if removed, can cause NullPointerExceptions. + AsyncAppender blocks on thread death. + NOTICE file added to distribution and jars. + Chainsaw of log4j 1.2 does not show TRACE level. + TRACE level missing in short introduction to log4j. + Update site generation to velocity 1.4 and remove dependency on logging/site project. + + + + Location info missing for TRACE level messages. + Console appender now behaves as before to fix + compatibility problem with JBoss introduced in 1.2.12 release due to fix + for bug 31056. Can still be configured to detect changes in the System.out + and System.err streams as needed by setting the follow property. + + + + Removed final qualifiers on member variables + in org.apache.log4j.chainsaw.LoggingReceiver which would cause + spurious compiler errors with JDK 1.1 and 1.2 javac compilers. + + Added a jndi.jar property to the build.xml. + + Added "release" target to build.xml. + + Removed references to obsolete documentation. + + Added protected accessors for member variables + topicConnection, topicSession, and topicPublisher. + + SyslogAppender now checks Layout.ignoresThrowable() just + like every other appender. + + DOMConfigurator would call LogLog.error to report + XML validation errors that caused no problems in the interpretation of the + configuration file. + + Fixed the JavaDoc links + for the XML sample files. + + Added getNext/setNext methods to org.apache.log4j.spi.Filter and deprecated + public "next" field. This mirrors the same change in the upcoming 1.3 + version and, hence, provides a migration path. + + Added o.a.log4j.Logger.trace(), o.a.log4j.Logger.isTraceEnabled() and + o.a.log4j.Level.TRACE + + Implemented serialization for Level. + + o.a.log4j.ConsoleAppender would ignore redirections + of System.out and System.err that occurred after configuration. + + o.a.log4j.xml.DOMConfigurator would not properly + interpret relative path names in external entity declarations. + + o.a.log4j.xml.XmlLayout would not properly escape + class names that contained '<' or '>'. + + Use of String.intern() in o.a.log4j.CategoryKey + would cause application to slow down. + + o.a.log4j.FileAppender would not create log file + if parent directory did not exist. + + o.a.log4j.AsyncAppender would deadlock if a + unchecked exception occurred in the attached appender causing the + dispatch thread to die. + + Added jdiff target to build.xml. + + log4j would not build with a JDK 1.5 javac. + + Added log4j 1.1 compatibility method + to o.a.l.helpers.Loader. + + Additional null terminating character in Windows + nteventlog.cpp code. + + Broken links to J2SE classes in javadocs. + + + + + o.a.log4j.or.jms.MessageRenderer + would not be compiled in the build.jms target. + + + + Version 1.2.10 was not released following the accepted rules and process of + the log4j project and Logging Services Project and was recalled and removed. + Please do not use version 1.2.10, it is not an official log4j release. + + + + Log4j version 1.2.9, is identical to version 1.2.8, except that + several key methods have been deprecated in preparation for version + 1.3.0, the next major release of log4j. These changes are intended to + enforce the rule that client code should never refer to the Category + class directly, but use the Logger class instead. Similarly, client + code should not refer to the Priority class but to the Level class + instead. + + For a more detailed discussion, refer to the document entitled + preparing for log4j 1.3 at: + + http://www.qos.ch/logging/preparingFor13.jsp + + + + + + XMLAppender would throw a + NullPointerException if the input message was null. Many thanks to + David Vandegrift for reporting the bug and to Hendrik Brummermann for + supplying the patch. + + Various versions of Xerces would not parse + log4j configuration scripts expressed in XML format. + + The "removes" buffer used in the flushBuffer() method + of JDBCAppender is now cleared, solving the memory leak. Thanks to John + Landers for reporting the bug and suggesting the fix. + + SocketAppender now honors ReconnectionDelay of 0. + Many thanks to Scott Schram for reporting the bug and providing the fix. + + + + Log4j now searches for the file log4j.xml as well as the file + log4j.properties during log4j initialization. + + + + + Add of new options in JMSAppender and new command line arguments in + JMSSink. + + Add new method getLoggerName() in LoggingEvent class. The + getLoggerName is the preferred way for accessing the logger + name. The public access categoryName field should not be accessed + directly. Similarly, added the getLevel method which is now the + preferred way of accessing the event's level. The public access + level field should not be accessed directly. The javadocs now mark + the categoryName and level fields as deprecated. + Modified existing appenders to comply with these new directives. + + Log4j now will check if a system property named "log4j.ignoreTCL" + is set. If it is set, then it will ignore the Thread Context + ClassLoader when loading classes. This solves the irritating + "appender is not assignable to Appender" messages observed when + log4j.jar is loaded by multiple class loaders. + The error reporting for this problem was also improved. + + Calling the MDC.get method with a null + argument would throw a NullPointerException. + + + + July 5th, 2002 + Calling an AsyncAppender close method also closes the embedded + appender instances. + + + + The JDBCAppender is marked as slated for replacement. Do not build + critical software using it. + + Add LF5 documentation and examples. Further tests are required + for full integration. + + XMLLayout can now output messages which contain embedded CDATA + sections.Many thanks to Michael + A. McAngus for supplying the relevant patch. + + The dispatcher thread associated with AsyncAppender is now marked + as a deamon thread. + + Add missing NTEventLogAppender.dll + + log4j.dtd was changed so that + <log4j:event> is now made of logger and level attributes instead of + category and priority. Changed XMLLayout to conform to the + DTD. Chainsaw was changed to adapt to the XMLLayout. + + Add missing LevelRangeFilter file. + + + + SyslogAppender would incorrectly compute + the length of the datagram to send to the remote syslogd host. + Reported by Mamoru Kadota. + + The stack trace of exception would not be + properly printed on the Compaq tru64 Unix platform. Initially + reported by Fabrice Claes and later by Espen H. Kolstad who also + provided the fix. + + + +Log4j configurators take the "NULL" string value as a synonym for + "INHERITED". Both of these two strings are legal level values for + setting the level of a logger. Both values are case insensitive. + +When loading component classes, log4j will now first attempt to use + the Thread Context Loader and if that fails, it will use + Class.forName. In log4j 1.2 and 1.2.1, only Class.forName was used + and the TCL was ignored. This change is a response to bug #9305 + opened by Scott M. Stark. + + + + + LoggingEvent.getMDCCopy() method now sets mdcCopyLookupRequired + instead of ndcLookupRequired. This bug would cause the wrong MDC + information to appear on a log server. It could only occur if the + client wrapped an AsyncAppender around a SocketAppender or if the + server used an AsyncAppender for its logging. + + + + + A closed TelnetAppender would continue waiting + for connections even if its ServerSocket was closed. This caused + the TelnetSocket to sit in a loop and complain about the closed + socket. + + AsyncAppender throws NullPointerException problem. The bug was actually in + AppenderSkeleton. + + Add support for recursive variable substiuton as requested by + Eric Chastan. + + SocketNode now used a BufferedInputStream as suggested by Kok Chong + + Fixed a problem with DailiyRollingAppender which would not + correctly compute the rollover period in certain timezones. + + Fixed documentation bug #2726 in FAQ.html. + + Added a flush statement in the + WriterAppender.writeFooter method. + + In XMLLayout, escaped the method attribute. The + XMLLayout also outputs each item of a stack trace in a separate + line. + + The + LoggingEvent.getMDCCopy method now clones the MDC instead of just + referencing it. + + The ANT build script was modified to use jar files specified in + the build.properties file instead of the CLASSPATH environment + variable. The build.properties file depends on local paths and is + supplied by the user. The build.properties.sample file is included + in the distribution. The build.sh and build.bat scripts have + been removed. This is the way many other jakarta projects build their + projects. The jar files in the dist/lib directory were also removed + since they are no longer used. + + The DOMConfigurator now interprets the string after the '#' + character in the value attribute within the <level> element as + the fully qualified class name of a custom Level. This is consistent + with the way log4j handles "level" values in other places. The + class attribute is still honored. + + Add Oliver Burn's chainsaw tool to the core log4j + distribution. Visualisation and dynamic filtering of log events is + bound to be a very important area of activity in the future. + + Add the org.apache.log4j.jdbc.JDBCAppender which as the name + indicates sends events to a database using the JDBC API. Thanks to + Kevin Steppe for supplying the code. + + Add SocketHubAppender class as contributed by Mark Womack. This + appender sends LoggingEvent objects to a set of remote a log + servers. + + In the Category class, the getChainedPriority method has been + replaced with getEffectiveLevel method. + + Replaced the custom class loading based on the thread context class + loader with a simple Class.forName() call. This solves two allied + but distinct problems encountered when using Ant with JUnit + although the bug is more general. In one instance of the + problem, log4j would throw java.lang.NoClassDefFoundError for + org/apache/log4j/AppenderSkeleton where log4j.jar and related + classes were clearly available to the Ant classloader. In another + incarnation, log4j would reject a custom appender claiming that it is + not assignable to a org.apache.log4j.Appender variable. This would + occur when log4j.jar was available to both the Ant classloader and the + system classloader.
    + + Thanks to Dave Herman for providing detailed scenarios exposing + the issues involved. See + http://forum.java.sun.com/thread.jsp?forum=38&thread=70946 + http://forum.java.sun.com/thread.jsp?forum=38&thread=70946#479697 + http://marc.theaimsgroup.com/?l=ant-user&m=101139178705895&w=2 + for more details.
    + + Fixed the complaints the compiler issued when using the + Logger.setLevel() method. + + Incorporated the performance enhancements to ISO8601DateFormat and + AbsoluteTimeDateFormat classes submitted by Andrew Vajoczki. + + Source code written for log4j 1.1.3.jar will compile fine with + log4j 1.2X. However, code compiled for log4j 1.1.3 would previously + systematically throw "java.lang.NoSuchMethodError" runtime exceptions + when run with log4j 1.2 - prior to beta2. This problem has been + corrected in beta2. Pheew, that was a close one. + + Log4j 1.2 is now backward compatible in serialization of + LoggingEvents. For example, a 1.1.3 SocketAppedner can write to 1.2 + SocketServer. Similarly a 1.2 JMSAppender will work with 1.1.3 + JMSSink. This should ease the move to log4j 1.2, especially in + large deployments. + + The src/java/org/apache/log4j/examples/ directory moved under the + top-level directory as examples/. + + Fixed the ArrayIndexOutOfBoundsException that was thrown by + AsyncAppender if multiple threads were trying to log an event + containing an exception near simultaneously. Thanks to Thomas Tuft Muller + for reporting this bug. + + Improved error reporting in DOMConfigurator. Thanks to Thomas Tuft + Muller for contributing the enhancement. + + Log4j is now configurable using JMX. JMX support is not of + production quality. + + Add support for different encodings in WriterAppender. Thanks to + Ben Sandee for submitting the relevant patch. + + Modified SMTPAppender to allow multiple email sessions. Thanks to + Jon Skeet for supplying the relevant patch. + + The CategoryFactory class has been replaced by the LoggerFactory + class. The makeNewCategoryInstance method has been renamed as + makeNewLoggerInstance. This change requires subclasses of Category + classes to be modified and recompiled. + + The Level class replaced the Priority class. Priority class now + extends Level to preserve backward compatibility. + + The Logger class replaced the Category class. Logger class + extends Category to preserve backward compatibility. We proudly + mark this change with a single star for 100% compatibility. + + The Category.assert method has been replaced by + Category.assertLog. This change was necessary because assert is a + language reserved word in JDK 1.4. + + 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. + + The disable(Level) methods in Hierarchy have been removed and been + replaced by threshold methods. + + Add buffered IO capability to FileAppender and subclasses. + + The location information (or stack information) was not correctly + transmitted by JMSAppender. + + Add event reporting capability to the Hierarchy class. + + Add 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 diagnostic 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 and independently by Ray Millard. + + Removed deprecated methods disable(Priority), disableAll, + disableDebug, disableInfo and enableAll in BasicConfigurator. + + Add supports java.io.Reader objects in the method doConfigure(), + instead of only InputStream. Thanks to Mark Womack for submitting + the relevant patch. + + Corrected the restart bug in DailyRollingFileAppender. Thanks to + Jim Moore for supplying the relevant patch. +
    + + + + Add 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. + + + + + 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. + + + + Add missing custom priority support in PropertyConfigurator. + +Made a number of fields protected instead of default access in + SMTPAppender. + + + + + This release has the same code as 1.1b7. It differs only in a few minor + documentation changes. + + + +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. + +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. + + + +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. + + Add PriorityRangeFilter by Simon Kitching. See the Threshold + option in AppenderSkeleton for a more convenient alternative. + + + +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. + + Add missing PropertySetterException class to log4j-core.jar. + Thanks to ma.darche@free.fr for reporting this bug. + + + +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. + + + + Add 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. + + + + + The directory structure has changed to better suit Jakarta + conventions + + Add 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. + + Add 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 "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. + + + + + 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. + + Add getLayout(), getErrorHandler(), and getFilter() to the + Appender interface. + + Add getOption(key) method to the OptionHandler interface and modified + implementations of it as appropriate. + + Add 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. + + Add 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. + + + + + +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. + + + + +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. + + Add 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. + + + + + Add the missing build.inc file to the distribution. No code + changed. + + + + + +This version corrects some documentation and build script bugs; + code has not changed. + + + + +Package hierarchy now starts at org.apache.log4j. + +

    Add 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. + +

    Add 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.

    + + Add 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. + + Add 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. + + Add 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. +
    + + + +Corrected a typo making NTEventLogAppender.dll register the wrong + category message file. Thanks to Peter Hayes for accurately + reporting this bug. + +The DOMConfigurator and PropertyConfigurator can now automatically + detect modified configuration files and re-read them. + + Add AsyncAppender which buffers log requests and serves them + at a later time. AsyncAppender can increase logging performance + tremendously if logging operations are interspersed with long + and blocking non CPU-intensive operations, typically I/O or network + access. For CPU intensive applications, using the AsyncAppender + will actualy degrade logging performance by 10 to 25 percent. + +The log4j.dtd has been modified to allow appenders to refer to + other appenders by IDREF. + +The DOMConfigurator has been modified to take advantage of ID/IDREF + attributes when referring to appenders. This change requires a + DOM Level-2 API compliant parser. DOM Level-2 java bindings are + available at + http://www.w3.org/TR/1999/WD-DOM-Level-2-19990923/java-binding.html. + + Add the configure(String filename) method to DOMConfigurator. + This method requires the presence of a JAXP compatible parser. + At this time, the only DOM2 and JAXP compatible parser seems to be + the Apache xerces parser. + + Add the PriorityMatchFilter allowing filtering by exact priority + match. This was a common request by users. + +The configuration of a category is now an atomic operation. This + ensures that log requests are not lost while configuration is in + progress. Anders Kristensen was to first to observe the potential + problems in non-atomic configurations. + + + + +The "log4j" element has been renamed to "configuration" in the + log4j DTD. This change requires that log4j configuration files + written in XML be modified. Since the log4j element figures only + once in the XML file, this change should take little time. + +ResourceBundles are now category instance specific and no longer + class static. Moreover, like other properties resource bundles + are inherited from the category hierarchy. + +The jar files log4j.jar and log4j-full.jar now contain versioning + information in their respective manifest files. + +Corrected an inconsistency in the NTEventLogAppender which broke it. + +Fixed a bug where configuration files were not parsed correctely + due to trailing spaces in option values as returned by + java.util.Properties. Trailing spaces are now removed from option + values. This bug was quite disconcerting because the + trailing spaces cannot be seen without careful examination of the + configuration file. + + Add the XMLLayout. + + The output of the XMLLayout consists of a series of log4j:event + elements. It does not output a complete XML file. The output is designed to + be included as an external entity to form a well-formed XML file. + + Add a new abstract class org.log4j.helpers.DateLayout. The TTCCLayout + now extends DateLayout. + +Corrected a rather subtle performance bug in the buffer management code + in PatternLayout. Thanks to Vladislav Dutov and Constantine + A. Plotnikov for for insisting on the correction of this bug. + +Created a new package called org.log4j.spi. This new package + holds classes that are hidden from the casual user but are needed + to extend log4j. + + Add org.log4j.varia.ExternallyRolledFileAppender to handle + externally triggered file rollovers. + + Add support for multiple hierarchy trees. + +PatternLayout can now be subclassed to support new conversion + patterns. + +Extended the DOMConfigurator and the log4j DTD to properly handle + sub-classing of Category and Priority classes. + There have been also minor adjustments to other classes to handle + sub-classing. These changes should be invisible to users. + + All categories except the root category can be sub-classed and also + assigned priorities sub-classing org.log4j.Priority. + + The root category always exists and CANNOT be subclassed. + + The ProppertyConfigurator remains unchanged. Thus, it does not + handle extensions of the Category class. + + Add filter support in appenders. The DOMConfigurator and the + log4j.dtd have been enhanced to support filters. + + Add error handling support to appenders. The DOMConfigurator and the + log4j.dtd have been enhanced to support filters. + + Add support for correct interpretation of location information in + IBM's Visual Age environment. Thanks to Wolf Siberski for supplying + the relevant patch. + + Add getAdditivity method to Category. This feature was requested + by Constantin Mitran. (mitran at ecircle.de) + + + + +Corrected multiple bugs in default initialization code of + Category class. Thanks to Jeff Turner for identifying and supplying + corrective patches. + + + + + Add the %n conversion character to PatternLayout so that a line + separator can be specified in a platform independent way. + +In 0.8.5 internal Priority integer values were decoupled from the + Unix Syslog values. This broke SyslogAppedder. A new function + Priority.toSyslogInt is introduced to solve this bug. + +Corrected a bug where the internal priority integer + + + + +All log4j internal output is now prepended with the string + "log4j: ". This makes is easier to differentiate log4j internal + logs from messages output by other sources. + +Sub-classes of Category class must now specify their fully + qualified name when constructing logging events. This allows the %C + conversion specifier in PatternLayout to work properly even with + sub-classes or wrappers of Category. + + Add the method disableDebug to BasicConfigurator. This method + disables all print requests of debug priority regardless its + category. Similar methods disableInfo, disable, disableAll and + enableAll have also been added. Disable type methods can be + overriden by setting the log4j.disableOverride system property. + + Calling BasicConfigurator.disableInfo is equivalent to the now + deprecated flagAsShippedCode method. + +Given the above changes, the system property + log4j.shippedCodeFlagOverride is no longer honored. + +It is now possible to sub-class Category. The sub-classes may + continue to adhere to the category hierarchy. This was a frequently + requested feature. + +Corrected a problem with the additivity flag being ignored in + categories without appenders. This bug was discovered by Anders + Kristensen. + + Add a method BasicConfigurator.resetConfiguration to reset the + log4j environment. This method should be used sparingly. + +At the initialization of the Category class, the file + log4j.properties will now be searched from the search path used to + load classes. If the file can be found, then it is fed to the + PropertyConfigurator.configure(java.net.URL) method. + +Failing to access system properties within the static initializer + of BasicConfigurator class is no longer reported as an error but as + a debug message. Thanks to Gilles Schlienger for reporting this + problem with applets. + +Corrected a bug which caused infinite loops when using conversion + patterns with a single element, fortunately under very rare + circumstances. This bug was first reported by Igor Potraev, the + author of log4p. It was independently reported by Joe Haberl from + IBM Global Services. + + Add a mechanism to lazily remove references to dead threads in + the NDC class. Indeed, in previous versions calling NDC.pop within + a thread but forgetting to call to NDC.remove before exiting (that + thread) resulted in a memory leak. + +Corrected a huge memory leak in SocketAppender. This leak was due + to the ObjectOutputStream indefinitely holding a reference for each + written to the stream. Thanks to Dan MacDonald for very accurately + describing this bug. + +The log and l7dlog methods in Category no longer ignore the shipped + code flag. This bug was reported by Mario Schomburg. + + Add missing NDC information to LoggingEvent.writeObject + method. + +Corrected handling of SocketException in SocketNode. Thanks to + Gerald Gutierez (ggutierez@emobiledata.com) for reporting this and + the previous problem. + +Phased out custom shell scripts to build java documentation and jar + files in favor of Jakarta's ANT. It was becoming a nuisance to keep + the ANT build file in sync with the custom shell scripts. + + + + + + +The NT EventViewer no longer complains about missing message 4096. + +Minor corrections in documentation. + + Add missing icons GIFs into the distribution. + +SocketNode now attempts to close the socket when exiting. Thanks to + Moses Hohman (mmhohman@rainbow.uchicago.edu) for noting this. + +Removed the com.ibm.log4j from the javadoc directory. This seems to + confuse VAJ. Thanks to Steve Ashcroft for reporting this problem. + + + + +As a result of the infinite loop problem (see next item), added + over 800 new test cases to stress-test the code in CategoryFactory + class where category creation occurs. + +Under certain rare circumstances the Category.getInstance method + entered an infinite loop. Thanks to Mario Schomburg from IBM Global + Services / Hannover for identifying this problem and proposing a + patch. + +DOMConfigurator and the log4j.dtd were out of sync on the type of + the priority directive. As a result, priority directives all + defaulted to DEBUG. Thanks to Peter (petervt@users.sourceforge.net) + for accurately reporting this bug. + +Minor additions to the FAQ. + + Add the NumberCruncher example showing how the NDC class can be + used to distinguish output from different clients. + + Add the %x conversion specifier to the TTCC_CONVERSION_PATTERN in + the PatternLayout class. This is consistent expected output of + Trivial.java example. Thanks to Jerome (schrom@users.sourceforge.net) + for reporting this bug. + + + + + +The value of the additivity option would not be parsed properly by + the ProperytConfigurator if the line containing the option + contained trailing spaces. + + + + +The localized logging methods (l7dlog) omitted priority based + evaluation and erroneously logged all requests. + + + + + +The close method was added to the Appender interface allowing + appender implementations to release any resources they may have + allocated. + +The package naming scheme of changed from "com.ibm.log4j.*" to + "org.log4j.*". The new naming reflects the open source nature of + the project and is consistent with the URL http://www.log4j.org. + + Add internationalization support. See the newly introduced l7dlog + methods in Category class. + +In the FileAppender, the File option now admits variable + substitution. For example, if "java.home" system property is set + to /home/xyz and the File option is given the value + "%{java.home}/test.log", then File option will be interpreted as + "/home/xyz/test.log". + + Thanks to Avy Sharell (sharell@online.fr) for contributing this + feature. + +SocketAppender is now officially part of the package. It is capable + of sending logging events to a remote SocketNode. The SocketNode + logs events according to server (local) policy. For example, a + client can log events to a local file and also send them to a + remote server (a SocketNode). This server can log the event to any + number of files, to the console, to any number of TextPaneAppenders + and even re-transmit the event to another server, and so forth. + + This paradigm is common in most logging systems, e.g. Syslog and NT + Event Log. Many thanks to Andrew Harrison for showing a way to + actually implement the paradigm. + +The Category.callAppenders method now accepts a LoggingEvent + instead of creating one itself. This was necessary to accommodate + events generated at a remote client. + +LoggingEvent class changed slightly to support remote logging. The + category field (a Category) has been replaced by the categoryName + field (a String). + + + + +Corrected a bug in Category.removeAppender(String) which would + never remove the desired appender. Thanks to Moses Hohman for + reporting this bug. + + + + +Corrected a bug RollingFileAppender which would throw an uncaught + exception in case output file could not be opened for + writing. Thanks to Vinay Aggarwal for signaling this problem. + + + + +The log4j.override key defined in BasicConfigurator has been + renamed to log4j.shippedCodeFlagOverride. + +The getCurrentCategories method in the Category class would not + return the correct value. Thanks to Timothy Potter + (tpotter@agency.com) for reporting this problem. + +Appenders now admit a priority threshold as an option. All requests + with a priority lower than the appender's threshold priority are + ignored by the appender. + +Integrated Christopher Taylor's DOMConfigurator parsing XML + configuration files. + +The jar file log4j-net.jar has been replaced by log4j-full.jar. It + contains DOMConfigurator.class in addition to the com.ibm.log4j.net + package. + + Add support for the ANT build tool. Thanks to Christopher Taylor + for supplying the build.xml file. ANT is available form + http://jakarta.apache.org. + +FileAppender's File option now accepts the values "System.out" or + "System.err". If one these values is suppiled in a configuration + file then the output is directed to the corresponding stream. + Moreover, the default constructor of FileAppender no longer sets + System.out as an output target nor does it define a default + layout. + + Add caller class (C), caller file name (F), caller line number + (L), caller method name (M) conversion specifiers to the + PatternLayout class. + + The category conversion specifier now takes an optional precision + modifier allowing the user to control the number of right most + components in the category name that will be printed. + + Corrected a bug occuring when the caller file name and line number + information were unavilable due to JIT compilation. In that case, + the PatternLayout would not properly use the rest of the available + location information. + + The above enhancements and bug-fixes originate from comments by + Nelson Minar (nelson@monkey.org). + + + + +The SimpleLayout and TTCCLayout are replaced by the PatternLayout + in the log4j.jar file to keep its size small. These two layouts are + still part of the package. + +The PatternLayout class is introduced. This new layout is + configurable using a conversion pattern which is parsed at + runtime. This allows the user to choose the output layout without + writing any code and only at a marginal performance cost compared + to the dedicated layouts such as SimpleLayout and TTCCLayout. The + PatternLayout also allows the user to determine minimum and maximum + field lengths. + + The PatternLayout was written by Jim Cakalic + (jim_cakalic@na.biomerieux.com). + +All internal components now use LoggingEvent instances to specifiy + logging information. + +Corrected a problem with a missing variable initialization in + SyslogAppender. This caused NullPinterException to be thrown when + logging exceptions. + + Added a default constructor to SyslogAppender. The lack of this + constructor caused PropertyConfigurator to throw a + java.lang.InstantiationException when the appender type was set to + be SyslogAppender. + + Thanks to Yves Bossel (ybossel@opengets.cl) for accurately + identifying these bugs. + + Modified some other related option handling code in + SyslogAppender. + +Made NDC.get public access instead of default access. Thanks to + Y. J. Chun (monac@softonnet.com) for reporting this problem. + +PropertyConfigurator now parses the additivity option for + categories. + +Corrected the value of the ADDITIVITY_PREFIX constant to match the + documented value, that is "log4j.additivity". + +Corrected a really bad bug where System.out would be closed when + PropertyConfigurator.configure was called. Thanks to Christopher + Taylor (cstaylor@pacbell.net) for tracking and reporting this bug. + +The PropertyConfiguator now prints debug messages if the flag + "log4j.configDebug" is defined in the configuration + file. Previously, only if the system property "log4j.configDebug" + was set would debug messages be printed. A question by Shawn + Kircher (skircher@vninet.com) induced this change. + +In AbsoluteTimeDateFormat, DateTimeDateFormat and ISO8601DateFormat + the separator between the seconds and milliseconds has been changed + to comma from full stop, in order to be compliant with ISO8601's + preferred sign. Thanks to Jim Cakalic + (jim_cakalic@na.biomerieux.com) for pointing out this discrepancy + with the standard. + +Corrected a bug where RollingFileAppender would not work + properly on Windows systems. Thanks to Heinz Richter + (heinz.richter@ecmwf.int) for noting this problem. + + + + +Core classes are now independent of the format of the options + file. Configurable core classes implement the OptionHandler + interface. OptionHandlers allows configurators to learn the + relevant option names. The configurator feeds option values to the + OptionHandler which configures itself. + + As a result of these changes, the Init class has been broken down + to two separate classes: the BasicConfigurator and the + PropertiesConfigurator. + + An XML configurator for 0.8.0 has been already written by + Christopher Taylor (cstaylor@pacbell.net). + + Add multiple appender support per category. The appenders follow + the category hierarchy, i.e. a child category inherits the + appenders of its parents. + + Add an assert() method to the Category class. Steven Marcus + (srnm@awaretechnologies.com) requested this addition. + +Automatic stack printing is no longer supported. This was an unused + and unreliable feature which unnecessarily complicated the + code. + +log4j now emits a single warning message when no appender to write to + could be found. This is typically the case when the user forgets + to configure the log4j environment. This change was suggested by + Jim Cakalic (jim_cakalic@na.biomerieux.com). + +RollingFileAppender adds file roll over capability-implemented by + Heinz Richter (heinz.richter@ecmwf.int). + +Corrected a bug where a java.lang.NoClassDefFoundError would be + thrown because com.ibm.log4j.helpers.SyslogTracerPrintWriter was + not included in log4j.jar. Thanks to Jim Cakalic (jim_cakalic@na.biomerieux.com) + for signaling this bug. + + + + + +There has been an important API changes. The Log, NOPLog and ILog + classes have been removed. Their functionality has been migrated to + the Category class. + + In this release, instead of writing + + ILog.debug(CAT, "Some message."); + + one will write + + CAT.debug("Some message."); + + Arndt Schoenewald <arndt@ibm23093i821.mc.schoenewald.de> observed that + one could use the Category objects directly for logging. + +It is no longer possible to instantiate Category objects directly. + Instead, one would use the factory method + Category.getInstance(String name). [***] + + There category instantiation code was moved to CateogryFactory + class. This class has package visibility and remains hidden from + the user. + + This stylistic improvement was suggested by Luke Blanshard + (luke@quiq.com). + +The Init class offers methods to initialize the log4j + environment. The Init.flagAsShippedCode method replaces the NOPLog + class. + +Changes in the documentation to reflect the API changes. + +The NDC.cloneStack and inherit methods now tolerate null-stacks. + + + + + +TTCCLayout now takes a java.text.DateFormat object as a + parameter. The task of formatting the date is delegated to this + object. + + Added four classes extending the java.text.DateFormat class. These + are RelativeTimeDateFormat, AbsoluteTimeDateFormat, + DateTimeDateFormat and ISO8601DateFormat classes. + + Thanks to Arndt Schoenewald <arndt@ibm23093i821.mc.schoenewald.de> + for suggesting the ISO8601 date format. + + These four classes can be parametrized with a particular + TimeZone. The TTCCLayout class now accepts a new configuration file + option called "TimeZone". + + These four DateFormats are less malleable than the + java.text.SimpleDateFormat but they are also much faster. + + As a consequence of these changes, the setRelativeTime, + setDatePrinting methods in TTCCLayout have been removed along with + the associated configuration file options RelativeTime, + DatePrinting and TimePrinting. + + The current code is inspired by code contributed by + Heinz Richter (heinz.richter@ecmwf.int). + +The Log.emerg method has been deprecated. If you use statements of + EMERG priority, please use the Log.log form instead. + + Add getDepth and setMaxdepth methods to the NDC class. This makes + it easier to manage the nested context depth especially when + callees push but forget to pop. + +Moved the documentation in com/ibm/log4j/package.html to + com/ibm/log4j/overview.html. Many users were failing to read the + com/ibm/log4j/package.html description due to the unfortunate + layout of the text. Hopefully more people will read the package + overview in its present location. + + Add the com.ibm.log4j.net package for doing remote logging using + TCP sockets. This is still experimental code. + + Add new debug, .., emerg methods that do not require a category + parameter. They assume the "root" category, that is the decision to + whether print or not is made by comparing the statement's priority + with the default priority. + + + + + Add a new ILog.init method accepting an Appender and a + configuration file as parameters. + +FileAppender's setWriter and setFile methods where not instantiating + a new tracer. This caused stack traces to be lost! SyslogAppender + had a similar problem. + +The FileAppender and SyslogAppender where not calling the layout's + readConfig method to set layout specific options. Thanks to Heinz + Richter (heinz.richter@ecmwf.int) for reporting this bug. + +Corrected a bug in Log.log() method where the appender was always + called with Priority.DEBUG. Thanks to Oliver Boehm + (Oliver.Boehm@abaxx.de) for reporting this bug. + + + + + Add Syslog compatibility. One can now choose (at runtime) between + remote syslog logging or file logging. + Syslog logging performance, although not appalling, is significantly + slower than file logging. + +Priority class was enriched with the previously missing priorities + NOTICE, ALERT and CRIT. The internal constants were also aligned with + the syslog counterparts. + + Add the Log.log method to support the new priorities. + +TracerPrintWriter is now an independent class instead of being a + nested top-level class in Tracer. + +A number of writers, namely the SyslogWriter, SyslogQuietWriter, + SyslogTracerPrintWriter, were added to the helper package. + +Log.force method was removed. The various Appender.doAppend + implementations take over its functionality. + +FileAppender and SyslogAppender now use QuietWriter. QuietWriter is + a FilterWriter which hides exceptions and instead emits a single + warning message to System.err. + +The layout is now an initialization parameter to the appender + type. Previously, the layout and the appender where independent + parameters to the Log constructor. + +Many small improvements and corrections in the documentation. + Syslog related documentation remains sparse. + +ILog.init() and ILog.init(String configFile) have been changed to + call ILog.init(,,,) with "com.ibm.log4j.Log.class" as the first + parameter. This makes it easier for people to get familiar with log4j. + + Add missing files to the make directory. These files are useful + for those wishing to use the log4j make environment. Thanks to "Lee + Hall" <LHall@JavaFoundry.com> for reporting this omission. + Until recently the make environment failed to compile RMI stubs in + a single run. This nagging problem has been corrected thanks to + help from Thomas Eirich (IBM Zurich Research Lab). + + + + +Some users have been rightly complaining about the verbosity + TTCCLayout's date output. The full date output is now shortened to + "dd MMM YYYY HH:mm:ss.SSS" for example, "06 Nov 1994 08:49:37.459" + In addition, users may now choose to print only time information, + as in "08:49:37.459". + +The package now uses Writer instead of OutputStream as its output + target. This makes the log4j code smaller and easier to + understand at the cost of a slight performance degradation. As a + result of this change a few method names in FileAppender class were + changed. + +Preliminary experiments with SyslogAppedner and SyslogLayout show + that syslog compatibility is not far away. The difficultly is + adding syslog compatibility without making radical changes to the + current log4j architecture. + +Corrected a bug in the NOPLog.createInstance method which always + created a Log singleton even if the system property "log4j.logType" + was set to NOPLog. Thanks to Robert Gottofrey + (Robert.Gottofrey@wdr.com) for reporting this bug and the + associated test case. + +Removed the inconsistent "Layout" configuration option in + Log.readConfig(). This change should be transparent to most + users. + + + + +The LogCreationManager class has been removed. Its functionality + has been transfered to the createInstance and getInstance methods + in the Log and NOPLog classes. The new way of creating instances is + both simpler and less error prone although just as flexible. + + As a result of these changes, the init family of methods in the + ILog class have been adjusted to the new way of creating the log + singleton. + +The Appender interface has been introduced. The method of writing a + log statement into an output stream can now be varied by using a + different Appender. The new FileAppender offers the same + functionality that was previously part of the Log class. + +Changed the time format used in TTCCLayout to be of the form "Day, + dd MMM YYYY HH:mm:ss.SSS GMT" for example, "Sun, 06 Nov 1994 + 22:49:37.459 GMT". This format is almost the same as the format + specified in RFC 1123 and also the format recommended in RFC + 2616. The only difference is the additional milliseconds + information. + +The layout specific options were not read from the configuration + file due to a missing instruction. Many thanks to Vikram Sridharan + (Vikram.Sridharan@alysis.com) to patiently pointing out this + omission to an unbelieving maintainer. + + + + +Version 0.7.0 and above will be distributed under the IBM Public + License (IPL). The IPL is an approved open source license (see + http://www.opensource.org/licenses/ for a list). It grants similar + rights to the previous ALPHAWORKS license agreement, in particular, + the right to redistribute and to modify the package. + +The Log class can now be parameterized with a Layout object. + Layouts determine the format of what is printed, where as the Log + class decides when to print and to where. + + As a result of this modularization, the CGULog and NOPCGULog + classes no longer exists. CGULog class has been replaced with the + TTCCLayout (Time Thread Context Category). This should make it + easier to create new log output formats. + + Some time in the near future, the Log class will be further broken + down to allow different strategies for writing to output streams. + +Renamed com.ibm.util.log hierarchy to to com.ibm.log4j. I wanted to + do this for some time. I feel release 0.7.0 was the last + opportunity to do so. I am sorry for the the trouble caused by this + change. + +New NDC class. This class implements nested diagnostic contexts as + suggested by Neil Harrison in the article "Patterns for Logging + Diagnostic Messages" part of the book "Pattern Languages of Program + Design 3" edited by Martin et al. Nested diagnostic contexts is a + nifty feature that was missing up to now. + + The StressNDC test class seems to break JDK 1.2.2 beta on AIX. On + Linux and NT using sun's JDK 1.2.2 it seem to work OK. In any case, + tests done with StressNDC and associated perl script seem to + indicate that the NDC class is bug-free. + +Corrected a date formatting bug in CGULog class where on some + environments the wrong month was printed. Thanks to Christopher + Williams (Christopher_Williams@mail.northgrum.com) for signaling + this bug. Also changed the month format from a number to a three + letter abbreviation such as "Jan", "Feb", ..., "Dec". The new + format is unambiguous regardless of local date format. + + + + +Clearer documentation with still much room for improvement. + +Corrected a bug in the Tracer class which always used the Unix line + separator instead of the system specific separator. Thanks to + Vikram Sridharan (Vikram.Sridharan@alysis.com) for singaling this + bug. + +Corrected a runaway comment which gulped the CGULog.readConfig + method. + + Add the init family of methods to the ILog class to ease the + setup of a basic logging environment. Thanks to Mark Donszelmann + (Mark.Donszelmann@cern.ch) for this enhancement. + +Just an hour after releasing version 0.6.1 detected and corrected a + bug where the Tracer class would correctly print Exception stack + trace but not the type of the Exception. Replaced the + distribution on www.zurich.ibm.com without changing the version + number. I hope nobody is using the intermediary (and buggy) release + of 0.6.1. + + + + +Better documentation with still much room for improvement. + +For consistence sake, added setDefaultPriority and + getDefaultPriority methods to the Category class and deprecated + setDefaultPriority in the Log.class. + +Corrected a major bug where if two categories were homonyms the + second instance would not be properly initialized. + +Increased the speed of Exception logging from about 4000 + microseconds to about 1000. It seems that for some people Exception + logging is performance critical. Improved implementation is a + variant of Nocolai's (XNH@crisplant.com) implementation. + + + + +Release of log4j 0.6.0 with incomplete documentation. + + Add a stress test program to debug the new Category class. It + turns out that the test program was as hard to get right as the + Category class. Given the favorable results of the stress test I am + quite confident that the new class is now bug free. This assumption + has been proven to be wrong. See above. + +

    Created a new class called Category to manipulate categories + instead of plain Strings. The new class is just as easy to use. + However, the evaluation of whether to log or not to log is at least + 10 times faster. The NOP class performance remain unaffected by the + change. (You can't improve on the performance of an empty function + call.)

    + +

    Many thanks to Alex Blewitt "Alex.Blewitt@ioshq.com" for his + valuable comments. He was the first to observe that finding Strings + in a hash table was an expensive operation.

    + +

    This change will require some recoding on your part. See the FAQ + for more details.

    + +Modified the force in Log and CGULog method to use a byte[] buffer + instead of a StringBuffer. The old code was clearer but the new one + is at least 25% faster. + + Add regression testing. + +

    We now enforce a policy where the OutputStream set by + setOutputStream is a user managed resource whereas the OutputStream + opened using setLogFile is the Log class' responsibility.

    + +

    The setLogFile method now closes any previous OutputStream if only + if opened through setLogFile. If the previous OutputStream was + opened by the user and set through setOutputStream the previous + OutputStream is untouched.

    + +

    Similarly, setOutputStream will close any previous OutputStream if + and only if it was opened using setLogFile.

    +
    + + Add a new method logOutputStreamExists to the Log class allowing + the programmer to check if there is already an opened stream before + trying to set a new one. A stream can be opened as a byproduct of + reading the configuration file. + +

    Changed the behavior of the (private) Log.Append method in case of + failure to write to the OutputStream.

    + +

    Previously, in case of failure, we reverted to System.err. Now, we + emit a warning message and discard all future log messages. The + new behavior is consistent with our current unreliable logging + semantics. The change prevents an otherwise functional program + from failing because the terminal is flooded with logging messages.

    + +Renamed the iLog to ILog to remain consistent with our class naming + scheme. The initial intention was to add ILog and deprecate + iLog. However, I am running CVS on a fat16 partition, causing + serious problems when files differ only in case. + +Corrected a bug where the LogFileName was not remembered. Thanks to + Jens for signaling this bug. +
    + + +Now the programmer can choose to truncate the log file instead of + always appending to it. This functionality was first requested and + intially implemented by "Jens Uwe Pipka" jens.pipka@gmx.de. + +setLogFile now opens the requested file instead of having the + Append function open it later. Cleaned up some related code in the + Append function. Although nobody has requested it, there is still + no method to close the log file. This is harder to implement + reliably than it sounds. + +Simplified setLogOutputStream so that it does no longer return the + previously set OutputStream. + + + + + +Joe Walker (joe@eireneh.com) observed that the + LogCreationManager.getSingleton mechanism was cumbersome. There is + now a new class iLog (indirect Log) which hides the need to call + getSingleton. Performance testing on my 233Mhz Thinkpad shows that + this indirection has small performance impact on non-logged calls + in the order of 40 nanoseconds. The impact on logged calls is + negligible. + + Add a jar file to the distribution. The jar file contains only + the files you would need to use log but not other classes needed + for testing nor examples. + +Corrected a bug where CGUNOPLog was not integrated to the Makefile. + + Add new public methods isDebugEnabled and isInfoEnabled to allow + programmers to check whether a debug/info statement will be logged + without incurring the cost of message parameter construction. This + addition was suggested by Luke Blanshard Luke@quiq.com. + +Renamed the private method evaluate to isEnabled. Also made it + final with no apparent speed gains. In addition, made the + Log.force method public. + +New syntactic sugar debug, ..., emerg, methods to log objects. + +Modified the interface to deal with Throwables and not just + Exceptions. My thanks to Luke Blanshard for signaling this "bug". + + Add more tests to the LogPerformance class. In particular, to + test the influence of indirect debug calls. + + Add a "make" mini-tutorial for those who want to modify the code. + +License updated to standard alphaWorks license allowing + modifications to source code. However, this license explicitly + requires that modifications be communicated back to alphaWorks. + + + + +Initial availability on alphaWorks. Refer to the FAQ for the lineage of the package. + + +
    diff --git a/src/java/org/apache/log4j/AsyncAppender.java b/src/java/org/apache/log4j/AsyncAppender.java deleted file mode 100644 index e9fb7d615c..0000000000 --- a/src/java/org/apache/log4j/AsyncAppender.java +++ /dev/null @@ -1,331 +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.txt file. */ - -// Contibutors: Aaron Greenhouse -// Thomas Tuft Muller - -package org.apache.log4j; - -import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.helpers.BoundedFIFO; -import org.apache.log4j.spi.AppenderAttachable; -import org.apache.log4j.helpers.AppenderAttachableImpl; -import org.apache.log4j.helpers.LogLog; -import java.util.Enumeration; - -/** - The AsyncAppender lets users log events asynchronously. It uses a - bounded buffer to store logging events. - -

    The AsyncAppender will collect the events sent to it and then - dispatch them to all the appenders that are attached to it. You can - attach multiple appenders to an AsyncAppender. - -

    The AsyncAppender uses a separate thread to serve the events in - its bounded buffer. - -

    Refer to the results in {@link org.apache.log4j.performance.Logging} - for the impact of using this appender. - -

    Important note: The AsyncAppender can only - be script configured using the {@link - org.apache.log4j.xml.DOMConfigurator}. Refer to example configuration - files sample4.xml - and sample5.xml. - - - - @author Ceki Gülcü - @since 0.9.1 */ -public class AsyncAppender extends AppenderSkeleton - implements AppenderAttachable { - - /** The default buffer size is set to 128 events. */ - public static final int DEFAULT_BUFFER_SIZE = 128; - - //static Category cat = Category.getInstance(AsyncAppender.class.getName()); - - BoundedFIFO bf = new BoundedFIFO(DEFAULT_BUFFER_SIZE); - - AppenderAttachableImpl aai; - Dispatcher dispatcher; - boolean locationInfo = false; - - boolean interruptedWarningMessage = false; - - public - AsyncAppender() { - // Note: The dispatcher code assumes that the aai is set once and - // for all. - aai = new AppenderAttachableImpl(); - dispatcher = new Dispatcher(bf, this); - dispatcher.start(); - } - - - public - void addAppender(Appender newAppender) { - synchronized(aai) { - aai.addAppender(newAppender); - } - } - - public - void append(LoggingEvent event) { - // Set the NDC and thread name for the calling thread as these - // LoggingEvent fields were not set at event creation time. - event.getNDC(); - event.getThreadName(); - // Get a copy of this thread's MDC. - event.getMDCCopy(); - if(locationInfo) { - event.getLocationInformation(); - } - synchronized(bf) { - while(bf.isFull()) { - try { - //LogLog.debug("Waiting for free space in buffer, "+bf.length()); - bf.wait(); - } catch(InterruptedException e) { - if(!interruptedWarningMessage) { - interruptedWarningMessage = true; - LogLog.warn("AsyncAppender interrupted.", e); - } else { - LogLog.warn("AsyncAppender interrupted again."); - } - } - } - - //cat.debug("About to put new event in buffer."); - bf.put(event); - if(bf.wasEmpty()) { - //cat.debug("Notifying dispatcher to process events."); - bf.notify(); - } - } - } - - /** - Close this AsyncAppender by interrupting the - dispatcher thread which will process all pending events before - exiting. - */ - public - void close() { - synchronized(this) { - // avoid multiple close, otherwise one gets NullPointerException - if(closed) { - return; - } - closed = true; - } - - // The following cannot be synchronized on "this" because the - // dispatcher synchronizes with "this" in its while loop. If we - // did synchronize we would systematically get deadlocks when - // close was called. - dispatcher.close(); - try { - dispatcher.join(); - } catch(InterruptedException e) { - LogLog.error("Got an InterruptedException while waiting for the "+ - "dispatcher to finish.", e); - } - dispatcher = null; - bf = null; - } - - public - Enumeration getAllAppenders() { - synchronized(aai) { - return aai.getAllAppenders(); - } - } - - public - Appender getAppender(String name) { - synchronized(aai) { - return aai.getAppender(name); - } - } - - /** - Returns the current value of the LocationInfo option. - */ - public - boolean getLocationInfo() { - return locationInfo; - } - - /** - Is the appender passed as parameter attached to this category? - */ - public - boolean isAttached(Appender appender) { - return aai.isAttached(appender); - } - - - /** - The AsyncAppender does not require a layout. Hence, - this method always returns false. */ - public - boolean requiresLayout() { - return false; - } - - public - void removeAllAppenders() { - synchronized(aai) { - aai.removeAllAppenders(); - } - } - - - public - void removeAppender(Appender appender) { - synchronized(aai) { - aai.removeAppender(appender); - } - } - - public - void removeAppender(String name) { - synchronized(aai) { - aai.removeAppender(name); - } - } - - /** - The LocationInfo option takes a boolean value. By - default, it is set to false which means there will be no effort - to extract the location information related to the event. As a - result, the event that will be ultimately logged will likely to - contain the wrong location information (if present in the log - format). - -

    Location information extraction is comparatively very slow and - should be avoided unless performance is not a concern. - */ - public - void setLocationInfo(boolean flag) { - locationInfo = flag; - } - - - /** - The BufferSize option takes a non-negative integer - value. This integer value determines the maximum size of the - bounded buffer. Increasing the size of the buffer is always - safe. However, if an existing buffer holds unwritten elements, - then decreasing the buffer size will result in event - loss. Nevertheless, while script configuring the - AsyncAppender, it is safe to set a buffer size smaller than the - {@link #DEFAULT_BUFFER_SIZE default buffer size} because - configurators guarantee that an appender cannot be used before - being completely configured. - */ - public - void setBufferSize(int size) { - bf.resize(size); - } - - /** - Returns the current value of the BufferSize option. - */ - public - int getBufferSize() { - return bf.getMaxSize(); - } - -} -// ------------------------------------------------------------------------------ -// ------------------------------------------------------------------------------ -// ---------------------------------------------------------------------------- -class Dispatcher extends Thread { - - BoundedFIFO bf; - AppenderAttachableImpl aai; - boolean interrupted = false; - AsyncAppender container; - - Dispatcher(BoundedFIFO bf, AsyncAppender container) { - this.bf = bf; - this.container = container; - this.aai = container.aai; - // set the dispatcher priority to lowest possible value - this.setPriority(Thread.MIN_PRIORITY); - this.setName("Dispatcher-"+getName()); - // set the dispatcher priority to MIN_PRIORITY plus or minus 2 - // depending on the direction of MIN to MAX_PRIORITY. - //+ (Thread.MAX_PRIORITY > Thread.MIN_PRIORITY ? 1 : -1)*2); - - } - - void close() { - synchronized(bf) { - interrupted = true; - // We have a waiting dispacther if and only if bf.length is - // zero. In that case, we need to give it a death kiss. - if(bf.length() == 0) { - bf.notify(); - } - } - } - - - - /** - The dispatching strategy is to wait until there are events in the - buffer to process. After having processed an event, we release - the monitor (variable bf) so that new events can be placed in the - buffer, instead of keeping the monitor and processing the remaining - events in the buffer. - -

    Other approaches might yield better results. - - */ - public - void run() { - - //Category cat = Category.getInstance(Dispatcher.class.getName()); - - LoggingEvent event; - - while(true) { - synchronized(bf) { - if(bf.length() == 0) { - // Exit loop if interrupted but only if the the buffer is empty. - if(interrupted) { - //cat.info("Exiting."); - return; - } - try { - //LogLog.debug("Waiting for new event to dispatch."); - bf.wait(); - } catch(InterruptedException e) { - LogLog.error("The dispathcer should not be interrupted."); - break; - } - } - event = bf.get(); - if(bf.wasFull()) { - //LogLog.debug("Notifying AsyncAppender about freed space."); - bf.notify(); - } - } // synchronized - - // The synchronization on parent is necessary to protect against - // operations on the aai object of the parent - synchronized(container.aai) { - if(aai != null && event != null) { - aai.appendLoopOnAppenders(event); - } - } - } // while - } -} diff --git a/src/java/org/apache/log4j/CategoryKey.java b/src/java/org/apache/log4j/CategoryKey.java deleted file mode 100644 index b3c94ad3c5..0000000000 --- a/src/java/org/apache/log4j/CategoryKey.java +++ /dev/null @@ -1,41 +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.txt file. */ - -package org.apache.log4j; - -/** - CategoryKey is heavily used internally to accelerate hash table searches. - @author Ceki Gülcü -*/ -class CategoryKey { - - String name; - int hashCache; - - CategoryKey(String name) { - this.name = name.intern(); - hashCache = name.hashCode(); - } - - final - public - int hashCode() { - return hashCache; - } - - final - public - boolean equals(Object rArg) { - if(this == rArg) - return true; - - if(rArg != null && CategoryKey.class == rArg.getClass()) - return name == ((CategoryKey)rArg ).name; - else - return false; - } -} diff --git a/src/java/org/apache/log4j/ConsoleAppender.java b/src/java/org/apache/log4j/ConsoleAppender.java deleted file mode 100644 index fc1447461f..0000000000 --- a/src/java/org/apache/log4j/ConsoleAppender.java +++ /dev/null @@ -1,99 +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.txt file. */ - -package org.apache.log4j; - -import java.io.OutputStreamWriter; -import org.apache.log4j.helpers.LogLog; - -/** - ConsoleAppender appends log events to System.out or - System.err using a layout specified by the - user. The default target is System.out. - - @author Ceki Gülcü - @since 1.1 */ -public class ConsoleAppender extends WriterAppender { - - public static final String SYSTEM_OUT = "System.out"; - public static final String SYSTEM_ERR = "System.err"; - - protected String target = SYSTEM_OUT; - - /** - The default constructor does nothing. - */ - public ConsoleAppender() { - } - - public ConsoleAppender(Layout layout) { - this(layout, SYSTEM_OUT); - } - - public ConsoleAppender(Layout layout, String target) { - this.layout = layout; - - if (SYSTEM_OUT.equals(target)) { - setWriter(new OutputStreamWriter(System.out)); - } else if (SYSTEM_ERR.equalsIgnoreCase(target)) { - setWriter(new OutputStreamWriter(System.err)); - } else { - targetWarn(target); - } - } - - /** - Sets the value of the Target option. Recognized values are - "System.out" and "System.err". Any other value will be ignored. - */ - public - void setTarget(String value) { - String v = value.trim(); - - if (SYSTEM_OUT.equalsIgnoreCase(v)) { - target = SYSTEM_OUT; - } else if (SYSTEM_ERR.equalsIgnoreCase(v)) { - target = SYSTEM_ERR; - } else { - targetWarn(value); - } - } - - /** - Returns the current value of the Target property. The default - value of the option is "System.out". - - See also {@link #setTarget}. - - */ - public - String getTarget() { - return target; - } - - void targetWarn(String val) { - LogLog.warn("["+val+"] should be System.out or System.err."); - LogLog.warn("Using System.out (default)."); - } - - public - void activateOptions() { - if(target.equals(SYSTEM_OUT)) { - setWriter(new OutputStreamWriter(System.out)); - } else { - setWriter(new OutputStreamWriter(System.err)); - } - } - - /** - Override the parent method to do nothing. - */ - protected - final - void closeWriter() { - } -} diff --git a/src/java/org/apache/log4j/DefaultCategoryFactory.java b/src/java/org/apache/log4j/DefaultCategoryFactory.java deleted file mode 100644 index 1250084d3e..0000000000 --- a/src/java/org/apache/log4j/DefaultCategoryFactory.java +++ /dev/null @@ -1,21 +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.txt file. */ - -package org.apache.log4j; - -import org.apache.log4j.spi.LoggerFactory; - -class DefaultCategoryFactory implements LoggerFactory { - - DefaultCategoryFactory() { - } - - public - Logger makeNewLoggerInstance(String name) { - return new Logger(name); - } -} diff --git a/src/java/org/apache/log4j/Logger.java b/src/java/org/apache/log4j/Logger.java deleted file mode 100644 index aab789ddad..0000000000 --- a/src/java/org/apache/log4j/Logger.java +++ /dev/null @@ -1,127 +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.txt file. */ - -package org.apache.log4j; - -import org.apache.log4j.spi.LoggerFactory; - - -/** - This is the central class in the log4j package. Most logging - operations, except configuration, are done through this class. - - @since log4j 1.2 - - @author Ceki Gülcü */ -public class Logger extends Category { - - /** - The fully qualified name of the Level class. See also the - getFQCN method. */ - private static final String FQCN = Level.class.getName(); - - - protected - Logger(String name) { - super(name); - } - - /** - Log a message object with the {@link Level#FINE FINE} level which - is just an alias for the {@link Level#DEBUG DEBUG} level. - -

    This method first checks if this category is DEBUG - enabled by comparing the level of this category with the {@link - Level#DEBUG DEBUG} level. If this category is - DEBUG enabled, then it converts the message object - (passed as parameter) to a string by invoking the appropriate - {@link org.apache.log4j.or.ObjectRenderer}. It then proceeds to call all the - registered appenders in this category and also higher in the - hierarchy depending on the value of the additivity flag. - -

    WARNING Note that passing a {@link Throwable} to this - method will print the name of the Throwable but no - stack trace. To print a stack trace use the {@link #debug(Object, - Throwable)} form instead. - - @param message the message object to log. */ - //public - //void fine(Object message) { - // if(repository.isDisabled(Level.DEBUG_INT)) - // return; - // if(Level.DEBUG.isGreaterOrEqual(this.getChainedLevel())) { - // forcedLog(FQCN, Level.DEBUG, message, null); - // } - //} - - - /** - Log a message object with the FINE level including - the stack trace of the {@link Throwable} t passed as - parameter. - -

    See {@link #fine(Object)} form for more detailed information. - - @param message the message object to log. - @param t the exception to log, including its stack trace. */ - //public - //void fine(Object message, Throwable t) { - // if(repository.isDisabled(Level.DEBUG_INT)) - // return; - // if(Level.DEBUG.isGreaterOrEqual(this.getChainedLevel())) - // forcedLog(FQCN, Level.FINE, message, t); - //} - - /** - Retrieve a logger by name. - */ - static - public - Logger getLogger(String name) { - return LogManager.getLogger(name); - } - - /** - Same as calling getLogger(clazz.getName()). - */ - static - public - Logger getLogger(Class clazz) { - return LogManager.getLogger(clazz.getName()); - } - - - /** - Retrieve the root logger. - */ - public - static - Logger getRootLogger() { - return LogManager.getRootLogger(); - } - - /** - Like {@link #getLogger(String)} except that the type of logger - instantiated depends on the type returned by the {@link - LoggerFactory#makeNewLoggerInstance} method of the - factory parameter. - -

    This method is intended to be used by sub-classes. - - @param name The name of the logger to retrieve. - - @param factory A {@link LoggerFactory} implementation that will - actually create a new Instance. - - @since 0.8.5 */ - public - static - Logger getLogger(String name, LoggerFactory factory) { - return LogManager.getLogger(name, factory); - } - -} diff --git a/src/java/org/apache/log4j/ProvisionNode.java b/src/java/org/apache/log4j/ProvisionNode.java deleted file mode 100644 index 4faf539470..0000000000 --- a/src/java/org/apache/log4j/ProvisionNode.java +++ /dev/null @@ -1,18 +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.txt file. */ - -package org.apache.log4j; - -import java.util.Vector; - -class ProvisionNode extends Vector { - - ProvisionNode(Logger logger) { - super(); - this.addElement(logger); - } -} diff --git a/src/java/org/apache/log4j/chainsaw/ExitAction.java b/src/java/org/apache/log4j/chainsaw/ExitAction.java deleted file mode 100644 index 8fb0ce8c9b..0000000000 --- a/src/java/org/apache/log4j/chainsaw/ExitAction.java +++ /dev/null @@ -1,38 +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.txt file. */ -package org.apache.log4j.chainsaw; - -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import org.apache.log4j.Category; - -/** - * Encapsulates the action to exit. - * - * @author Oliver Burn - * @version 1.0 - */ -class ExitAction - extends AbstractAction -{ - /** use to log messages **/ - private static final Category LOG = Category.getInstance(ExitAction.class); - /** The instance to share **/ - public static final ExitAction INSTANCE = new ExitAction(); - - /** Stop people creating instances **/ - private ExitAction() {} - - /** - * Will shutdown the application. - * @param aIgnore ignored - */ - public void actionPerformed(ActionEvent aIgnore) { - LOG.info("shutting down"); - System.exit(0); - } -} diff --git a/src/java/org/apache/log4j/config/PropertySetterException.java b/src/java/org/apache/log4j/config/PropertySetterException.java deleted file mode 100644 index b8cb0e00a5..0000000000 --- a/src/java/org/apache/log4j/config/PropertySetterException.java +++ /dev/null @@ -1,44 +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.config; - -/** - * Thrown when an error is encountered whilst attempting to set a property - * using the {@link PropertySetter} utility class. - * - * @author Anders Kristensen - * @since 1.1 - */ -public class PropertySetterException extends Exception { - protected Throwable rootCause; - - public - PropertySetterException(String msg) { - super(msg); - } - - public - PropertySetterException(Throwable rootCause) - { - super(); - this.rootCause = rootCause; - } - - /** - Returns descriptive text on the cause of this exception. - */ - public - String getMessage() { - String msg = super.getMessage(); - if (msg == null && rootCause != null) { - msg = rootCause.getMessage(); - } - return msg; - } -} \ No newline at end of file diff --git a/src/java/org/apache/log4j/helpers/FormattingInfo.java b/src/java/org/apache/log4j/helpers/FormattingInfo.java deleted file mode 100644 index a8b5e41a38..0000000000 --- a/src/java/org/apache/log4j/helpers/FormattingInfo.java +++ /dev/null @@ -1,36 +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.txt file. - */ - -package org.apache.log4j.helpers; - - -/** - FormattingInfo instances contain the information obtained when parsing - formatting modifiers in conversion modifiers. - - @author Jim Cakalic - @author Ceki Gülcü - - @since 0.8.2 - */ -public class FormattingInfo { - int min = -1; - int max = 0x7FFFFFFF; - boolean leftAlign = false; - - void reset() { - min = -1; - max = 0x7FFFFFFF; - leftAlign = false; - } - - void dump() { - LogLog.debug("min="+min+", max="+max+", leftAlign="+leftAlign); - } -} - diff --git a/src/java/org/apache/log4j/helpers/Loader.java b/src/java/org/apache/log4j/helpers/Loader.java deleted file mode 100644 index 222c2ccffe..0000000000 --- a/src/java/org/apache/log4j/helpers/Loader.java +++ /dev/null @@ -1,138 +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.txt file. */ - -package org.apache.log4j.helpers; - -import java.net.URL; -//import java.awt.Image; -//import java.awt.Toolkit; - -/** - Load resources (or images) from various sources. - - @author Ceki Gülcü - */ - -public class Loader { - - static final String TSTR = "Caught Exception while in Loader.getResource. This may be innocuous."; - - // We conservatively assume that we are running under Java 1.x - static private boolean java1 = true; - - static { - String prop = OptionConverter.getSystemProperty("java.version", null); - - if(prop != null) { - int i = prop.indexOf('.'); - if(i != -1) { - if(prop.charAt(i+1) != '1') - java1 = false; - } - } - } - - /** - This method will search for resource in different - places. The rearch order is as follows: - -

      - -

    1. Search for resource using the thread context - class loader under Java2. If that fails, search for - resource using the class loader that loaded this - class (Loader). Under JDK 1.1, only the the class - loader that loaded this class (Loader) is used. - -

    2. Try one last time with - ClassLoader.getSystemResource(resource), that is is - using the system class loader in JDK 1.2 and virtual machine's - built-in class loader in JDK 1.1. - -
    - - */ - static - public - URL getResource(String resource) { - ClassLoader classLoader = null; - URL url = null; - - try { - if(!java1) { - classLoader = Thread.currentThread().getContextClassLoader(); - if(classLoader != null) { - LogLog.debug("Trying to find ["+resource+"] using context classloader " - +classLoader+"."); - url = classLoader.getResource(resource); - if(url != null) { - return url; - } - } - } - - // We could not find resource. Ler us now try with the - // classloader that loaded this class. - classLoader = Loader.class.getClassLoader(); - if(classLoader == null) { - LogLog.warn("Loader.class.getClassLoader returned null!"); - } else { - - LogLog.debug("Trying to find ["+resource+"] using "+classLoader - +" class loader."); - url = classLoader.getResource(resource); - if(url != null) { - return url; - } - } - } catch(Throwable t) { - LogLog.warn(TSTR, t); - } - - // Last ditch attempt: get the resource from the class path. It - // may be the case that clazz was loaded by the Extentsion class - // loader which the parent of the system class loader. Hence the - // code below. - LogLog.debug("Trying to find ["+resource+ - "] using ClassLoader.getSystemResource()."); - return ClassLoader.getSystemResource(resource); - } - - /** - Are we running under JDK 1.x? - */ - public - static - boolean isJava1() { - return java1; - } - - - /** - Load the specified class using the Thread - contextClassLoader if running under Java2 or current - class loader if running under JDK 1.1. - */ - static - public - Class loadClass (Double clazz) throws ClassNotFoundException { - return null; - // if(java1) { - // return Class.forName(clazz); - // } else { - // try { - // return Thread.currentThread().getContextClassLoader().loadClass(clazz); - // } catch(Exception e) { - // // we reached here because - // // currentThread().getContextClassLoader() is null or because - // // of a security exceptio, or because clazz could not be - // // loaded, in any case we now try one more time - // return Class.forName(clazz); - // } - // } - } -} diff --git a/src/java/org/apache/log4j/helpers/NullEnumeration.java b/src/java/org/apache/log4j/helpers/NullEnumeration.java deleted file mode 100644 index e7dd29e2ee..0000000000 --- a/src/java/org/apache/log4j/helpers/NullEnumeration.java +++ /dev/null @@ -1,43 +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.txt file. - */ - -package org.apache.log4j.helpers; - -import java.util.Enumeration; -import java.util.NoSuchElementException; - -/** - - An always-empty Enumerator. - - @author Anders Kristensen - @since version 1.0 - */ -public class NullEnumeration implements Enumeration { - private static final NullEnumeration instance = new NullEnumeration(); - - private - NullEnumeration() { - } - - public - static - NullEnumeration getInstance() { - return instance; - } - - public - boolean hasMoreElements() { - return false; - } - - public - Object nextElement() { - throw new NoSuchElementException(); - } -} diff --git a/src/java/org/apache/log4j/helpers/SyslogQuietWriter.java b/src/java/org/apache/log4j/helpers/SyslogQuietWriter.java deleted file mode 100644 index 9e30777dc7..0000000000 --- a/src/java/org/apache/log4j/helpers/SyslogQuietWriter.java +++ /dev/null @@ -1,47 +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.txt file. - */ - -package org.apache.log4j.helpers; - - - -import java.io.Writer; -import org.apache.log4j.spi.ErrorHandler; - -/** - SyslogQuietWriter extends QuietWriter by prepending the syslog - level code before each printed String. - - @since 0.7.3 -*/ -public class SyslogQuietWriter extends QuietWriter { - - int syslogFacility; - int level; - - public - SyslogQuietWriter(Writer writer, int syslogFacility, ErrorHandler eh) { - super(writer, eh); - this.syslogFacility = syslogFacility; - } - - public - void setLevel(int level) { - this.level = level; - } - - public - void setSyslogFacility(int syslogFacility) { - this.syslogFacility = syslogFacility; - } - - public - void write(String string) { - super.write("<"+(syslogFacility | level)+">" + string); - } -} diff --git a/src/java/org/apache/log4j/helpers/SyslogWriter.java b/src/java/org/apache/log4j/helpers/SyslogWriter.java deleted file mode 100644 index 81a05f152a..0000000000 --- a/src/java/org/apache/log4j/helpers/SyslogWriter.java +++ /dev/null @@ -1,78 +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.txt file. - */ - -package org.apache.log4j.helpers; - - -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; - -/** - SyslogWriter is a wrapper around the java.net.DatagramSocket class - so that it behaves like a java.io.Writer. - - @since 0.7.3 -*/ -public class SyslogWriter extends Writer { - - final int SYSLOG_PORT = 514; - static String syslogHost; - - private InetAddress address; - private DatagramSocket ds; - - public - SyslogWriter(String syslogHost) { - this.syslogHost = syslogHost; - - try { - this.address = InetAddress.getByName(syslogHost); - } - catch (UnknownHostException e) { - LogLog.error("Could not find " + syslogHost + - ". All logging will FAIL.", e); - } - - try { - this.ds = new DatagramSocket(); - } - catch (SocketException e) { - e.printStackTrace(); - LogLog.error("Could not instantiate DatagramSocket to " + syslogHost + - ". 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 { - DatagramPacket packet = new DatagramPacket(string.getBytes(), - string.length(), - address, SYSLOG_PORT); - - if(this.ds != null) - ds.send(packet); - - } - - public - void flush() {} - - public - void close() {} -} diff --git a/src/java/org/apache/log4j/helpers/ThreadLocalMap.java b/src/java/org/apache/log4j/helpers/ThreadLocalMap.java deleted file mode 100644 index 811314ba34..0000000000 --- a/src/java/org/apache/log4j/helpers/ThreadLocalMap.java +++ /dev/null @@ -1,33 +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.txt file. - */ - -package org.apache.log4j.helpers; - -import java.util.Hashtable; - -/** - ThreadLocalMap extends {@link InheritableThreadLocal} - to bequeath a copy of the hashtable of the MDC of the parent - thread. - - @author Ceki Gülcü - @since 1.2 -*/ -final public class ThreadLocalMap extends InheritableThreadLocal { - - public - final - Object childValue(Object parentValue) { - Hashtable ht = (Hashtable) parentValue; - if(ht != null) { - return ht.clone(); - } else { - return null; - } - } -} diff --git a/src/java/org/apache/log4j/helpers/Transform.java b/src/java/org/apache/log4j/helpers/Transform.java deleted file mode 100644 index 66e6c8041b..0000000000 --- a/src/java/org/apache/log4j/helpers/Transform.java +++ /dev/null @@ -1,56 +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.txt file. */ - -package org.apache.log4j.helpers; - -import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.spi.LocationInfo; - -/** - Utility class for transforming strings. - */ -public class Transform { - - /** - * This method takes a string which may contain HTML tags (ie, , , - * etc) and converts the '<' and '>' characters to their HTML escape - * sequences. - * - * @param input The text to be converted. - * @return The input string with the characters '<' and '>' replaced with - * < and > respectively. - */ - static - public - String escapeTags(String input) { - //Check if the string is null or zero length -- if so, return - //what was sent in. - - if( input == null || input.length() == 0 ) { - return input; - } - - //Use a StringBuffer in lieu of String concatenation -- it is - //much more efficient this way. - - StringBuffer buf = new StringBuffer(input.length() + 6); - char ch = ' '; - - int len = input.length(); - for(int i=0; i < len; i++) { - ch = input.charAt(i); - if(ch == '<') { - buf.append("<"); - } else if(ch == '>') { - buf.append(">"); - } else { - buf.append(ch); - } - } - return buf.toString(); - } -} diff --git a/src/java/org/apache/log4j/jmx/Agent.java b/src/java/org/apache/log4j/jmx/Agent.java deleted file mode 100644 index 3049a91792..0000000000 --- a/src/java/org/apache/log4j/jmx/Agent.java +++ /dev/null @@ -1,39 +0,0 @@ - -package org.apache.log4j.jmx; - -import javax.management.ObjectName; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; -import com.sun.jdmk.comm.HtmlAdaptorServer; - -import org.apache.log4j.Category; - - -public class Agent { - - static Category log = Category.getInstance(Agent.class); - - public Agent() { - } - - - public - void start() { - - MBeanServer server = MBeanServerFactory.createMBeanServer(); - HtmlAdaptorServer html = new HtmlAdaptorServer(); - - try { - log.info("Registering HtmlAdaptorServer instance."); - server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082")); - log.info("Registering HierarchyDynamicMBean instance."); - HierarchyDynamicMBean hdm = new HierarchyDynamicMBean(); - server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default")); - - } catch(Exception e) { - log.error("Problem while regitering MBeans instances.", e); - return; - } - html.start(); - } -} diff --git a/src/java/org/apache/log4j/jmx/MethodUnion.java b/src/java/org/apache/log4j/jmx/MethodUnion.java deleted file mode 100644 index f810d654f0..0000000000 --- a/src/java/org/apache/log4j/jmx/MethodUnion.java +++ /dev/null @@ -1,22 +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.txt file. */ - -package org.apache.log4j.jmx; - -import java.lang.reflect.Method; - -class MethodUnion { - - Method readMethod; - Method writeMethod; - - MethodUnion( Method readMethod, Method writeMethod) { - this.readMethod = readMethod; - this.writeMethod = writeMethod; - } - -} diff --git a/src/java/org/apache/log4j/jmx/T.java b/src/java/org/apache/log4j/jmx/T.java deleted file mode 100644 index 24724744e3..0000000000 --- a/src/java/org/apache/log4j/jmx/T.java +++ /dev/null @@ -1,22 +0,0 @@ - - -import org.apache.log4j.jmx.Agent; -import org.apache.log4j.Category; -import org.apache.log4j.BasicConfigurator; -import org.apache.log4j.*; - -public class T { - - - public static void main(String[] args) { - Category cat = Category.getInstance(T.class); - Layout layout = new PatternLayout("%r %p [%t] %c - %m%n"); - ConsoleAppender consoleAppender = new ConsoleAppender(layout); - - consoleAppender.setName("console"); - BasicConfigurator.configure(consoleAppender); - Agent agent = new Agent(); - agent.start(); - } - -} diff --git a/src/java/org/apache/log4j/lf5/util/ProductProperties.java b/src/java/org/apache/log4j/lf5/util/ProductProperties.java deleted file mode 100644 index dc9e41ba01..0000000000 --- a/src/java/org/apache/log4j/lf5/util/ProductProperties.java +++ /dev/null @@ -1,248 +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.txt file. - */ -package org.apache.log4j.lf5.util; - -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -/** - * ProductProperties holds the properties dealing with - * this product. There is never a need - * for multiple instances of this class, thus this class - * is a singleton. - * - * The properties file format is as follows: - * - * #Any arbitrary comments are denoted with a # - * - * #Mandatory properties - * product.name= - * product.version.number= - * product.release.date= - * product.release.type= - * - * - * Note that this class will throw an ExceptionInInitializerError if - * initialization fails, or if the required properties are absent. - * - * @author Robert Shaw - * @author Michael J. Sikorsky - * @author Brent Sprecher - */ - -// Contributed by ThoughtWorks Inc. - -public class ProductProperties { - //-------------------------------------------------------------------------- - // Constants: - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - // Protected Variables: - //-------------------------------------------------------------------------- - - /** Collection of properties. */ - protected Properties _productProperties; - //protected final boolean _validFlag; - - //-------------------------------------------------------------------------- - // Private Variables: - //-------------------------------------------------------------------------- - private static ProductProperties _reference = null; - private static Object _synchronizingObject = new Object(); - - //-------------------------------------------------------------------------- - // Constructors: - //-------------------------------------------------------------------------- - - /** - * Construct an ProductProperties with the mandatory properties. - * Use the constructor that configures a ProductProperties - * off of a properties file if you wish to take advantage - * of additional properties. - * - */ - private ProductProperties() { - this(new Resource("org/apache/log4j/lf5/lf5.properties")); - } - - private ProductProperties(Resource resource) { - super(); - - _productProperties = new Properties(); - - try { - InputStream source = getSource(resource); - byte[] contents = StreamUtils.getBytes(source); - _productProperties = getProperties(contents); - source.close(); - validateProductProperties(); - } catch (Exception e) { - String error = e.getMessage(); - throw new ExceptionInInitializerError(error); - } - } - - - //-------------------------------------------------------------------------- - // Public Methods: - //-------------------------------------------------------------------------- - - public static ProductProperties getInstance() { - if (_reference == null) { - synchronized (_synchronizingObject) { - if (_reference == null) { - _reference = new ProductProperties(); - } - } - } - return _reference; - } - - /** - * Mandatory internally recognized property. - */ - public static String getPropertyNameOfProductName() { - return "product.name"; - } - - /** - * Mandatory internally recognized property. - */ - public static String getPropertyNameOfProductVersionNumber() { - return "product.version.number"; - } - - /** - * Mandatory internally recognized property. - */ - public static String getPropertyNameOfProductReleaseDate() { - return "product.release.date"; - } - - /** - * Get the product name. - */ - public String getProductName() { - return _productProperties.getProperty(getPropertyNameOfProductName()); - } - - /** - * Set the product name. - */ - public void setProductName(String productName) { - _productProperties.setProperty(getPropertyNameOfProductName(), - productName); - } - - /** - * Get the product version number. - */ - public String getProductVersionNumber() { - return - _productProperties.getProperty(getPropertyNameOfProductVersionNumber()); - } - - /** - * Set the product version number. - */ - public void setProductVersionNumber(String productVersionNumber) { - _productProperties.setProperty(getPropertyNameOfProductVersionNumber(), - productVersionNumber); - } - - /** - * Get the product release date. - */ - public String getProductReleaseDate() { - return - _productProperties.getProperty(getPropertyNameOfProductReleaseDate()); - } - - /** - * Set the product release date. - */ - public void setProductReleaseDate(String productReleaseDate) { - _productProperties.setProperty(getPropertyNameOfProductReleaseDate(), - productReleaseDate); - } - - /** - * Retrieve any of the mandatory properties, or any additional - * properties that were placed in the database configuration file. - */ - public String get(String name) { - return _productProperties.getProperty(name); - } - - /** - * Set any property. - */ - public Object set(String name, String value) { - return _productProperties.setProperty(name, value); - } - - public String getLogFactor5() { - return getString("lf5"); - } - - public String getString(String propertyName) { - return String.valueOf(get(propertyName)); - } - - //-------------------------------------------------------------------------- - // Protected Methods: - //-------------------------------------------------------------------------- - /** - * @throws java.lang.Exception - */ - protected void validateProductProperties() throws Exception { - String value = null; - - value = getProductVersionNumber(); - if ((value == null) || value.equals("")) { - throw new Exception("Product version number is null."); - } - - value = getProductReleaseDate(); - if ((value == null) || value.equals("")) { - throw new Exception("Product release date is null."); - } - - } - - //-------------------------------------------------------------------------- - // Private Methods: - //-------------------------------------------------------------------------- - - private InputStream getSource(Resource resource) { - return new BufferedInputStream( - ResourceUtils.getResourceAsStream(this, resource)); - } - - private Properties getProperties(byte[] contents) throws IOException { - ByteArrayInputStream source = new ByteArrayInputStream(contents); - Properties result = new Properties(); - result.load(source); - source.close(); - return result; - } - - //-------------------------------------------------------------------------- - // Nested Top-Level Classes or Interfaces - //-------------------------------------------------------------------------- -} - - - - - - diff --git a/src/java/org/apache/log4j/lf5/viewer/LogFactor5AboutDialog.java b/src/java/org/apache/log4j/lf5/viewer/LogFactor5AboutDialog.java deleted file mode 100644 index ef24a82ac1..0000000000 --- a/src/java/org/apache/log4j/lf5/viewer/LogFactor5AboutDialog.java +++ /dev/null @@ -1,136 +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.txt file. - */ -package org.apache.log4j.lf5.viewer; - -import org.apache.log4j.lf5.util.ProductProperties; -import org.apache.log4j.lf5.util.Resource; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.net.URL; - -/** - * LogFactor5AboutDialog - * - * @author Michael J. Sikorsky - * @author Robert Shaw - * @author Brent Sprecher - * @author Brad Marlborough - */ - -// Contributed by ThoughtWorks Inc. - -public class LogFactor5AboutDialog extends JDialog { - //-------------------------------------------------------------------------- - // Constants: - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - // Protected Variables: - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - // Private Variables: - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - // Constructors: - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - // Public Methods: - //-------------------------------------------------------------------------- - - public LogFactor5AboutDialog(Frame owner) { - super(owner, "About LogFactor5", true); - - ProductProperties props = ProductProperties.getInstance(); - - setTitle("About LogFactor5"); - - JPanel imagePanel = new JPanel(); - Resource aboutResource = new Resource("org/apache/log4j/lf5/viewer/images/" + - "lf5_about.gif"); - URL aboutIconURL = aboutResource.getURL(); - ImageIcon aboutIcon = null; - if (aboutIconURL != null) { - aboutIcon = new ImageIcon(aboutIconURL); - } - - JLabel imageLabel = new JLabel(); - - if (aboutIcon != null) { - imageLabel.setIcon(aboutIcon); - } - imagePanel.add(imageLabel); - - JPanel textPanel = new JPanel(); - textPanel.setLayout(new GridLayout(3, 1)); - - - int numberOfRows = 13; - numberOfRows = 11; // we need less room for a registered user. - JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new GridLayout(numberOfRows, 1)); - JLabel aboutLF5 = new JLabel("LogFactor5 v" + props.getProductVersionNumber(), JLabel.CENTER); - aboutLF5.setHorizontalAlignment(SwingConstants.CENTER); - JLabel donate = new JLabel("Contributed by ThoughtWorks Inc."); - donate.setHorizontalAlignment(SwingConstants.CENTER); - mainPanel.add(aboutLF5); - mainPanel.add(Box.createVerticalStrut(10)); - mainPanel.add(donate); - mainPanel.add(Box.createVerticalStrut(10)); - - JButton ok = new JButton("OK"); - JPanel southPanel = new JPanel(); - southPanel.setLayout(new FlowLayout()); - southPanel.add(ok); - ok.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - hide(); - } - } - - ); - getContentPane().add(imagePanel, BorderLayout.NORTH); - getContentPane().add(mainPanel, BorderLayout.CENTER); - getContentPane().add(southPanel, BorderLayout.SOUTH); - setSize(414, 400); - center(); - } - //-------------------------------------------------------------------------- - // Protected Methods: - //-------------------------------------------------------------------------- - - protected void center() { - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension comp = getSize(); - - setLocation(((screen.width - comp.width) / 2), - ((screen.height - comp.height) / 2)); - - } - - //-------------------------------------------------------------------------- - // Private Methods: - //-------------------------------------------------------------------------- - - //-------------------------------------------------------------------------- - // Nested Top-Level Classes or Interfaces: - //-------------------------------------------------------------------------- - -} - - - - - - diff --git a/src/java/org/apache/log4j/lf5/viewer/images/lf5_about.gif b/src/java/org/apache/log4j/lf5/viewer/images/lf5_about.gif deleted file mode 100644 index cdc59ef00f..0000000000 Binary files a/src/java/org/apache/log4j/lf5/viewer/images/lf5_about.gif and /dev/null differ diff --git a/src/java/org/apache/log4j/lf5/viewer/images/lf5_small_icon.png b/src/java/org/apache/log4j/lf5/viewer/images/lf5_small_icon.png deleted file mode 100644 index d3462e327d..0000000000 Binary files a/src/java/org/apache/log4j/lf5/viewer/images/lf5_small_icon.png and /dev/null differ diff --git a/src/java/org/apache/log4j/net/JMSAppender.java b/src/java/org/apache/log4j/net/JMSAppender.java deleted file mode 100644 index 165ed1a7ea..0000000000 --- a/src/java/org/apache/log4j/net/JMSAppender.java +++ /dev/null @@ -1,200 +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.txt file. */ - -package org.apache.log4j.net; - -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.spi.ErrorCode; -import org.apache.log4j.helpers.LogLog; - -import javax.jms.*; -import javax.naming.InitialContext; -import javax.naming.Context; -import javax.naming.NameNotFoundException; -import javax.naming.NamingException; - -/** - A simple appender based on JMS. - - @author Ceki Gülcü -*/ -public class JMSAppender extends AppenderSkeleton { - - TopicConnection topicConnection; - TopicSession topicSession; - TopicPublisher topicPublisher; - String topicBindingName; - String tcfBindingName; - boolean locationInfo; - - public - JMSAppender() { - } - - /** - The TopicConnectionFactoryBindingName option takes a - string value. Its value will be used to lookup the appropriate - TopicConnectionFactory from the JNDI context. - */ - public - void setTopicConnectionFactoryBindingName(String tcfBindingName) { - this.tcfBindingName = tcfBindingName; - } - - /** - Returns the value of the TopicConnectionFactoryBindingName option. - */ - public - String getTopicConnectionFactoryBindingName() { - return tcfBindingName; - } - - /** - The TopicBindingName option takes a - string value. Its value will be used to lookup the appropriate - Topic from the JNDI context. - */ - public - void setTopicBindingName(String topicBindingName) { - this.topicBindingName = topicBindingName; - } - - /** - Returns the value of the TopicBindingName option. - */ - public - String getTopicBindingName() { - return topicBindingName; - } - - - /** - Returns value of the LocationInfo property which - determines whether location (stack) info is sent to the remote - subscriber. */ - public - boolean getLocationInfo() { - return locationInfo; - } - - public - void activateOptions() { - TopicConnectionFactory topicConnectionFactory; - - try { - Context ctx = new InitialContext(); - topicConnectionFactory = (TopicConnectionFactory) lookup(ctx, tcfBindingName); - topicConnection = topicConnectionFactory.createTopicConnection(); - topicConnection.start(); - - topicSession = topicConnection.createTopicSession(false, - Session.AUTO_ACKNOWLEDGE); - - Topic topic = (Topic) lookup(ctx, topicBindingName); - topicPublisher = topicSession.createPublisher(topic); - - ctx.close(); - } catch(Exception e) { - errorHandler.error("Error while activating options for appender named ["+name+ - "].", e, ErrorCode.GENERIC_FAILURE); - } - } - - protected - Object lookup(Context ctx, String name) throws NamingException { - try { - return ctx.lookup(name); - } catch(NameNotFoundException e) { - LogLog.error("Could not find name ["+name+"]."); - throw e; - } - } - - protected - boolean checkEntryConditions() { - String fail = null; - - if(this.topicConnection == null) { - fail = "No TopicConnection"; - } else if(this.topicSession == null) { - fail = "No TopicSession"; - } else if(this.topicPublisher == null) { - fail = "No TopicPublisher"; - } - - if(fail != null) { - errorHandler.error(fail +" for JMSAppender named ["+name+"]."); - return false; - } else { - return true; - } - } - - /** - Close this JMSAppender. 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(topicSession != null) - topicSession.close(); - if(topicConnection != null) - topicConnection.close(); - } catch(Exception e) { - LogLog.error("Error while closing JMSAppender ["+name+"].", e); - } - // Help garbage collection - topicPublisher = null; - topicSession = null; - topicConnection = null; - } - - /** - This method called by {@link AppenderSkeleton#doAppend} method to - do most of the real appending work. */ - public - void append(LoggingEvent event) { - if(!checkEntryConditions()) { - return; - } - - try { - ObjectMessage msg = topicSession.createObjectMessage(); - if(locationInfo) { - event.getLocationInformation(); - } - msg.setObject(event); - topicPublisher.publish(msg); - } catch(Exception e) { - errorHandler.error("Could not publish message in JMSAppender ["+name+"].", e, - ErrorCode.GENERIC_FAILURE); - } - } - - /** - If true, the information sent to the remote subscriber will include - location information. By default no location information is sent - to the subscriber. */ - public - void setLocationInfo(boolean locationInfo) { - this.locationInfo = locationInfo; - } - - - public - boolean requiresLayout() { - return false; - } -} diff --git a/src/java/org/apache/log4j/net/JMSSink.java b/src/java/org/apache/log4j/net/JMSSink.java deleted file mode 100644 index 877df006e4..0000000000 --- a/src/java/org/apache/log4j/net/JMSSink.java +++ /dev/null @@ -1,106 +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.txt file. */ - -package org.apache.log4j.net; - -import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.Category; -import org.apache.log4j.LogManager; -import org.apache.log4j.spi.RendererSupport; -import org.apache.log4j.spi.LoggerRepository; -import org.apache.log4j.or.jms.MessageRenderer; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.helpers.LogLog; - -import javax.jms.*; - -import javax.naming.InitialContext; -import javax.naming.Context; -import javax.naming.NameNotFoundException; -import javax.naming.NamingException; - -/** - A simple application receiving the logging events sent by a JMSAppender. - - - @author Ceki Gülcü -*/ -public class JMSSink { - - static public void main(String[] args) { - if(args.length != 3) { - usage("Wrong number of arguments."); - } - - String tcfBindingName = args[0]; - String topicBindingName = args[1]; - PropertyConfigurator.configure(args[2]); - - LoggerRepository rep = LogManager.getLoggerRepository(); - if(rep instanceof RendererSupport) { - ((RendererSupport) rep).setRenderer(Message.class, new MessageRenderer()); - } - - try { - Context ctx = new InitialContext(); - TopicConnectionFactory topicConnectionFactory; - topicConnectionFactory = (TopicConnectionFactory) lookup(ctx, - tcfBindingName); - - TopicConnection topicConnection = - topicConnectionFactory.createTopicConnection(); - topicConnection.start(); - - TopicSession topicSession = topicConnection.createTopicSession(false, - Session.AUTO_ACKNOWLEDGE); - - Topic topic = (Topic)ctx.lookup(topicBindingName); - - //TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic); - TopicSubscriber topicSubscriber = - topicSession.createDurableSubscriber(topic, "x"); - - - LoggingEvent event; - Category remoteCategory; - - while(true) { - ObjectMessage msg = (ObjectMessage)topicSubscriber.receive(); - event = (LoggingEvent) msg.getObject(); - remoteCategory = Category.getInstance(event.categoryName); - remoteCategory.callAppenders(event); - - // dump the JMSMessage - // remoteCategory.debug(msg); - - } - } catch(Exception e) { - LogLog.error("Could not read JMS message.", e); - } - } - - - protected - static - Object lookup(Context ctx, String name) throws NamingException { - try { - return ctx.lookup(name); - } catch(NameNotFoundException e) { - LogLog.error("Could not find name ["+name+"]."); - throw e; - } - } - - - static - void usage(String msg) { - System.err.println(msg); - System.err.println("Usage: java " + JMSSink.class.getName() - + " TopicConnectionFactoryBindingName TopicBindingName configFile"); - System.exit(1); - } -} diff --git a/src/java/org/apache/log4j/net/SimpleSocketServer.java b/src/java/org/apache/log4j/net/SimpleSocketServer.java deleted file mode 100644 index f8ca382ffb..0000000000 --- a/src/java/org/apache/log4j/net/SimpleSocketServer.java +++ /dev/null @@ -1,84 +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.Socket; -import java.net.ServerSocket; - -import org.apache.log4j.Category; -import org.apache.log4j.LogManager; -import org.apache.log4j.PropertyConfigurator; - - -/** - A simple {@link SocketNode} based server. - -
    -     Usage: java org.apache.log4j.net.SimpleSocketServer port configFile
    -
    -     where port is a part number where the server listens and
    -     configFile is a configuration file fed to the {@link
    -     PropertyConfigurator}.
    -   
    - - @author Ceki Gülcü - - @since 0.8.4 */ - -public class SimpleSocketServer { - - static Category cat = Category.getInstance(SimpleSocketServer.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 SocketNode(socket, - LogManager.getLoggerRepository())).start(); - } - } - catch(Exception e) { - e.printStackTrace(); - } - } - - - static - void usage(String msg) { - System.err.println(msg); - System.err.println( - "Usage: java " +SimpleSocketServer.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); - } -} diff --git a/src/java/org/apache/log4j/net/SocketNode.java b/src/java/org/apache/log4j/net/SocketNode.java deleted file mode 100644 index 4bcbd8235d..0000000000 --- a/src/java/org/apache/log4j/net/SocketNode.java +++ /dev/null @@ -1,92 +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.txt file. - */ - -package org.apache.log4j.net; - -import java.net.Socket; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.BufferedInputStream; - - -import org.apache.log4j.*; -import org.apache.log4j.spi.*; - -// Contributors: Moses Hohman - -/** - 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. - -

    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 SocketNode implements Runnable { - - Socket socket; - LoggerRepository hierarchy; - ObjectInputStream ois; - - static Logger logger = Logger.getLogger(SocketNode.class); - - public - SocketNode(Socket socket, LoggerRepository hierarchy) { - this.socket = socket; - this.hierarchy = hierarchy; - try { - ois = new ObjectInputStream( - new BufferedInputStream(socket.getInputStream())); - } - catch(Exception e) { - logger.error("Could not open ObjectInputStream to "+socket, e); - } - } - - //public - //void finalize() { - //System.err.println("-------------------------Finalize called"); - // System.err.flush(); - //} - - public void run() { - LoggingEvent event; - Logger remoteLogger; - - try { - while(true) { - event = (LoggingEvent) ois.readObject(); - remoteLogger = hierarchy.getLogger(event.categoryName); - event.logger = remoteLogger; - if(event.level.isGreaterOrEqual(remoteLogger.getEffectiveLevel())) { - remoteLogger.callAppenders(event); - } - } - } - catch(java.io.EOFException e) { - logger.info("Caught java.io.EOFException closing conneciton."); - } catch(java.net.SocketException e) { - logger.info("Caught java.net.SocketException closing conneciton."); - } catch(IOException e) { - logger.info("Caught java.io.IOException: "+e); - logger.info("Closing connection."); - } catch(Exception e) { - logger.error("Unexpected exception. Closing conneciton.", e); - } - - try { - ois.close(); - } catch(Exception e) { - logger.info("Could not close connection.", e); - } - } -} diff --git a/src/java/org/apache/log4j/net/test/Loop.java b/src/java/org/apache/log4j/net/test/Loop.java deleted file mode 100644 index e5242f3546..0000000000 --- a/src/java/org/apache/log4j/net/test/Loop.java +++ /dev/null @@ -1,60 +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.test; - -import org.apache.log4j.*; -import org.apache.log4j.net.SocketAppender; - -public class Loop { - - public static void main(String[] args) { - - - Category root = Category.getRoot(); - Category cat = Category.getInstance(Loop.class.getName()); - - if(args.length != 2) - usage("Wrong number of arguments."); - - String host = args[0]; - int port = 0; - - try { - port = Integer.valueOf(args[1]).intValue(); - } - catch (NumberFormatException e) { - usage("Argument [" + args[1] + "] is not in proper int form."); - } - - SocketAppender sa = new SocketAppender(host, port); - Layout layout = new PatternLayout("%5p [%t] %x %c - %m\n"); - Appender so = new ConsoleAppender(layout, "System.out"); - root.addAppender(sa); - root.addAppender(so); - - int i = 0; - - while(true) { - NDC.push(""+ (i++)); - cat.debug("Debug message."); - root.info("Info message."); - NDC.pop(); - } - - } - - static - void usage(String msg) { - System.err.println(msg); - System.err.println( - "Usage: java " +Loop.class.getName() + " host port"); - System.exit(1); - } - - -} diff --git a/src/java/org/apache/log4j/net/test/SMTPMin.java b/src/java/org/apache/log4j/net/test/SMTPMin.java deleted file mode 100644 index 6777157b08..0000000000 --- a/src/java/org/apache/log4j/net/test/SMTPMin.java +++ /dev/null @@ -1,55 +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.test; - -import org.apache.log4j.*; - -public class SMTPMin { - - static Category cat = Category.getInstance(SMTPMin.class); - - public - static - void main(String argv[]) { - if(argv.length == 1) - init(argv[0]); - else - usage("Wrong number of arguments."); - - NDC.push("some context"); - test(); - } - - static - void usage(String msg) { - System.err.println(msg); - System.err.println("Usage: java " + SMTPMin.class.getName() - + " configFile"); - System.exit(1); - } - - static - void init(String configFile) { - PropertyConfigurator.configure(configFile); - } - - - static - void test() { - int i = 0; - cat.debug( "Message " + i++); - cat.debug("Message " + i++, new Exception("Just testing.")); - cat.info( "Message " + i++); - cat.warn( "Message " + i++); - cat.error( "Message " + i++); - cat.log(Priority.FATAL, "Message " + i++); - Category.shutdown(); - Thread.currentThread().getThreadGroup().list(); - } - -} diff --git a/src/java/org/apache/log4j/net/test/SocketMin.java b/src/java/org/apache/log4j/net/test/SocketMin.java deleted file mode 100644 index 15ab781eb6..0000000000 --- a/src/java/org/apache/log4j/net/test/SocketMin.java +++ /dev/null @@ -1,102 +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.test; - -import org.apache.log4j.Category; -import org.apache.log4j.BasicConfigurator; -import org.apache.log4j.net.SocketAppender; -import org.apache.log4j.Priority; -import org.apache.log4j.NDC; -import java.io.InputStreamReader; - -public class SocketMin { - - static Category cat = Category.getInstance(SyslogMin.class.getName()); - static SocketAppender s; - - public - static - void main(String argv[]) { - if(argv.length == 3) - init(argv[0], argv[1]); - else - usage("Wrong number of arguments."); - - NDC.push("some context"); - if(argv[2].equals("true")) - loop(); - else - test(); - - s.close(); - } - - static - void usage(String msg) { - System.err.println(msg); - System.err.println("Usage: java " + SocketMin.class - + " host port true|false"); - System.exit(1); - } - - static - void init(String host, String portStr) { - Category root = Category.getRoot(); - BasicConfigurator.configure(); - try { - int port = Integer.parseInt(portStr); - cat.info("Creating socket appender ("+host+","+port+")."); - s = new SocketAppender(host, port); - s.setName("S"); - root.addAppender(s); - } - catch(java.lang.NumberFormatException e) { - e.printStackTrace(); - usage("Could not interpret port number ["+ portStr +"]."); - } - catch(Exception e) { - System.err.println("Could not start!"); - e.printStackTrace(); - System.exit(1); - } - } - - static - void loop() { - Category root = Category.getRoot(); - InputStreamReader in = new InputStreamReader(System.in); - System.out.println("Type 'q' to quit"); - int i; - int k = 0; - while (true) { - cat.debug("Message " + k++); - cat.info("Message " + k++); - cat.warn("Message " + k++); - cat.error("Message " + k++, new Exception("Just testing")); - try {i = in.read(); } - catch(Exception e) { return; } - if(i == -1) break; - if(i == 'q') break; - if(i == 'r') { - System.out.println("Removing appender S"); - root.removeAppender("S"); - } - } - } - - static - void test() { - int i = 0; - cat.debug( "Message " + i++); - cat.info( "Message " + i++); - cat.warn( "Message " + i++); - cat.error( "Message " + i++); - cat.log(Priority.FATAL, "Message " + i++); - cat.debug("Message " + i++, new Exception("Just testing.")); - } -} diff --git a/src/java/org/apache/log4j/net/test/SyslogMin.java b/src/java/org/apache/log4j/net/test/SyslogMin.java deleted file mode 100644 index 3c8f039777..0000000000 --- a/src/java/org/apache/log4j/net/test/SyslogMin.java +++ /dev/null @@ -1,60 +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.test; - -import org.apache.log4j.Category; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.Priority; -import org.apache.log4j.NDC; - - -public class SyslogMin { - - static Category CAT = Category.getInstance(SyslogMin.class.getName()); - - public - static - void main(String argv[]) { - - if(argv.length == 1) { - ProgramInit(argv[0]); - } - else { - Usage("Wrong number of arguments."); - } - test("someHost"); - } - - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java " + SyslogMin.class + " configFile"); - System.exit(1); - } - - - static - void ProgramInit(String configFile) { - int port = 0; - PropertyConfigurator.configure(configFile); - } - - static - void test(String host) { - NDC.push(host); - int i = 0; - CAT.debug( "Message " + i++); - CAT.info( "Message " + i++); - CAT.warn( "Message " + i++); - CAT.error( "Message " + i++); - CAT.log(Priority.FATAL, "Message " + i++); - CAT.debug("Message " + i++, new Exception("Just testing.")); - } -} diff --git a/src/java/org/apache/log4j/net/test/intermediarySocketServer.lcf b/src/java/org/apache/log4j/net/test/intermediarySocketServer.lcf deleted file mode 100644 index af3a758de4..0000000000 --- a/src/java/org/apache/log4j/net/test/intermediarySocketServer.lcf +++ /dev/null @@ -1,23 +0,0 @@ - -# ---------------------------------------------------------------------------- -# This config file is intended to be used by an intermediary SocketServer that -# relays its log output to another SocketServer. This is used mostly to test -# SocketServer cascading. -# ---------------------------------------------------------------------------- - - -log4j.configDebug=true - -log4j.rootCategory=DEBUG, SOCKETSERV, CON - -log4j.category.org.apache.log4j.net=DEBUG -log4j.appender.SOCKETSERV=org.apache.log4j.net.SocketAppender -log4j.appender.SOCKETSERV.RemoteHost=localhost -log4j.appender.SOCKETSERV.Port=15000 -log4j.appender.SOCKETSERV.layout=org.apache.log4j.PatternLayout -log4j.appender.SOCKETSERV.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m%n - - -log4j.appender.CON=org.apache.log4j.ConsoleAppender -log4j.appender.CON.layout=org.apache.log4j.PatternLayout -log4j.appender.CON.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m%n \ No newline at end of file diff --git a/src/java/org/apache/log4j/net/test/jms.lcf b/src/java/org/apache/log4j/net/test/jms.lcf deleted file mode 100644 index a8e353594e..0000000000 --- a/src/java/org/apache/log4j/net/test/jms.lcf +++ /dev/null @@ -1,6 +0,0 @@ - -log4j.rootCategory=DEBUG, A1 -log4j.configDebug=true -log4j.appender.A1=org.apache.log4j.net.JMSAppender -log4j.appender.A1.TopicBindingName=LOGBN -log4j.appender.A1.TopicConnectionFactoryBindingName=TCFBN diff --git a/src/java/org/apache/log4j/net/test/logging.lcf b/src/java/org/apache/log4j/net/test/logging.lcf deleted file mode 100644 index e10dbc8c2c..0000000000 --- a/src/java/org/apache/log4j/net/test/logging.lcf +++ /dev/null @@ -1,9 +0,0 @@ -log4j.rootCategory= , testAppender -log4j.configDebug=true -log4j.appender.testAppender=org.apache.log4j.net.SyslogAppender -log4j.appender.testAppender.SyslogHost=localhost -log4j.appender.testAppender.Facility=LOCAL0 -log4j.appender.testAppender.FacilityPrinting= -log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout -log4j.appender.testAppender.layout.DateFormat=NULL -log4j.appender.testAppender.layout.TimeZone= diff --git a/src/java/org/apache/log4j/net/test/loop.lcf b/src/java/org/apache/log4j/net/test/loop.lcf deleted file mode 100644 index 5913848788..0000000000 --- a/src/java/org/apache/log4j/net/test/loop.lcf +++ /dev/null @@ -1,9 +0,0 @@ -log4j.rootCategory= , A1 -log4j.configDebug=true -log4j.appender.A1=org.apache.log4j.RollingFileAppender -log4j.appender.A1.Append=true -log4j.appender.A1.File=loop.log -log4j.appender.A1.MaxFileSize=100KB -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%p [%t] - %m\n - diff --git a/src/java/org/apache/log4j/net/test/socketClient.lcf b/src/java/org/apache/log4j/net/test/socketClient.lcf deleted file mode 100644 index 66cc5aaa78..0000000000 --- a/src/java/org/apache/log4j/net/test/socketClient.lcf +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------------------------------------------- -# This config file is intended to be used by a client wishing to log using -# a SocketAppender to a SyslogServer or equivalent. -# ------------------------------------------------------------------------- - -log4j.configDebug=true - -log4j.rootCategory=DEBUG, A1, CON - -log4j.category.org.apache.log4j.net=DEBUG -log4j.appender.A1=org.apache.log4j.net.SocketAppender -log4j.appender.A1.RemoteHost=localhost -log4j.appender.A1.Port=15000 -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m%n - - -log4j.appender.CON=org.apache.log4j.ConsoleAppender -log4j.appender.CON.layout=org.apache.log4j.PatternLayout -log4j.appender.CON.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m%n \ No newline at end of file diff --git a/src/java/org/apache/log4j/net/test/socketServer.lcf b/src/java/org/apache/log4j/net/test/socketServer.lcf deleted file mode 100644 index 574d644489..0000000000 --- a/src/java/org/apache/log4j/net/test/socketServer.lcf +++ /dev/null @@ -1,12 +0,0 @@ - -# ------------------------------------------------------------------- -# This config file is intended to be used by a SocketServer that logs -# events received from various clients on the console. -# ------------------------------------------------------------------- - -log4j.rootCategory=DEBUG, A1 -log4j.category.org.apache.log4j.net=DEBUG -log4j.appender.A1=org.apache.log4j.ConsoleAppender -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m%n - diff --git a/src/java/org/apache/log4j/net/test/syslog.lcf b/src/java/org/apache/log4j/net/test/syslog.lcf deleted file mode 100644 index 417ad6988e..0000000000 --- a/src/java/org/apache/log4j/net/test/syslog.lcf +++ /dev/null @@ -1,20 +0,0 @@ - -# ------------------------------------------------+ -# Set the host variable to match your environment | -# ------------------------------------------------+ -host=torino.qos.ch - - -log4j.rootCategory=DEBUG, A1 - -log4j.appender.A1=org.apache.log4j.net.SyslogAppender -log4j.appender.A1.SyslogHost=${host} - -log4j.appender.A1.layout=org.apache.log4j.PatternLayout - -# ----------------------------------------------------------------- -# The ConversionPattern should be terminated with a "\n" instead of -# the usual "%n" as the syslog host is most probably a unix machine. -# ----------------------------------------------------------------- -log4j.appender.A1.layout.ConversionPattern=%-5r %-5p [%t] %c{2} %x - %m\n - diff --git a/src/java/org/apache/log4j/net/test/syslogMin b/src/java/org/apache/log4j/net/test/syslogMin deleted file mode 100644 index ee0cea0ec9..0000000000 --- a/src/java/org/apache/log4j/net/test/syslogMin +++ /dev/null @@ -1,21 +0,0 @@ - - - -# Read the .functions file -. ../../test/.functions - -declare -i start=$1 - -setPERL - - echo "log4j.rootCategory= , testAppender" > $LCF - lecho "log4j.configDebug=true" - lecho "log4j.appender.testAppender=org.apache.log4j.net.SyslogAppender" - lecho "log4j.appender.testAppender.SyslogHost=localhost" - lecho "log4j.appender.testAppender.Facility=LOCAL0" - lecho "log4j.appender.testAppender.FacilityPrinting=" - lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout" - lecho "log4j.appender.testAppender.layout.DateFormat=NULL" - lecho "log4j.appender.testAppender.layout.TimeZone=" - - java org.apache.log4j.net.test.SyslogMin $LCF diff --git a/src/java/org/apache/log4j/nt/EventLogCategories.mc b/src/java/org/apache/log4j/nt/EventLogCategories.mc deleted file mode 100644 index c896f54471..0000000000 --- a/src/java/org/apache/log4j/nt/EventLogCategories.mc +++ /dev/null @@ -1,24 +0,0 @@ -MessageId=0xC350 -Language=English -Fatal -. -MessageId=0x9C40 -Language=English -Error -. -MessageId=0x7530 -Language=English -Warn -. -MessageId=0x4E20 -Language=English -Info -. -MessageId=0x2710 -Language=English -Debug -. -MessageId=0x1000 -Language=English -%1 -. diff --git a/src/java/org/apache/log4j/nt/make.bat b/src/java/org/apache/log4j/nt/make.bat deleted file mode 100755 index ce73dd6d0d..0000000000 --- a/src/java/org/apache/log4j/nt/make.bat +++ /dev/null @@ -1,22 +0,0 @@ -@echo off - -REM This batch file is not intended for general use. - -javah org.apache.log4j.nt.NTEventLogAppender -javah org.apache.log4j.Priority - -MC EventLogCategories.mc - -RC -r -fo EventLogCategories.res EventLogCategories.rc - -SET JDK=c:\java\jdk1.1.7B\ -rem SET JDK=c:\java\jdk1.3\ - -@echo "Compiling" -CL /nologo /I %JDK%\include /I %JDK%\include\win32 /MD /W3 /GX /O2 /FD /c /D "NDEBUG" -DWINVER=0x400 -D_DLL -DWIN32 /D "_WINDOWS" nteventlog.cpp - -REM - -@echo -@echo "Linking" -LINK /subsystem:windows /INCREMENTAL:NO /dll /out:"NTEventLogAppender.dll" nteventlog.OBJ advapi32.lib EventLogCategories.res diff --git a/src/java/org/apache/log4j/nt/nteventlog.cpp b/src/java/org/apache/log4j/nt/nteventlog.cpp deleted file mode 100644 index ba8453c161..0000000000 --- a/src/java/org/apache/log4j/nt/nteventlog.cpp +++ /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.txt file. - */ - -#ifndef NtEventLogAppender_h -#define NtEventLogAppender_h -#include "org_apache_log4j_Priority.h" -#include "org_apache_log4j_nt_NTEventLogAppender.h" -#include - -// Borrowed unabashedly from the JNI Programmer's Guide -void JNU_ThrowByName(JNIEnv *env, const char *name, const char *msg) { - - jclass classForName = env->FindClass(name); - // If cls is null, an exception has already been thrown. - if (classForName != (jclass)0) { - env->ThrowNew(classForName, msg); - } - // cleanup - env->DeleteLocalRef(classForName); - return; -} - -// Borrowed unabashedly from the JNI Programmer's Guide -char *JNU_GetStringNativeChars(JNIEnv *env, jstring jstr) { - static jmethodID midStringGetBytes = 0; - jbyteArray bytes = 0; - jthrowable exc; - char *nstr = 0; - - //if (env->EnsureLocalCapacity(2) < 0) { - // out of memory - //return 0; - //} - - if (midStringGetBytes == 0) { - // Lookup and cache the String.getBytes() method id. - jclass stringClass = env->FindClass("java/lang/String"); - if (stringClass == 0) { - // An exception will have been thrown. - return 0; - } - midStringGetBytes = env->GetMethodID(stringClass, "getBytes", "()[B"); - env->DeleteLocalRef(stringClass); - if (midStringGetBytes == 0) { - // An exception will have been thrown. - return 0; - } - } - - bytes = (jbyteArray)env->CallObjectMethod(jstr, midStringGetBytes); - exc = env->ExceptionOccurred(); - if (exc == 0) { - // Attempt to malloc enough room for the length of the Java - // string plus one byte for the 0-terminator. - jint len = env->GetArrayLength(bytes); - nstr = (char *)malloc(len + 1); - if (nstr == 0) { - // malloc failed -- throw an OutOfMemoryError - JNU_ThrowByName(env, "java/lang/OutOfMemoryError", 0); - env->DeleteLocalRef(bytes); - return 0; - } - // copy to the malloc'd array and 0-terminate - env->GetByteArrayRegion(bytes, 0, len, (jbyte *)nstr); - nstr[len] = 0; - } else { - // cleanup - env->DeleteLocalRef(exc); - } - // cleanup - env->DeleteLocalRef(bytes); - return nstr; -} - -/* - * Convert log4j Priority to an EventLog category. Each category is - * backed by a message resource so that proper category names will - * be displayed in the NT Event Viewer. - */ -WORD getCategory(jint priority) { - // Priority values map directly to EventLog category values - return (WORD)(priority + 1); -} - -/* - * Convert log4j Priority to an EventLog type. The log4j package - * supports 8 defined priorites, but the NT EventLog only knows - * 3 event types of interest to us: ERROR, WARNING, and INFO. - */ -WORD getType(jint priority) { - WORD ret_val; - - switch (priority) { - case org_apache_log4j_Priority_FATAL_INT: - case org_apache_log4j_Priority_ERROR_INT: - ret_val = EVENTLOG_ERROR_TYPE; - break; - case org_apache_log4j_Priority_WARN_INT: - ret_val = EVENTLOG_WARNING_TYPE; - break; - case org_apache_log4j_Priority_INFO_INT: - case org_apache_log4j_Priority_DEBUG_INT: - default: - ret_val = EVENTLOG_INFORMATION_TYPE; - break; - } - return ret_val; -} - -HKEY regGetKey(TCHAR *subkey, DWORD *disposition) { - HKEY hkey = 0; - RegCreateKeyEx(HKEY_LOCAL_MACHINE, subkey, 0, NULL, - REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, - &hkey, disposition); - return hkey; -} - -void regSetString(HKEY hkey, TCHAR *name, TCHAR *value) { - RegSetValueEx(hkey, name, 0, REG_SZ, (LPBYTE)value, lstrlen(value)); -} - -void regSetDword(HKEY hkey, TCHAR *name, DWORD value) { - RegSetValueEx(hkey, name, 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD)); -} - -/* - * Add this source with appropriate configuration keys to the registry. - */ -void addRegistryInfo(char *source) { - const TCHAR *prefix = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\"; - DWORD disposition; - HKEY hkey = 0; - TCHAR subkey[256]; - - lstrcpy(subkey, prefix); - lstrcat(subkey, source); - hkey = regGetKey(subkey, &disposition); - if (disposition == REG_CREATED_NEW_KEY) { - regSetString(hkey, "EventMessageFile", "NTEventLogAppender.dll"); - regSetString(hkey, "CategoryMessageFile", "NTEventLogAppender.dll"); - regSetDword(hkey, "TypesSupported", (DWORD)7); - regSetDword(hkey, "CategoryCount", (DWORD)8); - } - //RegSetValueEx(hkey, "EventMessageFile", 0, REG_SZ, (LPBYTE)dllname, lstrlen(dllname)); - //RegSetValueEx(hkey, "CategoryMessageFile", 0, REG_SZ, (LPBYTE)dllname, lstrlen(dllname)); - //RegSetValueEx(hkey, "TypesSupported", 0, REG_DWORD, (LPBYTE)&whichTypes, sizeof(DWORD)); - //RegSetValueEx(hkey, "CategoryCount", 0, REG_DWORD, (LPBYTE)&numCategories, sizeof(DWORD)); - RegCloseKey(hkey); - return; -} - -/* - * Class: org.apache.log4j.nt.NTEventLogAppender - * Method: registerEventSource - * Signature: (Ljava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_apache_log4j_nt_NTEventLogAppender_registerEventSource( - JNIEnv *env, jobject java_this, jstring server, jstring source) { - - char *nserver = 0; - char *nsource = 0; - - if (server != 0) { - nserver = JNU_GetStringNativeChars(env, server); - } - if (source != 0) { - nsource = JNU_GetStringNativeChars(env, source); - } - addRegistryInfo(nsource); - jint handle = (jint)RegisterEventSource(nserver, nsource); - free((void *)nserver); - free((void *)nsource); - return handle; -} - -/* - * Class: org_apache_log4j_nt_NTEventLogAppender - * Method: reportEvent - * Signature: (ILjava/lang/String;I)V - */ -JNIEXPORT void JNICALL Java_org_apache_log4j_nt_NTEventLogAppender_reportEvent( - JNIEnv *env, jobject java_this, jint handle, jstring jstr, jint priority) { - - jboolean localHandle = JNI_FALSE; - if (handle == 0) { - // Client didn't give us a handle so make a local one. - handle = (jint)RegisterEventSource(NULL, "Log4j"); - localHandle = JNI_TRUE; - } - - // convert Java String to character array - const int numStrings = 1; - LPCTSTR array[numStrings]; - char *nstr = JNU_GetStringNativeChars(env, jstr); - array[0] = nstr; - - // This is the only message supported by the package. It is backed by - // a message resource which consists of just '%1' which is replaced - // by the string we just created. - const DWORD messageID = 0x1000; - ReportEvent((HANDLE)handle, getType(priority), - getCategory(priority), - messageID, NULL, 1, 0, array, NULL); - - free((void *)nstr); - if (localHandle == JNI_TRUE) { - // Created the handle here so free it here too. - DeregisterEventSource((HANDLE)handle); - } - return; -} - -/* - * Class: org_apache_log4j_nt_NTEventLogAppender - * Method: deregisterEventSource - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_org_apache_log4j_nt_NTEventLogAppender_deregisterEventSource( -JNIEnv *env, -jobject java_this, -jint handle) -{ - DeregisterEventSource((HANDLE)handle); -} - - -#endif diff --git a/src/java/org/apache/log4j/nt/test/NTMin.java b/src/java/org/apache/log4j/nt/test/NTMin.java deleted file mode 100644 index 52351c12ea..0000000000 --- a/src/java/org/apache/log4j/nt/test/NTMin.java +++ /dev/null @@ -1,61 +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.nt.test; - - -import org.apache.log4j.Category; -import org.apache.log4j.BasicConfigurator; -import org.apache.log4j.nt.NTEventLogAppender; -import org.apache.log4j.Priority; -import org.apache.log4j.NDC; - - -public class NTMin { - - static Category cat = Category.getInstance(NTMin.class.getName()); - - public - static - void main(String argv[]) { - - //if(argv.length == 1) { - init(); - //} - //else { - //Usage("Wrong number of arguments."); - //} - test("someHost"); - } - - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java " + NTMin.class + ""); - System.exit(1); - } - - - static - void init() { - - BasicConfigurator.configure(new NTEventLogAppender()); - } - - static - void test(String host) { - NDC.push(host); - int i = 0; - cat.debug( "Message " + i++); - cat.info( "Message " + i++); - cat.warn( "Message " + i++); - cat.error( "Message " + i++); - cat.log(Priority.FATAL, "Message " + i++); - cat.debug("Message " + i++, new Exception("Just testing.")); - } -} diff --git a/src/java/org/apache/log4j/or/DefaultRenderer.java b/src/java/org/apache/log4j/or/DefaultRenderer.java deleted file mode 100644 index d4066c94e1..0000000000 --- a/src/java/org/apache/log4j/or/DefaultRenderer.java +++ /dev/null @@ -1,28 +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.or; - -/** - The default Renderer renders objects by calling their - toString method. - - @author Ceki Gülcü - @since 1.0 */ -class DefaultRenderer implements ObjectRenderer { - - DefaultRenderer() { - } - - /** - Render the object passed as parameter by calling its - toString method. */ - public - String doRender(Object o) { - return o.toString(); - } -} diff --git a/src/java/org/apache/log4j/or/ObjectRenderer.java b/src/java/org/apache/log4j/or/ObjectRenderer.java deleted file mode 100644 index 5d98d69ce4..0000000000 --- a/src/java/org/apache/log4j/or/ObjectRenderer.java +++ /dev/null @@ -1,22 +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.or; - -/** - Implement this interface in order to render objects as strings. - - @author Ceki Gülcü - @since 1.0 */ -public interface ObjectRenderer { - - /** - Render the object passed as parameter as a String. - */ - public - String doRender(Object o); -} diff --git a/src/java/org/apache/log4j/performance/ConcatVsArray.java b/src/java/org/apache/log4j/performance/ConcatVsArray.java deleted file mode 100644 index a3f6aca97f..0000000000 --- a/src/java/org/apache/log4j/performance/ConcatVsArray.java +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 1996-1999, International Business Machines -// Corporation. All Rights Reserved. - -package org.apache.log4j.performance; - -import java.util.Date; - -/** - Measure difference in performance of string concatenation versus - creating an anonymous string array. - -

    You should be able to see that anonymous string array - construction is significatnly faster than string concatenation. The - difference increases proportionally with the length of the strings - to be concatanated. - - @author Ceki Gülcü - */ -public class ConcatVsArray { - - - static - void Usage() { - System.err.println("Usage: java org.apache.log4j.performance.ConcatVsArray " + - "string1 string2 runLength\n" + - " where runLength is an integer."); - System.exit(1); - } - - public static void main(String args[]) { - - if(args.length != 3) { - Usage(); - } - - String s1 = args[0]; - String s2 = args[1]; - int runLength = 0; - try { - runLength = Integer.parseInt(args[2]); - } - catch(java.lang.NumberFormatException e) { - System.err.println(e); - Usage(); - } - - double micros; - - String[] sa; - long before = new Date().getTime(); - for(int i = 0; i < runLength; i++) { - sa = new String[]{s1, s2}; - } - micros = (new Date().getTime() - before)*1000.0/runLength; - System.out.println("The anonymous array loop took around " + micros + " microseconds."); - - String s; - before = new Date().getTime(); - for(int i = 0; i < runLength; i++) { - s = s1 + s2; - } - micros = (new Date().getTime() - before)*1000.0/runLength; - System.out.println("The append loop took around " + micros + " microseconds."); - - } -} diff --git a/src/java/org/apache/log4j/performance/Logging.java b/src/java/org/apache/log4j/performance/Logging.java deleted file mode 100644 index 8bf504daee..0000000000 --- a/src/java/org/apache/log4j/performance/Logging.java +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright 1996-1999, International Business Machines -// Corporation. All Rights Reserved. - -// Copyright 2000, Ceki Gulcu. All Rights Reserved. - -// See the LICENCE file for the terms of distribution. - -package org.apache.log4j.performance; - -import org.apache.log4j.Category; -import org.apache.log4j.xml.DOMConfigurator; - -import org.apache.log4j.NDC; -import org.apache.log4j.performance.NOPWriter; - - -/** - Measure the performance of logging. - -

    Experimental results are listed below in units of - micro-seconds. Measurements were done on a AMD Duron clocked - at 800Mhz running Windows 2000 and Sun's 1.3 JDK. - -

    - - - - - - - - - - - - - - - -
    Layout -NullAppender -FileAppender -FileAppender (no flush) -AsyncAppender (no flush) - -
    SimpleLayout -4 -21 -16 -33 - -
    PatternLayout "%p - %m%n" -4 -21 -16 -32 - -
    PatternLayout "%-5p - %m%n" -4 -NA -NA -NA - -
    TTCCLayout/RELATIVE -10 -37 -31 -45 - -
    PatternLayout "%r [%t] %-5p %c{2} %x - %m%n" -11 -NA -NA -NA - -
    PatternLayout "%r [%t] %-5p %.10c %x - %m%n" -11 -NA -NA -NA - -
    PatternLayout "%r [%t] %-5p %.20c %x - %m%n" -11 -NA -NA -NA - -
    PatternLayout "%r [%t] %-5p %c - %m%n" -9 -36 -29 -45 - -
    TTCCLayout/ISO8601 -25 -58 -51 -71 - -
    PatternLayout "%d{ISO8601} [%t] %-5p %c %x - %m%n" -28 -62 -55 -76 - -
    PatternLayout "%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n" -46 -82 -72 -94 - -
    PatternLayout "%l - %m%n" - 241 - 317 - 299 - 251 - -
    PatternLayout "%C.%M.%L - %m%n" -267 -NA -NA -NA - -
    - -

    The results of the measurements (should) show that: - -

      - -
    1. The PatternLayout perforance is very close to the performance of - a dedicated layout of equivalent format. - -

    2. Format specifiers in conversion patterns have almost no impact - on performance. - -

    3. Formating time and date information is costly. Using relative - time has the least impact on performance. It is recommended that to - use log4j specific date formatters such as the {@link - org.apache.log4j.helpers.ISO8601DateFormat} instead of the standard {@link - java.text.SimpleDateFormat} because of its poor performance. See - the %d conversion character in {@link - org.apache.log4j.PatternLayout}. - -

    4. Avoiding the flush operation at the end of each append - results in a performance gain of 10 to 20 percent. However, there - is safety tradeoff invloved in skipping flushing. Indeed, when - flushing is skipped, then it is likely that the last few log events - will not be recorded on disk when the application exits. This is a - high price to pay even for a 20% performance gain. - -

    5. The AsyncAppender does not automatically - increase performance. On the contrary, it significantly degrades - performance. The performance tests done here very quickly fill up - the bounded buffer of the AsyncAppender and there is - cosiderable overhead in managing this bounded buffer. - -

      On the other hand, had we interleaved logging operations with - long blocking and non CPU-intensive operations, such as I/O, - network access, sleeping threads, then the - AsyncAppender would have tremendously reduced the cost - of logging in terms of overall application runtime. - -

      In a variant of this test, we have inserted a short sleep - operation between every 10 log operations. When the total slept - time is substracted, logging with the AsyncLogger - takes no time at all. In other words, logging is done for "free". - -

    6. Extracting location information is comparatively slow. It - implies at least a ten fold increase in logging time! It should be - avoided unless performace is not a concern. It has been reported - from a trusted source that logging with location information on AIX - machines will kill your application's performance. - -
    - - @author Ceki Gülcü - - */ -public class Logging { - - static int runLength; - static int delay = -1; - /** - A delay is applied after every burstLen log - requests. The default value of this constant is 100. */ - static int burstLen = 100; - static int DELAY_MULT = 1000/burstLen; - - static Category cat = Category.getInstance("A0123456789.B0123456789.C0123456789"); - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println( - "Usage: java "+Logging.class.getName()+" confFile runLength [delay] [burstLen]\n"+ - " confFile is an XML configuration file and\n"+ - " runLength (integer) is the length of test loop.\n"+ - " delay is the time in millisecs to wait every bustLen log requests."); - System.exit(1); - } - - /** - Usage: java org.apache.log4j.performance.Logging confFile runLength [delay] [burstLen] - -

    confFile is an XML configuration file and - runLength (integer) is the length of test loop, - delay is the time in millisecs to sleep every - bustLen log requests. - -

    This application just prints the average time it took to log. - - - */ - public static void main(String argv[]) { - - if(argv.length == 2) - init(argv[0], argv[1], null, null); - else if( argv.length == 4) - init(argv[0], argv[1], argv[2], argv[3]); - else - Usage("Wrong number of arguments."); - - - NDC.push("some context"); - - double delta; - String msg = "ABCDEGHIJKLMNOPQRSTUVWXYZabcdeghijklmnopqrstuvwxyz1234567890"; - if(delay <= 0) - delta = NoDelayLoop(cat, msg); - else - delta = DelayedLoop(cat, msg); - - System.out.print((int)delta); - - Category.shutdown(); - - } - - /** - Program wide initialization method. - */ - static - void init(String configFile, String runLengthStr, String delayStr, - String burstLenStr) { - try { - runLength = Integer.parseInt(runLengthStr); - if(delayStr != null) { - delay = Integer.parseInt(delayStr); - } - if(delayStr != null) { - burstLen = Integer.parseInt(burstLenStr); - DELAY_MULT = 1000/burstLen; - } - } - catch(java.lang.NumberFormatException e) { - e.printStackTrace(); - } - DOMConfigurator.configure(configFile); - } - - static - double NoDelayLoop(Category category, String msg) { - long before = System.currentTimeMillis(); - for(int i = 0; i < runLength; i++) { - category.info(msg); - } - return ((System.currentTimeMillis() - before)*1000.0)/runLength; - } - - static - double DelayedLoop(Category category, String msg) { - long before = System.currentTimeMillis(); - int j = 0; - Thread currentThread = Thread.currentThread(); - for(int i = 0; i < runLength; i++) { - category.info(msg); - if(j++ == burstLen) { - j = 0; - try{currentThread.sleep(delay);}catch(Exception e){} - } - - } - double actualTime = ((System.currentTimeMillis()-before)*1000.0/runLength); - System.out.println("actual time: "+actualTime); - return (actualTime - delay*DELAY_MULT); - } -} diff --git a/src/java/org/apache/log4j/performance/NOPWriter.java b/src/java/org/apache/log4j/performance/NOPWriter.java deleted file mode 100644 index 9662360c38..0000000000 --- a/src/java/org/apache/log4j/performance/NOPWriter.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 1996-1999, International Business Machines -// Corporation. All Rights Reserved. - -package org.apache.log4j.performance; - -import java.io.Writer; -import java.io.IOException; - -/** - Extends {@link Writer} with methods that return immediately without - doing anything. This class is used to measure the cost of - constructing a log message but not actually writing to the - OutputStream. - - @author Ceki Gülcü -*/ -public class NOPWriter extends Writer { - - //public - //NOPWriter() { - //} - - - public - void write(char[] cbuf) throws IOException {} - - public - void write(char[] cbuf, int off, int len) throws IOException {} - - - public - void write(int b) throws IOException {} - - public - void write(String s) throws IOException {} - - public - void write(String s, int off, int len) throws IOException {} - - public - void flush() throws IOException { - } - - public - void close() throws IOException { - System.err.println("Close called."); - } -} diff --git a/src/java/org/apache/log4j/performance/NotLogging.java b/src/java/org/apache/log4j/performance/NotLogging.java deleted file mode 100644 index 783655a022..0000000000 --- a/src/java/org/apache/log4j/performance/NotLogging.java +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright 1996-2000, International Business Machines -// Corporation. All Rights Reserved. - -package org.apache.log4j.performance; - - -import org.apache.log4j.Category; -import org.apache.log4j.SimpleLayout; -import org.apache.log4j.ConsoleAppender; - -import org.apache.log4j.Level; - -/** - Measure the performance of evaluating whether to log or not to log, - but not actually logging. - -

    This program takes two arguments, a string which should be - "true" for testing shipped code performance and "false" for testing - debug-enabled performance the second argument is the run length of - the measurement loops. - -

    The results of the measurement (should) show that - -

      - -

      -

    • Category evaluation is independent of the length of the category name. - -

      -

    • As expected, using the {@link Category#isDebugEnabled - isDebugEnabled} and {@link Category#isInfoEnabled isInfoEnabled} - methods eliminates the overhead of message argument construction. - -

    • Message argument construction can be an important slowing - factor while evaluating whether to log or not. - -
    - - @author Ceki Gülcü - -*/ -public class NotLogging { - - static int runLength; - - final static int INITIAL_HASH_SIZE = 101; - - static String SHORT_MSG = "Hello World"; - - static Category SHORT_CAT = Category.getInstance("A0123456789"); - static Category MEDIUM_CAT= Category.getInstance("A0123456789.B0123456789"); - static Category LONG_CAT = - Category.getInstance("A0123456789.B0123456789.C0123456789"); - - static Category INEXISTENT_SHORT_CAT = Category.getInstance("I0123456789"); - static Category INEXISTENT_MEDIUM_CAT= - Category.getInstance("I0123456789.B0123456789"); - static Category INEXISTENT_LONG_CAT= - Category.getInstance("I0123456789.B0123456789.C0123456789"); - - - static Category[] CAT_ARRAY = new Category[] {SHORT_CAT, MEDIUM_CAT, - LONG_CAT, INEXISTENT_SHORT_CAT, - INEXISTENT_MEDIUM_CAT, - INEXISTENT_LONG_CAT}; - - static - void Usage() { - System.err.println( - "Usage: java org.apache.log4j.test.NotLogging true|false runLength\n" + - "true indicates shipped code, false indicates code in development" + - " where runLength is an int representing the run length of loops\n"+ - "We suggest that runLength be at least 100'000."); - System.exit(1); - } - - public static void main(String argv[]) { - - if(argv.length != 2) { - Usage(); - } - ProgramInit(argv); - double delta; - - - System.out.println(); - for(int i = 0; i < CAT_ARRAY.length; i++) { - delta = SimpleMessage(CAT_ARRAY[i], SHORT_MSG, runLength); - System.out.println("Simple argument, " + delta - + " micros. Cat: " + CAT_ARRAY[i].getName()); - } - - System.out.println(); - for(int i = 0; i < CAT_ARRAY.length; i++) { - delta = FullyOptimizedComplexMessage(CAT_ARRAY[i], runLength); - System.out.println("Fully optimized complex, " + delta + - " micros. Cat: " + CAT_ARRAY[i].getName()); - } - - System.out.println(); - for(int i = 0; i < CAT_ARRAY.length; i++) { - delta = ComplexMessage(CAT_ARRAY[i], runLength); - System.out.println("Complex message argument, " + delta + - " micros. Cat: " + CAT_ARRAY[i].getName()); - } - - } - - /** - Program wide initialization method. */ - static - void ProgramInit(String[] args) { - - try { - runLength = Integer.parseInt(args[1]); - } - catch(java.lang.NumberFormatException e) { - System.err.println(e); - Usage(); - } - - - ConsoleAppender appender = new ConsoleAppender(new SimpleLayout()); - - if("false".equals(args[0])) { - // nothing to do - } else if ("true".equals(args[0])) { - System.out.println("Flagging as shipped code."); - Category.getDefaultHierarchy().setThreshold((Level) Level.WARN); - } else - Usage(); - - SHORT_CAT.setLevel((Level) Level.INFO); - Category.getRoot().setLevel((Level) Level.INFO); - - } - - - static - double SimpleMessage(Category category, String msg, long runLength) { - long before = System.currentTimeMillis(); - for(int i = 0; i < runLength; i++) { - category.debug(msg); - } - return (System.currentTimeMillis() - before)*1000.0/runLength; - } - - static - double FullyOptimizedComplexMessage(Category category, long runLength) { - long before = System.currentTimeMillis(); - for(int i = 0; i < runLength; i++) { - if(category.isDebugEnabled()) - category.debug("Message" + i + - " bottles of beer standing on the wall."); - } - return (System.currentTimeMillis() - before)*1000.0/runLength; - } - - static - double ComplexMessage(Category category, long runLength) { - long before = System.currentTimeMillis(); - for(int i = 0; i < runLength; i++) { - category.debug("Message" + i + - " bottles of beer standing on the wall."); - } - return (System.currentTimeMillis() - before)*1000.0/runLength; - } -} diff --git a/src/java/org/apache/log4j/performance/NullAppender.java b/src/java/org/apache/log4j/performance/NullAppender.java deleted file mode 100644 index e7ce56eb77..0000000000 --- a/src/java/org/apache/log4j/performance/NullAppender.java +++ /dev/null @@ -1,53 +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.performance; - -import org.apache.log4j.Layout; -import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.AppenderSkeleton; - -/** - A bogus appender which calls the format method of its layout object - but does not write the result anywhere. - */ -public class NullAppender extends AppenderSkeleton { - - public static String s; - public String t; - - public - NullAppender() {} - - public - NullAppender(Layout layout) { - this.layout = layout; - } - - public - void close() {} - - public - void doAppend(LoggingEvent event) { - if(layout != null) { - t = layout.format(event); - s = t; - } - } - - public - void append(LoggingEvent event) { - } - - /** - This is a bogus appender but it still uses a layout. - */ - public - boolean requiresLayout() { - return true; - } -} diff --git a/src/java/org/apache/log4j/performance/package.html b/src/java/org/apache/log4j/performance/package.html deleted file mode 100644 index 91f326a97c..0000000000 --- a/src/java/org/apache/log4j/performance/package.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - -

    Package to measure the performance of the different log4j components. - - -


    -
    - -Last modified: Thu Dec 16 10:32:43 MET 1999 - - diff --git a/src/java/org/apache/log4j/performance/xml/logging201.xml b/src/java/org/apache/log4j/performance/xml/logging201.xml deleted file mode 100644 index d1c21e2d06..0000000000 --- a/src/java/org/apache/log4j/performance/xml/logging201.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/performance/xml/logging202.xml b/src/java/org/apache/log4j/performance/xml/logging202.xml deleted file mode 100644 index 5850075db9..0000000000 --- a/src/java/org/apache/log4j/performance/xml/logging202.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/performance/xml/logging203.xml b/src/java/org/apache/log4j/performance/xml/logging203.xml deleted file mode 100644 index 7d2d70464f..0000000000 --- a/src/java/org/apache/log4j/performance/xml/logging203.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/performance/xml/logging204.xml b/src/java/org/apache/log4j/performance/xml/logging204.xml deleted file mode 100644 index 05210f3d5f..0000000000 --- a/src/java/org/apache/log4j/performance/xml/logging204.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/performance/xml/logging205.xml b/src/java/org/apache/log4j/performance/xml/logging205.xml deleted file mode 100644 index f9d0ad34f7..0000000000 --- a/src/java/org/apache/log4j/performance/xml/logging205.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/performance/xml/logging206.xml b/src/java/org/apache/log4j/performance/xml/logging206.xml deleted file mode 100644 index a695214b54..0000000000 --- a/src/java/org/apache/log4j/performance/xml/logging206.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/performance/xml/logging207.xml b/src/java/org/apache/log4j/performance/xml/logging207.xml deleted file mode 100644 index a4098a9390..0000000000 --- a/src/java/org/apache/log4j/performance/xml/logging207.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/spi/Configurator.java b/src/java/org/apache/log4j/spi/Configurator.java deleted file mode 100644 index 7b7c7abcc8..0000000000 --- a/src/java/org/apache/log4j/spi/Configurator.java +++ /dev/null @@ -1,51 +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.txt file. */ - -package org.apache.log4j.spi; - -import org.apache.log4j.spi.LoggerRepository; -import java.net.URL; - -/** - Implemented by classes capable of configuring log4j using a URL. - - @since 1.0 - @author Anders Kristensen - */ -public interface Configurator { - - /** -

    ENABLE_KEY is the name of the constant - holding the string value log4j.enable. - -

    Setting the system property log4j.disable to DEBUG, - INFO, WARN, ERROR or FATAL is equivalent to calling the {@link - Hierarchy#disable} method with the corresponding level. - - @since 1.2 */ - // public static final String ENABLE_KEY = "log4j.enable"; - - - /** - Special level value signifying inherited behaviour. The - current value of this string constant is inherited. - */ - public static final String INHERITED = "inherited"; - - - - /** - Interpret a resource pointed by a URL and set up log4j accordingly. - - The configuration is done relative to the hierarchy - parameter. - - @param url The URL to parse - @param hierarchy The hierarchy to operation upon. - */ - void doConfigure(URL url, LoggerRepository repository); -} diff --git a/src/java/org/apache/log4j/spi/DefaultRepositorySelector.java b/src/java/org/apache/log4j/spi/DefaultRepositorySelector.java deleted file mode 100644 index d3550148e5..0000000000 --- a/src/java/org/apache/log4j/spi/DefaultRepositorySelector.java +++ /dev/null @@ -1,21 +0,0 @@ - - - -package org.apache.log4j.spi; - - -public class DefaultRepositorySelector implements RepositorySelector { - - final LoggerRepository repository; - - public - DefaultRepositorySelector(LoggerRepository repository) { - this.repository = repository; - } - - public - LoggerRepository getLoggerRepository() { - return repository; - } -} - diff --git a/src/java/org/apache/log4j/spi/ErrorCode.java b/src/java/org/apache/log4j/spi/ErrorCode.java deleted file mode 100644 index d56cdf99c1..0000000000 --- a/src/java/org/apache/log4j/spi/ErrorCode.java +++ /dev/null @@ -1,26 +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.txt file. */ - -package org.apache.log4j.spi; - - -/** - This interface defines commonly encoutered error codes. - - @author Ceki Gülcü - @since 0.9.0 - */ -public interface ErrorCode { - - public final int GENERIC_FAILURE = 0; - public final int WRITE_FAILURE = 1; - public final int FLUSH_FAILURE = 2; - public final int CLOSE_FAILURE = 3; - public final int FILE_OPEN_FAILURE = 4; - public final int MISSING_LAYOUT = 5; - public final int ADDRESS_PARSE_FAILURE = 6; -} diff --git a/src/java/org/apache/log4j/spi/HierarchyEventListener.java b/src/java/org/apache/log4j/spi/HierarchyEventListener.java deleted file mode 100644 index 2837d1e1f0..0000000000 --- a/src/java/org/apache/log4j/spi/HierarchyEventListener.java +++ /dev/null @@ -1,34 +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.txt file. */ - -package org.apache.log4j.spi; - -import org.apache.log4j.*; - -/** - Listen to events occuring within a {@link - org.apache.log4j.Hierarchy Hierarchy}. - - @author Ceki Gülcü - @since 1.2 - - */ -public interface HierarchyEventListener { - - - //public - //void categoryCreationEvent(Category cat); - - - public - void addAppenderEvent(Category cat, Appender appender); - - public - void removeAppenderEvent(Category cat, Appender appender); - - -} diff --git a/src/java/org/apache/log4j/spi/LoggerFactory.java b/src/java/org/apache/log4j/spi/LoggerFactory.java deleted file mode 100644 index 423deafc73..0000000000 --- a/src/java/org/apache/log4j/spi/LoggerFactory.java +++ /dev/null @@ -1,28 +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.txt file. */ - -package org.apache.log4j.spi; - -import org.apache.log4j.Logger; - -/** - - Implement this interface to create new instances of Logger or - a sub-class of Logger. - -

    See examples/subclass/MyLogger.java for an example. - - @author Ceki Gülcü - @since version 0.8.5 - - */ -public interface LoggerFactory { - - public - Logger makeNewLoggerInstance(String name); - -} diff --git a/src/java/org/apache/log4j/spi/RendererSupport.java b/src/java/org/apache/log4j/spi/RendererSupport.java deleted file mode 100644 index 6aef97300d..0000000000 --- a/src/java/org/apache/log4j/spi/RendererSupport.java +++ /dev/null @@ -1,18 +0,0 @@ - - -package org.apache.log4j.spi; - -import org.apache.log4j.*; -import org.apache.log4j.or.RendererMap; -import org.apache.log4j.or.ObjectRenderer; - - -public interface RendererSupport { - - public - RendererMap getRendererMap(); - - public - void setRenderer(Class renderedClass, ObjectRenderer renderer); - -} diff --git a/src/java/org/apache/log4j/spi/ThrowableInformation.java b/src/java/org/apache/log4j/spi/ThrowableInformation.java deleted file mode 100644 index 06d13c18e6..0000000000 --- a/src/java/org/apache/log4j/spi/ThrowableInformation.java +++ /dev/null @@ -1,124 +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.txt file. */ - -package org.apache.log4j.spi; - -import java.io.Writer; -import java.io.PrintWriter; -import java.util.Vector; - -/** - - - - */ -public class ThrowableInformation implements java.io.Serializable { - - static final long serialVersionUID = -4748765566864322735L; - - private transient Throwable throwable; - private String[] rep; - - public - ThrowableInformation(Throwable throwable) { - this.throwable = throwable; - } - - public - Throwable getThrowable() { - return throwable; - } - - public - String[] getThrowableStrRep() { - if(rep != null) { - return (String[]) rep.clone(); - } else { - VectorWriter vw = new VectorWriter(); - throwable.printStackTrace(vw); - rep = vw.toStringArray(); - vw.clear(); - return rep; - } - } -} - -class VectorWriter extends PrintWriter { - - private Vector v; - - VectorWriter() { - super(new NullWriter()); - v = new Vector(); - } - - // Support for Orion - public - void print(Object o) { - v.addElement(o.toString()); - } - - // Support for Orion - public - void print(char[] s) { - v.addElement(new String(s)); - } - - // Support for Orion - public - void print(String s) { - v.addElement(s); - } - - public - void println(Object o) { - v.addElement(o.toString()); - } - - // JDK 1.1.x apprenly uses this form of println while in - // printStackTrace() - public - void println(char[] s) { - v.addElement(new String(s)); - } - - public - void println(String s) { - v.addElement(s); - } - - public - String[] toStringArray() { - int len = v.size(); - String[] sa = new String[len]; - for(int i = 0; i < len; i++) { - sa[i] = (String) v.elementAt(i); - } - return sa; - } - - public - void clear() { - v.setSize(0); - } -} - -class NullWriter extends Writer { - - public - void close() { - } - - public - void flush() { - } - - public - void write(char[] cbuf, int off, int len) { - } -} - diff --git a/src/java/org/apache/log4j/spi/TriggeringEventEvaluator.java b/src/java/org/apache/log4j/spi/TriggeringEventEvaluator.java deleted file mode 100644 index c6872fdb70..0000000000 --- a/src/java/org/apache/log4j/spi/TriggeringEventEvaluator.java +++ /dev/null @@ -1,30 +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.txt file. */ - -package org.apache.log4j.spi; - -/** - - Implementions of this interface allow certain appenders to decide - when to perform an appender specific action. - -

    For example the {@link org.apache.log4j.net.SMTPAppender} sends - an email when the {@link #isTriggeringEvent} method returns - true and adds the event to an internal buffer when the - returned result is false. - - @author Ceki Gülcü - @since version 1.0 - - */ -public interface TriggeringEventEvaluator { - - /** - Is this the triggering event? - */ - public boolean isTriggeringEvent(LoggingEvent event); -} diff --git a/src/java/org/apache/log4j/test/.cvsignore b/src/java/org/apache/log4j/test/.cvsignore deleted file mode 100644 index 31b2fd0f00..0000000000 --- a/src/java/org/apache/log4j/test/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -test* -current.reg* -logging.lcf -socket.lcf -temp* \ No newline at end of file diff --git a/src/java/org/apache/log4j/test/.functions b/src/java/org/apache/log4j/test/.functions deleted file mode 100644 index 38fec0f4de..0000000000 --- a/src/java/org/apache/log4j/test/.functions +++ /dev/null @@ -1,96 +0,0 @@ - -# Constants -NOPWriter=NOPWriter -LCF=logging.lcf -TEMP=temp -OUTPUT=current.reg -ROOT_PREFIX="log4j.rootCategory" -CAT_PREFIX="log4j.category" - -DEF_DEBUG=-Dlog4j.configDebug - -SHALLOW_CAT="$CAT_PREFIX.org.apache.log4j.test.Shallow" -LOG_CAT="$CAT_PREFIX.org.apache.log4j.Log" -SIMPLE="org.apache.log4j.SimpleLayout" -TTCC="org.apache.log4j.TTCCLayout" - -# +=============================================+ -# Strip the filename, retain the directory only.| -# +=============================================+ -function getShellScriptDirectory { - local dir - - dir=${0%/*} - - if [ "$dir" = "." ] - then - dir=$(pwd) - elif [ "${dir#/}" = "$dir" ] # dir does not start with a / - then - dir=$(pwd)/$dir - fi - echo $dir -} -# +============================================= -# Compensate for ZRL idiosyncrasy -# +============================================= -function setPERL { - if [ -z "$PERL" ] - then - PERL=perl - fi -} -# ============================================= -# Echo to $LCF -# ============================================= -function lecho { - # The quotes ensure that spaces in arguments are preserved. - echo "$*" >> $LCF -} -# +============================================ -# Print a message and exit. -# +============================================ -function die { - echo $1 - exit 1 -} -function makeRollingConfigFile { - fileName=$1 - rootPriority=$2 - maxFileSize=$3; - maxBackupIndex=$4; - - PRE="log4j.appender.roll" - echo "$PRE=org.apache.log4j.RollingFileAppender" > $LCF - echo "$PRE.File=$fileName" >> $LCF - echo "$PRE.MaxFileSize=$maxFileSize" >> $LCF - echo "$PRE.MaxBackupIndex=$maxBackupIndex" >> $LCF - - echo "$ROOT_PREFIX=$rootPriority, roll" >> $LCF - -} -# ============================================== -# Delete the file if exists -# ============================================== -function deleteFile { - if [ -e $1 ]; then - echo "Deleting file [$1]." - rm $1 - fi -} -# ============================================== -function runRollingFiles() { - confFile=$1 - - java -Dlog4j.configDebug=x org.apache.log4j.test.RollingFiles $confFile -} -# ---------------------------------------------------------------------- -function check() { - if ! cmp -s $1 $2 - then - echo "The output of current code DIFFERS from witness." - exit 1; - fi -} -# ---------------------------------------------------------------------- - diff --git a/src/java/org/apache/log4j/test/AsyncAppenderTest.java b/src/java/org/apache/log4j/test/AsyncAppenderTest.java deleted file mode 100644 index b3eff7faa4..0000000000 --- a/src/java/org/apache/log4j/test/AsyncAppenderTest.java +++ /dev/null @@ -1,67 +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.test; - -import org.apache.log4j.Category; -import org.apache.log4j.xml.DOMConfigurator; - -/** - Test the coordination of the AsyncAppender with its Dispatcher. - @author Ceki Gülcü -*/ -public class AsyncAppenderTest { - - static Category cat = Category.getInstance(AsyncAppenderTest.class); - static int delayBeforeClose; - - - public - static - void main(String argv[]) { - - if(argv.length == 2) - init(argv[0], argv[1]); - else - usage("Wrong number of arguments."); - test(); - } - - - static - void usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java "+ Shallow.class.getName() + - "configFile"); - System.exit(1); - } - - static - void init(String configFile, String delayBeforeCloseStr) { - DOMConfigurator.configure(configFile); - try { - delayBeforeClose = Integer.parseInt(delayBeforeCloseStr); - } catch(java.lang.NumberFormatException e) { - e.printStackTrace(); - usage("Could not convert ["+delayBeforeCloseStr+"] to Integer."); - } - } - - - static - void test() { - Category root = Category.getRoot(); - for(int i = 0; i < 100; i++) { - root.debug("Message " + i); - } - - try{Thread.currentThread().sleep(delayBeforeClose);}catch(Exception e){} - Category.shutdown(); - } - - -} diff --git a/src/java/org/apache/log4j/test/Base64.java b/src/java/org/apache/log4j/test/Base64.java deleted file mode 100644 index a3b1fc2c94..0000000000 --- a/src/java/org/apache/log4j/test/Base64.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 1996-1999, International Business Machines -// Corporation. All Rights Reserved. - - -package org.apache.log4j.test; - -class Base64 { - - final static int MAX_LINE = 76; - - static byte[] asciiEncoding = - //A B C D E F G H I J K L M N O P Q - {65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - //R S ... Z a b c d e f g - 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, - //h i j k l m n o p q r s t u - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - //v w x y z 0 1 2 3 4 5 6 7 8 9 + / - 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47}; - - static char[] charEnc = new char[64]; - - static { - for(int i = 0; i < 26; i ++) { - charEnc[i] = (char) ('A' + i); - charEnc[i+26] = (char) ('a' + i); - } - for(int i = 0; i < 10; i ++) { - charEnc[i+52] = (char) ('0' + i); - } - charEnc[62] = '+'; - charEnc[63] = '/'; - } - - - - static - String toString(byte[] inbuf) { - return toString(inbuf, 0, inbuf.length); - } - /** - - */ - static - String toString(byte[] inbuf, int offset, int length) { - - StringBuffer output = new StringBuffer((length)*4/3 + 1); - - int in; - char[] out = new char[4]; - - int i = offset; - boolean ended = false; - int last = offset + length; - int j; - int bitsRead; - - while(!ended) { - in = 0; - bitsRead = 0; - for(j = 0; j < 3; j++) { - if(i == last) { - ended = true; - break; - } - in = (in << 8) | (inbuf[i++] & 0xFF); - bitsRead += 8; - } - - while(bitsRead >= 6) { - bitsRead -= 6; - output.append(charEnc[(in >>> bitsRead) & 0x3F]); - } - - if(bitsRead == 4) { - output.append(charEnc[(in & 0x0F) << 2]); - output.append("="); - } - else if (bitsRead == 2) { - output.append(charEnc[(in & 0x03) << 4]); - output.append("=="); - } - } - return output.toString(); - } - - - public static void main(String[] args) { - - byte[] inbuf = new byte[MAX_LINE]; - - while(true) { - try { - int read = System.in.read(inbuf, 0, MAX_LINE); - if(read == -1) break; - System.out.println("Read " + read + " chars."); - System.out.println(Base64.toString(inbuf, 0, read)); - } - catch (Exception e) { - System.out.println("Exception " + e); - } - - } - } -} diff --git a/src/java/org/apache/log4j/test/CategoryWrapper.java b/src/java/org/apache/log4j/test/CategoryWrapper.java deleted file mode 100644 index fd5928d679..0000000000 --- a/src/java/org/apache/log4j/test/CategoryWrapper.java +++ /dev/null @@ -1,61 +0,0 @@ - -package org.apache.log4j.test; - -import org.apache.log4j.*; - -/** - This is just to test that wrapper can work. This implementation is - actually quite bad and should be avoided. - -*/ - -public class CategoryWrapper { - - - Category c; - static String FQCN = CategoryWrapper.class.getName(); - - CategoryWrapper(String name) { - c = Category.getInstance(name); - } - - public - static - void main(String argv[]) { - Layout layout = new PatternLayout("%p [%t] %C %F - %m\n"); - Appender out = new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT); - CategoryWrapper w1 = new CategoryWrapper("c1"); - w1.addAppender(out); - w1.print("hello"); - } - - - public - void addAppender(Appender appender) { - c.addAppender(appender); - } - - public - void print(String msg) { - - // You have to supply the fully qualified named of the wrapper - // class to the specially tailored category.log method for - // PatternLayout's %C conversion pattern to work. - - // We have to add the ".print" string because the invocation of - // wrapper.print method is made from the wrapper itself (main - // method). This is highly unusual. The fqcn of the wrapper is - // normally sufficient. - - c.log(FQCN+".print", Priority.DEBUG, msg, null); - } - - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println("Usage: java "+CategoryWrapper.class.getName() - + " fileName"); - System.exit(1); - } -} diff --git a/src/java/org/apache/log4j/test/ConfigurationFileParsing.java b/src/java/org/apache/log4j/test/ConfigurationFileParsing.java deleted file mode 100644 index 0e274df7fc..0000000000 --- a/src/java/org/apache/log4j/test/ConfigurationFileParsing.java +++ /dev/null @@ -1,44 +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.test; - -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.Category; -import org.apache.log4j.NDC; - -public class ConfigurationFileParsing { - - public - static - void main(String argv[]) { - - if(argv.length == 1) { - NDC.push("testing"); - PropertyConfigurator.configure(argv[0]); - Category root = Category.getRoot(); - root.debug("Message 1"); - root.debug("Message 2"); - NDC.pop(); - Category.shutdown(); - } - else { - Usage("Wrong number of arguments."); - } - - } - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println("Usage: java "+ConfigurationFileParsing.class.getName() - + " fileName"); - System.exit(1); - } - - -} diff --git a/src/java/org/apache/log4j/test/DRFATest.java b/src/java/org/apache/log4j/test/DRFATest.java deleted file mode 100644 index 07b0968e17..0000000000 --- a/src/java/org/apache/log4j/test/DRFATest.java +++ /dev/null @@ -1,91 +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.txt file. - */ - -package org.apache.log4j.test; -import org.apache.log4j.BasicConfigurator; -import org.apache.log4j.Category; -import org.apache.log4j.Layout; -import org.apache.log4j.PatternLayout; -import org.apache.log4j.Appender; -import org.apache.log4j.DailyRollingFileAppender; - - -/** - This class is used in testing the DailyRollingFileAppender. - @author Ceki Gülcü -*/ -public class DRFATest { - - static Category cat = Category.getInstance(DRFATest.class); - - static int limit; - - public - static - void main(String argv[]) { - if(argv.length == 1) - init(argv[0]); - else - usage("Wrong number of arguments."); - test(); - } - - static - void usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java "+ DRFATest.class.getName()+" length"); - System.exit(1); - } - - static - void init(String limitStr) { - try { - limit = Integer.parseInt(limitStr); - } catch(java.lang.NumberFormatException e) { - usage("Could not convert "+limitStr+" to int"); - } - } - - static - void test() { - - Layout layout = new PatternLayout("%d{yyyy-MM-dd-HH-mm ss:SSS} %m%n"); - try { - Appender appender = new DailyRollingFileAppender(layout, "test", - "'.'yyyy-MM-dd-HH-mm" ); - appender.setName("drfa"); - BasicConfigurator.configure(appender); - } catch(Exception e) { - System.err.println("Could not create DailyRollingFileAppender"); - e.printStackTrace(); - } - - System.out.println("Limit: "+limit); - - for(int i = 0; i < limit; i++) { - System.out.println(i); - cat.debug("Message"+ i); - delay(10000); - - if((i % 7) == 0) { - System.out.println("Sleeping 1min."); - delay(60000); - System.err.println(""); - } - } - } - - - static - void delay(int amount) { - try { - Thread.currentThread().sleep(amount); - } - catch(Exception e) {} - } -} - diff --git a/src/java/org/apache/log4j/test/DefaultInit.java b/src/java/org/apache/log4j/test/DefaultInit.java deleted file mode 100644 index 8c3616d996..0000000000 --- a/src/java/org/apache/log4j/test/DefaultInit.java +++ /dev/null @@ -1,21 +0,0 @@ - -package org.apache.log4j.test; - -import org.apache.log4j.Category; - -public class DefaultInit { - - static Category cat = Category.getInstance(DefaultInit.class); - - public static void main( String[] argv) { - cat.debug("Hello world"); - } - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java org.apache.log4j.test.DefaultInit "); - System.exit(1); - } - -} diff --git a/src/java/org/apache/log4j/test/DelayedLoop.java b/src/java/org/apache/log4j/test/DelayedLoop.java deleted file mode 100644 index 3af6a48e8b..0000000000 --- a/src/java/org/apache/log4j/test/DelayedLoop.java +++ /dev/null @@ -1,66 +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.test; - -import org.apache.log4j.Category; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.xml.DOMConfigurator; - -/** - This test program sits in a loop and logs things. Its logging is - configured by a configuration file. Changes to this configuration - file are monitored and when a change occurs, the config file is re-read. - - - @author Ceki Gülcü */ -public class DelayedLoop { - - static Category cat = Category.getInstance(DelayedLoop.class); - static int loopLength; - - public - static - void main(String argv[]) { - - if(argv.length == 1) - init(argv[0]); - else - usage("Wrong number of arguments."); - test(); - } - - - static - void usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java " + DelayedLoop.class.getName() + - "configFile"); - System.exit(1); - } - - - static - void init(String configFile) { - if(configFile.endsWith("xml")) { - DOMConfigurator.configureAndWatch(configFile, 3000); - } else { - PropertyConfigurator.configureAndWatch(configFile, 3000); - } - } - - static - void test() { - int i = 0; - while(true) { - cat.debug("MSG "+i++); - try { - Thread.currentThread().sleep(1000); - } catch(Exception e) {} - } - } -} diff --git a/src/java/org/apache/log4j/test/FQCNTest.java b/src/java/org/apache/log4j/test/FQCNTest.java deleted file mode 100644 index 5d6a3377ef..0000000000 --- a/src/java/org/apache/log4j/test/FQCNTest.java +++ /dev/null @@ -1,105 +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.test; - -import org.apache.log4j.*; -import org.apache.log4j.spi.*; -//import org.apache.log4j.xml.examples.XPriority; - -/** - This class is a shallow test of the various appenders and - layouts. It also tests their reading of the configuration file. - @author Ceki Gülcü -*/ -public class FQCNTest { - - //static Logger cat = Logger.getLoggerInstance("dddd"); - - public - static - void main(String argv[]) throws Exception { - if(argv.length == 1) - init(argv[0]); - else - usage("Wrong number of arguments."); - test(); - } - - static - void usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java "+ FQCNTest.class.getName()+"outputFile"); - System.exit(1); - } - - static - void init(String file) throws Exception { - Layout layout = new PatternLayout("%p %c (%C{2}#%M) - %m%n"); - FileAppender appender = new FileAppender(layout, file, false); - appender.setLayout(layout); - Category root = Category.getRoot(); - root.addAppender(appender); - } - - - static - void test() { - X1Logger x1 = X1Logger.getX1Logger("x1"); - x1.debug("hello"); - x1.debug1("hello"); - x1.debug2("hello"); - } -} - - -// ========================================================================== -// ========================================================================== -// ========================================================================== - -class X1Logger extends Logger { - static String FQCN = X1Logger.class.getName() + "."; - - private static X1LoggerFactory factory = new X1LoggerFactory(); - - public X1Logger(String name) { - super(name); - } - - public - void debug1(Object message) { - super.log(FQCN, Priority.DEBUG, message + " world.", null); - } - - public - void debug2(Object message) { - super.log(FQCN, Priority.DEBUG, message, null); - } - - protected - String getFQCN() { - return X1Logger.FQCN; - } - - public - static - X1Logger getX1Logger(String name) { - return ((X1Logger) Logger.getLogger(name, factory)); - } -} - -class X1LoggerFactory implements LoggerFactory { - - public - X1LoggerFactory() { - } - - public - Logger makeNewLoggerInstance(String name) { - return new X1Logger(name); - } -} diff --git a/src/java/org/apache/log4j/test/Finalize.java b/src/java/org/apache/log4j/test/Finalize.java deleted file mode 100644 index 3c9c8bab50..0000000000 --- a/src/java/org/apache/log4j/test/Finalize.java +++ /dev/null @@ -1,88 +0,0 @@ - - -package org.apache.log4j.test; - -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.Category; -import java.io.InputStreamReader; -import java.util.Enumeration; - -public class Finalize { - - static Category CAT = Category.getInstance(Finalize.class.getName()); - - public - static - void main(String argv[]) { - - if(argv.length == 1) - init(argv[0]); - else - Usage("Wrong number of arguments."); - - test(); - } - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java " + Finalize.class.getName() + - " configFile"); - System.exit(1); - } - - - static - void init(String configFile) { - PropertyConfigurator.configure(configFile); - } - - static - void test() { - int i = -1; - - InputStreamReader in = new InputStreamReader(System.in); - Category root = Category.getRoot(); - - System.out.println("Type 'q' to quit"); - int j = 0; - while (true) { - System.gc(); - try {i = in.read(); } - catch(Exception e) { return; } - System.gc(); - System.out.println("Read ["+i+"]."); - if(i == -1) - break; - else if(i == 'q') - break; - else - root.debug("Hello " + (++j)); - } - - //foo(root); - root.removeAllAppenders(); - System.gc(); delay(3000); - System.gc(); delay(3000); - System.gc(); delay(3000); System.gc(); - } - - static - void foo(Category cat) { - Enumeration enum = cat.getAllAppenders(); - while(enum != null && enum.hasMoreElements()) { - ((org.apache.log4j.Appender) enum.nextElement()).close(); - } - } - - - - static - void delay(int amount) { - try { - Thread.currentThread().sleep(amount); - } - catch(Exception e) {} - } - -} diff --git a/src/java/org/apache/log4j/test/Hello.java b/src/java/org/apache/log4j/test/Hello.java deleted file mode 100644 index ac663f3237..0000000000 --- a/src/java/org/apache/log4j/test/Hello.java +++ /dev/null @@ -1,29 +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.test; - -import org.apache.log4j.Category; -import org.apache.log4j.BasicConfigurator; - -/** - Very simple log4j usage example. - - @author Ceki Gülcü - */ -public class Hello { - - static Category cat = Category.getInstance(Hello.class); - - public - static - void main(String argv[]) { - BasicConfigurator.configure(); - cat.debug("Hello world."); - cat.info("What a beatiful day."); - } -} diff --git a/src/java/org/apache/log4j/test/L7D.java b/src/java/org/apache/log4j/test/L7D.java deleted file mode 100644 index edc663b546..0000000000 --- a/src/java/org/apache/log4j/test/L7D.java +++ /dev/null @@ -1,79 +0,0 @@ - - -// Copyright 1996-2000, International Business Machines -// Corporation. All Rights Reserved. -// -// See the LICENCE file for the terms of distribution. - -package org.apache.log4j.test; - -import org.apache.log4j.*; -import java.util.*; -import java.text.*; - -/** - This class is a simple test of the localization routines in - Category class. - - @author Ceki Gülcü, IBM Zurich Research Laboratory */ -public class L7D { - static ResourceBundle[] bundles; - - - public - static - void main(String args[]) { - if(args.length == 3) - init(args[0], args[1], args[2]); - else - Usage("Wrong number of arguments."); - - test(); - } - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java " + L7D.class.getName() + - "configFile ISO639LanguageCode ISO2166CountryCode"); - System.exit(1); - } - - static - void init(String configFile, String lanCode, String countryCode) { - PropertyConfigurator.configure(configFile); - bundles = new ResourceBundle[3]; - - try { - bundles[0] = ResourceBundle.getBundle("L7D", new Locale("en", "US")); - bundles[1] = ResourceBundle.getBundle("L7D", new Locale("fr", "FR")); - bundles[2] = ResourceBundle.getBundle("L7D", new Locale("fr", "CH")); - - } - catch(MissingResourceException e) { - e.printStackTrace(); - } - } - - static - void test() { - Category root = Category.getRoot(); - - for(int i = 0; i < bundles.length; i++) { - root.setResourceBundle(bundles[i]); - - root.l7dlog(Priority.DEBUG, "bogus1", null); - root.l7dlog(Priority.INFO, "test", null); - root.l7dlog(Priority.WARN, "hello_world", null); - root.l7dlog(Priority.DEBUG, "msg1", - new Object[] {new Integer(i+1), "log4j"}, null); - root.l7dlog(Priority.ERROR, "bogusMsg", - new Object[] {new Integer(i+1), "log4j"}, null); - root.l7dlog(Priority.ERROR, "msg1", - new Object[] {new Integer(i+1), "log4j"}, null); - root.l7dlog(Priority.INFO, "bogus2", null); - } - - } - -} diff --git a/src/java/org/apache/log4j/test/L7D_en_US.properties b/src/java/org/apache/log4j/test/L7D_en_US.properties deleted file mode 100644 index 4620e30e5f..0000000000 --- a/src/java/org/apache/log4j/test/L7D_en_US.properties +++ /dev/null @@ -1,3 +0,0 @@ -test=This is the English, US test. -hello_world=Hello world. -msg1=This is test number {0} with string argument {1}. diff --git a/src/java/org/apache/log4j/test/L7D_fr.properties b/src/java/org/apache/log4j/test/L7D_fr.properties deleted file mode 100644 index 2e883c5c83..0000000000 --- a/src/java/org/apache/log4j/test/L7D_fr.properties +++ /dev/null @@ -1,3 +0,0 @@ -test=Ceci est le test en francais pour la France. -hello_world=Bonjour la France. -msg1=Ceci est le test numero {0} contenant l''argument {1}. diff --git a/src/java/org/apache/log4j/test/L7D_fr_CH.properties b/src/java/org/apache/log4j/test/L7D_fr_CH.properties deleted file mode 100644 index 89293954d9..0000000000 --- a/src/java/org/apache/log4j/test/L7D_fr_CH.properties +++ /dev/null @@ -1,2 +0,0 @@ -test=Ceci est le test en francais pour la p'tite Suisse. -hello world=Salut le monde. diff --git a/src/java/org/apache/log4j/test/MDCStress.java b/src/java/org/apache/log4j/test/MDCStress.java deleted file mode 100644 index 9e7b97cd24..0000000000 --- a/src/java/org/apache/log4j/test/MDCStress.java +++ /dev/null @@ -1,143 +0,0 @@ - -package org.apache.log4j.test; - -import org.apache.log4j.*; - - -import java.util.Random; - -public class MDCStress extends Thread { - - static Category root = Category.getRoot(); - static Category log = Category.getInstance(MDCStress.class); - - static Random random = new Random(17); - - static final int BRANCHING_FACTOR = 2; - static final int LOOP_LENGTH = 12; - - static int maxThreads; - static int threadCounter = 0; - static int totalThreads = 0; - - - public - static - void main(String args[]) { - - Layout layout = new PatternLayout("%r [%t] depth=%X{depth} total=%X{total} - %m%n"); - Appender appender = new ConsoleAppender(layout); - root.addAppender(appender); - - if(args.length != 1) { - usage(); - } - try { - maxThreads = Integer.parseInt(args[0]); - } - catch(java.lang.NumberFormatException e) { - System.err.println(e); - usage(); - } - - while(true) { - synchronized(MDCStress.class) { - // Adding 1 to ensure that at least 1 child is created. - createChildren(randomInt(BRANCHING_FACTOR) + 1, 0); - - // wait until all threads are finished - try { - root.debug("About to wait for notification."); - MDCStress.class.wait(); - root.debug( "Got a notification."); - } - catch(InterruptedException e) { - root.warn("Unpextected InterruptedException received.", e); - } - } - } - - } - - static - void usage() { - System.err.println( "Usage: "+MDCStress.class + " maxThreads"); - System.exit(1); - } - - - public - static - void createChildren(int n, int currentDepth) { - if (n <= 0) - return; - - synchronized(MDCStress.class) { - n = maxThreadsConstained(n); - for(int i = 0; i < n; i++) { - threadCounter++; - totalThreads++; - log.debug("Creating Thread-"+(totalThreads-1)); - new MDCStress(currentDepth+1, totalThreads-1).start(); - } - } - } - - - int depth; - int total; - - MDCStress(int depth, int totalThreads) { - this.depth = depth; - this.total = totalThreads; - } - - public - void run() { - log.debug("Entered run()"); - - createChildren(randomInt(BRANCHING_FACTOR), depth); - - MDC.put("depth", new Integer(depth)); - MDC.put("total", new Integer(this.total)); - - log.debug("Set MDC variables."); - - createChildren(randomInt(BRANCHING_FACTOR), depth); - - - synchronized(MDCStress.class) { - threadCounter--; - root.debug("Exiting run loop. " + threadCounter); - if(threadCounter <= 0) { - MDCStress.class.notify(); // wake up the main thread - } - } - - } - - - static - public - int maxThreadsConstained(int a) { - int maxAllowed = MDCStress.maxThreads - MDCStress.threadCounter; - return a <= maxAllowed ? a : maxAllowed; - } - - /** - Return a random value in the range - */ - public - static - int randomInt(int n) { - int r = random.nextInt() % n; - return r >= 0 ? r : -r; - } - - public - static - String randomID() { - return Integer.toHexString(random.nextInt()& 0xFFFFFF); - } - -} diff --git a/src/java/org/apache/log4j/test/MultipleAppenders.java b/src/java/org/apache/log4j/test/MultipleAppenders.java deleted file mode 100644 index 3ffd335e62..0000000000 --- a/src/java/org/apache/log4j/test/MultipleAppenders.java +++ /dev/null @@ -1,54 +0,0 @@ - - -package org.apache.log4j.test; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.Category; -import org.apache.log4j.Appender; -import java.util.Enumeration; -import java.util.Vector; - -public class MultipleAppenders { - - public - static - void main(String argv[]) { - - // A1 and A2 should be added to root by reading the config file - PropertyConfigurator.configure(argv[0]); - - Category root = Category.getRoot(); - - Enumeration e1 = root.getAllAppenders(); - Vector v = new Vector(1); - - while(e1.hasMoreElements()) { - Appender a = (Appender) e1.nextElement(); - v.addElement(a); - String appenderName = a.getName(); - if(a != root.getAppender(appenderName)) { - System.out.println(appenderName + " lookup failed. Exiting."); - System.exit(1); - } - // attempt to add the existing appender - root.addAppender(a); - } - - // attempt to add a null appender - root.addAppender(null); - - Enumeration e2 = root.getAllAppenders(); - - for(int i = 0; i < v.size(); i++) { - if(v.elementAt(i) != e2.nextElement()) { - } - } - - if(e2.hasMoreElements()){ - System.out.println("Failure, e2 has remaining elements. Exiting."); - System.exit(1); - } - System.out.println("OK"); - } - - -} diff --git a/src/java/org/apache/log4j/test/PatternTest.java b/src/java/org/apache/log4j/test/PatternTest.java deleted file mode 100644 index b7feaed044..0000000000 --- a/src/java/org/apache/log4j/test/PatternTest.java +++ /dev/null @@ -1,78 +0,0 @@ - -package org.apache.log4j.test; - -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.Category; -import org.apache.log4j.Priority; -/** - This class is a test of the PatternLayout class. - - @author Ceki Gülcü -*/ -public class PatternTest { - static Category CAT = Category.getInstance(PatternTest.class); - - - public - static - void main(String argv[]) { - - if(argv.length == 1) - init(argv[0]); - else - Usage("Wrong number of arguments."); - - test(); - } - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java " + PatternTest.class.getName() + - " configFile"); - System.exit(1); - } - static - void init(String configFile) { - PropertyConfigurator.configure(configFile); - } - - static - void test() { - int i = -1; - Category root = Category.getRoot(); - - CAT.debug("Message " + ++i); - root.debug("Message " + i); - - CAT.info ("Message " + ++i); - root.info("Message " + i); - - CAT.warn ("Message " + ++i); - root.warn("Message " + i); - - CAT.error("Message " + ++i); - root.error("Message " + i); - - CAT.log(Priority.FATAL, "Message " + ++i); - root.log(Priority.FATAL, "Message " + i); - - Exception e = new Exception("Just testing"); - CAT.debug("Message " + ++i, e); - root.debug("Message " + i, e); - - CAT.info("Message " + ++i, e); - root.info("Message " + i, e); - - CAT.warn("Message " + ++i , e); - root.warn("Message " + i , e); - - CAT.error("Message " + ++i, e); - root.error("Message " + i, e); - - CAT.log(Priority.FATAL, "Message " + ++i, e); - root.log(Priority.FATAL, "Message " + i, e); - - Category.shutdown(); - } -} diff --git a/src/java/org/apache/log4j/test/PrintProperties.java b/src/java/org/apache/log4j/test/PrintProperties.java deleted file mode 100644 index b6bfc7d4a5..0000000000 --- a/src/java/org/apache/log4j/test/PrintProperties.java +++ /dev/null @@ -1,27 +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.test; - -import java.io.*; -import org.apache.log4j.config.PropertyPrinter; - -/** - Prints the configuration of the log4j default hierarchy - (which needs to be auto-initialized) as a propoperties file - on System.out. - - @author Anders Kristensen - */ -public class PrintProperties { - public - static - void main(String[] args) { - new PropertyPrinter(new PrintWriter(System.out), true); - } -} \ No newline at end of file diff --git a/src/java/org/apache/log4j/test/README b/src/java/org/apache/log4j/test/README deleted file mode 100644 index ece49e2ff2..0000000000 --- a/src/java/org/apache/log4j/test/README +++ /dev/null @@ -1,9 +0,0 @@ - -The log4j test suite has been verfied to run on both Windows NT/2000 -and Linux. However, the suite requires the bash shell and perl. On -most Unix systems these are included by default. On Windows systems -you nedd to install the Cygwin tools from - - http://sources.redhat.com/cygwin - -In case of problems send an e-mail note to log4j-dev@jakarta.apache.org. diff --git a/src/java/org/apache/log4j/test/ROFile.java b/src/java/org/apache/log4j/test/ROFile.java deleted file mode 100644 index 4f36a0fb32..0000000000 --- a/src/java/org/apache/log4j/test/ROFile.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.log4j.test; - -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.Category; - -public class ROFile { - - static Category cat = Category.getInstance(ROFile.class.getName()); - - public - static - void main(String argv[]) { - - if(argv.length == 1) - init(argv[0]); - else - Usage("Wrong number of arguments."); - - test(); - } - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java " + ROFile.class.getName() + - "configFile"); - System.exit(1); - } - - static - void init(String configFile) { - PropertyConfigurator.configure(configFile); - } - - static - void test() { - int i = -1; - cat.debug("Message " + ++i); - } -} diff --git a/src/java/org/apache/log4j/test/Shallow.java b/src/java/org/apache/log4j/test/Shallow.java deleted file mode 100644 index 2a202d0384..0000000000 --- a/src/java/org/apache/log4j/test/Shallow.java +++ /dev/null @@ -1,99 +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.txt file. - */ -// NOTICE: Some tests are sensitive to line numbers! -package org.apache.log4j.test; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.xml.DOMConfigurator; -import org.apache.log4j.Category; -import org.apache.log4j.NDC; -import org.apache.log4j.Priority; -/** - This class is a shallow test of the various appenders and - layouts. It also tests their reading of the configuration file. - @author Ceki Gülcü -*/ -public class Shallow { - - static Category cat = Category.getInstance(Shallow.class); - - public - static - void main(String argv[]) { - if(argv.length == 1) - init(argv[0]); - else - usage("Wrong number of arguments."); - test(); - } - - static - void usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java "+ Shallow.class.getName()+"configFile"); - System.exit(1); - } - - static - void init(String configFile) { - if(configFile.endsWith(".xml")) - DOMConfigurator.configure(configFile); - else - PropertyConfigurator.configure(configFile); - } - - static - void test() { - int i = -1; - NDC.push("NDC"); - Category root = Category.getRoot(); - cat.debug("Message " + ++i); - root.debug("Message " + i); - - cat.info ("Message " + ++i); - root.info("Message " + i); - - cat.warn ("Message " + ++i); - root.warn("Message " + i); - - cat.error("Message " + ++i); - root.error("Message " + i); - - cat.log(Priority.FATAL, "Message " + ++i); - root.log(Priority.FATAL, "Message " + i); - - Exception e = new Exception("Just testing"); - cat.debug("Message " + ++i, e); - root.debug("Message " + i, e); - - cat.info("Message " + ++i, e); - root.info("Message " + i, e); - - cat.warn("Message " + ++i , e); - root.warn("Message " + i , e); - - cat.error("Message " + ++i, e); - root.error("Message " + i, e); - - cat.log(Priority.FATAL, "Message " + ++i, e); - root.log(Priority.FATAL, "Message " + i, e); - - root.setPriority(Priority.FATAL); - - // It is always a good idea to call this method when exiting an - // application. - Category.shutdown(); - } - - - static - void delay(int amount) { - try { - Thread.currentThread().sleep(amount); - } - catch(Exception e) {} - } -} diff --git a/src/java/org/apache/log4j/test/ShortSocketServer.java b/src/java/org/apache/log4j/test/ShortSocketServer.java deleted file mode 100644 index e1ba36bc35..0000000000 --- a/src/java/org/apache/log4j/test/ShortSocketServer.java +++ /dev/null @@ -1,68 +0,0 @@ - - -package org.apache.log4j.test; - -import java.net.Socket; -import java.net.ServerSocket; - -import org.apache.log4j.Category; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.helpers.LogLog; -import org.apache.log4j.net.SocketNode; - -/** -*/ - -public class ShortSocketServer { - - static Category cat = Category.getInstance(ShortSocketServer.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 { - LogLog.debug("Listening on port " + port); - ServerSocket serverSocket = new ServerSocket(port); - LogLog.debug("Waiting to accept a new client."); - Socket socket = serverSocket.accept(); - LogLog.debug("Connected to client at " + socket.getInetAddress()); - LogLog.debug("Starting new socket node."); - SocketNode sn = new SocketNode(socket, Category.getDefaultHierarchy()); - Thread t = new Thread(sn); - t.start(); - t.join(); - } - catch(Exception e) { - cat.error("Error while in main.", e); - } - } - - - static - void usage(String msg) { - System.err.println(msg); - System.err.println( - "Usage: java " +ShortSocketServer.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); - } -} diff --git a/src/java/org/apache/log4j/test/SpacePad.java b/src/java/org/apache/log4j/test/SpacePad.java deleted file mode 100644 index 91a9989d5a..0000000000 --- a/src/java/org/apache/log4j/test/SpacePad.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.apache.log4j.test; - -public class SpacePad { - - static String[] SPACES = {" ", " ", " ", " ", //1,2,4,8 spaces - " ", // 16 spaces - " " }; // 32 - - static public void main(String[] args) { - StringBuffer sbuf = new StringBuffer(); - - for(int i = 0; i < 35; i++) { - sbuf.setLength(0); - sbuf.append("\""); - spacePad(sbuf, i); - sbuf.append("\""); - System.out.println(sbuf.toString()); - } - - sbuf.setLength(0); - sbuf.append("\""); - spacePad(sbuf, 67); - sbuf.append("\""); - System.out.println(sbuf.toString()); - - } - static - public - void spacePad(StringBuffer sbuf, int length) { - //LogLog.debug("Padding with " + length + " spaces."); - while(length >= 32) { - sbuf.append(SPACES[5]); - length -= 32; - } - - for(int i = 4; i >= 0; i--) { - if((length & (1<> $TEMP.x - mv $TEMP.x $TEMP - fi - - $PERL filter.pl $TEMP $OUTPUT ConfigurationFileParsing $options - if [ $? != 0 ]; then - echo "The output is not in expected format. See the file [$OUTPUT]." - exit 1 - fi - - check witness/confParsing.$TEST $OUTPUT; echo " OK" -} - - -# ========================================================================= -# Just run ConfigurationFileParsing and direct the output to STDOUT or -# STDERR. -# ========================================================================= -function testConfigurationParsingII { - conf=$1; - target=$2 - - case $target in - OUT ) - java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $conf>$TEMP - ;; - ERR ) - java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $conf>& $TEMP - ;; - esac - - check witness/confParsing.$TEST $TEMP; echo " OK" -} -# ====================================================== - -declare -i TEST - - -TEST=1; -if [ $TEST -ge $start ]; then - D_FLAG=$DEF_DEBUG - echo "log4j.rootCategory=DEBUG, testAppender" > $LCF - lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender" - lecho "log4j.appender.testAppender.File= $TEMP" - lecho "log4j.appender.testAppender.Append=false" - lecho "log4j.appender.testAppender.layout.ContextPrinting= false " - lecho "log4j.appender.testAppender.layout.ThreadPrinting= xx " - lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout " - testConfigurationParsing $LCF LINE_NUMBER -fi - -TEST=2; -if [ $TEST -ge $start ]; then - D_FLAG=$DEF_DEBUG - echo "log4j.rootCategory=DEBUG, testAppender" > $LCF - lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender" - lecho "log4j.appender.testAppender.File= $TEMP" - lecho "log4j.appender.testAppender.Append=false" - lecho "log4j.appender.testAppender.MaxFileSize=1KB" - lecho "log4j.appender.testAppender.MaxBackupIndex= 1 " - lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout" - lecho "log4j.appender.testAppender.layout.ThreadPrinting=true" - lecho "log4j.appender.testAppender.layout.DateFormat=ReLaTIve" - testConfigurationParsing $LCF RELATIVE -fi - -TEST=3; -if [ $TEST -ge $start ]; then - D_FLAG=$DEF_DEBUG - echo "18:25:32.394 [main] DEBUG testing - HELLO WORLD" > $TEMP - echo "log4j.rootCategory=DEBUG, testAppender" > $LCF - lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender" - lecho "log4j.appender.testAppender.File=$TEMP" - lecho "log4j.appender.testAppender.Append=true" - lecho "log4j.appender.testAppender.MaxFileSize=54" - lecho "log4j.appender.testAppender.MaxBackupIndex= 0 " - lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout" - lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute" - lecho "log4j.appender.testAppender.layout.TimeZone=GMT" - testConfigurationParsing $LCF ABSOLUTE -fi - - -TEST=4; -if [ $TEST -ge $start ]; then - D_FLAG=$DEF_DEBUG - echo "18:25:32,394 [main] DEBUG testing - HELLO WORLD" > $TEMP - echo "log4j.rootCategory= DEBUG , testAppender" > $LCF - lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender" - lecho "log4j.appender.testAppender.File=$TEMP" - lecho "log4j.appender.testAppender.Append=true" - lecho "log4j.appender.testAppender.MaxFileSize=155" - lecho "log4j.appender.testAppender.MaxBackupIndex=0" - lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout" - lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute" - lecho "log4j.appender.testAppender.layout.TimeZone=ECT" - testConfigurationParsing $LCF ABSOLUTE -fi - - -TEST=5; -if [ $TEST -ge $start ]; then - D_FLAG="" - echo "18:25:32,394 [main] DEBUG testing - HELLO WORLD" > $TEMP - echo "log4j.rootCategory= DEBUG , testAppender" > $LCF - lecho "log4j.debug=" - lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender" - lecho "log4j.appender.testAppender.File=$TEMP" - lecho "log4j.appender.testAppender.Append= true" - lecho "log4j.appender.testAppender.MaxFileSize= 1 " - lecho "log4j.appender.testAppender.MaxBackupIndex= 2" - lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout" - lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute" - lecho "log4j.appender.testAppender.layout.TimeZone=ECT" - testConfigurationParsing $LCF ABSOLUTE $TEMP.2 $TEMP.1 -fi - -TEST=6; -if [ $TEST -ge $start ]; then - D_FLAG="" - echo "log4j.rootCategory= , testAppender" > $LCF - lecho "log4j.debug=" - lecho "log4j.appender.testAppender=org.apache.log4j.FileAppender" - lecho "log4j.appender.testAppender.File=$TEMP" - lecho "log4j.appender.testAppender.Append= false " - lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout" - lecho "log4j.appender.testAppender.layout.DateFormat=dAtE" - lecho "log4j.appender.testAppender.layout.TimeZone=" - - testConfigurationParsing $LCF DATE -fi - - -TEST=7; -if [ $TEST -ge $start ]; then - D_FLAG="" - echo "18:25:32,394 [main] DEBUG testing - HELLO WORLD" > $TEMP - echo "log4j.rootCategory= DEBUG , testAppender, inexistentAppender" > $LCF - lecho "log4j.debug=false" - lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender" - lecho "log4j.appender.testAppender.File=$TEMP" - lecho "log4j.appender.testAppender.Append= true" - lecho "log4j.appender.testAppender.MaxFileSize= 1 " - lecho "log4j.appender.testAppender.MaxBackupIndex=2 " - lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout" - lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute" - lecho "log4j.appender.testAppender.layout.TimeZone=ECT" - - testConfigurationParsing $LCF ABSOLUTE $TEMP.2 $TEMP.1 -fi - - -TEST=8; -if [ $TEST -ge $start ]; then - D_FLAG="" - echo "log4j.rootCategory= DEBUG , testAppender" > $LCF - lecho "log4j.debug=false" - lecho "log4j.appender.testAppender=org.apache.log4j.ConsoleAppender" - # Note the spaces - lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout " - lecho "log4j.appender.testAppender.layout.ConversionPattern=[%t] %p - %m%n" - echo -n " ConfigurationParsing test $TEST - " - testConfigurationParsingII $LCF OUT -fi - -TEST=9; -if [ $TEST -ge $start ]; then - D_FLAG="" - echo "log4j.rootCategory= DEBUG , testAppender" > $LCF - lecho "log4j.debug=false" - lecho "log4j.appender.testAppender=org.apache.log4j.ConsoleAppender" - lecho "log4j.appender.testAppender.Target= System.out " -# lecho "log4j.appender.testAppender.Append= true " - lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout" - lecho "log4j.appender.testAppender.layout.ConversionPattern=[%t] %p - %m%n" - echo -n " ConfigurationParsing test $TEST (can fail if anything is written to System.err) - " - testConfigurationParsingII $LCF ERR -fi - -# Test variable subst from System properties -TEST=10; -if [ $TEST -ge $start ]; then - D_FLAG="" - echo "log4j.rootCategory= DEBUG , testAppender" > $LCF - lecho "log4j.debug=false" - lecho "log4j.appender.testAppender=org.apache.log4j.FileAppender" - # We escape the dollar sign to avoid substitution at the shell level. - lecho "log4j.appender.testAppender.File=\${user.dir}/$TEMP" - lecho "log4j.appender.testAppender.Append=false" - lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout" - lecho "log4j.appender.testAppender.layout.ConversionPattern=AVY [%t] %p-%m%n" - testConfigurationParsing $LCF NONE -fi - -rm $TEMP > /dev/null - -# Test variable subst from the config file itself -TEST=11; -if [ $TEST -ge $start ]; then - D_FALG="" - echo "log4j.rootCategory= DEBUG , testAppender" > $LCF - lecho "log4j.configDebug=false" - # $TEMP will be replaced by the shell - lecho "t=$TEMP" - lecho "log4j.appender.testAppender=org.apache.log4j.FileAppender" - # We escape the dollar sign to avoid substitution at the shell level. - lecho "log4j.appender.testAppender.File=\${t}" - lecho "log4j.appender.testAppender.Append=false" - lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout" - lecho "log4j.appender.testAppender.layout.ConversionPattern=VSUB [%t] %p-%m%n" - testConfigurationParsing $LCF NONE -fi - - - - - - - - - - - -# Do SyslogAppender test (not real tests) - -TEST=100; - -if [ $TEST -ge $start ]; then - D_FLAG="" - echo "log4j.rootCategory= , testAppender" > $LCF - lecho "log4j.debug=true" - lecho "log4j.appender.testAppender=org.apache.log4j.net.SyslogAppender" - lecho "log4j.appender.testAppender.SyslogHost=localhost" - lecho "log4j.appender.testAppender.Facility= LOCAL0 " - lecho "log4j.appender.testAppender.FacilityPrinting=true" - lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout" - lecho "log4j.appender.testAppender.layout.DateFormat=NULL" - lecho "log4j.appender.testAppender.layout.TimeZone=" - - echo -n " ConfigurationParsing test $TEST - " - java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $LCF -fi - - -TEST=101; - -if [ $TEST -ge $start ]; then - D_FLAG="" - echo "log4j.rootCategory= , testAppender" > $LCF - lecho "log4j.debug=true" - lecho "log4j.appender.testAppender=org.apache.log4j.net.SyslogAppender" - lecho "log4j.appender.testAppender.SyslogHost=localhost" - lecho "log4j.appender.testAppender.Facility=" - lecho "log4j.appender.testAppender.FacilityPrinting=" - lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout" - lecho "log4j.appender.testAppender.layout.DateFormat=NULL" - lecho "log4j.appender.testAppender.layout.TimeZone=" - - echo -n " ConfigurationParsing test $TEST - " - java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $LCF -fi diff --git a/src/java/org/apache/log4j/test/customCategory b/src/java/org/apache/log4j/test/customCategory deleted file mode 100644 index 36adae9eb3..0000000000 --- a/src/java/org/apache/log4j/test/customCategory +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# A regression test to check support custom priorities - -# Read the .functions file -. .functions - -# If set, allows to skip tests -declare -i start=$1 -echo "start=$start TEMP=$TEMP OUTPUT=$OUTPUT" - -function testCustomCat { - layout=$1 - - echo -n "Custom Priority test $TEST - " - java -Dlog4j.debug org.apache.log4j.test.CustomCategoryTest $LCF - - check witness/customCat.$TEST $TEMP; echo "OK." -} - - - -setPERL - -declare -i TEST - -TEST=1 -if [ $TEST -ge $start ]; then - echo "LOG4J=org.apache.log4j" > $LCF - lecho "log4j.rootCategory=TRACE#\${LOG4J}.xml.examples.XLevel, testAppender" - lecho "log4j.loggerFactory=\${LOG4J}.xml.examples.XLogger\$XFactory" - lecho "log4j.appender.testAppender=\${LOG4J}.FileAppender" - lecho "log4j.appender.testAppender=\${LOG4J}.FileAppender" - lecho "log4j.appender.testAppender.File=$TEMP" - lecho "log4j.appender.testAppender.Append=false" - lecho "log4j.appender.testAppender.layout=\${LOG4J}.PatternLayout " - lecho "log4j.appender.testAppender.layout.ConversionPattern=%-5p - %m%n" - testCustomCat -fi - - - diff --git a/src/java/org/apache/log4j/test/defaultInit b/src/java/org/apache/log4j/test/defaultInit deleted file mode 100644 index e05628d855..0000000000 --- a/src/java/org/apache/log4j/test/defaultInit +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash - -# Read the .functions file -. .functions - -# If set, allows to skip tests -declare -i start=$1 - -# ================================================== -function testDefaultInit { - echo -n "Default initialization test $TEST - " - - if [ -e $TEMP ]; then - #echo "Deleting $TEMP." - rm $TEMP - touch $TEMP - fi - - java $1 -Dlog4j.debug org.apache.log4j.test.DefaultInit - - check witness/definit.$TEST $TEMP; echo "OK." -} -# ================================================== - - -declare -i TEST - -function createProperties { - echo "log4j.rootCategory=DEBUG, A1" > $LCF - lecho "log4j.appender.A1=org.apache.log4j.FileAppender" - lecho "log4j.appender.A1.File=$TEMP" - lecho "log4j.appender.A1.Append=false" - lecho "log4j.appender.A1.layout=org.apache.log4j.PatternLayout " - lecho "log4j.appender.A1.layout.ConversionPattern=%m%n" -} - -LCF=log4j.properties -createProperties - -TEST=1 -if [ $TEST -ge $start ]; then - testDefaultInit -fi - -TEST=2 -if [ $TEST -ge $start ]; then - testDefaultInit -Dlog4j.defaultInitOverride -fi - -TEST=3 -if [ $TEST -ge $start ]; then - testDefaultInit -Dlog4j.defaultInitOverride=true -fi - -TEST=4 -if [ $TEST -ge $start ]; then - testDefaultInit -Dlog4j.defaultInitOverride= -fi - -TEST=5 -if [ $TEST -ge $start ]; then - testDefaultInit -Dlog4j.defaultInitOverride=false -fi - -rm $LCF - -LCF=props -createProperties - -TEST=6 -if [ $TEST -ge $start ]; then - testDefaultInit -Dlog4j.configuration=props -fi - -rm $LCF diff --git a/src/java/org/apache/log4j/test/domTest b/src/java/org/apache/log4j/test/domTest deleted file mode 100644 index adf10088de..0000000000 --- a/src/java/org/apache/log4j/test/domTest +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash - -# A regression test to check the PatternLayout code. - -# Read the .functions -. .functions - - -# If set, allows to skip tests -declare -i start=$1 - -echo "start=$start TEMP=$TEMP OUTPUT=$OUTPUT" -# ================================================================== -function testDOM { - - configFile=$1 - layoutA1=$2 - layoutA2=$3 - - deleteFile temp.A1 > /dev/null; deleteFile output.A1 > /dev/null ; - deleteFile temp.A2 > /dev/null; deleteFile output.A2 > /dev/null; - touch temp.A1 temp.A2 - - echo -n "DOM test $TEST - " - #java org.apache.log4j.xml.test.DOMTest $configFile - java -Dlog4j.configDebug org.apache.log4j.xml.test.DOMTest $configFile - - $PERL filter.pl temp.A1 output.A1 DOMTest $layoutA1 - if [ $? != 0 ]; then - echo "The output(1) is not in expected format. See the file [output.A1]." - exit 1 - fi - - $PERL filter.pl temp.A2 output.A2 DOMTest $layoutA2 - if [ $? != 0 ]; then - echo "The output(2) is not in expected format. See the file [output.A2]." - exit 1 - fi - - - check witness/domTest.A1.$TEST output.A1; echo -n "-" - check witness/domTest.A2.$TEST output.A2; echo " OK" - -} -# ================================================================== -function simpleTest { - - configFile=$1 - - echo -n "DOM test $TEST - " - java org.apache.log4j.xml.test.DOMTest $configFile - #java -Dlog4j.configDebug org.apache.log4j.xml.test.DOMTest $configFile - $PERL filter.pl $TEMP $OUTPUT DOMTest LINE_NUMBER - - check witness/domTest.$TEST $OUTPUT; echo " OK" - -} -# ================================================================== - - -setPERL - -declare -i TEST - -TEST=1 -if [ $TEST -ge $start ]; then - testDOM xml/domTest$TEST.xml LINE_NUMBER ISO8601 -fi - -TEST=2 -if [ $TEST -ge $start ]; then - echo "THIS TEST WILL ECHO WARNINGS (BUT DOES NOT THROW EXCEPTIONS)." - testDOM xml/domTest$TEST.xml LINE_NUMBER ISO8601 -fi - -TEST=3 -if [ $TEST -ge $start ]; then - testDOM xml/domTest$TEST.xml RELATIVE RELATIVE -fi - -for TEST in 4 5 6 7 8 9 10 11 12 -do - if [ $TEST -ge $start ]; then - simpleTest xml/domTest$TEST.xml - fi -done - - diff --git a/src/java/org/apache/log4j/test/drfa b/src/java/org/apache/log4j/test/drfa deleted file mode 100644 index c3ce23094f..0000000000 --- a/src/java/org/apache/log4j/test/drfa +++ /dev/null @@ -1,36 +0,0 @@ -if [ -z "$PERL" ] -then - PERL=perl -fi - -. .functions - -#rm test -#rm test.* - -echo "starting org.apache.log4j.test.DRFATest 5" -java -Dlog4j.debug org.apache.log4j.test.DRFATest 5 -$PERL drfa.pl || die "drfa test FAILED." - -echo -n "About to sleep ";date -sleep 60 -echo -n "After sleep ";date -echo "Starting org.apache.log4j.test.DRFATest 10" -java -Dlog4j.debug org.apache.log4j.test.DRFATest 10 -$PERL drfa.pl || die "drfa test FAILED." - - -echo -n "About to sleep ";date -sleep 60 -echo -n "After sleep ";date -echo "Starting org.apache.log4j.test.DRFATest 100" -java -Dlog4j.debug org.apache.log4j.test.DRFATest 100 -$PERL drfa.pl || die "drfa test FAILED." - - -echo -n "About to sleep ";date -sleep 60 -echo -n "After sleep ";date -echo "Starting org.apache.log4j.test.DRFATest 100" -java -Dlog4j.debug org.apache.log4j.test.DRFATest 100 -$PERL drfa.pl || die "drfa test FAILED." diff --git a/src/java/org/apache/log4j/test/drfa.pl b/src/java/org/apache/log4j/test/drfa.pl deleted file mode 100644 index 5ee1a2b547..0000000000 --- a/src/java/org/apache/log4j/test/drfa.pl +++ /dev/null @@ -1,45 +0,0 @@ - -$|=1; - -while($next = ) { - - print "Reading $next\n"; - check($next); -} - -print "Reading test\n"; -checkResidual(); - -sub checkResidual() { - open(F, "test"); - - while() { - if($_ =~ /(.*) \d\d:/) { - $p = $1; - } else { - die "In [test] unexpected line: [$_]\n"; - } - - if($old && $old != $p) { - die "Mismatch in [test] unexpected line: [$_]\n"; - } else { - print " $_"; - } - $old = $p; - } -} - -sub check() { - my ($filename) = @_; - - open(F, $filename); - $_ = $filename; - $p = s/test.//; - while() { - if($_ =~ /$p/) { - print " $_"; - } else { - die "In [$filename] unexpected line: [$_]\n"; - } - } -} diff --git a/src/java/org/apache/log4j/test/extSupport b/src/java/org/apache/log4j/test/extSupport deleted file mode 100644 index 82a360eadb..0000000000 --- a/src/java/org/apache/log4j/test/extSupport +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# A regression test to check extension support in DOMConfigurator and elsewhere - -# Read the .functions file -. .functions - -# If set, allows to skip tests -declare -i start=$1 -echo "start=$start TEMP=$TEMP OUTPUT=$OUTPUT" - -function testExtSupport { - configFile=$1 - - echo -n "Extension support test $TEST - " - java org.apache.log4j.xml.test.XTest $configFile - - check witness/ext.$TEST $OUTPUT; echo "OK." -} - - -echo "-- $OUTPUT" - -declare -i TEST - -TEST=1 -if [ $TEST -ge $start ]; then - testExtSupport xml/ext$TEST.xml -fi \ No newline at end of file diff --git a/src/java/org/apache/log4j/test/filter.pl b/src/java/org/apache/log4j/test/filter.pl deleted file mode 100644 index b0f8b3ea8e..0000000000 --- a/src/java/org/apache/log4j/test/filter.pl +++ /dev/null @@ -1,132 +0,0 @@ - -# Usage: perl filter.pl input output exceptionString layout -# where exceptionString is the string to filter in stack traces -# layout is one of NONE|LINE_NUMBER|RELATIVE|DATE|ABSOLUTE|ISO8601|HTML -# - -$INPUT=$ARGV[0]; -$OUTPUT=$ARGV[1]; -$EXSTR=$ARGV[2]; -$LAYOUT=$ARGV[3]; # filtering type - - -open(IN, $INPUT) || die "Could not open $INPUT"; -open(OUT, ">$OUTPUT") || die "Could not open $OUTPUT"; - -local($oldfh) = select(); select(OUT); $|=1; select($oldfh); - -if ($LAYOUT =~ "NONE") { - doNoneFilter(); -} elsif($LAYOUT =~ "LINE_NUMBER") { - doLineNumberFilter(); -} elsif($LAYOUT =~ "HTML") { - doHTMLFilter(); -} else { - doFilter($LAYOUT); -} - -close(OUT); - -sub wrongFormat { - my $line = $_; - print "Wrong format. Offending line: \"$_\"\n"; - exit 1; -} - -sub doNoneFilter { - while() { - print OUT; - } -} - -sub doHTMLFilter { - while() { - if(/\($EXSTR\.java:\d*\)/) { - s/\($EXSTR\.java:\d+\)/\($EXSTR\.java:XXX\)/g; - } - elsif(/\(Compiled Code\)/) { - s/\(Compiled Code\)$/\($EXSTR\.java:XXX\)/g; - } - elsif(/\(Unknown Source\)/) { - s/\(Unknown Source\)$/\($EXSTR\.java:XXX\)/g; - } - elsif(/\d+<\/td>/) { - s/\d+<\/td>/XXX<\/td>/; - } - print OUT ; - } -} - -sub doLineNumberFilter { - while() { - if(/\($EXSTR\.java:\d*\)/) { - s/\($EXSTR\.java:\d+\)$/\($EXSTR\.java:XXX\)/; - print OUT; - } elsif(/\(Compiled Code\)/) { - s/\(Compiled Code\)$/\($EXSTR\.java:XXX\)/; - print OUT; - } elsif(/\(Unknown Source\)/) { - s/\(Unknown Source\)$/\($EXSTR\.java:XXX\)/; - print OUT; - } else { - print OUT; - } - } -} - - -sub doFilter() { - my $layout = $_[0]; - $basicPat = "\\[main\\] (FATAL|ERROR|WARN|INFO|DEBUG)"; - #$basicPat = 'main'; - - - $timePat = "\\d\\d:\\d\\d:\\d\\d,\\d{3}"; # "17:49:20.733" - - #$datePat = "\\d\\d [A-Z][a-z]{2} \\d{4}"; # 20 Dec 1999 - # The month is locale dependent - $datePat = "\\d\\d .{3,6} \\d{4}"; # 20 Dec 1999 - - if($layout =~ "NULL") { - $pattern = $basicPat; - } - # 98 [main] ERROR DEB - Message 15 - elsif($layout =~ "RELATIVE") { - $pattern = "^\\d+ $basicPat"; - } - # 17:49:20.733 [main] ERROR DEB - Message 15 - elsif($layout =~ "ABSOLUTE") { - $pattern = "^$timePat $basicPat"; - } - elsif ($layout =~ "DATE") { - $pattern = "^$datePat $timePat $basicPat"; - } - elsif ($layout =~ "ISO8601") { - $pattern = "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3} $basicPat"; - } - else { - die "Unknown layout [$layout]"; - } - - #print "PATTERN \"$pattern\"\n"; - while() { - if (/$pattern/o) { - $i = index($_,"[main]"); - print OUT substr($_, $i); - } elsif(/\($EXSTR\.java:\d*\)/) { - s/\($EXSTR\.java:\d+\)$/\($EXSTR\.java:XXX\)/; - print OUT; - } elsif(/\(Compiled Code\)/) { - s/\(Compiled Code\)$/\($EXSTR\.java:XXX\)/; - print OUT; - } elsif(/\(Unknown Source\)/) { - s/\(Unknown Source\)$/\($EXSTR\.java:XXX\)/; - print OUT; - } elsif (/^java\.lang\.Exception: Just testing$/) { - print OUT; - } - else { - wrongFormat($_); - } - } -} diff --git a/src/java/org/apache/log4j/test/finalize b/src/java/org/apache/log4j/test/finalize deleted file mode 100644 index 54f0ec9c54..0000000000 --- a/src/java/org/apache/log4j/test/finalize +++ /dev/null @@ -1,45 +0,0 @@ - - -# Read the .functions file -. .functions - -declare -i start=$1 - -# ====================================================== -function testFinalize { - conf=$1 - - - java -Dlog4j.configDebug org.apache.log4j.test.Finalize $conf -} -# ====================================================== - - - -declare -i TEST - - -TEST=1 -if [ $TEST -ge $start ]; then - D_FLAG=$DEF_DEBUG - echo "log4j.rootCategory=DEBUG, A1" > $LCF - lecho "log4j.appender.A1=org.apache.log4j.FileAppender" - lecho "log4j.appender.A1.File=$TEMP" - lecho "log4j.appender.A1.Append=false" - lecho "log4j.appender.A1.layout.ConversionPattern=%m\n" - lecho "log4j.appender.A1.layout=org.apache.log4j.PatternLayout" - testFinalize $LCF -fi - -TEST=2 -if [ $TEST -ge $start ]; then - D_FLAG=$DEF_DEBUG - echo "log4j.rootCategory=DEBUG, A1" > $LCF - lecho "log4j.appender.A1=org.apache.log4j.net.SocketAppender" - lecho "log4j.appender.A1.RemoteHost=$REMOTE_HOST" - lecho "log4j.appender.A1.Port=12345" - lecho "log4j.appender.A1.ReconnectionDelay=2000" - testFinalize $LCF -fi - - diff --git a/src/java/org/apache/log4j/test/fqcn b/src/java/org/apache/log4j/test/fqcn deleted file mode 100644 index a97c97af9e..0000000000 --- a/src/java/org/apache/log4j/test/fqcn +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# A regression test to check the caller localization in subclasses of Category - -# Read the .functions file -. .functions - -# If set, allows to skip tests -declare -i start=$1 -echo "start=$start TEMP=$TEMP OUTPUT=$OUTPUT" - -function testFQCN { - layout=$1 - - echo -n "FQCN test $TEST - " - java org.apache.log4j.test.FQCNTest $OUTPUT - - check witness/fqcn.$TEST $OUTPUT; echo "OK." -} - - - -declare -i TEST - -TEST=1 -if [ $TEST -ge $start ]; then - testFQCN -fi \ No newline at end of file diff --git a/src/java/org/apache/log4j/test/getOptions b/src/java/org/apache/log4j/test/getOptions deleted file mode 100644 index 881853e63a..0000000000 --- a/src/java/org/apache/log4j/test/getOptions +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# Read the .functions file -. .functions - -# If set, allows to skip tests -declare -i start=$1 - -# ================================================== -function testGetOptions { - echo -n "OptionHandler.getOption() test $TEST - " - - if [ -e $TEMP ]; then - #echo "Deleting $TEMP." - rm $TEMP - touch $TEMP - fi - - java $1 -Dlog4j.configuration=$LCF org.apache.log4j.test.PrintProperties | sort > $TEMP - - check witness/getOptions.$TEST $TEMP; echo "OK." -} -# ================================================== - - -declare -i TEST - -function createProperties { - echo -n "" > $LCF - #if [ -n "$1" ]; then - # lecho "log4j.configurator=$1" - #fi - lecho "log4j.appender.f=org.apache.log4j.FileAppender" - lecho "log4j.appender.f.File=$TEMP" - lecho "log4j.appender.f.Append=false" - lecho "log4j.appender.f.layout=org.apache.log4j.PatternLayout " - lecho "log4j.appender.f.layout.ConversionPattern=%m%n" - lecho "log4j.rootCategory=DEBUG, f" - lecho "log4j.category.org.apache.log4j=INFO, f" -} - -createProperties - -TEST=1 -if [ $TEST -ge $start ]; then - testGetOptions -fi - -rm $LCF diff --git a/src/java/org/apache/log4j/test/l7d b/src/java/org/apache/log4j/test/l7d deleted file mode 100644 index 2743b4342e..0000000000 --- a/src/java/org/apache/log4j/test/l7d +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# Read the .functions file -. .functions - -declare -i start=$1 - -# ------------------------------------------------ -function testL7D { - configFile=$1 - lang=$2 - country=$3 - - echo -n "L7D test $TEST - " - java org.apache.log4j.test.L7D $configFile $lang $country - - check witness/l7d.$TEST $TEMP; echo " OK." -} -# ------------------------------------------------ - -declare -i TEST - - -TEST=1; -if [ $TEST -ge $start ]; then - D_FLAG=$DEF_DEBUG - echo "log4j.rootCategory=INFO, testAppender" > $LCF - lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender" - lecho "log4j.appender.testAppender.File=$TEMP" - lecho "log4j.appender.testAppender.Append=false" - lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout" - lecho "log4j.appender.testAppender.layout.ConversionPattern=T$TEST %5p - %m%n" - testL7D $LCF en US -fi diff --git a/src/java/org/apache/log4j/test/multipleAppenders b/src/java/org/apache/log4j/test/multipleAppenders deleted file mode 100755 index 02aeee89e4..0000000000 --- a/src/java/org/apache/log4j/test/multipleAppenders +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Read the .functions file -. .functions - -setPERL - -echo "log4j.rootCategory=DEBUG, A1, A2" > $LCF -lecho "log4j.appender.A1=org.apache.log4j.FileAppender" -lecho "log4j.appender.A1.File=$TEMP" -lecho "log4j.appender.A1.Append=false" -lecho "log4j.appender.A1.layout=org.apache.log4j.TTCCLayout" -lecho "log4j.appender.A1.layout.ContextPrinting=false" -lecho "log4j.appender.A1.layout.ThreadPrinting=xx" - -lecho "log4j.appender.A2=org.apache.log4j.FileAppender" -lecho "log4j.appender.A2.File=$TEMP.1" -lecho "log4j.appender.A2.Append=false" -lecho "log4j.appender.A2.layout=org.apache.log4j.TTCCLayout" -lecho "log4j.appender.A2.layout.ContextPrinting=false" -lecho "log4j.appender.A2.layout.ThreadPrinting=true" - -echo -n " MultipleAppenders test $TEST - " -java $D_FLAG org.apache.log4j.test.MultipleAppenders $LCF - diff --git a/src/java/org/apache/log4j/test/mycat b/src/java/org/apache/log4j/test/mycat deleted file mode 100644 index e954d30c85..0000000000 --- a/src/java/org/apache/log4j/test/mycat +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# Read the .functions file -. .functions - -# If set, allows to skip tests -declare -i start=$1 - - -declare -i TEST - -function testSubclassing { - - echo -n "Subclassing test $TEST - " - java examples.subclass.MyLoggerTest $LCF - check witness/mycat.$TEST $TEMP; echo "OK." -} - - -TEST=1 -if [ $TEST -ge $start ]; then - echo "log4j.rootCategory=DEBUG, A1" > $LCF - lecho "log4j.appender.A1=org.apache.log4j.FileAppender" - lecho "log4j.appender.A1.File=$TEMP" - lecho "log4j.appender.A1.Append=false" - lecho "log4j.appender.A1.layout=org.apache.log4j.PatternLayout " - lecho "log4j.appender.A1.layout.ConversionPattern=%c %p - %m%n" - testSubclassing -fi - -rm $TEMP > /dev/null -TEST=2 -if [ $TEST -ge $start ]; then - echo "The next test outputs error messages." - echo "log4j.rootCategory=DEBUG, A1" > $LCF - lecho "log4j.appender.A1=org.apache.log4j.FileAppender" - lecho "log4j.appender.A1.File=$TEMP" - lecho "log4j.appender.A1.Append=false" - lecho "log4j.appender.A1.layout=org.apache.log4j.PatternLayout " - lecho "log4j.appender.A1.layout.ConversionPattern=%c %p - %m%n" - lecho "log4j.category.some.cat=DEBUG" - testSubclassing -fi - -rm $TEMP > /dev/null -TEST=3 -if [ $TEST -ge $start ]; then - echo "log4j.rootCategory=DEBUG, A1" > $LCF - lecho "log4j.appender.A1=org.apache.log4j.FileAppender" - lecho "log4j.appender.A1.File=$TEMP" - lecho "log4j.appender.A1.Append=false" - lecho "log4j.appender.A1.layout=org.apache.log4j.PatternLayout " - lecho "log4j.appender.A1.layout.ConversionPattern=%c %p - %m%n" - lecho "log4j.category.some.cat=DEBUG" - lecho "log4j.loggerFactory=examples.subclass.MyLoggerFactory" - testSubclassing -fi diff --git a/src/java/org/apache/log4j/test/package.html b/src/java/org/apache/log4j/test/package.html deleted file mode 100644 index 6081c183b2..0000000000 --- a/src/java/org/apache/log4j/test/package.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - -

    Package used to test the functionality of log4j. - -


    -
    - -Last modified: Tue Nov 16 20:26:36 MET 1999 - - diff --git a/src/java/org/apache/log4j/test/propConfig b/src/java/org/apache/log4j/test/propConfig deleted file mode 100644 index 447e0fab6d..0000000000 --- a/src/java/org/apache/log4j/test/propConfig +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -# Read the .functions file -. .functions - -# If set, allows to skip tests -declare -i start=$1 - -# ================================================== -function testPropConfig { - echo -n "PropertyConfiguratorInterface test $TEST - " - - if [ -e $TEMP ]; then - #echo "Deleting $TEMP." - rm $TEMP - touch $TEMP - fi - - java $* org.apache.log4j.test.DefaultInit > $TEMP - check witness/propCfg.$TEST $TEMP; echo "OK." -} -# ================================================== - - -declare -i TEST - -LCF=log4j.properties - -function createProperties { - echo "" > $LCF - lecho "log4j.rootLogger=DEBUG, A1" - lecho "log4j.appender.A1=org.apache.log4j.FileAppender" - lecho "log4j.appender.A1.File=$TEMP" - lecho "log4j.appender.A1.Append=false" - lecho "log4j.appender.A1.layout=org.apache.log4j.PatternLayout " - lecho "log4j.appender.A1.layout.ConversionPattern=%m%n" -} - -createProperties - -TEST=1 -if [ $TEST -ge $start ]; then - testPropConfig -fi - -#org.apache.log4j.test.SysoutConfigurator - -TEST=2 -if [ $TEST -ge $start ]; then - testPropConfig -Dlog4j=debug -Dlog4j.configuration=file:$LCF -Dlog4j.configuratorClass=org.apache.log4j.test.SysoutConfigurator -fi - - -rm $LCF diff --git a/src/java/org/apache/log4j/test/roTest b/src/java/org/apache/log4j/test/roTest deleted file mode 100644 index 94cb9f5aa2..0000000000 --- a/src/java/org/apache/log4j/test/roTest +++ /dev/null @@ -1,30 +0,0 @@ - -# A regression test to check the option reading code and print formats. - -# Read the .functions file -. .functions - -A1_PREFIX="log4j.appender.A1" - -# ---------------------------------------------------------------------- -function testRO { - confFile=$1 - - echo -n "ReadOnlyFile test $TEST - " - java -Dlog4j.configDebug org.apache.log4j.test.ROFile $confFile - -} - -touch readonly -chmod -w readonly - -echo "$A1_PREFIX=org.apache.log4j.RollingFileAppender" > $LCF -lecho "$A1_PREFIX.Append=true" -lecho "$A1_PREFIX.File=readonly" -lecho "$A1_PREFIX.layout=org.apache.log4j.PatternLayout" -lecho "$A1_PREFIX.layout.ConversionPattern=%p [%t] = %m" -lecho "$ROOT_PREFIX=DEBUG, A1" -testRO $LCF - -rm -f readonly - diff --git a/src/java/org/apache/log4j/test/runAll b/src/java/org/apache/log4j/test/runAll deleted file mode 100644 index 0b44b94185..0000000000 --- a/src/java/org/apache/log4j/test/runAll +++ /dev/null @@ -1,19 +0,0 @@ - -#!/bin/sh - -. .functions - -deleteFile log4j.properties - -./shallow || die "shallow test FAILED." -./defaultInit || die "defaultInit test FAILED." -./propConfig || die "propConfig test FAILED." -./getOptions || die "getOptions test FAILED." -./domTest || die "domTest FAILED." -./multipleAppenders || die "multipleAppenders test FAILED." -./confParsing || die "confParsing test FAILED." -#./customCategory || die "customCategory test FAILED." -./mycat || die "mycat test FAILED." -./l7d || die "L7D test FAILED." -./fqcn || die "FQCN test FAILED." -#./extSupport || die "Extension support test FAILED." diff --git a/src/java/org/apache/log4j/test/serialization/README b/src/java/org/apache/log4j/test/serialization/README deleted file mode 100644 index 4c8b23e435..0000000000 --- a/src/java/org/apache/log4j/test/serialization/README +++ /dev/null @@ -1,36 +0,0 @@ - ======================= - Serialization unit test - ======================= - -Running the serialization test is not for the faint of heart. It is -complicated because we are trying to read or write two different -versions of the same class. This requires unusual classloading -techniques. - -Compiling -========= - -step1) - -The file SerializationUT.java must be compiled with only the Java -rt.jar and junit.jar on the class path. The compilation must be -carried out from the directory where this README file is located. - -step2) - -Compile the files T/T113.java and T/T12.java. See the files -compile.sample.bat and compile.sample.sh under the T/ -directory. Compilations must be carried in T/. - -Running -======= -Tests use the same classpath and are run as follows: - - 1) cd to $LOG4J_HOME/src/java/org/apache/log4j/test/serialization - - This is where this README file is located. - - 2) Run - - java junit.textui.TestRunner SerializationUT - diff --git a/src/java/org/apache/log4j/test/serialization/SerializationUT.java b/src/java/org/apache/log4j/test/serialization/SerializationUT.java deleted file mode 100644 index 5bf529a298..0000000000 --- a/src/java/org/apache/log4j/test/serialization/SerializationUT.java +++ /dev/null @@ -1,226 +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.txt file. */ - -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.framework.Test; -import java.util.Hashtable; - -import java.net.URL; -import java.net.URLClassLoader; -import java.lang.reflect.Method; - -/** - The SerializationUnitTest checks whether the {@link LoggingEvent} - objects are compatible across different log4j versions. - - @author Ceki Gülcü - -*/ -public class SerializationUT extends TestCase { - - // String categoryName - // String ndc - // boolan ndcLookupRequired - // String renderedMessage - // String threadName - // long timeStamp - - - static URLClassLoader classLoader113; - static Class class113; - static Object o113; - static Method serMethod113; - static Method deserMethod113; - - static URLClassLoader classLoader12a7; - static Class class12a7; - static Object o12a7; - static Method serMethod12a7; - static Method deserMethod12a7; - - public SerializationUT(String name) { - super(name); - } - - public - void setUp() throws Exception { - - try { - URL urlLocal = new URL("file:T/"); - - URL url113 = new URL("file:T/log4j-1.1.3.jar"); - - classLoader113 = new URLClassLoader(new URL[] {urlLocal, url113}); - class113 = classLoader113.loadClass("T113"); - o113 = class113.newInstance(); - serMethod113 = class113.getMethod("serialize", - new Class[] {java.util.Hashtable.class}); - - deserMethod113 = class113.getMethod("deserialize", - new Class[] {byte[].class}); - - - URL url2a7 = new URL("file:T/log4j-1.2alpha7.jar"); - - classLoader12a7 = new URLClassLoader(new URL[] {urlLocal, url2a7}); - class12a7 = classLoader12a7.loadClass("T12"); - o12a7 = class12a7.newInstance(); - serMethod12a7 = class12a7.getMethod("serialize", - new Class[] {java.util.Hashtable.class}); - deserMethod12a7 = class12a7.getMethod("deserialize", - new Class[] {byte[].class}); - } catch(Exception e) { - e.printStackTrace(); - throw e; - } - - System.out.println("---Exiting setup"); - } - - public - void tearDown() { - } - - - /** - Test writing in 1.1.3 and reading from 1.1.3. Here we are testing - the test. */ - public - void test1() throws Exception { - - Hashtable inHt = new Hashtable(); - Hashtable witness = new Hashtable(); - - inHt.put("categoryName", "a.b.c"); - inHt.put("priorityStr", "DEBUG"); - inHt.put("message", "hello"); - - witness.put("categoryName", "a.b.c"); - witness.put("priorityStr", "DEBUG"); - witness.put("renderedMessage", "hello"); - - byte[] buf = (byte[]) serMethod113.invoke(o113, new Object[] {inHt}); - - Hashtable outHt = (Hashtable) deserMethod113.invoke(o113, new Object[] {buf}); - - System.out.println("witness"+witness); - System.out.println("outHt "+outHt); - - assertEquals(witness, outHt); - } - - /** - Test writing 1.2 and reading from 1.2. Here we are testing the test. - */ - public - void test2() throws Exception { - - Hashtable inHt = new Hashtable(); - Hashtable witness = new Hashtable(); - - inHt.put("categoryName", "a.b.c"); - inHt.put("priorityStr", "DEBUG"); - inHt.put("message", "hello"); - - witness.put("categoryName", "a.b.c"); - witness.put("priorityStr", "DEBUG"); - witness.put("renderedMessage", "hello"); - - byte[] buf = (byte[]) serMethod12a7.invoke(o12a7, new Object[] {inHt}); - - Hashtable outHt = (Hashtable) deserMethod12a7.invoke(o12a7, new Object[] {buf}); - assertEquals(witness, outHt); - } - - /** - Test writing 1.1.3 and reading from 1.2. - */ - public - void test3() throws Exception { - - Hashtable inHt = new Hashtable(); - Hashtable witness = new Hashtable(); - - inHt.put("categoryName", "a.b.c"); - inHt.put("priorityStr", "DEBUG"); - inHt.put("message", "hello"); - - witness.put("categoryName", "a.b.c"); - witness.put("priorityStr", "DEBUG"); - witness.put("renderedMessage", "hello"); - byte[] buf = (byte[]) serMethod113.invoke(o113, new Object[] {inHt}); - Hashtable outHt = (Hashtable) deserMethod12a7.invoke(o12a7, new Object[] {buf}); - assertEquals(witness, outHt); - } - - /** - Test writing 1.2 and reading from 1.1.3. - */ - public - void test4() throws Exception { - - Hashtable inHt = new Hashtable(); - Hashtable witness = new Hashtable(); - - inHt.put("categoryName", "a.b.c"); - inHt.put("priorityStr", "DEBUG"); - inHt.put("message", "hello"); - Exception e = new ComparableException("test4"); - inHt.put("throwable", e); - - witness.put("categoryName", "a.b.c"); - witness.put("priorityStr", "DEBUG"); - witness.put("renderedMessage", "hello"); - witness.put("throwable", e); - - byte[] buf = (byte[]) serMethod12a7.invoke(o12a7, new Object[] {inHt}); - - Hashtable outHt = (Hashtable) deserMethod113.invoke(o113, new Object[] {buf}); - - //System.out.println("witness"+witness); - //System.out.println("outHt "+outHt); - - assertEquals(witness, outHt); - } - - - public - static - Test suite() { - TestSuite suite = new TestSuite(); - suite.addTest(new SerializationUT("test1")); - suite.addTest(new SerializationUT("test2")); - suite.addTest(new SerializationUT("test3")); - suite.addTest(new SerializationUT("test4")); - return suite; - } -} - -class ComparableException extends Exception { - - public ComparableException(String msg) { - super(msg); - } - - public boolean equals(Object o) { - System.out.println("ComparableException.equals called."); - if(!(o instanceof ComparableException)) - return false; - - ComparableException r = (ComparableException) o; - - if(r.getMessage() == null) { - if(getMessage() != null) - return false; - } else if(!r.getMessage().equals(getMessage())) { - return false; - } - return true; - } -} - diff --git a/src/java/org/apache/log4j/test/serialization/T/T113.java b/src/java/org/apache/log4j/test/serialization/T/T113.java deleted file mode 100644 index 746123a884..0000000000 --- a/src/java/org/apache/log4j/test/serialization/T/T113.java +++ /dev/null @@ -1,72 +0,0 @@ - -import java.io.*; - -import org.apache.log4j.Category; -import org.apache.log4j.Priority; -import org.apache.log4j.spi.LoggingEvent; - -import java.util.Hashtable; - - -// String categoryName -// String ndc -// boolan ndcLookupRequired -// String renderedMessage -// String threadName -// long timeStamp - -// LocationInfo -// ThrowableInformation ti. -public class T113 { - - public - byte[] serialize(Hashtable ht) { - try { - Category category = Category.getInstance((String) ht.get("categoryName")); - - - LoggingEvent event = new LoggingEvent("org.apache.log4j.Category", - category, - Priority.toPriority((String)ht.get("priorityStr")), - ht.get("message"), - (Throwable) ht.get("throwable")); - event.getThreadName(); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(event); - oos.flush(); - return baos.toByteArray(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public - Hashtable deserialize(byte[] buf) { - try { - System.out.println("deserialize called."); - ByteArrayInputStream bais = new ByteArrayInputStream(buf); - ObjectInputStream si = new ObjectInputStream(bais); - LoggingEvent event = (LoggingEvent) si.readObject(); - System.out.println("Desrialization looks successful."); - - return eventToHashtable(event); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - Hashtable eventToHashtable(LoggingEvent event) { - Hashtable ht = new Hashtable(); - ht.put("categoryName", event.categoryName); - ht.put("renderedMessage", event.getRenderedMessage()); - ht.put("priorityStr", event.priority.toString()); - ht.put("throwableInfo", event.getThrowableInformation()); - return ht; - } - -} - diff --git a/src/java/org/apache/log4j/test/serialization/T/T12.java b/src/java/org/apache/log4j/test/serialization/T/T12.java deleted file mode 100644 index 9ccf3e1204..0000000000 --- a/src/java/org/apache/log4j/test/serialization/T/T12.java +++ /dev/null @@ -1,71 +0,0 @@ - -import java.io.*; - -import org.apache.log4j.*; -import org.apache.log4j.spi.LoggingEvent; - -import java.util.Hashtable; - - -// String categoryName -// String ndc -// boolan ndcLookupRequired -// String renderedMessage -// String threadName -// long timeStamp - -// LocationInfo -// ThrowableInformation ti. -public class T12 { - - public - byte[] serialize(Hashtable ht) { - try { - Category category = Category.getInstance((String) ht.get("categoryName")); - - - LoggingEvent event = new LoggingEvent("org.apache.log4j.Category", - category, - Level.toLevel((String)ht.get("priorityStr")), - ht.get("message"), - (Throwable) ht.get("throwable")); - event.getThreadName(); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(event); - oos.flush(); - return baos.toByteArray(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public - Hashtable deserialize(byte[] buf) { - try { - System.out.println("deserialize called."); - ByteArrayInputStream bais = new ByteArrayInputStream(buf); - ObjectInputStream si = new ObjectInputStream(bais); - LoggingEvent event = (LoggingEvent) si.readObject(); - System.out.println("Desrialization looks successful."); - - return eventToHashtable(event); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - Hashtable eventToHashtable(LoggingEvent event) { - Hashtable ht = new Hashtable(); - ht.put("categoryName", event.categoryName); - ht.put("renderedMessage", event.getRenderedMessage()); - ht.put("priorityStr", event.level.toString()); - ht.put("throwableInfo", event.getThrowableInformation()); - return ht; - } - -} - diff --git a/src/java/org/apache/log4j/test/serialization/T/compile.sample.bat b/src/java/org/apache/log4j/test/serialization/T/compile.sample.bat deleted file mode 100755 index bc1e69762f..0000000000 --- a/src/java/org/apache/log4j/test/serialization/T/compile.sample.bat +++ /dev/null @@ -1,15 +0,0 @@ - -@REM This little script compiles the files T113.java and T12.java with -@REM different classpaths. -@REM -@REM You have to set the classpath to point to rt.jar depending on your -@REM environment. - -set CLASSPATH=.;%JAVA_HOME%\jre\lib\rt.jar;log4j-1.1.3.jar - -echo [%CLASSPATH%] - -javac T113.java - -set CLASSPATH=.;%JAVA_HOME%\jre\lib\rt.jar;log4j-1.2alpha7.jar -javac -deprecation T12.java \ No newline at end of file diff --git a/src/java/org/apache/log4j/test/serialization/T/compile.sample.sh b/src/java/org/apache/log4j/test/serialization/T/compile.sample.sh deleted file mode 100644 index 1af7a4ee60..0000000000 --- a/src/java/org/apache/log4j/test/serialization/T/compile.sample.sh +++ /dev/null @@ -1,12 +0,0 @@ - -# This little Unix script compiles the files T113.java and T12.java -# with different classpaths. - -# You have to set the classpath to point to rt.jar depending on your -# environment. - -CLASSPATH=".:$JAVA_HOME/jre/lib/rt.jar:log4j-1.1.3.jar" -javac -deprecation T113.java - -CLASSPATH=".:$JAVA_HOME/jre/lib/rt.jar:log4j-1.2alpha7.jar" -javac -deprecation T12.java \ No newline at end of file diff --git a/src/java/org/apache/log4j/test/shallow b/src/java/org/apache/log4j/test/shallow deleted file mode 100644 index 3b416f4271..0000000000 --- a/src/java/org/apache/log4j/test/shallow +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash - -# A regression test to check the option reading code and print formats. - -# Read the .functions file -. .functions - -A1_PREFIX="log4j.appender.A1" -A2_PREFIX="log4j.appender.A2" - -PORT=12345 -DELAY=5000 - -# If set, allows to skip tests -declare -i start=$1 - -# ---------------------------------------------------------------------- -function testShallow { - layout=$1 - - echo -n "Shallow test $TEST - " - runShallow $LCF - $PERL filter.pl $TEMP.A1 $OUTPUT.A1 Shallow $layout - $PERL filter.pl $TEMP.A2 $OUTPUT.A2 Shallow $layout - if [ $? != 0 ]; then - echo "The output is not in expected format. See the file [$OUTPUT]." - exit 1 -fi - check witness/shallow.A1.$TEST $OUTPUT.A1; echo -n "-" - check witness/shallow.A2.$TEST $OUTPUT.A2; echo " OK." -} -# +============================================ -# Make a config file for the shallow test -# +============================================ -function makeShallowConfigFile { - logFile=$1 - rootPriority=$2 - shallowPriority=$3 - layoutClass=$4 - dateFormat=$5 - additivity=$6 - - echo "$A1_PREFIX=org.apache.log4j.FileAppender" > $LCF - echo "$A1_PREFIX.Append=false" >> $LCF - echo "$A1_PREFIX.layout=$layoutClass" >> $LCF - echo "$A1_PREFIX.layout.DateFormat=$dateFormat" >> $LCF - - echo "$A2_PREFIX=org.apache.log4j.FileAppender" >> $LCF - echo "$A2_PREFIX.append=false" >> $LCF - echo "$A2_PREFIX.layout=$layoutClass" >> $LCF - echo "$A2_PREFIX.layout.DateFormat=$dateFormat" >> $LCF - - - echo "$A1_PREFIX.File=$logFile.A1" >> $LCF - echo "$A2_PREFIX.File=$logFile.A2" >> $LCF - - echo "$ROOT_PREFIX=$rootPriority, A1" >> $LCF - echo "log4j.logger.org.apache.log4j.test.Shallow=$shallowPriority, A2" >> $LCF - - if [ -n "$additivity" ]; then - echo "log4j.additivity.org.apache.log4j.test.Shallow=$additivity" >> $LCF - fi - -} -# ---------------------------------------------------------------------- -function runShallow() { - confFile=$1 - #java -Dlog4j.configDebug org.apache.log4j.test.Shallow $confFile - java org.apache.log4j.test.Shallow $confFile -} -# ---------------------------------------------------------------------- -function testSocket { - layout=$1 - echo -n "Shallow test $TEST - " - runShallow $LCF - sleep 8 - $PERL filter.pl $TEMP $OUTPUT Shallow $layout - check witness/shallow.$TEST $OUTPUT; echo " Test PASSED O.K." -} -# =============================================================== - -setPERL - -declare -i TEST - -TEST=1 -if [ $TEST -ge $start ]; then - - makeShallowConfigFile $TEMP DEBUG " " $SIMPLE - testShallow LINE_NUMBER -fi - - -TEST=2 -if [ $TEST -ge $start ]; then - makeShallowConfigFile $TEMP INFO DEBUG $SIMPLE xxx true - testShallow LINE_NUMBER -fi - -TEST=3 -if [ $TEST -ge $start ]; then - makeShallowConfigFile $TEMP DEBUG " " $TTCC NULL true - testShallow LINE_NUMBER -fi - -TEST=4 -if [ $TEST -ge $start ]; then - makeShallowConfigFile $TEMP INFO " " $TTCC RELATIVE - testShallow RELATIVE -fi - -TEST=5 -if [ $TEST -ge $start ]; then - makeShallowConfigFile $TEMP DEBUG WARN $TTCC ABSOLUTE - testShallow ABSOLUTE -fi - -TEST=6 -if [ $TEST -ge $start ]; then - makeShallowConfigFile $TEMP DEBUG WARN $TTCC DATE - testShallow DATE -fi - -TEST=7 -if [ $TEST -ge $start ]; then - makeShallowConfigFile $TEMP DEBUG WARN $TTCC DATE false - testShallow DATE -fi - -TEST=8 -if [ $TEST -ge $start ]; then - makeShallowConfigFile $TEMP DEBUG DEBUG $TTCC DATE false - echo "$A1_PREFIX.Threshold=WARN" >> $LCF - testShallow DATE -fi - - diff --git a/src/java/org/apache/log4j/test/stressAsyncAppender.pl b/src/java/org/apache/log4j/test/stressAsyncAppender.pl deleted file mode 100644 index aeb99a557a..0000000000 --- a/src/java/org/apache/log4j/test/stressAsyncAppender.pl +++ /dev/null @@ -1,60 +0,0 @@ - -# Copyright 2000, Ceki Gulcu. All rights reserved. - -package SAA; - -$SAA::size = 0; -$SAA::sizeAvg = 0; -$n = 0; -$expected = 0; -while() { - my @ndc; - - #print $_; - $SAA::sizeAvg = ($SAA::sizeAvg*$n + $SAA::size)/(++$n); - if($n % 10000 == 0) { - print "n=$n, size=$SAA::size, sizeAverage: $SAA::sizeAvg,\n"; - } - - #25607 [Thread-17] DEBUG AsyncAppender - About to put new event in buffer. - if(/^\d+\s+\[(.+)\] DEBUG\s+(.*)\s-\s(.*)$/) { - $thread = $1; - $cat = $2; - $msg = $3; - - #print "cat is [$cat]\n"; - - if($cat =~ /AsyncAppender/) { - if($msg =~ /About to put new event in buffer./) { - #print "Got: About to put new event in buffer.\n"; - $SAA::size++; - } elsif ($msg =~ /Notifying dispatcher to process events./) { - if($SAA::size != 1) { - die "size not 1 ($SAA::size), as dispatcher is notified."; - } - } - } elsif ($cat =~ /Dispatcher/) { - if($msg =~ /Waiting for new event to dispatch./) { - if($SAA::size != 0) { - die "size not 0 ($SAA::size), as dispatcher waits for new events."; - } - } elsif($msg =~ /About to get new event./) { - #print "--------------------Got: About to get new event.\n"; - $SAA::size--; - if($SAA::size < 0) { - die "Negative buffer size: $SAA::size\n"; - } - } - } elsif ($cat =~ root) { - if($msg =~ /Message number (\d+)/) { - $new = $1; - if($expected != $new) { - die "expected $expected, but got $new\n"; - } else { - $expected = $new+1; - } - } - - } - } -} diff --git a/src/java/org/apache/log4j/test/stressCategory b/src/java/org/apache/log4j/test/stressCategory deleted file mode 100644 index 30833c0c9d..0000000000 --- a/src/java/org/apache/log4j/test/stressCategory +++ /dev/null @@ -1,899 +0,0 @@ -# ==================================================== -function stressTest { - java org.apache.log4j.StressCategory $* - if [ "$?" = "0" ] - then - echo "Passed category stress test $index." - index=$index+1 - else - echo "Failed stress test with arguments [$*]" - exit - fi -} -# ==================================================== - -declare -i index -index=1 - -stressTest a b -stressTest a a.b -# -stressTest a b c -stressTest a b a.c -stressTest a b b.c -stressTest a a.b c -stressTest a a.b a.c -stressTest a a.b a.b.c -# -stressTest a b c d -stressTest a b c a.d -stressTest a b c b.d -stressTest a b c c.d -stressTest a b a.c d -stressTest a b a.c a.d -stressTest a b a.c b.d -stressTest a b a.c a.c.d -stressTest a b b.c d -stressTest a b b.c a.d -stressTest a b b.c b.d -stressTest a b b.c b.c.d -stressTest a a.b c d -stressTest a a.b c a.d -stressTest a a.b c a.b.d -stressTest a a.b c c.d -stressTest a a.b a.c d -stressTest a a.b a.c a.d -stressTest a a.b a.c a.b.d -stressTest a a.b a.c a.c.d -stressTest a a.b a.b.c d -stressTest a a.b a.b.c a.d -stressTest a a.b a.b.c a.b.d -stressTest a a.b a.b.c a.b.c.d -# -stressTest a b c d e -stressTest a b c d a.e -stressTest a b c d b.e -stressTest a b c d c.e -stressTest a b c d d.e -stressTest a b c a.d e -stressTest a b c a.d a.e -stressTest a b c a.d b.e -stressTest a b c a.d c.e -stressTest a b c a.d a.d.e -stressTest a b c b.d e -stressTest a b c b.d a.e -stressTest a b c b.d b.e -stressTest a b c b.d c.e -stressTest a b c b.d b.d.e -stressTest a b c c.d e -stressTest a b c c.d a.e -stressTest a b c c.d b.e -stressTest a b c c.d c.e -stressTest a b c c.d c.d.e -stressTest a b a.c d e -stressTest a b a.c d a.e -stressTest a b a.c d b.e -stressTest a b a.c d a.c.e -stressTest a b a.c d d.e -stressTest a b a.c a.d e -stressTest a b a.c a.d a.e -stressTest a b a.c a.d b.e -stressTest a b a.c a.d a.c.e -stressTest a b a.c a.d a.d.e -stressTest a b a.c b.d e -stressTest a b a.c b.d a.e -stressTest a b a.c b.d b.e -stressTest a b a.c b.d a.c.e -stressTest a b a.c b.d b.d.e -stressTest a b a.c a.c.d e -stressTest a b a.c a.c.d a.e -stressTest a b a.c a.c.d b.e -stressTest a b a.c a.c.d a.c.e -stressTest a b a.c a.c.d a.c.d.e -stressTest a b b.c d e -stressTest a b b.c d a.e -stressTest a b b.c d b.e -stressTest a b b.c d b.c.e -stressTest a b b.c d d.e -stressTest a b b.c a.d e -stressTest a b b.c a.d a.e -stressTest a b b.c a.d b.e -stressTest a b b.c a.d b.c.e -stressTest a b b.c a.d a.d.e -stressTest a b b.c b.d e -stressTest a b b.c b.d a.e -stressTest a b b.c b.d b.e -stressTest a b b.c b.d b.c.e -stressTest a b b.c b.d b.d.e -stressTest a b b.c b.c.d e -stressTest a b b.c b.c.d a.e -stressTest a b b.c b.c.d b.e -stressTest a b b.c b.c.d b.c.e -stressTest a b b.c b.c.d b.c.d.e -stressTest a a.b c d e -stressTest a a.b c d a.e -stressTest a a.b c d a.b.e -stressTest a a.b c d c.e -stressTest a a.b c d d.e -stressTest a a.b c a.d e -stressTest a a.b c a.d a.e -stressTest a a.b c a.d a.b.e -stressTest a a.b c a.d c.e -stressTest a a.b c a.d a.d.e -stressTest a a.b c a.b.d e -stressTest a a.b c a.b.d a.e -stressTest a a.b c a.b.d a.b.e -stressTest a a.b c a.b.d c.e -stressTest a a.b c a.b.d a.b.d.e -stressTest a a.b c c.d e -stressTest a a.b c c.d a.e -stressTest a a.b c c.d a.b.e -stressTest a a.b c c.d c.e -stressTest a a.b c c.d c.d.e -stressTest a a.b a.c d e -stressTest a a.b a.c d a.e -stressTest a a.b a.c d a.b.e -stressTest a a.b a.c d a.c.e -stressTest a a.b a.c d d.e -stressTest a a.b a.c a.d e -stressTest a a.b a.c a.d a.e -stressTest a a.b a.c a.d a.b.e -stressTest a a.b a.c a.d a.c.e -stressTest a a.b a.c a.d a.d.e -stressTest a a.b a.c a.b.d e -stressTest a a.b a.c a.b.d a.e -stressTest a a.b a.c a.b.d a.b.e -stressTest a a.b a.c a.b.d a.c.e -stressTest a a.b a.c a.b.d a.b.d.e -stressTest a a.b a.c a.c.d e -stressTest a a.b a.c a.c.d a.e -stressTest a a.b a.c a.c.d a.b.e -stressTest a a.b a.c a.c.d a.c.e -stressTest a a.b a.c a.c.d a.c.d.e -stressTest a a.b a.b.c d e -stressTest a a.b a.b.c d a.e -stressTest a a.b a.b.c d a.b.e -stressTest a a.b a.b.c d a.b.c.e -stressTest a a.b a.b.c d d.e -stressTest a a.b a.b.c a.d e -stressTest a a.b a.b.c a.d a.e -stressTest a a.b a.b.c a.d a.b.e -stressTest a a.b a.b.c a.d a.b.c.e -stressTest a a.b a.b.c a.d a.d.e -stressTest a a.b a.b.c a.b.d e -stressTest a a.b a.b.c a.b.d a.e -stressTest a a.b a.b.c a.b.d a.b.e -stressTest a a.b a.b.c a.b.d a.b.c.e -stressTest a a.b a.b.c a.b.d a.b.d.e -stressTest a a.b a.b.c a.b.c.d e -stressTest a a.b a.b.c a.b.c.d a.e -stressTest a a.b a.b.c a.b.c.d a.b.e -stressTest a a.b a.b.c a.b.c.d a.b.c.e -stressTest a a.b a.b.c a.b.c.d a.b.c.d.e -# -stressTest a b c d e f -stressTest a b c d e a.f -stressTest a b c d e b.f -stressTest a b c d e c.f -stressTest a b c d e d.f -stressTest a b c d e e.f -stressTest a b c d a.e f -stressTest a b c d a.e a.f -stressTest a b c d a.e b.f -stressTest a b c d a.e c.f -stressTest a b c d a.e d.f -stressTest a b c d a.e a.e.f -stressTest a b c d b.e f -stressTest a b c d b.e a.f -stressTest a b c d b.e b.f -stressTest a b c d b.e c.f -stressTest a b c d b.e d.f -stressTest a b c d b.e b.e.f -stressTest a b c d c.e f -stressTest a b c d c.e a.f -stressTest a b c d c.e b.f -stressTest a b c d c.e c.f -stressTest a b c d c.e d.f -stressTest a b c d c.e c.e.f -stressTest a b c d d.e f -stressTest a b c d d.e a.f -stressTest a b c d d.e b.f -stressTest a b c d d.e c.f -stressTest a b c d d.e d.f -stressTest a b c d d.e d.e.f -stressTest a b c a.d e f -stressTest a b c a.d e a.f -stressTest a b c a.d e b.f -stressTest a b c a.d e c.f -stressTest a b c a.d e a.d.f -stressTest a b c a.d e e.f -stressTest a b c a.d a.e f -stressTest a b c a.d a.e a.f -stressTest a b c a.d a.e b.f -stressTest a b c a.d a.e c.f -stressTest a b c a.d a.e a.d.f -stressTest a b c a.d a.e a.e.f -stressTest a b c a.d b.e f -stressTest a b c a.d b.e a.f -stressTest a b c a.d b.e b.f -stressTest a b c a.d b.e c.f -stressTest a b c a.d b.e a.d.f -stressTest a b c a.d b.e b.e.f -stressTest a b c a.d c.e f -stressTest a b c a.d c.e a.f -stressTest a b c a.d c.e b.f -stressTest a b c a.d c.e c.f -stressTest a b c a.d c.e a.d.f -stressTest a b c a.d c.e c.e.f -stressTest a b c a.d a.d.e f -stressTest a b c a.d a.d.e a.f -stressTest a b c a.d a.d.e b.f -stressTest a b c a.d a.d.e c.f -stressTest a b c a.d a.d.e a.d.f -stressTest a b c a.d a.d.e a.d.e.f -stressTest a b c b.d e f -stressTest a b c b.d e a.f -stressTest a b c b.d e b.f -stressTest a b c b.d e c.f -stressTest a b c b.d e b.d.f -stressTest a b c b.d e e.f -stressTest a b c b.d a.e f -stressTest a b c b.d a.e a.f -stressTest a b c b.d a.e b.f -stressTest a b c b.d a.e c.f -stressTest a b c b.d a.e b.d.f -stressTest a b c b.d a.e a.e.f -stressTest a b c b.d b.e f -stressTest a b c b.d b.e a.f -stressTest a b c b.d b.e b.f -stressTest a b c b.d b.e c.f -stressTest a b c b.d b.e b.d.f -stressTest a b c b.d b.e b.e.f -stressTest a b c b.d c.e f -stressTest a b c b.d c.e a.f -stressTest a b c b.d c.e b.f -stressTest a b c b.d c.e c.f -stressTest a b c b.d c.e b.d.f -stressTest a b c b.d c.e c.e.f -stressTest a b c b.d b.d.e f -stressTest a b c b.d b.d.e a.f -stressTest a b c b.d b.d.e b.f -stressTest a b c b.d b.d.e c.f -stressTest a b c b.d b.d.e b.d.f -stressTest a b c b.d b.d.e b.d.e.f -stressTest a b c c.d e f -stressTest a b c c.d e a.f -stressTest a b c c.d e b.f -stressTest a b c c.d e c.f -stressTest a b c c.d e c.d.f -stressTest a b c c.d e e.f -stressTest a b c c.d a.e f -stressTest a b c c.d a.e a.f -stressTest a b c c.d a.e b.f -stressTest a b c c.d a.e c.f -stressTest a b c c.d a.e c.d.f -stressTest a b c c.d a.e a.e.f -stressTest a b c c.d b.e f -stressTest a b c c.d b.e a.f -stressTest a b c c.d b.e b.f -stressTest a b c c.d b.e c.f -stressTest a b c c.d b.e c.d.f -stressTest a b c c.d b.e b.e.f -stressTest a b c c.d c.e f -stressTest a b c c.d c.e a.f -stressTest a b c c.d c.e b.f -stressTest a b c c.d c.e c.f -stressTest a b c c.d c.e c.d.f -stressTest a b c c.d c.e c.e.f -stressTest a b c c.d c.d.e f -stressTest a b c c.d c.d.e a.f -stressTest a b c c.d c.d.e b.f -stressTest a b c c.d c.d.e c.f -stressTest a b c c.d c.d.e c.d.f -stressTest a b c c.d c.d.e c.d.e.f -stressTest a b a.c d e f -stressTest a b a.c d e a.f -stressTest a b a.c d e b.f -stressTest a b a.c d e a.c.f -stressTest a b a.c d e d.f -stressTest a b a.c d e e.f -stressTest a b a.c d a.e f -stressTest a b a.c d a.e a.f -stressTest a b a.c d a.e b.f -stressTest a b a.c d a.e a.c.f -stressTest a b a.c d a.e d.f -stressTest a b a.c d a.e a.e.f -stressTest a b a.c d b.e f -stressTest a b a.c d b.e a.f -stressTest a b a.c d b.e b.f -stressTest a b a.c d b.e a.c.f -stressTest a b a.c d b.e d.f -stressTest a b a.c d b.e b.e.f -stressTest a b a.c d a.c.e f -stressTest a b a.c d a.c.e a.f -stressTest a b a.c d a.c.e b.f -stressTest a b a.c d a.c.e a.c.f -stressTest a b a.c d a.c.e d.f -stressTest a b a.c d a.c.e a.c.e.f -stressTest a b a.c d d.e f -stressTest a b a.c d d.e a.f -stressTest a b a.c d d.e b.f -stressTest a b a.c d d.e a.c.f -stressTest a b a.c d d.e d.f -stressTest a b a.c d d.e d.e.f -stressTest a b a.c a.d e f -stressTest a b a.c a.d e a.f -stressTest a b a.c a.d e b.f -stressTest a b a.c a.d e a.c.f -stressTest a b a.c a.d e a.d.f -stressTest a b a.c a.d e e.f -stressTest a b a.c a.d a.e f -stressTest a b a.c a.d a.e a.f -stressTest a b a.c a.d a.e b.f -stressTest a b a.c a.d a.e a.c.f -stressTest a b a.c a.d a.e a.d.f -stressTest a b a.c a.d a.e a.e.f -stressTest a b a.c a.d b.e f -stressTest a b a.c a.d b.e a.f -stressTest a b a.c a.d b.e b.f -stressTest a b a.c a.d b.e a.c.f -stressTest a b a.c a.d b.e a.d.f -stressTest a b a.c a.d b.e b.e.f -stressTest a b a.c a.d a.c.e f -stressTest a b a.c a.d a.c.e a.f -stressTest a b a.c a.d a.c.e b.f -stressTest a b a.c a.d a.c.e a.c.f -stressTest a b a.c a.d a.c.e a.d.f -stressTest a b a.c a.d a.c.e a.c.e.f -stressTest a b a.c a.d a.d.e f -stressTest a b a.c a.d a.d.e a.f -stressTest a b a.c a.d a.d.e b.f -stressTest a b a.c a.d a.d.e a.c.f -stressTest a b a.c a.d a.d.e a.d.f -stressTest a b a.c a.d a.d.e a.d.e.f -stressTest a b a.c b.d e f -stressTest a b a.c b.d e a.f -stressTest a b a.c b.d e b.f -stressTest a b a.c b.d e a.c.f -stressTest a b a.c b.d e b.d.f -stressTest a b a.c b.d e e.f -stressTest a b a.c b.d a.e f -stressTest a b a.c b.d a.e a.f -stressTest a b a.c b.d a.e b.f -stressTest a b a.c b.d a.e a.c.f -stressTest a b a.c b.d a.e b.d.f -stressTest a b a.c b.d a.e a.e.f -stressTest a b a.c b.d b.e f -stressTest a b a.c b.d b.e a.f -stressTest a b a.c b.d b.e b.f -stressTest a b a.c b.d b.e a.c.f -stressTest a b a.c b.d b.e b.d.f -stressTest a b a.c b.d b.e b.e.f -stressTest a b a.c b.d a.c.e f -stressTest a b a.c b.d a.c.e a.f -stressTest a b a.c b.d a.c.e b.f -stressTest a b a.c b.d a.c.e a.c.f -stressTest a b a.c b.d a.c.e b.d.f -stressTest a b a.c b.d a.c.e a.c.e.f -stressTest a b a.c b.d b.d.e f -stressTest a b a.c b.d b.d.e a.f -stressTest a b a.c b.d b.d.e b.f -stressTest a b a.c b.d b.d.e a.c.f -stressTest a b a.c b.d b.d.e b.d.f -stressTest a b a.c b.d b.d.e b.d.e.f -stressTest a b a.c a.c.d e f -stressTest a b a.c a.c.d e a.f -stressTest a b a.c a.c.d e b.f -stressTest a b a.c a.c.d e a.c.f -stressTest a b a.c a.c.d e a.c.d.f -stressTest a b a.c a.c.d e e.f -stressTest a b a.c a.c.d a.e f -stressTest a b a.c a.c.d a.e a.f -stressTest a b a.c a.c.d a.e b.f -stressTest a b a.c a.c.d a.e a.c.f -stressTest a b a.c a.c.d a.e a.c.d.f -stressTest a b a.c a.c.d a.e a.e.f -stressTest a b a.c a.c.d b.e f -stressTest a b a.c a.c.d b.e a.f -stressTest a b a.c a.c.d b.e b.f -stressTest a b a.c a.c.d b.e a.c.f -stressTest a b a.c a.c.d b.e a.c.d.f -stressTest a b a.c a.c.d b.e b.e.f -stressTest a b a.c a.c.d a.c.e f -stressTest a b a.c a.c.d a.c.e a.f -stressTest a b a.c a.c.d a.c.e b.f -stressTest a b a.c a.c.d a.c.e a.c.f -stressTest a b a.c a.c.d a.c.e a.c.d.f -stressTest a b a.c a.c.d a.c.e a.c.e.f -stressTest a b a.c a.c.d a.c.d.e f -stressTest a b a.c a.c.d a.c.d.e a.f -stressTest a b a.c a.c.d a.c.d.e b.f -stressTest a b a.c a.c.d a.c.d.e a.c.f -stressTest a b a.c a.c.d a.c.d.e a.c.d.f -stressTest a b a.c a.c.d a.c.d.e a.c.d.e.f -stressTest a b b.c d e f -stressTest a b b.c d e a.f -stressTest a b b.c d e b.f -stressTest a b b.c d e b.c.f -stressTest a b b.c d e d.f -stressTest a b b.c d e e.f -stressTest a b b.c d a.e f -stressTest a b b.c d a.e a.f -stressTest a b b.c d a.e b.f -stressTest a b b.c d a.e b.c.f -stressTest a b b.c d a.e d.f -stressTest a b b.c d a.e a.e.f -stressTest a b b.c d b.e f -stressTest a b b.c d b.e a.f -stressTest a b b.c d b.e b.f -stressTest a b b.c d b.e b.c.f -stressTest a b b.c d b.e d.f -stressTest a b b.c d b.e b.e.f -stressTest a b b.c d b.c.e f -stressTest a b b.c d b.c.e a.f -stressTest a b b.c d b.c.e b.f -stressTest a b b.c d b.c.e b.c.f -stressTest a b b.c d b.c.e d.f -stressTest a b b.c d b.c.e b.c.e.f -stressTest a b b.c d d.e f -stressTest a b b.c d d.e a.f -stressTest a b b.c d d.e b.f -stressTest a b b.c d d.e b.c.f -stressTest a b b.c d d.e d.f -stressTest a b b.c d d.e d.e.f -stressTest a b b.c a.d e f -stressTest a b b.c a.d e a.f -stressTest a b b.c a.d e b.f -stressTest a b b.c a.d e b.c.f -stressTest a b b.c a.d e a.d.f -stressTest a b b.c a.d e e.f -stressTest a b b.c a.d a.e f -stressTest a b b.c a.d a.e a.f -stressTest a b b.c a.d a.e b.f -stressTest a b b.c a.d a.e b.c.f -stressTest a b b.c a.d a.e a.d.f -stressTest a b b.c a.d a.e a.e.f -stressTest a b b.c a.d b.e f -stressTest a b b.c a.d b.e a.f -stressTest a b b.c a.d b.e b.f -stressTest a b b.c a.d b.e b.c.f -stressTest a b b.c a.d b.e a.d.f -stressTest a b b.c a.d b.e b.e.f -stressTest a b b.c a.d b.c.e f -stressTest a b b.c a.d b.c.e a.f -stressTest a b b.c a.d b.c.e b.f -stressTest a b b.c a.d b.c.e b.c.f -stressTest a b b.c a.d b.c.e a.d.f -stressTest a b b.c a.d b.c.e b.c.e.f -stressTest a b b.c a.d a.d.e f -stressTest a b b.c a.d a.d.e a.f -stressTest a b b.c a.d a.d.e b.f -stressTest a b b.c a.d a.d.e b.c.f -stressTest a b b.c a.d a.d.e a.d.f -stressTest a b b.c a.d a.d.e a.d.e.f -stressTest a b b.c b.d e f -stressTest a b b.c b.d e a.f -stressTest a b b.c b.d e b.f -stressTest a b b.c b.d e b.c.f -stressTest a b b.c b.d e b.d.f -stressTest a b b.c b.d e e.f -stressTest a b b.c b.d a.e f -stressTest a b b.c b.d a.e a.f -stressTest a b b.c b.d a.e b.f -stressTest a b b.c b.d a.e b.c.f -stressTest a b b.c b.d a.e b.d.f -stressTest a b b.c b.d a.e a.e.f -stressTest a b b.c b.d b.e f -stressTest a b b.c b.d b.e a.f -stressTest a b b.c b.d b.e b.f -stressTest a b b.c b.d b.e b.c.f -stressTest a b b.c b.d b.e b.d.f -stressTest a b b.c b.d b.e b.e.f -stressTest a b b.c b.d b.c.e f -stressTest a b b.c b.d b.c.e a.f -stressTest a b b.c b.d b.c.e b.f -stressTest a b b.c b.d b.c.e b.c.f -stressTest a b b.c b.d b.c.e b.d.f -stressTest a b b.c b.d b.c.e b.c.e.f -stressTest a b b.c b.d b.d.e f -stressTest a b b.c b.d b.d.e a.f -stressTest a b b.c b.d b.d.e b.f -stressTest a b b.c b.d b.d.e b.c.f -stressTest a b b.c b.d b.d.e b.d.f -stressTest a b b.c b.d b.d.e b.d.e.f -stressTest a b b.c b.c.d e f -stressTest a b b.c b.c.d e a.f -stressTest a b b.c b.c.d e b.f -stressTest a b b.c b.c.d e b.c.f -stressTest a b b.c b.c.d e b.c.d.f -stressTest a b b.c b.c.d e e.f -stressTest a b b.c b.c.d a.e f -stressTest a b b.c b.c.d a.e a.f -stressTest a b b.c b.c.d a.e b.f -stressTest a b b.c b.c.d a.e b.c.f -stressTest a b b.c b.c.d a.e b.c.d.f -stressTest a b b.c b.c.d a.e a.e.f -stressTest a b b.c b.c.d b.e f -stressTest a b b.c b.c.d b.e a.f -stressTest a b b.c b.c.d b.e b.f -stressTest a b b.c b.c.d b.e b.c.f -stressTest a b b.c b.c.d b.e b.c.d.f -stressTest a b b.c b.c.d b.e b.e.f -stressTest a b b.c b.c.d b.c.e f -stressTest a b b.c b.c.d b.c.e a.f -stressTest a b b.c b.c.d b.c.e b.f -stressTest a b b.c b.c.d b.c.e b.c.f -stressTest a b b.c b.c.d b.c.e b.c.d.f -stressTest a b b.c b.c.d b.c.e b.c.e.f -stressTest a b b.c b.c.d b.c.d.e f -stressTest a b b.c b.c.d b.c.d.e a.f -stressTest a b b.c b.c.d b.c.d.e b.f -stressTest a b b.c b.c.d b.c.d.e b.c.f -stressTest a b b.c b.c.d b.c.d.e b.c.d.f -stressTest a b b.c b.c.d b.c.d.e b.c.d.e.f -stressTest a a.b c d e f -stressTest a a.b c d e a.f -stressTest a a.b c d e a.b.f -stressTest a a.b c d e c.f -stressTest a a.b c d e d.f -stressTest a a.b c d e e.f -stressTest a a.b c d a.e f -stressTest a a.b c d a.e a.f -stressTest a a.b c d a.e a.b.f -stressTest a a.b c d a.e c.f -stressTest a a.b c d a.e d.f -stressTest a a.b c d a.e a.e.f -stressTest a a.b c d a.b.e f -stressTest a a.b c d a.b.e a.f -stressTest a a.b c d a.b.e a.b.f -stressTest a a.b c d a.b.e c.f -stressTest a a.b c d a.b.e d.f -stressTest a a.b c d a.b.e a.b.e.f -stressTest a a.b c d c.e f -stressTest a a.b c d c.e a.f -stressTest a a.b c d c.e a.b.f -stressTest a a.b c d c.e c.f -stressTest a a.b c d c.e d.f -stressTest a a.b c d c.e c.e.f -stressTest a a.b c d d.e f -stressTest a a.b c d d.e a.f -stressTest a a.b c d d.e a.b.f -stressTest a a.b c d d.e c.f -stressTest a a.b c d d.e d.f -stressTest a a.b c d d.e d.e.f -stressTest a a.b c a.d e f -stressTest a a.b c a.d e a.f -stressTest a a.b c a.d e a.b.f -stressTest a a.b c a.d e c.f -stressTest a a.b c a.d e a.d.f -stressTest a a.b c a.d e e.f -stressTest a a.b c a.d a.e f -stressTest a a.b c a.d a.e a.f -stressTest a a.b c a.d a.e a.b.f -stressTest a a.b c a.d a.e c.f -stressTest a a.b c a.d a.e a.d.f -stressTest a a.b c a.d a.e a.e.f -stressTest a a.b c a.d a.b.e f -stressTest a a.b c a.d a.b.e a.f -stressTest a a.b c a.d a.b.e a.b.f -stressTest a a.b c a.d a.b.e c.f -stressTest a a.b c a.d a.b.e a.d.f -stressTest a a.b c a.d a.b.e a.b.e.f -stressTest a a.b c a.d c.e f -stressTest a a.b c a.d c.e a.f -stressTest a a.b c a.d c.e a.b.f -stressTest a a.b c a.d c.e c.f -stressTest a a.b c a.d c.e a.d.f -stressTest a a.b c a.d c.e c.e.f -stressTest a a.b c a.d a.d.e f -stressTest a a.b c a.d a.d.e a.f -stressTest a a.b c a.d a.d.e a.b.f -stressTest a a.b c a.d a.d.e c.f -stressTest a a.b c a.d a.d.e a.d.f -stressTest a a.b c a.d a.d.e a.d.e.f -stressTest a a.b c a.b.d e f -stressTest a a.b c a.b.d e a.f -stressTest a a.b c a.b.d e a.b.f -stressTest a a.b c a.b.d e c.f -stressTest a a.b c a.b.d e a.b.d.f -stressTest a a.b c a.b.d e e.f -stressTest a a.b c a.b.d a.e f -stressTest a a.b c a.b.d a.e a.f -stressTest a a.b c a.b.d a.e a.b.f -stressTest a a.b c a.b.d a.e c.f -stressTest a a.b c a.b.d a.e a.b.d.f -stressTest a a.b c a.b.d a.e a.e.f -stressTest a a.b c a.b.d a.b.e f -stressTest a a.b c a.b.d a.b.e a.f -stressTest a a.b c a.b.d a.b.e a.b.f -stressTest a a.b c a.b.d a.b.e c.f -stressTest a a.b c a.b.d a.b.e a.b.d.f -stressTest a a.b c a.b.d a.b.e a.b.e.f -stressTest a a.b c a.b.d c.e f -stressTest a a.b c a.b.d c.e a.f -stressTest a a.b c a.b.d c.e a.b.f -stressTest a a.b c a.b.d c.e c.f -stressTest a a.b c a.b.d c.e a.b.d.f -stressTest a a.b c a.b.d c.e c.e.f -stressTest a a.b c a.b.d a.b.d.e f -stressTest a a.b c a.b.d a.b.d.e a.f -stressTest a a.b c a.b.d a.b.d.e a.b.f -stressTest a a.b c a.b.d a.b.d.e c.f -stressTest a a.b c a.b.d a.b.d.e a.b.d.f -stressTest a a.b c a.b.d a.b.d.e a.b.d.e.f -stressTest a a.b c c.d e f -stressTest a a.b c c.d e a.f -stressTest a a.b c c.d e a.b.f -stressTest a a.b c c.d e c.f -stressTest a a.b c c.d e c.d.f -stressTest a a.b c c.d e e.f -stressTest a a.b c c.d a.e f -stressTest a a.b c c.d a.e a.f -stressTest a a.b c c.d a.e a.b.f -stressTest a a.b c c.d a.e c.f -stressTest a a.b c c.d a.e c.d.f -stressTest a a.b c c.d a.e a.e.f -stressTest a a.b c c.d a.b.e f -stressTest a a.b c c.d a.b.e a.f -stressTest a a.b c c.d a.b.e a.b.f -stressTest a a.b c c.d a.b.e c.f -stressTest a a.b c c.d a.b.e c.d.f -stressTest a a.b c c.d a.b.e a.b.e.f -stressTest a a.b c c.d c.e f -stressTest a a.b c c.d c.e a.f -stressTest a a.b c c.d c.e a.b.f -stressTest a a.b c c.d c.e c.f -stressTest a a.b c c.d c.e c.d.f -stressTest a a.b c c.d c.e c.e.f -stressTest a a.b c c.d c.d.e f -stressTest a a.b c c.d c.d.e a.f -stressTest a a.b c c.d c.d.e a.b.f -stressTest a a.b c c.d c.d.e c.f -stressTest a a.b c c.d c.d.e c.d.f -stressTest a a.b c c.d c.d.e c.d.e.f -stressTest a a.b a.c d e f -stressTest a a.b a.c d e a.f -stressTest a a.b a.c d e a.b.f -stressTest a a.b a.c d e a.c.f -stressTest a a.b a.c d e d.f -stressTest a a.b a.c d e e.f -stressTest a a.b a.c d a.e f -stressTest a a.b a.c d a.e a.f -stressTest a a.b a.c d a.e a.b.f -stressTest a a.b a.c d a.e a.c.f -stressTest a a.b a.c d a.e d.f -stressTest a a.b a.c d a.e a.e.f -stressTest a a.b a.c d a.b.e f -stressTest a a.b a.c d a.b.e a.f -stressTest a a.b a.c d a.b.e a.b.f -stressTest a a.b a.c d a.b.e a.c.f -stressTest a a.b a.c d a.b.e d.f -stressTest a a.b a.c d a.b.e a.b.e.f -stressTest a a.b a.c d a.c.e f -stressTest a a.b a.c d a.c.e a.f -stressTest a a.b a.c d a.c.e a.b.f -stressTest a a.b a.c d a.c.e a.c.f -stressTest a a.b a.c d a.c.e d.f -stressTest a a.b a.c d a.c.e a.c.e.f -stressTest a a.b a.c d d.e f -stressTest a a.b a.c d d.e a.f -stressTest a a.b a.c d d.e a.b.f -stressTest a a.b a.c d d.e a.c.f -stressTest a a.b a.c d d.e d.f -stressTest a a.b a.c d d.e d.e.f -stressTest a a.b a.c a.d e f -stressTest a a.b a.c a.d e a.f -stressTest a a.b a.c a.d e a.b.f -stressTest a a.b a.c a.d e a.c.f -stressTest a a.b a.c a.d e a.d.f -stressTest a a.b a.c a.d e e.f -stressTest a a.b a.c a.d a.e f -stressTest a a.b a.c a.d a.e a.f -stressTest a a.b a.c a.d a.e a.b.f -stressTest a a.b a.c a.d a.e a.c.f -stressTest a a.b a.c a.d a.e a.d.f -stressTest a a.b a.c a.d a.e a.e.f -stressTest a a.b a.c a.d a.b.e f -stressTest a a.b a.c a.d a.b.e a.f -stressTest a a.b a.c a.d a.b.e a.b.f -stressTest a a.b a.c a.d a.b.e a.c.f -stressTest a a.b a.c a.d a.b.e a.d.f -stressTest a a.b a.c a.d a.b.e a.b.e.f -stressTest a a.b a.c a.d a.c.e f -stressTest a a.b a.c a.d a.c.e a.f -stressTest a a.b a.c a.d a.c.e a.b.f -stressTest a a.b a.c a.d a.c.e a.c.f -stressTest a a.b a.c a.d a.c.e a.d.f -stressTest a a.b a.c a.d a.c.e a.c.e.f -stressTest a a.b a.c a.d a.d.e f -stressTest a a.b a.c a.d a.d.e a.f -stressTest a a.b a.c a.d a.d.e a.b.f -stressTest a a.b a.c a.d a.d.e a.c.f -stressTest a a.b a.c a.d a.d.e a.d.f -stressTest a a.b a.c a.d a.d.e a.d.e.f -stressTest a a.b a.c a.b.d e f -stressTest a a.b a.c a.b.d e a.f -stressTest a a.b a.c a.b.d e a.b.f -stressTest a a.b a.c a.b.d e a.c.f -stressTest a a.b a.c a.b.d e a.b.d.f -stressTest a a.b a.c a.b.d e e.f -stressTest a a.b a.c a.b.d a.e f -stressTest a a.b a.c a.b.d a.e a.f -stressTest a a.b a.c a.b.d a.e a.b.f -stressTest a a.b a.c a.b.d a.e a.c.f -stressTest a a.b a.c a.b.d a.e a.b.d.f -stressTest a a.b a.c a.b.d a.e a.e.f -stressTest a a.b a.c a.b.d a.b.e f -stressTest a a.b a.c a.b.d a.b.e a.f -stressTest a a.b a.c a.b.d a.b.e a.b.f -stressTest a a.b a.c a.b.d a.b.e a.c.f -stressTest a a.b a.c a.b.d a.b.e a.b.d.f -stressTest a a.b a.c a.b.d a.b.e a.b.e.f -stressTest a a.b a.c a.b.d a.c.e f -stressTest a a.b a.c a.b.d a.c.e a.f -stressTest a a.b a.c a.b.d a.c.e a.b.f -stressTest a a.b a.c a.b.d a.c.e a.c.f -stressTest a a.b a.c a.b.d a.c.e a.b.d.f -stressTest a a.b a.c a.b.d a.c.e a.c.e.f -stressTest a a.b a.c a.b.d a.b.d.e f -stressTest a a.b a.c a.b.d a.b.d.e a.f -stressTest a a.b a.c a.b.d a.b.d.e a.b.f -stressTest a a.b a.c a.b.d a.b.d.e a.c.f -stressTest a a.b a.c a.b.d a.b.d.e a.b.d.f -stressTest a a.b a.c a.b.d a.b.d.e a.b.d.e.f -stressTest a a.b a.c a.c.d e f -stressTest a a.b a.c a.c.d e a.f -stressTest a a.b a.c a.c.d e a.b.f -stressTest a a.b a.c a.c.d e a.c.f -stressTest a a.b a.c a.c.d e a.c.d.f -stressTest a a.b a.c a.c.d e e.f -stressTest a a.b a.c a.c.d a.e f -stressTest a a.b a.c a.c.d a.e a.f -stressTest a a.b a.c a.c.d a.e a.b.f -stressTest a a.b a.c a.c.d a.e a.c.f -stressTest a a.b a.c a.c.d a.e a.c.d.f -stressTest a a.b a.c a.c.d a.e a.e.f -stressTest a a.b a.c a.c.d a.b.e f -stressTest a a.b a.c a.c.d a.b.e a.f -stressTest a a.b a.c a.c.d a.b.e a.b.f -stressTest a a.b a.c a.c.d a.b.e a.c.f -stressTest a a.b a.c a.c.d a.b.e a.c.d.f -stressTest a a.b a.c a.c.d a.b.e a.b.e.f -stressTest a a.b a.c a.c.d a.c.e f -stressTest a a.b a.c a.c.d a.c.e a.f -stressTest a a.b a.c a.c.d a.c.e a.b.f -stressTest a a.b a.c a.c.d a.c.e a.c.f -stressTest a a.b a.c a.c.d a.c.e a.c.d.f -stressTest a a.b a.c a.c.d a.c.e a.c.e.f -stressTest a a.b a.c a.c.d a.c.d.e f -stressTest a a.b a.c a.c.d a.c.d.e a.f -stressTest a a.b a.c a.c.d a.c.d.e a.b.f -stressTest a a.b a.c a.c.d a.c.d.e a.c.f -stressTest a a.b a.c a.c.d a.c.d.e a.c.d.f -stressTest a a.b a.c a.c.d a.c.d.e a.c.d.e.f -stressTest a a.b a.b.c d e f -stressTest a a.b a.b.c d e a.f -stressTest a a.b a.b.c d e a.b.f -stressTest a a.b a.b.c d e a.b.c.f -stressTest a a.b a.b.c d e d.f -stressTest a a.b a.b.c d e e.f -stressTest a a.b a.b.c d a.e f -stressTest a a.b a.b.c d a.e a.f -stressTest a a.b a.b.c d a.e a.b.f -stressTest a a.b a.b.c d a.e a.b.c.f -stressTest a a.b a.b.c d a.e d.f -stressTest a a.b a.b.c d a.e a.e.f -stressTest a a.b a.b.c d a.b.e f -stressTest a a.b a.b.c d a.b.e a.f -stressTest a a.b a.b.c d a.b.e a.b.f -stressTest a a.b a.b.c d a.b.e a.b.c.f -stressTest a a.b a.b.c d a.b.e d.f -stressTest a a.b a.b.c d a.b.e a.b.e.f -stressTest a a.b a.b.c d a.b.c.e f -stressTest a a.b a.b.c d a.b.c.e a.f -stressTest a a.b a.b.c d a.b.c.e a.b.f -stressTest a a.b a.b.c d a.b.c.e a.b.c.f -stressTest a a.b a.b.c d a.b.c.e d.f -stressTest a a.b a.b.c d a.b.c.e a.b.c.e.f -stressTest a a.b a.b.c d d.e f -stressTest a a.b a.b.c d d.e a.f -stressTest a a.b a.b.c d d.e a.b.f -stressTest a a.b a.b.c d d.e a.b.c.f -stressTest a a.b a.b.c d d.e d.f -stressTest a a.b a.b.c d d.e d.e.f -stressTest a a.b a.b.c a.d e f -stressTest a a.b a.b.c a.d e a.f -stressTest a a.b a.b.c a.d e a.b.f -stressTest a a.b a.b.c a.d e a.b.c.f -stressTest a a.b a.b.c a.d e a.d.f -stressTest a a.b a.b.c a.d e e.f -stressTest a a.b a.b.c a.d a.e f -stressTest a a.b a.b.c a.d a.e a.f -stressTest a a.b a.b.c a.d a.e a.b.f -stressTest a a.b a.b.c a.d a.e a.b.c.f -stressTest a a.b a.b.c a.d a.e a.d.f -stressTest a a.b a.b.c a.d a.e a.e.f -stressTest a a.b a.b.c a.d a.b.e f -stressTest a a.b a.b.c a.d a.b.e a.f -stressTest a a.b a.b.c a.d a.b.e a.b.f -stressTest a a.b a.b.c a.d a.b.e a.b.c.f -stressTest a a.b a.b.c a.d a.b.e a.d.f -stressTest a a.b a.b.c a.d a.b.e a.b.e.f -stressTest a a.b a.b.c a.d a.b.c.e f -stressTest a a.b a.b.c a.d a.b.c.e a.f -stressTest a a.b a.b.c a.d a.b.c.e a.b.f -stressTest a a.b a.b.c a.d a.b.c.e a.b.c.f -stressTest a a.b a.b.c a.d a.b.c.e a.d.f -stressTest a a.b a.b.c a.d a.b.c.e a.b.c.e.f -stressTest a a.b a.b.c a.d a.d.e f -stressTest a a.b a.b.c a.d a.d.e a.f -stressTest a a.b a.b.c a.d a.d.e a.b.f -stressTest a a.b a.b.c a.d a.d.e a.b.c.f -stressTest a a.b a.b.c a.d a.d.e a.d.f -stressTest a a.b a.b.c a.d a.d.e a.d.e.f -stressTest a a.b a.b.c a.b.d e f -stressTest a a.b a.b.c a.b.d e a.f -stressTest a a.b a.b.c a.b.d e a.b.f -stressTest a a.b a.b.c a.b.d e a.b.c.f -stressTest a a.b a.b.c a.b.d e a.b.d.f -stressTest a a.b a.b.c a.b.d e e.f -stressTest a a.b a.b.c a.b.d a.e f -stressTest a a.b a.b.c a.b.d a.e a.f -stressTest a a.b a.b.c a.b.d a.e a.b.f -stressTest a a.b a.b.c a.b.d a.e a.b.c.f -stressTest a a.b a.b.c a.b.d a.e a.b.d.f -stressTest a a.b a.b.c a.b.d a.e a.e.f -stressTest a a.b a.b.c a.b.d a.b.e f -stressTest a a.b a.b.c a.b.d a.b.e a.f -stressTest a a.b a.b.c a.b.d a.b.e a.b.f -stressTest a a.b a.b.c a.b.d a.b.e a.b.c.f -stressTest a a.b a.b.c a.b.d a.b.e a.b.d.f -stressTest a a.b a.b.c a.b.d a.b.e a.b.e.f -stressTest a a.b a.b.c a.b.d a.b.c.e f -stressTest a a.b a.b.c a.b.d a.b.c.e a.f -stressTest a a.b a.b.c a.b.d a.b.c.e a.b.f -stressTest a a.b a.b.c a.b.d a.b.c.e a.b.c.f -stressTest a a.b a.b.c a.b.d a.b.c.e a.b.d.f -stressTest a a.b a.b.c a.b.d a.b.c.e a.b.c.e.f -stressTest a a.b a.b.c a.b.d a.b.d.e f -stressTest a a.b a.b.c a.b.d a.b.d.e a.f -stressTest a a.b a.b.c a.b.d a.b.d.e a.b.f -stressTest a a.b a.b.c a.b.d a.b.d.e a.b.c.f -stressTest a a.b a.b.c a.b.d a.b.d.e a.b.d.f -stressTest a a.b a.b.c a.b.d a.b.d.e a.b.d.e.f -stressTest a a.b a.b.c a.b.c.d e f -stressTest a a.b a.b.c a.b.c.d e a.f -stressTest a a.b a.b.c a.b.c.d e a.b.f -stressTest a a.b a.b.c a.b.c.d e a.b.c.f -stressTest a a.b a.b.c a.b.c.d e a.b.c.d.f -stressTest a a.b a.b.c a.b.c.d e e.f -stressTest a a.b a.b.c a.b.c.d a.e f -stressTest a a.b a.b.c a.b.c.d a.e a.f -stressTest a a.b a.b.c a.b.c.d a.e a.b.f -stressTest a a.b a.b.c a.b.c.d a.e a.b.c.f -stressTest a a.b a.b.c a.b.c.d a.e a.b.c.d.f -stressTest a a.b a.b.c a.b.c.d a.e a.e.f -stressTest a a.b a.b.c a.b.c.d a.b.e f -stressTest a a.b a.b.c a.b.c.d a.b.e a.f -stressTest a a.b a.b.c a.b.c.d a.b.e a.b.f -stressTest a a.b a.b.c a.b.c.d a.b.e a.b.c.f -stressTest a a.b a.b.c a.b.c.d a.b.e a.b.c.d.f -stressTest a a.b a.b.c a.b.c.d a.b.e a.b.e.f -stressTest a a.b a.b.c a.b.c.d a.b.c.e f -stressTest a a.b a.b.c a.b.c.d a.b.c.e a.f -stressTest a a.b a.b.c a.b.c.d a.b.c.e a.b.f -stressTest a a.b a.b.c a.b.c.d a.b.c.e a.b.c.f -stressTest a a.b a.b.c a.b.c.d a.b.c.e a.b.c.d.f -stressTest a a.b a.b.c a.b.c.d a.b.c.e a.b.c.e.f -stressTest a a.b a.b.c a.b.c.d a.b.c.d.e f -stressTest a a.b a.b.c a.b.c.d a.b.c.d.e a.f -stressTest a a.b a.b.c a.b.c.d a.b.c.d.e a.b.f -stressTest a a.b a.b.c a.b.c.d a.b.c.d.e a.b.c.f -stressTest a a.b a.b.c a.b.c.d a.b.c.d.e a.b.c.d.f -stressTest a a.b a.b.c a.b.c.d a.b.c.d.e a.b.c.d.e.f - -# -stressTest a a.b a.b.c1 a.b.c1.d1 a.b.c1.d2 a.b.c1.d3 a.b.c2 -stressTest a a.b a.b.c a.b.c.d a.b.c.d.e a.b.c.d.e.f a.b.c.d.e.f.g - - diff --git a/src/java/org/apache/log4j/test/stressCategory.pl b/src/java/org/apache/log4j/test/stressCategory.pl deleted file mode 100644 index 875d2ca6d3..0000000000 --- a/src/java/org/apache/log4j/test/stressCategory.pl +++ /dev/null @@ -1,57 +0,0 @@ - -# This perl script all combinations of tree structures based on the "args" -# array. - -# For example, if args = ("a", "b", "c"), it will output: -# -# stressTest a b c -# stressTest a b a.c -# stressTest a b b.c -# stressTest a a.b c -# stressTest a a.b a.c -# stressTest a a.b a.b.c - -$prefix = "stressTest"; - -@tree = (""); - -@args = ("a", "b"); -permute(0, @tree); - -@args = ("a", "b", "c"); -permute(0, @tree); - -@args = ("a", "b", "c", "d"); -permute(0, @tree); - -@args = ("a", "b", "c", "d", "e"); -permute(0, @tree); - -@args = ("a", "b", "c", "d", "e", "f"); -permute(0, @tree); - - -sub permute() { - my ($i, @t) = @_; - #print "Tree is @t\n"; - #print "i is $i \n"; - - if($i == $#args + 1) { - print "$prefix @t\n"; - return; - } - - foreach $j (@t) { - #print "J is $j \n"; - #print "args[$i]=$args[$i]\n"; - if($j eq "") { - $next = "$args[$i]"; - } - else { - $next = "$j.$args[$i]"; - } - - permute($i+1, (@t, $next)); - } - -} diff --git a/src/java/org/apache/log4j/test/stressNDC b/src/java/org/apache/log4j/test/stressNDC deleted file mode 100644 index 93530034f7..0000000000 --- a/src/java/org/apache/log4j/test/stressNDC +++ /dev/null @@ -1,6 +0,0 @@ -if [ -z "$PERL" ] -then - PERL=perl -fi - -java org.apache.log4j.test.StressNDC $1 | $PERL StressNDC.pl diff --git a/src/java/org/apache/log4j/test/witness/confParsing.1 b/src/java/org/apache/log4j/test/witness/confParsing.1 deleted file mode 100644 index f679458ca5..0000000000 --- a/src/java/org/apache/log4j/test/witness/confParsing.1 +++ /dev/null @@ -1,2 +0,0 @@ -[main] DEBUG root - Message 1 -[main] DEBUG root - Message 2 diff --git a/src/java/org/apache/log4j/test/witness/confParsing.10 b/src/java/org/apache/log4j/test/witness/confParsing.10 deleted file mode 100644 index 6941ab2051..0000000000 --- a/src/java/org/apache/log4j/test/witness/confParsing.10 +++ /dev/null @@ -1,2 +0,0 @@ -AVY [main] DEBUG-Message 1 -AVY [main] DEBUG-Message 2 diff --git a/src/java/org/apache/log4j/test/witness/confParsing.11 b/src/java/org/apache/log4j/test/witness/confParsing.11 deleted file mode 100644 index ef6ea2ad51..0000000000 --- a/src/java/org/apache/log4j/test/witness/confParsing.11 +++ /dev/null @@ -1,2 +0,0 @@ -VSUB [main] DEBUG-Message 1 -VSUB [main] DEBUG-Message 2 diff --git a/src/java/org/apache/log4j/test/witness/confParsing.2 b/src/java/org/apache/log4j/test/witness/confParsing.2 deleted file mode 100644 index e740f81250..0000000000 --- a/src/java/org/apache/log4j/test/witness/confParsing.2 +++ /dev/null @@ -1,2 +0,0 @@ -[main] DEBUG root testing - Message 1 -[main] DEBUG root testing - Message 2 diff --git a/src/java/org/apache/log4j/test/witness/confParsing.3 b/src/java/org/apache/log4j/test/witness/confParsing.3 deleted file mode 100644 index 1f4dfb9de1..0000000000 --- a/src/java/org/apache/log4j/test/witness/confParsing.3 +++ /dev/null @@ -1 +0,0 @@ -[main] DEBUG root testing - Message 2 diff --git a/src/java/org/apache/log4j/test/witness/confParsing.4 b/src/java/org/apache/log4j/test/witness/confParsing.4 deleted file mode 100644 index 63b67e541b..0000000000 --- a/src/java/org/apache/log4j/test/witness/confParsing.4 +++ /dev/null @@ -1,3 +0,0 @@ -[main] DEBUG testing - HELLO WORLD -[main] DEBUG root testing - Message 1 -[main] DEBUG root testing - Message 2 diff --git a/src/java/org/apache/log4j/test/witness/confParsing.5 b/src/java/org/apache/log4j/test/witness/confParsing.5 deleted file mode 100644 index 63b67e541b..0000000000 --- a/src/java/org/apache/log4j/test/witness/confParsing.5 +++ /dev/null @@ -1,3 +0,0 @@ -[main] DEBUG testing - HELLO WORLD -[main] DEBUG root testing - Message 1 -[main] DEBUG root testing - Message 2 diff --git a/src/java/org/apache/log4j/test/witness/confParsing.6 b/src/java/org/apache/log4j/test/witness/confParsing.6 deleted file mode 100644 index e740f81250..0000000000 --- a/src/java/org/apache/log4j/test/witness/confParsing.6 +++ /dev/null @@ -1,2 +0,0 @@ -[main] DEBUG root testing - Message 1 -[main] DEBUG root testing - Message 2 diff --git a/src/java/org/apache/log4j/test/witness/confParsing.7 b/src/java/org/apache/log4j/test/witness/confParsing.7 deleted file mode 100644 index 63b67e541b..0000000000 --- a/src/java/org/apache/log4j/test/witness/confParsing.7 +++ /dev/null @@ -1,3 +0,0 @@ -[main] DEBUG testing - HELLO WORLD -[main] DEBUG root testing - Message 1 -[main] DEBUG root testing - Message 2 diff --git a/src/java/org/apache/log4j/test/witness/confParsing.8 b/src/java/org/apache/log4j/test/witness/confParsing.8 deleted file mode 100644 index 1df45268ef..0000000000 --- a/src/java/org/apache/log4j/test/witness/confParsing.8 +++ /dev/null @@ -1,2 +0,0 @@ -[main] DEBUG - Message 1 -[main] DEBUG - Message 2 diff --git a/src/java/org/apache/log4j/test/witness/confParsing.9 b/src/java/org/apache/log4j/test/witness/confParsing.9 deleted file mode 100644 index 1df45268ef..0000000000 --- a/src/java/org/apache/log4j/test/witness/confParsing.9 +++ /dev/null @@ -1,2 +0,0 @@ -[main] DEBUG - Message 1 -[main] DEBUG - Message 2 diff --git a/src/java/org/apache/log4j/test/witness/customCat.1 b/src/java/org/apache/log4j/test/witness/customCat.1 deleted file mode 100644 index af70b03a1f..0000000000 --- a/src/java/org/apache/log4j/test/witness/customCat.1 +++ /dev/null @@ -1,6 +0,0 @@ -TRACE - Message 0 -DEBUG - Message 1 -INFO - Message 2 -WARN - Message 3 -ERROR - Message 4 -LETHAL - Message 5 diff --git a/src/java/org/apache/log4j/test/witness/definit.1 b/src/java/org/apache/log4j/test/witness/definit.1 deleted file mode 100644 index 802992c422..0000000000 --- a/src/java/org/apache/log4j/test/witness/definit.1 +++ /dev/null @@ -1 +0,0 @@ -Hello world diff --git a/src/java/org/apache/log4j/test/witness/definit.2 b/src/java/org/apache/log4j/test/witness/definit.2 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/java/org/apache/log4j/test/witness/definit.3 b/src/java/org/apache/log4j/test/witness/definit.3 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/java/org/apache/log4j/test/witness/definit.4 b/src/java/org/apache/log4j/test/witness/definit.4 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/java/org/apache/log4j/test/witness/definit.5 b/src/java/org/apache/log4j/test/witness/definit.5 deleted file mode 100644 index 802992c422..0000000000 --- a/src/java/org/apache/log4j/test/witness/definit.5 +++ /dev/null @@ -1 +0,0 @@ -Hello world diff --git a/src/java/org/apache/log4j/test/witness/definit.6 b/src/java/org/apache/log4j/test/witness/definit.6 deleted file mode 100644 index 802992c422..0000000000 --- a/src/java/org/apache/log4j/test/witness/definit.6 +++ /dev/null @@ -1 +0,0 @@ -Hello world diff --git a/src/java/org/apache/log4j/test/witness/domTest.10 b/src/java/org/apache/log4j/test/witness/domTest.10 deleted file mode 100644 index 4a2ce8c062..0000000000 --- a/src/java/org/apache/log4j/test/witness/domTest.10 +++ /dev/null @@ -1,2 +0,0 @@ -INFO test.DOMTest - Message 1 -INFO root - Message 1 diff --git a/src/java/org/apache/log4j/test/witness/domTest.11 b/src/java/org/apache/log4j/test/witness/domTest.11 deleted file mode 100644 index 8c16ea6d90..0000000000 --- a/src/java/org/apache/log4j/test/witness/domTest.11 +++ /dev/null @@ -1,2 +0,0 @@ -WARN test.DOMTest - Message 2 -WARN root - Message 2 diff --git a/src/java/org/apache/log4j/test/witness/domTest.12 b/src/java/org/apache/log4j/test/witness/domTest.12 deleted file mode 100644 index 9960bc1d48..0000000000 --- a/src/java/org/apache/log4j/test/witness/domTest.12 +++ /dev/null @@ -1,24 +0,0 @@ -DEBUG test.DOMTest - Message 0 -DEBUG root - Message 0 -INFO test.DOMTest - Message 1 -INFO root - Message 1 -ERROR test.DOMTest - Message 3 -ERROR root - Message 3 -FATAL test.DOMTest - Message 4 -FATAL root - Message 4 -DEBUG test.DOMTest - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -DEBUG root - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -ERROR test.DOMTest - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -ERROR root - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/domTest.4 b/src/java/org/apache/log4j/test/witness/domTest.4 deleted file mode 100644 index fe6e2b332e..0000000000 --- a/src/java/org/apache/log4j/test/witness/domTest.4 +++ /dev/null @@ -1,12 +0,0 @@ -ERROR test.DOMTest - Message 3 -ERROR root - Message 3 -FATAL test.DOMTest - Message 4 -FATAL root - Message 4 -ERROR test.DOMTest - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -ERROR root - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/domTest.5 b/src/java/org/apache/log4j/test/witness/domTest.5 deleted file mode 100644 index 9633880812..0000000000 --- a/src/java/org/apache/log4j/test/witness/domTest.5 +++ /dev/null @@ -1,26 +0,0 @@ -DEBUG test.DOMTest - Message 0 -DEBUG root - Message 0 -INFO test.DOMTest - Message 1 -INFO root - Message 1 -WARN test.DOMTest - Message 2 -WARN root - Message 2 -ERROR test.DOMTest - Message 3 -ERROR root - Message 3 -FATAL test.DOMTest - Message 4 -FATAL root - Message 4 -DEBUG test.DOMTest - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -DEBUG root - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -ERROR test.DOMTest - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -ERROR root - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/domTest.6 b/src/java/org/apache/log4j/test/witness/domTest.6 deleted file mode 100644 index 3c27dfafc1..0000000000 --- a/src/java/org/apache/log4j/test/witness/domTest.6 +++ /dev/null @@ -1,4 +0,0 @@ -INFO test.DOMTest - Message 1 -INFO root - Message 1 -WARN test.DOMTest - Message 2 -WARN root - Message 2 diff --git a/src/java/org/apache/log4j/test/witness/domTest.7 b/src/java/org/apache/log4j/test/witness/domTest.7 deleted file mode 100644 index 478b640574..0000000000 --- a/src/java/org/apache/log4j/test/witness/domTest.7 +++ /dev/null @@ -1,24 +0,0 @@ -DEBUG test.DOMTest - Message 0 -DEBUG root - Message 0 -WARN test.DOMTest - Message 2 -WARN root - Message 2 -ERROR test.DOMTest - Message 3 -ERROR root - Message 3 -FATAL test.DOMTest - Message 4 -FATAL root - Message 4 -DEBUG test.DOMTest - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -DEBUG root - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -ERROR test.DOMTest - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -ERROR root - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/domTest.8 b/src/java/org/apache/log4j/test/witness/domTest.8 deleted file mode 100644 index 39a4e528e6..0000000000 --- a/src/java/org/apache/log4j/test/witness/domTest.8 +++ /dev/null @@ -1,6 +0,0 @@ -WARN test.DOMTest - Message 2 -WARN root - Message 2 -ERROR test.DOMTest - Message 3 -ERROR root - Message 3 -FATAL test.DOMTest - Message 4 -FATAL root - Message 4 diff --git a/src/java/org/apache/log4j/test/witness/domTest.9 b/src/java/org/apache/log4j/test/witness/domTest.9 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/java/org/apache/log4j/test/witness/domTest.A1.1 b/src/java/org/apache/log4j/test/witness/domTest.A1.1 deleted file mode 100644 index 5d7b3fa5c2..0000000000 --- a/src/java/org/apache/log4j/test/witness/domTest.A1.1 +++ /dev/null @@ -1,39 +0,0 @@ -DEBUG test.DOMTest - Message 0 -DEBUG test.DOMTest - Message 0 -DEBUG root - Message 0 -INFO test.DOMTest - Message 1 -INFO test.DOMTest - Message 1 -INFO root - Message 1 -WARN test.DOMTest - Message 2 -WARN test.DOMTest - Message 2 -WARN root - Message 2 -ERROR test.DOMTest - Message 3 -ERROR test.DOMTest - Message 3 -ERROR root - Message 3 -FATAL test.DOMTest - Message 4 -FATAL test.DOMTest - Message 4 -FATAL root - Message 4 -DEBUG test.DOMTest - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -DEBUG test.DOMTest - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -DEBUG root - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -ERROR test.DOMTest - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -ERROR test.DOMTest - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -ERROR root - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/domTest.A1.2 b/src/java/org/apache/log4j/test/witness/domTest.A1.2 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/java/org/apache/log4j/test/witness/domTest.A1.3 b/src/java/org/apache/log4j/test/witness/domTest.A1.3 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/java/org/apache/log4j/test/witness/domTest.A2.1 b/src/java/org/apache/log4j/test/witness/domTest.A2.1 deleted file mode 100644 index 97882605e4..0000000000 --- a/src/java/org/apache/log4j/test/witness/domTest.A2.1 +++ /dev/null @@ -1,26 +0,0 @@ -[main] DEBUG org.apache.log4j.xml.test.DOMTest - Message 0 -[main] DEBUG root - Message 0 -[main] INFO org.apache.log4j.xml.test.DOMTest - Message 1 -[main] INFO root - Message 1 -[main] WARN org.apache.log4j.xml.test.DOMTest - Message 2 -[main] WARN root - Message 2 -[main] ERROR org.apache.log4j.xml.test.DOMTest - Message 3 -[main] ERROR root - Message 3 -[main] FATAL org.apache.log4j.xml.test.DOMTest - Message 4 -[main] FATAL root - Message 4 -[main] DEBUG org.apache.log4j.xml.test.DOMTest - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -[main] DEBUG root - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -[main] ERROR org.apache.log4j.xml.test.DOMTest - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) -[main] ERROR root - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/domTest.A2.2 b/src/java/org/apache/log4j/test/witness/domTest.A2.2 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/java/org/apache/log4j/test/witness/domTest.A2.3 b/src/java/org/apache/log4j/test/witness/domTest.A2.3 deleted file mode 100644 index 5922655c77..0000000000 --- a/src/java/org/apache/log4j/test/witness/domTest.A2.3 +++ /dev/null @@ -1,4 +0,0 @@ -[main] ERROR test.DOMTest - TEST3 Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.xml.test.DOMTest.test(DOMTest.java:XXX) - at org.apache.log4j.xml.test.DOMTest.main(DOMTest.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/enableFlagTest.1 b/src/java/org/apache/log4j/test/witness/enableFlagTest.1 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/java/org/apache/log4j/test/witness/enableFlagTest.2 b/src/java/org/apache/log4j/test/witness/enableFlagTest.2 deleted file mode 100644 index b422ddcfaf..0000000000 --- a/src/java/org/apache/log4j/test/witness/enableFlagTest.2 +++ /dev/null @@ -1 +0,0 @@ -FATAL [main] test.EnableFlagTest = m5 diff --git a/src/java/org/apache/log4j/test/witness/enableFlagTest.3 b/src/java/org/apache/log4j/test/witness/enableFlagTest.3 deleted file mode 100644 index 6c81bdce17..0000000000 --- a/src/java/org/apache/log4j/test/witness/enableFlagTest.3 +++ /dev/null @@ -1,2 +0,0 @@ -ERROR [main] test.EnableFlagTest = m4 -FATAL [main] test.EnableFlagTest = m5 diff --git a/src/java/org/apache/log4j/test/witness/enableFlagTest.4 b/src/java/org/apache/log4j/test/witness/enableFlagTest.4 deleted file mode 100644 index 244e782c78..0000000000 --- a/src/java/org/apache/log4j/test/witness/enableFlagTest.4 +++ /dev/null @@ -1,3 +0,0 @@ -WARN [main] test.EnableFlagTest = m3 -ERROR [main] test.EnableFlagTest = m4 -FATAL [main] test.EnableFlagTest = m5 diff --git a/src/java/org/apache/log4j/test/witness/enableFlagTest.5 b/src/java/org/apache/log4j/test/witness/enableFlagTest.5 deleted file mode 100644 index df019ef3fa..0000000000 --- a/src/java/org/apache/log4j/test/witness/enableFlagTest.5 +++ /dev/null @@ -1,4 +0,0 @@ -INFO [main] test.EnableFlagTest = m2 -WARN [main] test.EnableFlagTest = m3 -ERROR [main] test.EnableFlagTest = m4 -FATAL [main] test.EnableFlagTest = m5 diff --git a/src/java/org/apache/log4j/test/witness/enableFlagTest.6 b/src/java/org/apache/log4j/test/witness/enableFlagTest.6 deleted file mode 100644 index 335f6ea0a0..0000000000 --- a/src/java/org/apache/log4j/test/witness/enableFlagTest.6 +++ /dev/null @@ -1,5 +0,0 @@ -DEBUG [main] test.EnableFlagTest = m1 -INFO [main] test.EnableFlagTest = m2 -WARN [main] test.EnableFlagTest = m3 -ERROR [main] test.EnableFlagTest = m4 -FATAL [main] test.EnableFlagTest = m5 diff --git a/src/java/org/apache/log4j/test/witness/enableFlagTest.7 b/src/java/org/apache/log4j/test/witness/enableFlagTest.7 deleted file mode 100644 index 335f6ea0a0..0000000000 --- a/src/java/org/apache/log4j/test/witness/enableFlagTest.7 +++ /dev/null @@ -1,5 +0,0 @@ -DEBUG [main] test.EnableFlagTest = m1 -INFO [main] test.EnableFlagTest = m2 -WARN [main] test.EnableFlagTest = m3 -ERROR [main] test.EnableFlagTest = m4 -FATAL [main] test.EnableFlagTest = m5 diff --git a/src/java/org/apache/log4j/test/witness/fqcn.1 b/src/java/org/apache/log4j/test/witness/fqcn.1 deleted file mode 100644 index 24b03ebd67..0000000000 --- a/src/java/org/apache/log4j/test/witness/fqcn.1 +++ /dev/null @@ -1,3 +0,0 @@ -DEBUG x1 (test.FQCNTest#test) - hello -DEBUG x1 (test.FQCNTest#test) - hello world. -DEBUG x1 (test.FQCNTest#test) - hello diff --git a/src/java/org/apache/log4j/test/witness/getOptions.1 b/src/java/org/apache/log4j/test/witness/getOptions.1 deleted file mode 100644 index 46a2d13694..0000000000 --- a/src/java/org/apache/log4j/test/witness/getOptions.1 +++ /dev/null @@ -1,11 +0,0 @@ -log4j.appender.f.Append=false -log4j.appender.f.BufferSize=8192 -log4j.appender.f.BufferedIO=false -log4j.appender.f.File=temp -log4j.appender.f.ImmediateFlush=true -log4j.appender.f.layout.ContentType=text/plain -log4j.appender.f.layout.ConversionPattern=%m%n -log4j.appender.f.layout=org.apache.log4j.PatternLayout -log4j.appender.f=org.apache.log4j.FileAppender -log4j.category.org.apache.log4j=INFO, f -log4j.rootCategory=DEBUG, f diff --git a/src/java/org/apache/log4j/test/witness/l7d.1 b/src/java/org/apache/log4j/test/witness/l7d.1 deleted file mode 100644 index 0bc132b563..0000000000 --- a/src/java/org/apache/log4j/test/witness/l7d.1 +++ /dev/null @@ -1,21 +0,0 @@ -T1 INFO - This is the English, US test. -T1 WARN - Hello world. -T1 ERROR - No resource is associated with key "bogusMsg". -T1 ERROR - bogusMsg -T1 ERROR - This is test number 1 with string argument log4j. -T1 ERROR - No resource is associated with key "bogus2". -T1 INFO - bogus2 -T1 INFO - Ceci est le test en francais pour la France. -T1 WARN - Bonjour la France. -T1 ERROR - No resource is associated with key "bogusMsg". -T1 ERROR - bogusMsg -T1 ERROR - Ceci est le test numero 2 contenant l'argument log4j. -T1 ERROR - No resource is associated with key "bogus2". -T1 INFO - bogus2 -T1 INFO - Ceci est le test en francais pour la p'tite Suisse. -T1 WARN - Bonjour la France. -T1 ERROR - No resource is associated with key "bogusMsg". -T1 ERROR - bogusMsg -T1 ERROR - Ceci est le test numero 3 contenant l'argument log4j. -T1 ERROR - No resource is associated with key "bogus2". -T1 INFO - bogus2 diff --git a/src/java/org/apache/log4j/test/witness/mycat.1 b/src/java/org/apache/log4j/test/witness/mycat.1 deleted file mode 100644 index 8ab1b55b8e..0000000000 --- a/src/java/org/apache/log4j/test/witness/mycat.1 +++ /dev/null @@ -1 +0,0 @@ -some.cat DEBUG - Hello world. diff --git a/src/java/org/apache/log4j/test/witness/mycat.2 b/src/java/org/apache/log4j/test/witness/mycat.2 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/java/org/apache/log4j/test/witness/mycat.3 b/src/java/org/apache/log4j/test/witness/mycat.3 deleted file mode 100644 index 8ab1b55b8e..0000000000 --- a/src/java/org/apache/log4j/test/witness/mycat.3 +++ /dev/null @@ -1 +0,0 @@ -some.cat DEBUG - Hello world. diff --git a/src/java/org/apache/log4j/test/witness/propCfg.1 b/src/java/org/apache/log4j/test/witness/propCfg.1 deleted file mode 100644 index 802992c422..0000000000 --- a/src/java/org/apache/log4j/test/witness/propCfg.1 +++ /dev/null @@ -1 +0,0 @@ -Hello world diff --git a/src/java/org/apache/log4j/test/witness/propCfg.2 b/src/java/org/apache/log4j/test/witness/propCfg.2 deleted file mode 100644 index e64a372d74..0000000000 --- a/src/java/org/apache/log4j/test/witness/propCfg.2 +++ /dev/null @@ -1 +0,0 @@ -DEBUG - Hello world diff --git a/src/java/org/apache/log4j/test/witness/shallow.1000 b/src/java/org/apache/log4j/test/witness/shallow.1000 deleted file mode 100644 index 7938faf55c..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.1000 +++ /dev/null @@ -1,50 +0,0 @@ -DEBUG NDC [main] org.apache.log4j.test.Shallow Message 0 -DEBUG NDC [main] root Message 0 - INFO NDC [main] org.apache.log4j.test.Shallow Message 1 - INFO NDC [main] root Message 1 - WARN NDC [main] org.apache.log4j.test.Shallow Message 2 - WARN NDC [main] root Message 2 -ERROR NDC [main] org.apache.log4j.test.Shallow Message 3 -ERROR NDC [main] root Message 3 -FATAL NDC [main] org.apache.log4j.test.Shallow Message 4 -FATAL NDC [main] root Message 4 -DEBUG NDC [main] org.apache.log4j.test.Shallow Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -DEBUG NDC [main] root Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) - INFO NDC [main] org.apache.log4j.test.Shallow Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) - INFO NDC [main] root Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) - WARN NDC [main] org.apache.log4j.test.Shallow Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) - WARN NDC [main] root Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -ERROR NDC [main] org.apache.log4j.test.Shallow Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -ERROR NDC [main] root Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -FATAL NDC [main] org.apache.log4j.test.Shallow Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -FATAL NDC [main] root Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.1001 b/src/java/org/apache/log4j/test/witness/shallow.1001 deleted file mode 100644 index 9ea45d7d6f..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.1001 +++ /dev/null @@ -1,50 +0,0 @@ -DEBUG NDC [main] org.apache.log4j.test.Shallow (Shallow.java:55) Message 0 -DEBUG NDC [main] org.apache.log4j.test.Shallow (Shallow.java:56) Message 0 - INFO NDC [main] org.apache.log4j.test.Shallow (Shallow.java:58) Message 1 - INFO NDC [main] org.apache.log4j.test.Shallow (Shallow.java:59) Message 1 - WARN NDC [main] org.apache.log4j.test.Shallow (Shallow.java:61) Message 2 - WARN NDC [main] org.apache.log4j.test.Shallow (Shallow.java:62) Message 2 -ERROR NDC [main] org.apache.log4j.test.Shallow (Shallow.java:64) Message 3 -ERROR NDC [main] org.apache.log4j.test.Shallow (Shallow.java:65) Message 3 -FATAL NDC [main] org.apache.log4j.test.Shallow (Shallow.java:67) Message 4 -FATAL NDC [main] org.apache.log4j.test.Shallow (Shallow.java:68) Message 4 -DEBUG NDC [main] org.apache.log4j.test.Shallow (Shallow.java:71) Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -DEBUG NDC [main] org.apache.log4j.test.Shallow (Shallow.java:72) Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) - INFO NDC [main] org.apache.log4j.test.Shallow (Shallow.java:74) Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) - INFO NDC [main] org.apache.log4j.test.Shallow (Shallow.java:75) Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) - WARN NDC [main] org.apache.log4j.test.Shallow (Shallow.java:77) Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) - WARN NDC [main] org.apache.log4j.test.Shallow (Shallow.java:78) Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -ERROR NDC [main] org.apache.log4j.test.Shallow (Shallow.java:80) Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -ERROR NDC [main] org.apache.log4j.test.Shallow (Shallow.java:81) Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -FATAL NDC [main] org.apache.log4j.test.Shallow (Shallow.java:83) Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -FATAL NDC [main] org.apache.log4j.test.Shallow (Shallow.java:84) Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A1.1 b/src/java/org/apache/log4j/test/witness/shallow.A1.1 deleted file mode 100644 index 0f3794caad..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A1.1 +++ /dev/null @@ -1,50 +0,0 @@ -DEBUG - Message 0 -DEBUG - Message 0 -INFO - Message 1 -INFO - Message 1 -WARN - Message 2 -WARN - Message 2 -ERROR - Message 3 -ERROR - Message 3 -FATAL - Message 4 -FATAL - Message 4 -DEBUG - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -DEBUG - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -INFO - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -INFO - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -WARN - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -WARN - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -ERROR - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -ERROR - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -FATAL - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -FATAL - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A1.2 b/src/java/org/apache/log4j/test/witness/shallow.A1.2 deleted file mode 100644 index 72b8396430..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A1.2 +++ /dev/null @@ -1,45 +0,0 @@ -DEBUG - Message 0 -INFO - Message 1 -INFO - Message 1 -WARN - Message 2 -WARN - Message 2 -ERROR - Message 3 -ERROR - Message 3 -FATAL - Message 4 -FATAL - Message 4 -DEBUG - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -INFO - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -INFO - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -WARN - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -WARN - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -ERROR - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -ERROR - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -FATAL - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -FATAL - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A1.3 b/src/java/org/apache/log4j/test/witness/shallow.A1.3 deleted file mode 100644 index 2e6ca8185f..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A1.3 +++ /dev/null @@ -1,50 +0,0 @@ -[main] DEBUG org.apache.log4j.test.Shallow NDC - Message 0 -[main] DEBUG root NDC - Message 0 -[main] INFO org.apache.log4j.test.Shallow NDC - Message 1 -[main] INFO root NDC - Message 1 -[main] WARN org.apache.log4j.test.Shallow NDC - Message 2 -[main] WARN root NDC - Message 2 -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 3 -[main] ERROR root NDC - Message 3 -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 4 -[main] FATAL root NDC - Message 4 -[main] DEBUG org.apache.log4j.test.Shallow NDC - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] DEBUG root NDC - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] INFO org.apache.log4j.test.Shallow NDC - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] INFO root NDC - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN org.apache.log4j.test.Shallow NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN root NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR root NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL root NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A1.4 b/src/java/org/apache/log4j/test/witness/shallow.A1.4 deleted file mode 100644 index e6836961eb..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A1.4 +++ /dev/null @@ -1,40 +0,0 @@ -[main] INFO org.apache.log4j.test.Shallow NDC - Message 1 -[main] INFO root NDC - Message 1 -[main] WARN org.apache.log4j.test.Shallow NDC - Message 2 -[main] WARN root NDC - Message 2 -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 3 -[main] ERROR root NDC - Message 3 -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 4 -[main] FATAL root NDC - Message 4 -[main] INFO org.apache.log4j.test.Shallow NDC - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] INFO root NDC - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN org.apache.log4j.test.Shallow NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN root NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR root NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL root NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A1.5 b/src/java/org/apache/log4j/test/witness/shallow.A1.5 deleted file mode 100644 index d40c5d98ac..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A1.5 +++ /dev/null @@ -1,40 +0,0 @@ -[main] DEBUG root NDC - Message 0 -[main] INFO root NDC - Message 1 -[main] WARN org.apache.log4j.test.Shallow NDC - Message 2 -[main] WARN root NDC - Message 2 -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 3 -[main] ERROR root NDC - Message 3 -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 4 -[main] FATAL root NDC - Message 4 -[main] DEBUG root NDC - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] INFO root NDC - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN org.apache.log4j.test.Shallow NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN root NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR root NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL root NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A1.6 b/src/java/org/apache/log4j/test/witness/shallow.A1.6 deleted file mode 100644 index d40c5d98ac..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A1.6 +++ /dev/null @@ -1,40 +0,0 @@ -[main] DEBUG root NDC - Message 0 -[main] INFO root NDC - Message 1 -[main] WARN org.apache.log4j.test.Shallow NDC - Message 2 -[main] WARN root NDC - Message 2 -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 3 -[main] ERROR root NDC - Message 3 -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 4 -[main] FATAL root NDC - Message 4 -[main] DEBUG root NDC - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] INFO root NDC - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN org.apache.log4j.test.Shallow NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN root NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR root NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL root NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A1.7 b/src/java/org/apache/log4j/test/witness/shallow.A1.7 deleted file mode 100644 index 564f22cfc4..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A1.7 +++ /dev/null @@ -1,25 +0,0 @@ -[main] DEBUG root NDC - Message 0 -[main] INFO root NDC - Message 1 -[main] WARN root NDC - Message 2 -[main] ERROR root NDC - Message 3 -[main] FATAL root NDC - Message 4 -[main] DEBUG root NDC - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] INFO root NDC - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN root NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR root NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL root NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A1.8 b/src/java/org/apache/log4j/test/witness/shallow.A1.8 deleted file mode 100644 index c1afbe6d7d..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A1.8 +++ /dev/null @@ -1,15 +0,0 @@ -[main] WARN root NDC - Message 2 -[main] ERROR root NDC - Message 3 -[main] FATAL root NDC - Message 4 -[main] WARN root NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR root NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL root NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A2.1 b/src/java/org/apache/log4j/test/witness/shallow.A2.1 deleted file mode 100644 index a724c6a56a..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A2.1 +++ /dev/null @@ -1,25 +0,0 @@ -DEBUG - Message 0 -INFO - Message 1 -WARN - Message 2 -ERROR - Message 3 -FATAL - Message 4 -DEBUG - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -INFO - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -WARN - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -ERROR - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -FATAL - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A2.2 b/src/java/org/apache/log4j/test/witness/shallow.A2.2 deleted file mode 100644 index a724c6a56a..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A2.2 +++ /dev/null @@ -1,25 +0,0 @@ -DEBUG - Message 0 -INFO - Message 1 -WARN - Message 2 -ERROR - Message 3 -FATAL - Message 4 -DEBUG - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -INFO - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -WARN - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -ERROR - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -FATAL - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A2.3 b/src/java/org/apache/log4j/test/witness/shallow.A2.3 deleted file mode 100644 index 1ae373ad70..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A2.3 +++ /dev/null @@ -1,25 +0,0 @@ -[main] DEBUG org.apache.log4j.test.Shallow NDC - Message 0 -[main] INFO org.apache.log4j.test.Shallow NDC - Message 1 -[main] WARN org.apache.log4j.test.Shallow NDC - Message 2 -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 3 -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 4 -[main] DEBUG org.apache.log4j.test.Shallow NDC - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] INFO org.apache.log4j.test.Shallow NDC - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN org.apache.log4j.test.Shallow NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A2.4 b/src/java/org/apache/log4j/test/witness/shallow.A2.4 deleted file mode 100644 index 1bbfd2398c..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A2.4 +++ /dev/null @@ -1,20 +0,0 @@ -[main] INFO org.apache.log4j.test.Shallow NDC - Message 1 -[main] WARN org.apache.log4j.test.Shallow NDC - Message 2 -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 3 -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 4 -[main] INFO org.apache.log4j.test.Shallow NDC - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN org.apache.log4j.test.Shallow NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A2.5 b/src/java/org/apache/log4j/test/witness/shallow.A2.5 deleted file mode 100644 index 1df2f98412..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A2.5 +++ /dev/null @@ -1,15 +0,0 @@ -[main] WARN org.apache.log4j.test.Shallow NDC - Message 2 -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 3 -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 4 -[main] WARN org.apache.log4j.test.Shallow NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A2.6 b/src/java/org/apache/log4j/test/witness/shallow.A2.6 deleted file mode 100644 index 1df2f98412..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A2.6 +++ /dev/null @@ -1,15 +0,0 @@ -[main] WARN org.apache.log4j.test.Shallow NDC - Message 2 -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 3 -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 4 -[main] WARN org.apache.log4j.test.Shallow NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A2.7 b/src/java/org/apache/log4j/test/witness/shallow.A2.7 deleted file mode 100644 index 1df2f98412..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A2.7 +++ /dev/null @@ -1,15 +0,0 @@ -[main] WARN org.apache.log4j.test.Shallow NDC - Message 2 -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 3 -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 4 -[main] WARN org.apache.log4j.test.Shallow NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/witness/shallow.A2.8 b/src/java/org/apache/log4j/test/witness/shallow.A2.8 deleted file mode 100644 index 1ae373ad70..0000000000 --- a/src/java/org/apache/log4j/test/witness/shallow.A2.8 +++ /dev/null @@ -1,25 +0,0 @@ -[main] DEBUG org.apache.log4j.test.Shallow NDC - Message 0 -[main] INFO org.apache.log4j.test.Shallow NDC - Message 1 -[main] WARN org.apache.log4j.test.Shallow NDC - Message 2 -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 3 -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 4 -[main] DEBUG org.apache.log4j.test.Shallow NDC - Message 5 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] INFO org.apache.log4j.test.Shallow NDC - Message 6 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] WARN org.apache.log4j.test.Shallow NDC - Message 7 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] ERROR org.apache.log4j.test.Shallow NDC - Message 8 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) -[main] FATAL org.apache.log4j.test.Shallow NDC - Message 9 -java.lang.Exception: Just testing - at org.apache.log4j.test.Shallow.test(Shallow.java:XXX) - at org.apache.log4j.test.Shallow.main(Shallow.java:XXX) diff --git a/src/java/org/apache/log4j/test/xml/asyncTest.xml b/src/java/org/apache/log4j/test/xml/asyncTest.xml deleted file mode 100644 index cddfcc714c..0000000000 --- a/src/java/org/apache/log4j/test/xml/asyncTest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/java/org/apache/log4j/test/xml/domTest1.xml b/src/java/org/apache/log4j/test/xml/domTest1.xml deleted file mode 100644 index 6a9673be9a..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest1.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/domTest10.xml b/src/java/org/apache/log4j/test/xml/domTest10.xml deleted file mode 100644 index 3e2c2a8249..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest10.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/domTest11.xml b/src/java/org/apache/log4j/test/xml/domTest11.xml deleted file mode 100644 index aee35d648c..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest11.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/domTest12.xml b/src/java/org/apache/log4j/test/xml/domTest12.xml deleted file mode 100644 index 409ffc19b5..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest12.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/domTest2.xml b/src/java/org/apache/log4j/test/xml/domTest2.xml deleted file mode 100644 index bc4a8699b1..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest2.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/domTest3.xml b/src/java/org/apache/log4j/test/xml/domTest3.xml deleted file mode 100644 index 724295e90a..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest3.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/domTest4.xml b/src/java/org/apache/log4j/test/xml/domTest4.xml deleted file mode 100644 index 2c465c86ee..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest4.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/domTest5.xml b/src/java/org/apache/log4j/test/xml/domTest5.xml deleted file mode 100644 index 9101c28688..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest5.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/domTest6.xml b/src/java/org/apache/log4j/test/xml/domTest6.xml deleted file mode 100644 index e24c201046..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest6.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/domTest7.xml b/src/java/org/apache/log4j/test/xml/domTest7.xml deleted file mode 100644 index 8c641fb5ae..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest7.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/domTest8.xml b/src/java/org/apache/log4j/test/xml/domTest8.xml deleted file mode 100644 index 2a975a1e41..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest8.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/domTest9.xml b/src/java/org/apache/log4j/test/xml/domTest9.xml deleted file mode 100644 index d7ba221fd7..0000000000 --- a/src/java/org/apache/log4j/test/xml/domTest9.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/ext1.xml b/src/java/org/apache/log4j/test/xml/ext1.xml deleted file mode 100644 index fafe77ee9f..0000000000 --- a/src/java/org/apache/log4j/test/xml/ext1.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/test/xml/stressAsyncAppender.xml b/src/java/org/apache/log4j/test/xml/stressAsyncAppender.xml deleted file mode 100644 index d8c3dd9aae..0000000000 --- a/src/java/org/apache/log4j/test/xml/stressAsyncAppender.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java b/src/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java deleted file mode 100644 index 10ded93053..0000000000 --- a/src/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java +++ /dev/null @@ -1,29 +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.txt file. - */ - -package org.apache.log4j.varia; - -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.spi.Configurator; -import java.net.URL; -import org.apache.log4j.spi.LoggerRepository; - -public class ReloadingPropertyConfigurator implements Configurator { - - - PropertyConfigurator delegate = new PropertyConfigurator(); - - - public ReloadingPropertyConfigurator() { - } - - public - void doConfigure(URL url, LoggerRepository repository) { - } - -} diff --git a/src/java/org/apache/log4j/varia/test/Loop.java b/src/java/org/apache/log4j/varia/test/Loop.java deleted file mode 100644 index ae60aa2397..0000000000 --- a/src/java/org/apache/log4j/varia/test/Loop.java +++ /dev/null @@ -1,58 +0,0 @@ - -package org.apache.log4j.varia.test; - -import org.apache.log4j.Category; -import org.apache.log4j.PropertyConfigurator; - -/** - This test program reads a config file and attempts to log to the - appenders specified as many times as specified by the second - loopLength parameter. - - @author Ceki Gülcü */ -public class Loop { - - static Category cat = Category.getInstance(Loop.class.getName()); - static int loopLength; - - public - static - void main(String argv[]) { - - if(argv.length == 2) - init(argv[0], argv[1]); - else - usage("Wrong number of arguments."); - test(); - } - - - static - void usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java " + Loop.class.getName() + - "configFile loopLength"); - System.exit(1); - } - - - static - void init(String configFile, String loopStr) { - PropertyConfigurator.configure(configFile); - try { - loopLength = Integer.parseInt(loopStr); - } - catch(java.lang.NumberFormatException e) { - e.printStackTrace(); - usage("Could not interpret loopLength ["+ loopStr +"]."); - } - } - - static - void test() { - for(int i=0; i < loopLength; i++) { - Thread.yield(); - cat.debug("MSG "+i); - } - } -} diff --git a/src/java/org/apache/log4j/varia/test/checkForHoles.pl b/src/java/org/apache/log4j/varia/test/checkForHoles.pl deleted file mode 100644 index 2f1a2724f1..0000000000 --- a/src/java/org/apache/log4j/varia/test/checkForHoles.pl +++ /dev/null @@ -1,53 +0,0 @@ - -# This script checks for holes while rolling a log file. - -$input=$ARGV[0]; -$MAX_COUNT=$ARGV[1]; -$LAST_EXPECTED=$ARGV[2]; - -$counter = 0; -$expected = 0; - -for($i = $MAX_COUNT; $i >= 1; $i--) { - checkOrder("$input.$i"); -} - -checkOrder("$input"); - -if($expected == $LAST_EXPECTED) { - print "All files as expected.\n"; -} -else { - print "Missing output or unexpected output in $input$i.\n"; - exit 1; -} - - -sub checkOrder { - $file = $_[0]; - if(-e "$file") { - $firstLine = `head -1 $file`; - chomp $first; - $lastLine = `tail -1 $file`; - - if($firstLine =~ /MSG $expected/) { - print "First line of $file in expected order.\n"; - } - else { - print "First line of $file not as expected.\n"; - exit 1; - } - - if($lastLine =~ /MSG (\d*)/) { - $expected = $1 + 1; - } - else { - print "last line of $file in unexpected format.\n"; - exit 1; - } - } - else { - print "Skipping inexistent file [$file].\n"; - } -} - diff --git a/src/java/org/apache/log4j/varia/test/doRoll b/src/java/org/apache/log4j/varia/test/doRoll deleted file mode 100644 index 46cedb174e..0000000000 --- a/src/java/org/apache/log4j/varia/test/doRoll +++ /dev/null @@ -1,21 +0,0 @@ - -# Read the .functions file -. ../../test/.functions - - -LOOP_LEN=$1 -HOST=$2 -PORT=$3 - -declare -i i -i=0 - -while [ $i -lt $LOOP_LEN ] -do - sleep 1 - i=$i+1 - java -Dlog4j.configDebug org.apache.log4j.varia.Roller $HOST $PORT -done - - - diff --git a/src/java/org/apache/log4j/varia/test/elf.pl b/src/java/org/apache/log4j/varia/test/elf.pl deleted file mode 100644 index 235f650204..0000000000 --- a/src/java/org/apache/log4j/varia/test/elf.pl +++ /dev/null @@ -1,34 +0,0 @@ - -# This script continously renames the $input to $input.$counter, -# sleeps for one second, increments $counter and starts over until -# $counter reaches $MAX_COUNT. - -# The script is used for testing the ResilientFileAppender. - -$input=$ARGV[0]; -$MAX_COUNT=$ARGV[1]; - - -$counter = 0; - -while($MAX_COUNT > $counter) { - - if(!(-e $input)) { - print "File [$input] does not seem to exist. This can happen.\n"; - } - elsif(!(-f $input)) { - print "[$input] does not seem to be file.\n"; - } - elsif ( !(-w $input)) { - print "File $input does not seem to be writeeble!!!!\n"; - } - else { - print "Renaming $input to $input.$counter\n"; - rename $input, $input.$counter; - } - - - $counter++; - - sleep 1; -} diff --git a/src/java/org/apache/log4j/varia/test/externalRoll b/src/java/org/apache/log4j/varia/test/externalRoll deleted file mode 100644 index d265df6dcb..0000000000 --- a/src/java/org/apache/log4j/varia/test/externalRoll +++ /dev/null @@ -1,42 +0,0 @@ - -# This script - -# Read the .functions file -. ../../test/.functions - - -TEMP=temp -PORT=6700 - -MAX_COUNTER=15 -MAX_MESSAGES=500000 - - -setPERL - -echo "log4j.rootCategory=DEBUG, testAppender" > $LCF -lecho "log4j.appender.testAppender=org.apache.log4j.varia.ExternallyRolledFileAppender" -lecho "log4j.appender.testAppender.File=$TEMP" -lecho "log4j.appender.testAppender.Append=false" -lecho "log4j.appender.testAppender.Port=$PORT" -lecho "log4j.appender.testAppender.MaxBackupIndex=$MAX_COUNTER" -lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout" -lecho "log4j.appender.testAppender.layout.ConversionPattern=%m%n" - - -rm ${TEMP}* - - - -./doRoll $MAX_COUNTER localhost $PORT & -java -Dlog4j.configDebug org.apache.log4j.varia.test.Loop $LCF $MAX_MESSAGES - - - -if perl checkForHoles.pl $TEMP $MAX_COUNTER $MAX_MESSAGES -then - echo "Externally triggered roll over test PASSED." -else - echo "Externally triggered roll over test test FAILED." - exit 1 -fi diff --git a/src/java/org/apache/log4j/varia/test/resiliency b/src/java/org/apache/log4j/varia/test/resiliency deleted file mode 100644 index 20fd390fa5..0000000000 --- a/src/java/org/apache/log4j/varia/test/resiliency +++ /dev/null @@ -1,41 +0,0 @@ - -# This shell script checks whether for a given computing environment -# the ResilientFileAppender can cope with renaming of the file where -# the log output goes. - -# Test show that under Linux the ResilientFileAppender correctly copes -# with renaming of files. On the other hand, under Windows 2000 the -# premise of ResilientFileAppender is false because under Windows 2000 -# it is not possible to rename an open file. - -# Read the .functions file -. ../../test/.functions - - -TEMP=temp - -setPERL - -echo "log4j.rootCategory=DEBUG, testAppender" > $LCF -lecho "log4j.appender.testAppender=org.apache.log4j.ResilientFileAppender" -lecho "log4j.appender.testAppender.File=$TEMP" -lecho "log4j.appender.testAppender.Append=false" -lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout" -lecho "log4j.appender.testAppender.layout.ConversionPattern=%m%n" - - -rm ${TEMP}* - -MAX_COUNTER=3 -MAX_MESSAGES=50000 - -perl elf.pl $TEMP $MAX_COUNTER& -java org.apache.log4j.test.Loop $LCF $MAX_MESSAGES - -if perl checkForHoles.pl $TEMP $MAX_COUNTER $MAX_MESSAGES -then - echo "Resiliency test PASSED for this environment." -else - echo "Resiliency test FAILED." - exit 1 -fi diff --git a/src/java/org/apache/log4j/xml/.cvsignore b/src/java/org/apache/log4j/xml/.cvsignore deleted file mode 100644 index f590ca415d..0000000000 --- a/src/java/org/apache/log4j/xml/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -doc-files \ No newline at end of file diff --git a/src/java/org/apache/log4j/xml/SAXErrorHandler.java b/src/java/org/apache/log4j/xml/SAXErrorHandler.java deleted file mode 100644 index 8c80db45e4..0000000000 --- a/src/java/org/apache/log4j/xml/SAXErrorHandler.java +++ /dev/null @@ -1,37 +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.txt file. */ - -package org.apache.log4j.xml; - -import org.xml.sax.ErrorHandler; -import org.xml.sax.SAXParseException; -import org.apache.log4j.helpers.LogLog; - -public class SAXErrorHandler implements ErrorHandler { - - public - void error(SAXParseException ex) { - LogLog.error("Parsing error on line "+ex.getLineNumber()+" and column " - +ex.getColumnNumber()); - LogLog.error(ex.getMessage(), ex.getException()); - //LogLog.error("pid="+ex.getPublicId()+" sid="+ex.getSystemId()); - } - - public - void fatalError(SAXParseException ex) { - error(ex); - } - - public - void warning(SAXParseException ex) { - LogLog.warn("Parsing error on line "+ex.getLineNumber()+" and column " - +ex.getColumnNumber()); - LogLog.warn(ex.getMessage(), ex.getException()); - } - - -} diff --git a/src/java/org/apache/log4j/xml/XMLLayout.java b/src/java/org/apache/log4j/xml/XMLLayout.java deleted file mode 100644 index abc2fa284a..0000000000 --- a/src/java/org/apache/log4j/xml/XMLLayout.java +++ /dev/null @@ -1,162 +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.txt file. */ - -// Contributors: Mathias Bogaert - -package org.apache.log4j.xml; - -import org.apache.log4j.Layout; -import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.spi.LocationInfo; -import org.apache.log4j.helpers.OptionConverter; -import org.apache.log4j.helpers.DateLayout; -import org.apache.log4j.helpers.Transform; - -/** - The output of the XMLLayout consists of a series of log4j:event - elements as defined in the log4j.dtd. It does not output a - complete well-formed XML file. The output is designed to be - included as an external entity in a separate file to form - a correct XML file. - -

    For example, if abc is the name of the file where - the XMLLayout ouput goes, then a well-formed XML file would be: - -

    -   <?xml version="1.0" ?>
    -
    -   <!DOCTYPE log4j:eventSet SYSTEM "log4j.dtd" [<!ENTITY data SYSTEM "abc">]>
    -
    -   <log4j:eventSet version="1.2" xmlns:log4j="http://jakarta.apache.org/log4j/">
    -         &data;
    -   </log4j:eventSet>
    -   
    - -

    This approach enforces the independence of the XMLLayout and the - appender where it is embedded. - -

    The version attribute helps components to correctly - intrepret output generated by XMLLayout. The value of this - attribute should be "1.1" for output generated by log4j versions - prior to log4j 1.2 (final release) and "1.2" for relase 1.2 and - later. - - @author Ceki Gülcü - @since 0.9.0 */ -public class XMLLayout extends Layout { - - private final int DEFAULT_SIZE = 256; - private final int UPPER_LIMIT = 2048; - - private StringBuffer buf = new StringBuffer(DEFAULT_SIZE); - private boolean locationInfo = false; - - - /** - The LocationInfo option takes a boolean value. By - default, it is set to false which means there will be no location - information output by this layout. If the the option is set to - true, then the file name and line number of the statement - at the origin of the log statement will be output. - -

    If you are embedding this layout within an {@link - org.apache.log4j.net.SMTPAppender} then make sure to set the - LocationInfo option of that appender as well. - */ - public - void setLocationInfo(boolean flag) { - locationInfo = flag; - } - - /** - Returns the current value of the LocationInfo option. - */ - public - boolean getLocationInfo() { - return locationInfo; - } - - public - void activateOptions() { - } - - - /** - Formats a {@link LoggingEvent} in conformance with the log4j.dtd. */ - public - String format(LoggingEvent event) { - - // Reset working buffer. If the buffer is too large, then we need a new - // one in order to avoid the penalty of creating a large array. - if(buf.capacity() > UPPER_LIMIT) { - buf = new StringBuffer(DEFAULT_SIZE); - } else { - buf.setLength(0); - } - - // We yield to the \r\n heresy. - - buf.append("\r\n"); - - - buf.append("\r\n"); - - String ndc = event.getNDC(); - if(ndc != null) { - buf.append("\r\n"); - } - - String[] s = event.getThrowableStrRep(); - if(s != null) { - buf.append("\r\n"); - } - - if(locationInfo) { - LocationInfo locationInfo = event.getLocationInformation(); - buf.append("\r\n"); - } - - buf.append("\r\n\r\n"); - - return buf.toString(); - } - - /** - The XMLLayout prints and does not ignore exceptions. Hence the - return value false. - */ - public - boolean ignoresThrowable() { - return false; - } -} diff --git a/src/java/org/apache/log4j/xml/examples/.cvsignore b/src/java/org/apache/log4j/xml/examples/.cvsignore deleted file mode 100644 index f590ca415d..0000000000 --- a/src/java/org/apache/log4j/xml/examples/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -doc-files \ No newline at end of file diff --git a/src/java/org/apache/log4j/xml/examples/ReportParserError.java b/src/java/org/apache/log4j/xml/examples/ReportParserError.java deleted file mode 100644 index 8846e339f3..0000000000 --- a/src/java/org/apache/log4j/xml/examples/ReportParserError.java +++ /dev/null @@ -1,35 +0,0 @@ - -package org.apache.log4j.xml.examples; - -import org.apache.log4j.helpers.LogLog; - -/** - - This class is needed for validating a log4j.dtd derived XML file. - - @author Joe Kesselman - - @since 0.8.3 - - */ -public class ReportParserError implements org.xml.sax.ErrorHandler { - - void report(String msg, org.xml.sax.SAXParseException e) { - LogLog.error(msg+e.getMessage()+ "\n\tat line="+ e.getLineNumber()+ - " col="+e.getColumnNumber()+ " of "+ - "SystemId=\""+e.getSystemId()+ - "\" PublicID = \""+e.getPublicId()+'\"'); - } - - public void warning(org.xml.sax.SAXParseException e) { - report("WARNING: ", e); - } - - public void error(org.xml.sax.SAXParseException e) { - report("ERROR: ", e); - } - - public void fatalError(org.xml.sax.SAXParseException e) { - report("FATAL: ", e); - } -} diff --git a/src/java/org/apache/log4j/xml/examples/XMLSample.java b/src/java/org/apache/log4j/xml/examples/XMLSample.java deleted file mode 100644 index d3ee98cf7a..0000000000 --- a/src/java/org/apache/log4j/xml/examples/XMLSample.java +++ /dev/null @@ -1,61 +0,0 @@ - -package org.apache.log4j.xml.examples; - -import org.apache.log4j.xml.DOMConfigurator; -import org.apache.log4j.Category; -import java.net.*; - -/** - - This example code shows how to - read an XML based configuration file using a DOM parser. - -

    Sample XML files sample1.xml - and sample2.xml are provided. - - -

    Note that the log4j.dtd is not in the local directory. - It is found by the class loader. - - @author Ceki Gülcü - -*/ -public class XMLSample { - - static Category cat = Category.getInstance(XMLSample.class.getName()); - - public - static - void main(String argv[]) { - - if(argv.length == 1) - init(argv[0]); - else - Usage("Wrong number of arguments."); - sample(); - } - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java " + XMLSample.class.getName() + - "configFile"); - System.exit(1); - } - - static - void init(String configFile) { - DOMConfigurator.configure(configFile); - } - - static - void sample() { - int i = -1; - Category root = Category.getRoot(); - cat.debug("Message " + ++i); - cat.warn ("Message " + ++i); - cat.error("Message " + ++i); - Exception e = new Exception("Just testing"); - cat.debug("Message " + ++i, e); - } -} diff --git a/src/java/org/apache/log4j/xml/examples/extension1.xml b/src/java/org/apache/log4j/xml/examples/extension1.xml deleted file mode 100644 index af78d1ea2b..0000000000 --- a/src/java/org/apache/log4j/xml/examples/extension1.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/xml/examples/extension2.xml b/src/java/org/apache/log4j/xml/examples/extension2.xml deleted file mode 100644 index b4b3518ce9..0000000000 --- a/src/java/org/apache/log4j/xml/examples/extension2.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - -]> - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/java/org/apache/log4j/xml/examples/package.html b/src/java/org/apache/log4j/xml/examples/package.html deleted file mode 100644 index 21d9bdd86c..0000000000 --- a/src/java/org/apache/log4j/xml/examples/package.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - -

    Example usage of log4j with XML (including source code). - -

    This package's shows how log4j can be used with an XML -configuration file. - -

    See source code of XMLSample.java showing how to -configure with an XML file. Sample XML files -sample1.xml, -sample2.xml, -sample3.xml, -sample4.xml, -sample5.xml are provided. - -


    -
    - -Last modified: Wed Apr 12 22:27:25 MDT 2000 - - diff --git a/src/java/org/apache/log4j/xml/test/.cvsignore b/src/java/org/apache/log4j/xml/test/.cvsignore deleted file mode 100644 index 31efc8c599..0000000000 --- a/src/java/org/apache/log4j/xml/test/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -output* -temp* -current.reg \ No newline at end of file diff --git a/src/java/org/apache/log4j/xml/test/DOMTest.java b/src/java/org/apache/log4j/xml/test/DOMTest.java deleted file mode 100644 index 225cfb68e3..0000000000 --- a/src/java/org/apache/log4j/xml/test/DOMTest.java +++ /dev/null @@ -1,79 +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.xml.test; - -import org.apache.log4j.xml.DOMConfigurator; -import org.apache.log4j.Category; -import org.apache.log4j.Priority; -//import org.apache.log4j.xml.examples.ReportParserError; -//import org.apache.xerces.parsers.DOMParser; -//import java.io.FileInputStream; -//import org.xml.sax.InputSource; - -/** - @author Ceki Gülcü -*/ -public class DOMTest { - static Category cat = Category.getInstance(DOMTest.class.getName()); - - - public - static - void main(String argv[]) { - - if(argv.length == 1) - init(argv[0]); - else - Usage("Wrong number of arguments."); - - test(); - } - - static - void Usage(String msg) { - System.err.println(msg); - System.err.println( "Usage: java " + DOMTest.class.getName() + - " configFile"); - System.exit(1); - } - - static - void init(String configFile) { - DOMConfigurator.configure(configFile); - } - - static - void test() { - int i = -1; - Category root = Category.getRoot(); - - cat.debug("Message " + ++i); - root.debug("Message " + i); - - cat.info ("Message " + ++i); - root.info("Message " + i); - - cat.warn ("Message " + ++i); - root.warn("Message " + i); - - cat.error("Message " + ++i); - root.error("Message " + i); - - cat.log(Priority.FATAL, "Message " + ++i); - root.log(Priority.FATAL, "Message " + i); - - Exception e = new Exception("Just testing"); - cat.debug("Message " + ++i, e); - root.debug("Message " + i, e); - - cat.error("Message " + ++i, e); - root.error("Message " + i, e); - - Category.shutdown(); - } -} diff --git a/src/java/org/apache/log4j/xml/test/testlog.xml b/src/java/org/apache/log4j/xml/test/testlog.xml deleted file mode 100644 index dd54e58c44..0000000000 --- a/src/java/org/apache/log4j/xml/test/testlog.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/java/org/apache/log4j/Appender.java b/src/main/java/org/apache/log4j/Appender.java similarity index 77% rename from src/java/org/apache/log4j/Appender.java rename to src/main/java/org/apache/log4j/Appender.java index 36428113da..67703f523b 100644 --- a/src/java/org/apache/log4j/Appender.java +++ b/src/main/java/org/apache/log4j/Appender.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; @@ -73,7 +83,7 @@ public interface Appender { /** Set the {@link ErrorHandler} for this appender. - @ since 0.9.0 + @since 0.9.0 */ public void setErrorHandler(ErrorHandler errorHandler); diff --git a/src/java/org/apache/log4j/AppenderSkeleton.java b/src/main/java/org/apache/log4j/AppenderSkeleton.java similarity index 73% rename from src/java/org/apache/log4j/AppenderSkeleton.java rename to src/main/java/org/apache/log4j/AppenderSkeleton.java index caf95ba1b6..630516e767 100644 --- a/src/java/org/apache/log4j/AppenderSkeleton.java +++ b/src/main/java/org/apache/log4j/AppenderSkeleton.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; @@ -17,13 +27,14 @@ /** - Abstract superclass of the other appenders in the package. - - This class provides the code for common functionality, such as - support for threshold filtering and support for general filters. - - @since 0.8.1 - @author Ceki Gülcü */ + * Abstract superclass of the other appenders in the package. + * + * This class provides the code for common functionality, such as + * support for threshold filtering and support for general filters. + * + * @since 0.8.1 + * @author Ceki Gülcü + * */ public abstract class AppenderSkeleton implements Appender, OptionHandler { /** The layout variable does not need to be set if the appender @@ -53,6 +64,26 @@ public abstract class AppenderSkeleton implements Appender, OptionHandler { */ protected boolean closed = false; + /** + * Create new instance. + */ + public AppenderSkeleton() { + super(); + } + + /** + * Create new instance. + * Provided for compatibility with log4j 1.3. + * + * @param isActive true if appender is ready for use upon construction. + * Not used in log4j 1.2.x. + * @since 1.2.15 + */ + protected AppenderSkeleton(final boolean isActive) { + super(); + } + + /** Derived appenders should override this method if option structure @@ -72,7 +103,7 @@ void addFilter(Filter newFilter) { if(headFilter == null) { headFilter = tailFilter = newFilter; } else { - tailFilter.next = newFilter; + tailFilter.setNext(newFilter); tailFilter = newFilter; } } @@ -99,11 +130,10 @@ void clearFilters() { } /** - Finalize this appender by calling the imlenentation's + Finalize this appender by calling the derived class' close method. - @since 0.8.4 - */ + @since 0.8.4 */ public void finalize() { // An appender might be closed then garbage collected. There is no @@ -191,11 +221,10 @@ boolean isAsSevereAsThreshold(Priority priority) { /** - This method performs threshold checks and invokes filters before - delegating actual logging to the subclasses specific {@link - AppenderSkeleton#append} method. - - */ + * This method performs threshold checks and invokes filters before + * delegating actual logging to the subclasses specific {@link + * AppenderSkeleton#append} method. + * */ public synchronized void doAppend(LoggingEvent event) { @@ -204,7 +233,7 @@ void doAppend(LoggingEvent event) { return; } - if(!isAsSevereAsThreshold(event.level)) { + if(!isAsSevereAsThreshold(event.getLevel())) { return; } @@ -215,7 +244,7 @@ void doAppend(LoggingEvent event) { switch(f.decide(event)) { case Filter.DENY: return; case Filter.ACCEPT: break FILTER_LOOP; - case Filter.NEUTRAL: f = f.next; + case Filter.NEUTRAL: f = f.getNext(); } } diff --git a/src/main/java/org/apache/log4j/AsyncAppender.java b/src/main/java/org/apache/log4j/AsyncAppender.java new file mode 100644 index 0000000000..2a03eb63a6 --- /dev/null +++ b/src/main/java/org/apache/log4j/AsyncAppender.java @@ -0,0 +1,593 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Contibutors: Aaron Greenhouse +// Thomas Tuft Muller +package org.apache.log4j; + +import org.apache.log4j.helpers.AppenderAttachableImpl; +import org.apache.log4j.spi.AppenderAttachable; +import org.apache.log4j.spi.LoggingEvent; + +import java.text.MessageFormat; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + + +/** + * The AsyncAppender lets users log events asynchronously. + *

    + *

    + * The AsyncAppender will collect the events sent to it and then dispatch them + * to all the appenders that are attached to it. You can attach multiple + * appenders to an AsyncAppender. + *

    + *

    + *

    + * The AsyncAppender uses a separate thread to serve the events in its buffer. + *

    + *

    + * Important note: The AsyncAppender can only be script + * configured using the {@link org.apache.log4j.xml.DOMConfigurator}. + *

    + * + * @author Ceki Gülcü + * @author Curt Arnold + * @since 0.9.1 + */ +public class AsyncAppender extends AppenderSkeleton + implements AppenderAttachable { + /** + * The default buffer size is set to 128 events. + */ + public static final int DEFAULT_BUFFER_SIZE = 128; + + /** + * Event buffer, also used as monitor to protect itself and + * discardMap from simulatenous modifications. + */ + private final List buffer = new ArrayList(); + + /** + * Map of DiscardSummary objects keyed by logger name. + */ + private final Map discardMap = new HashMap(); + + /** + * Buffer size. + */ + private int bufferSize = DEFAULT_BUFFER_SIZE; + + /** Nested appenders. */ + AppenderAttachableImpl aai; + + /** + * Nested appenders. + */ + private final AppenderAttachableImpl appenders; + + /** + * Dispatcher. + */ + private final Thread dispatcher; + + /** + * Should location info be included in dispatched messages. + */ + private boolean locationInfo = false; + + /** + * Does appender block when buffer is full. + */ + private boolean blocking = true; + + /** + * Create new instance. + */ + public AsyncAppender() { + appenders = new AppenderAttachableImpl(); + + // + // only set for compatibility + aai = appenders; + + dispatcher = + new Thread(new Dispatcher(this, buffer, discardMap, appenders)); + + // It is the user's responsibility to close appenders before + // exiting. + dispatcher.setDaemon(true); + + // set the dispatcher priority to lowest possible value + // dispatcher.setPriority(Thread.MIN_PRIORITY); + dispatcher.setName("Dispatcher-" + dispatcher.getName()); + dispatcher.start(); + } + + /** + * Add appender. + * + * @param newAppender appender to add, may not be null. + */ + public void addAppender(final Appender newAppender) { + synchronized (appenders) { + appenders.addAppender(newAppender); + } + } + + /** + * {@inheritDoc} + */ + public void append(final LoggingEvent event) { + // + // if dispatcher thread has died then + // append subsequent events synchronously + // See bug 23021 + if ((dispatcher == null) || !dispatcher.isAlive() || (bufferSize <= 0)) { + synchronized (appenders) { + appenders.appendLoopOnAppenders(event); + } + + return; + } + + // Set the NDC and thread name for the calling thread as these + // LoggingEvent fields were not set at event creation time. + event.getNDC(); + event.getThreadName(); + // Get a copy of this thread's MDC. + event.getMDCCopy(); + if (locationInfo) { + event.getLocationInformation(); + } + + synchronized (buffer) { + while (true) { + int previousSize = buffer.size(); + + if (previousSize < bufferSize) { + buffer.add(event); + + // + // if buffer had been empty + // signal all threads waiting on buffer + // to check their conditions. + // + if (previousSize == 0) { + buffer.notifyAll(); + } + + break; + } + + // + // Following code is only reachable if buffer is full + // + // + // if blocking and thread is not already interrupted + // and not the dispatcher then + // wait for a buffer notification + boolean discard = true; + if (blocking + && !Thread.interrupted() + && Thread.currentThread() != dispatcher) { + try { + buffer.wait(); + discard = false; + } catch (InterruptedException e) { + // + // reset interrupt status so + // calling code can see interrupt on + // their next wait or sleep. + Thread.currentThread().interrupt(); + } + } + + // + // if blocking is false or thread has been interrupted + // add event to discard map. + // + if (discard) { + String loggerName = event.getLoggerName(); + DiscardSummary summary = (DiscardSummary) discardMap.get(loggerName); + + if (summary == null) { + summary = new DiscardSummary(event); + discardMap.put(loggerName, summary); + } else { + summary.add(event); + } + + break; + } + } + } + } + + /** + * Close this AsyncAppender by interrupting the dispatcher + * thread which will process all pending events before exiting. + */ + public void close() { + /** + * Set closed flag and notify all threads to check their conditions. + * Should result in dispatcher terminating. + */ + synchronized (buffer) { + closed = true; + buffer.notifyAll(); + } + + try { + dispatcher.join(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + org.apache.log4j.helpers.LogLog.error( + "Got an InterruptedException while waiting for the " + + "dispatcher to finish.", e); + } + + // + // close all attached appenders. + // + synchronized (appenders) { + Enumeration iter = appenders.getAllAppenders(); + + if (iter != null) { + while (iter.hasMoreElements()) { + Object next = iter.nextElement(); + + if (next instanceof Appender) { + ((Appender) next).close(); + } + } + } + } + } + + /** + * Get iterator over attached appenders. + * @return iterator or null if no attached appenders. + */ + public Enumeration getAllAppenders() { + synchronized (appenders) { + return appenders.getAllAppenders(); + } + } + + /** + * Get appender by name. + * + * @param name name, may not be null. + * @return matching appender or null. + */ + public Appender getAppender(final String name) { + synchronized (appenders) { + return appenders.getAppender(name); + } + } + + /** + * Gets whether the location of the logging request call + * should be captured. + * + * @return the current value of the LocationInfo option. + */ + public boolean getLocationInfo() { + return locationInfo; + } + + /** + * Determines if specified appender is attached. + * @param appender appender. + * @return true if attached. + */ + public boolean isAttached(final Appender appender) { + synchronized (appenders) { + return appenders.isAttached(appender); + } + } + + /** + * {@inheritDoc} + */ + public boolean requiresLayout() { + return false; + } + + /** + * Removes and closes all attached appenders. + */ + public void removeAllAppenders() { + synchronized (appenders) { + appenders.removeAllAppenders(); + } + } + + /** + * Removes an appender. + * @param appender appender to remove. + */ + public void removeAppender(final Appender appender) { + synchronized (appenders) { + appenders.removeAppender(appender); + } + } + + /** + * Remove appender by name. + * @param name name. + */ + public void removeAppender(final String name) { + synchronized (appenders) { + appenders.removeAppender(name); + } + } + + /** + * The LocationInfo option takes a boolean value. By default, it is + * set to false which means there will be no effort to extract the location + * information related to the event. As a result, the event that will be + * ultimately logged will likely to contain the wrong location information + * (if present in the log format). + *

    + *

    + * Location information extraction is comparatively very slow and should be + * avoided unless performance is not a concern. + *

    + * @param flag true if location information should be extracted. + */ + public void setLocationInfo(final boolean flag) { + locationInfo = flag; + } + + /** + * Sets the number of messages allowed in the event buffer + * before the calling thread is blocked (if blocking is true) + * or until messages are summarized and discarded. Changing + * the size will not affect messages already in the buffer. + * + * @param size buffer size, must be positive. + */ + public void setBufferSize(final int size) { + // + // log4j 1.2 would throw exception if size was negative + // and deadlock if size was zero. + // + if (size < 0) { + throw new java.lang.NegativeArraySizeException("size"); + } + + synchronized (buffer) { + // + // don't let size be zero. + // + bufferSize = (size < 1) ? 1 : size; + buffer.notifyAll(); + } + } + + /** + * Gets the current buffer size. + * @return the current value of the BufferSize option. + */ + public int getBufferSize() { + return bufferSize; + } + + /** + * Sets whether appender should wait if there is no + * space available in the event buffer or immediately return. + * + * @param value true if appender should wait until available space in buffer. + */ + public void setBlocking(final boolean value) { + synchronized (buffer) { + blocking = value; + buffer.notifyAll(); + } + } + + /** + * Gets whether appender should block calling thread when buffer is full. + * If false, messages will be counted by logger and a summary + * message appended after the contents of the buffer have been appended. + * + * @return true if calling thread will be blocked when buffer is full. + */ + public boolean getBlocking() { + return blocking; + } + + /** + * Summary of discarded logging events for a logger. + */ + private static final class DiscardSummary { + /** + * First event of the highest severity. + */ + private LoggingEvent maxEvent; + + /** + * Total count of messages discarded. + */ + private int count; + + /** + * Create new instance. + * + * @param event event, may not be null. + */ + public DiscardSummary(final LoggingEvent event) { + maxEvent = event; + count = 1; + } + + /** + * Add discarded event to summary. + * + * @param event event, may not be null. + */ + public void add(final LoggingEvent event) { + if (event.getLevel().toInt() > maxEvent.getLevel().toInt()) { + maxEvent = event; + } + + count++; + } + + /** + * Create event with summary information. + * + * @return new event. + */ + public LoggingEvent createEvent() { + String msg = + MessageFormat.format( + "Discarded {0} messages due to full event buffer including: {1}", + new Object[] { new Integer(count), maxEvent.getMessage() }); + + return new LoggingEvent( + "org.apache.log4j.AsyncAppender.DONT_REPORT_LOCATION", + Logger.getLogger(maxEvent.getLoggerName()), + maxEvent.getLevel(), + msg, + null); + } + } + + /** + * Event dispatcher. + */ + private static class Dispatcher implements Runnable { + /** + * Parent AsyncAppender. + */ + private final AsyncAppender parent; + + /** + * Event buffer. + */ + private final List buffer; + + /** + * Map of DiscardSummary keyed by logger name. + */ + private final Map discardMap; + + /** + * Wrapped appenders. + */ + private final AppenderAttachableImpl appenders; + + /** + * Create new instance of dispatcher. + * + * @param parent parent AsyncAppender, may not be null. + * @param buffer event buffer, may not be null. + * @param discardMap discard map, may not be null. + * @param appenders appenders, may not be null. + */ + public Dispatcher( + final AsyncAppender parent, final List buffer, final Map discardMap, + final AppenderAttachableImpl appenders) { + + this.parent = parent; + this.buffer = buffer; + this.appenders = appenders; + this.discardMap = discardMap; + } + + /** + * {@inheritDoc} + */ + public void run() { + boolean isActive = true; + + // + // if interrupted (unlikely), end thread + // + try { + // + // loop until the AsyncAppender is closed. + // + while (isActive) { + LoggingEvent[] events = null; + + // + // extract pending events while synchronized + // on buffer + // + synchronized (buffer) { + int bufferSize = buffer.size(); + isActive = !parent.closed; + + while ((bufferSize == 0) && isActive) { + buffer.wait(); + bufferSize = buffer.size(); + isActive = !parent.closed; + } + + if (bufferSize > 0) { + events = new LoggingEvent[bufferSize + discardMap.size()]; + buffer.toArray(events); + + // + // add events due to buffer overflow + // + int index = bufferSize; + + for ( + Iterator iter = discardMap.values().iterator(); + iter.hasNext();) { + events[index++] = ((DiscardSummary) iter.next()).createEvent(); + } + + // + // clear buffer and discard map + // + buffer.clear(); + discardMap.clear(); + + // + // allow blocked appends to continue + buffer.notifyAll(); + } + } + + // + // process events after lock on buffer is released. + // + if (events != null) { + for (int i = 0; i < events.length; i++) { + synchronized (appenders) { + appenders.appendLoopOnAppenders(events[i]); + } + } + } + } + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } + } + } +} diff --git a/src/java/org/apache/log4j/BasicConfigurator.java b/src/main/java/org/apache/log4j/BasicConfigurator.java similarity index 65% rename from src/java/org/apache/log4j/BasicConfigurator.java rename to src/main/java/org/apache/log4j/BasicConfigurator.java index 7817965efc..2d859cf436 100644 --- a/src/java/org/apache/log4j/BasicConfigurator.java +++ b/src/main/java/org/apache/log4j/BasicConfigurator.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // Contibutors: "Luke Blanshard" // "Mark DONSZELMANN" diff --git a/src/java/org/apache/log4j/Category.java b/src/main/java/org/apache/log4j/Category.java similarity index 89% rename from src/java/org/apache/log4j/Category.java rename to src/main/java/org/apache/log4j/Category.java index 110b86dd67..e28d12ff6e 100644 --- a/src/java/org/apache/log4j/Category.java +++ b/src/main/java/org/apache/log4j/Category.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // Contibutors: Alex Blewitt // Markus Oestreicher @@ -33,40 +43,47 @@ /** - This class has been deprecated and - replaced by the {@link Logger} subclass. It - will be kept around to preserve backward compatibility until mid - 2003. - -

    Logger is a subclass of Category, i.e. it extends - Category. In other words, a logger is a category. Thus, - all operations that can be performed on a category can be performed - on a logger. Whenever log4j is asked to produce a Category object, - it will instead produce a Logger object. However, methods that - previously accepted category objects still continue to accept - category objects. - -

    For example, the following are all legal and will work as expected. - + * This class has been deprecated and + * replaced by the {@link Logger} subclass. It + * will be kept around to preserve backward compatibility until mid + * 2003. + * + *

    Logger is a subclass of Category, i.e. it extends + * Category. In other words, a logger is a category. Thus, + * all operations that can be performed on a category can be + * performed on a logger. Internally, whenever log4j is asked to + * produce a Category object, it will instead produce a Logger + * object. Log4j 1.2 will never produce Category objects but + * only Logger instances. In order to preserve backward + * compatibility, methods that previously accepted category objects + * still continue to accept category objects. + * + *

    For example, the following are all legal and will work as + * expected. + *

    -      // Deprecated form:
    -      Category cat = Category.getInstance("foo.bar")
    -
    -      // Preferred form for retrieving loggers:
    -      Logger logger = Logger.getLogger("foo.bar")
    +       // Deprecated form:
    +       Category cat = Category.getInstance("foo.bar")
    +   
    +       // Preferred form for retrieving loggers:
    +       Logger logger = Logger.getLogger("foo.bar")
        
    - -

    The first form is deprecated and should be avoided. - -

    There is absolutely no need for new client code to use or - refer to the Category class. Whenever possible, - please avoid referring to it or using it. - -

    See the short manual for an - introduction on this class. - - @author Ceki Gülcü - @author Anders Kristensen */ + + *

    The first form is deprecated and should be avoided. + * + *

    There is absolutely no need for new client code to use or + * refer to the Category class. Whenever possible, + * please avoid referring to it or using it. + * + *

    See the short manual for an + * introduction on this class. + *

    + * See the document entitled preparing + * for log4j 1.3 for a more detailed discussion. + * + * @author Ceki Gülcü + * @author Anders Kristensen + */ public class Category implements AppenderAttachable { /** @@ -77,9 +94,6 @@ public class Category implements AppenderAttachable { //final Hierarchy defaultHierarchy = new Hierarchy(new // RootCategory(Level.DEBUG)); - - static int nooptimize; - /** The name of this category. */ @@ -207,10 +221,10 @@ void callAppenders(LoggingEvent event) { */ synchronized void closeNestedAppenders() { - Enumeration enum = this.getAllAppenders(); - if(enum != null) { - while(enum.hasMoreElements()) { - Appender a = (Appender) enum.nextElement(); + Enumeration enumeration = this.getAllAppenders(); + if(enumeration != null) { + while(enumeration.hasMoreElements()) { + Appender a = (Appender) enumeration.nextElement(); if(a instanceof AppenderAttachable) { a.close(); } @@ -315,7 +329,7 @@ If the named category exists (in the default hierarchy) then it @deprecated Please use {@link LogManager#exists} instead. - @version 0.8.5 */ + @since 0.8.5 */ public static Logger exists(String name) { @@ -431,9 +445,10 @@ Level getEffectiveLevel() { } /** - - @deprecated Has been replaced by the {@link #getEffectiveLevel} - method. */ + * + * @deprecated Please use the the {@link #getEffectiveLevel} method + * instead. + * */ public Priority getChainedPriority() { for(Category c = this; c != null; c=c.parent) { @@ -497,40 +512,20 @@ LoggerRepository getLoggerRepository() { /** - Retrieve a category with named as the name - parameter. If the named category already exists, then the - existing instance will be reutrned. Otherwise, a new instance is - created. - - By default, categories do not have a set level but inherit - it from the hierarchy. This is one of the central features of - log4j. - - Deprecated Please use {@link Logger#getLogger(String)} - instead. - - @param name The name of the category to retrieve. */ + * @deprecated Make sure to use {@link Logger#getLogger(String)} instead. + */ public static Category getInstance(String name) { - nooptimize++; return LogManager.getLogger(name); } /** - Shorthand for getInstance(clazz.getName()). - - @param clazz The name of clazz will be used as the - name of the category to retrieve. See {@link - #getInstance(String)} for more detailed information. - - Deprecated Please use {@link Logger#getLogger(Class)} instead. - - @since 1.0 */ + * @deprecated Please make sure to use {@link Logger#getLogger(Class)} instead. + */ public static Category getInstance(Class clazz) { - nooptimize++; return LogManager.getLogger(clazz); } @@ -581,16 +576,7 @@ Level getPriority() { /** - Return the root of the default category hierrachy. - -

    The root category is always instantiated and available. It's - name is "root". - -

    Nevertheless, calling {@link #getInstance - Category.getInstance("root")} does not retrieve the root category - but a category just under root named "root". - - Deprecated Use {@link Logger#getRootLogger()} instead. + * @deprecated Please use {@link Logger#getRootLogger()} instead. */ final public diff --git a/src/main/java/org/apache/log4j/CategoryKey.java b/src/main/java/org/apache/log4j/CategoryKey.java new file mode 100644 index 0000000000..fe0fff7970 --- /dev/null +++ b/src/main/java/org/apache/log4j/CategoryKey.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +/** + CategoryKey is a wrapper for String that apparently accellerated + hash table lookup in early JVM's. + @author Ceki Gülcü +*/ +class CategoryKey { + + String name; + int hashCache; + + CategoryKey(String name) { + this.name = name; + hashCache = name.hashCode(); + } + + final + public + int hashCode() { + return hashCache; + } + + final + public + boolean equals(Object rArg) { + if(this == rArg) + return true; + + if(rArg != null && CategoryKey.class == rArg.getClass()) + return name.equals(((CategoryKey)rArg ).name); + else + return false; + } +} diff --git a/src/main/java/org/apache/log4j/ConsoleAppender.java b/src/main/java/org/apache/log4j/ConsoleAppender.java new file mode 100644 index 0000000000..b44fd5fddc --- /dev/null +++ b/src/main/java/org/apache/log4j/ConsoleAppender.java @@ -0,0 +1,220 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import java.io.IOException; +import java.io.OutputStream; +import org.apache.log4j.helpers.LogLog; + +/** + * ConsoleAppender appends log events to System.out or + * System.err using a layout specified by the user. The + * default target is System.out. + * + * @author Ceki Gülcü + * @author Curt Arnold + * @since 1.1 */ +public class ConsoleAppender extends WriterAppender { + + public static final String SYSTEM_OUT = "System.out"; + public static final String SYSTEM_ERR = "System.err"; + + protected String target = SYSTEM_OUT; + + /** + * Determines if the appender honors reassignments of System.out + * or System.err made after configuration. + */ + private boolean follow = false; + + /** + * Constructs an unconfigured appender. + */ + public ConsoleAppender() { + } + + /** + * Creates a configured appender. + * + * @param layout layout, may not be null. + */ + public ConsoleAppender(Layout layout) { + this(layout, SYSTEM_OUT); + } + + /** + * Creates a configured appender. + * @param layout layout, may not be null. + * @param target target, either "System.err" or "System.out". + */ + public ConsoleAppender(Layout layout, String target) { + setLayout(layout); + setTarget(target); + activateOptions(); + } + + /** + * Sets the value of the Target option. Recognized values + * are "System.out" and "System.err". Any other value will be + * ignored. + * */ + public + void setTarget(String value) { + String v = value.trim(); + + if (SYSTEM_OUT.equalsIgnoreCase(v)) { + target = SYSTEM_OUT; + } else if (SYSTEM_ERR.equalsIgnoreCase(v)) { + target = SYSTEM_ERR; + } else { + targetWarn(value); + } + } + + /** + * Returns the current value of the Target property. The + * default value of the option is "System.out". + * + * See also {@link #setTarget}. + * */ + public + String getTarget() { + return target; + } + + /** + * Sets whether the appender honors reassignments of System.out + * or System.err made after configuration. + * @param newValue if true, appender will use value of System.out or + * System.err in force at the time when logging events are appended. + * @since 1.2.13 + */ + public final void setFollow(final boolean newValue) { + follow = newValue; + } + + /** + * Gets whether the appender honors reassignments of System.out + * or System.err made after configuration. + * @return true if appender will use value of System.out or + * System.err in force at the time when logging events are appended. + * @since 1.2.13 + */ + public final boolean getFollow() { + return follow; + } + + void targetWarn(String val) { + LogLog.warn("["+val+"] should be System.out or System.err."); + LogLog.warn("Using previously set target, System.out by default."); + } + + /** + * Prepares the appender for use. + */ + public void activateOptions() { + if (follow) { + if (target.equals(SYSTEM_ERR)) { + setWriter(createWriter(new SystemErrStream())); + } else { + setWriter(createWriter(new SystemOutStream())); + } + } else { + if (target.equals(SYSTEM_ERR)) { + setWriter(createWriter(System.err)); + } else { + setWriter(createWriter(System.out)); + } + } + + super.activateOptions(); + } + + /** + * {@inheritDoc} + */ + protected + final + void closeWriter() { + if (follow) { + super.closeWriter(); + } + } + + + /** + * An implementation of OutputStream that redirects to the + * current System.err. + * + */ + private static class SystemErrStream extends OutputStream { + public SystemErrStream() { + } + + public void close() { + } + + public void flush() { + System.err.flush(); + } + + public void write(final byte[] b) throws IOException { + System.err.write(b); + } + + public void write(final byte[] b, final int off, final int len) + throws IOException { + System.err.write(b, off, len); + } + + public void write(final int b) throws IOException { + System.err.write(b); + } + } + + /** + * An implementation of OutputStream that redirects to the + * current System.out. + * + */ + private static class SystemOutStream extends OutputStream { + public SystemOutStream() { + } + + public void close() { + } + + public void flush() { + System.out.flush(); + } + + public void write(final byte[] b) throws IOException { + System.out.write(b); + } + + public void write(final byte[] b, final int off, final int len) + throws IOException { + System.out.write(b, off, len); + } + + public void write(final int b) throws IOException { + System.out.write(b); + } + } + +} diff --git a/src/java/org/apache/log4j/DailyRollingFileAppender.java b/src/main/java/org/apache/log4j/DailyRollingFileAppender.java similarity index 74% rename from src/java/org/apache/log4j/DailyRollingFileAppender.java rename to src/main/java/org/apache/log4j/DailyRollingFileAppender.java index c90a209481..00a4ee5032 100644 --- a/src/java/org/apache/log4j/DailyRollingFileAppender.java +++ b/src/main/java/org/apache/log4j/DailyRollingFileAppender.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ @@ -52,11 +62,10 @@ '.'yyyy-MM Rollover at the beginning of each month - Assuming the first day of the week is Sunday, at Sunday 00:00, - March 25th, 2001, /foo/bar.log will be copied to - /foo/bar.log.2001-03. Logging for the month of April - will be output to /foo/bar.log until it rolls over - at the beginning of May. + At midnight of May 31st, 2002 /foo/bar.log will be + copied to /foo/bar.log.2002-05. Logging for the month + of June will be output to /foo/bar.log until it is + also rolled over the next month. '.'yyyy-ww @@ -64,18 +73,19 @@ Rollover at the first day of each week. The first day of the week depends on the locale. - At midnight, on March 31st, 2001, /foo/bar.log - will be copied to /foo/bar.log.2001-08. Logging for - the 9th week of 2001 will be output to /foo/bar.log - until it is rolled over the next week. + Assuming the first day of the week is Sunday, on Saturday + midnight, June 9th 2002, the file /foo/bar.log will be + copied to /foo/bar.log.2002-23. Logging for the 24th week + of 2002 will be output to /foo/bar.log until it is + rolled over the next week. '.'yyyy-MM-dd Rollover at midnight each day. - At midnight, on March 9th, 2001, /foo/bar.log will - be copied to /foo/bar.log.2001-03-08. Logging for the + At midnight, on March 8th, 2002, /foo/bar.log will + be copied to /foo/bar.log.2002-03-08. Logging for the 9th day of March will be output to /foo/bar.log until it is rolled over the next day. @@ -84,19 +94,19 @@ Rollover at midnight and midday of each day. - At noon, on March 9th, 2001, /foo/bar.log will be - copied to /foo/bar.log.2001-03-09-AM. Logging for the + At noon, on March 9th, 2002, /foo/bar.log will be + copied to /foo/bar.log.2002-03-09-AM. Logging for the afternoon of the 9th will be output to /foo/bar.log - until it is rolled over the next morning, i.e at midnight 00:00. + until it is rolled over at midnight. '.'yyyy-MM-dd-HH Rollover at the top of every hour. - At approximately 11:00,000, on March 9th, 2001, + At approximately 11:00.000 o'clock on March 9th, 2002, /foo/bar.log will be copied to - /foo/bar.log.2001-03-09-10. Logging for the 11th hour + /foo/bar.log.2002-03-09-10. Logging for the 11th hour of the 9th of March will be output to /foo/bar.log until it is rolled over at the beginning of the next hour. @@ -143,13 +153,19 @@ public class DailyRollingFileAppender extends FileAppender { private String datePattern = "'.'yyyy-MM-dd"; /** - The actual formatted filename that is currently being written to. + The log file will be renamed to the value of the + scheduledFilename variable when the next interval is entered. For + example, if the rollover period is one hour, the log file will be + renamed to the value of "scheduledFilename" at the beginning of + the next hour. + + The precise time when a rollover occurs depends on logging + activity. */ private String scheduledFilename; /** - The timestamp when we shall next recompute the filename. - */ + The next time we estimate a rollover should occur. */ private long nextCheck = System.currentTimeMillis () - 1; Date now = new Date(); @@ -160,14 +176,13 @@ public class DailyRollingFileAppender extends FileAppender { int checkPeriod = TOP_OF_TROUBLE; - + // The gmtTimeZone is used only in computeCheckPeriod() method. static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT"); /** The default constructor does nothing. */ - public - DailyRollingFileAppender() { + public DailyRollingFileAppender() { } /** @@ -188,19 +203,16 @@ public DailyRollingFileAppender (Layout layout, String filename, expected by {@link SimpleDateFormat}. This options determines the rollover schedule. */ - public - void setDatePattern(String pattern) { + public void setDatePattern(String pattern) { datePattern = pattern; } /** Returns the value of the DatePattern option. */ - public - String getDatePattern() { + public String getDatePattern() { return datePattern; } - public - void activateOptions() { + public void activateOptions() { super.activateOptions(); if(datePattern != null && fileName != null) { now.setTime(System.currentTimeMillis()); @@ -212,8 +224,8 @@ void activateOptions() { scheduledFilename = fileName+sdf.format(new Date(file.lastModified())); } else { - LogLog.error("Either Filename or DatePattern options are not set for ["+ - name+"]."); + LogLog.error("Either File or DatePattern options are not set for appender [" + +name+"]."); } } @@ -290,6 +302,9 @@ void rollOver() throws IOException { } String datedFilename = fileName+sdf.format(now); + // It is too early to roll over because we are still within the + // bounds of the current interval. Rollover will occur once the + // next interval is reached. if (scheduledFilename.equals(datedFilename)) { return; } @@ -303,8 +318,12 @@ void rollOver() throws IOException { } File file = new File(fileName); - file.renameTo(target); - LogLog.debug(fileName +" -> "+ scheduledFilename); + boolean result = file.renameTo(target); + if(result) { + LogLog.debug(fileName +" -> "+ scheduledFilename); + } else { + LogLog.error("Failed to rename ["+fileName+"] to ["+scheduledFilename+"]."); + } try { // This will also close the file. This is OK since multiple @@ -318,17 +337,14 @@ void rollOver() throws IOException { } /** - This method differentiates DailyRollingFileAppender from its - super class. - -

    Before actually logging, this method will check whether it is - time to do a rollover. If it is, it will schedule the next - rollover time and then rollover. - - - */ - protected - void subAppend(LoggingEvent event) { + * This method differentiates DailyRollingFileAppender from its + * super class. + * + *

    Before actually logging, this method will check whether it is + * time to do a rollover. If it is, it will schedule the next + * rollover time and then rollover. + * */ + protected void subAppend(LoggingEvent event) { long n = System.currentTimeMillis(); if (n >= nextCheck) { now.setTime(n); @@ -345,17 +361,12 @@ void subAppend(LoggingEvent event) { } /** - RollingCalendar is a helper class to - DailyRollingFileAppender. Using this class, it is easy to compute - and access the next Millis(). - - It subclasses the standard {@link GregorianCalendar}-object, to - allow access to the protected function getTimeInMillis(), which it - then exports. - - @author Eirik Lygre */ - + * RollingCalendar is a helper class to DailyRollingFileAppender. + * Given a periodicity type and the current time, it computes the + * start of the next interval. + * */ class RollingCalendar extends GregorianCalendar { + private static final long serialVersionUID = -3560331770601814177L; int type = DailyRollingFileAppender.TOP_OF_TROUBLE; @@ -371,13 +382,11 @@ void setType(int type) { this.type = type; } - public - long getNextCheckMillis(Date now) { + public long getNextCheckMillis(Date now) { return getNextCheckDate(now).getTime(); } - public - Date getNextCheckDate(Date now) { + public Date getNextCheckDate(Date now) { this.setTime(now); switch(type) { @@ -414,6 +423,7 @@ Date getNextCheckDate(Date now) { case DailyRollingFileAppender.TOP_OF_WEEK: this.set(Calendar.DAY_OF_WEEK, getFirstDayOfWeek()); this.set(Calendar.HOUR_OF_DAY, 0); + this.set(Calendar.MINUTE, 0); this.set(Calendar.SECOND, 0); this.set(Calendar.MILLISECOND, 0); this.add(Calendar.WEEK_OF_YEAR, 1); @@ -421,6 +431,7 @@ Date getNextCheckDate(Date now) { case DailyRollingFileAppender.TOP_OF_MONTH: this.set(Calendar.DATE, 1); this.set(Calendar.HOUR_OF_DAY, 0); + this.set(Calendar.MINUTE, 0); this.set(Calendar.SECOND, 0); this.set(Calendar.MILLISECOND, 0); this.add(Calendar.MONTH, 1); diff --git a/src/main/java/org/apache/log4j/DefaultCategoryFactory.java b/src/main/java/org/apache/log4j/DefaultCategoryFactory.java new file mode 100644 index 0000000000..c7bb0c4668 --- /dev/null +++ b/src/main/java/org/apache/log4j/DefaultCategoryFactory.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import org.apache.log4j.spi.LoggerFactory; + +class DefaultCategoryFactory implements LoggerFactory { + + DefaultCategoryFactory() { + } + + public + Logger makeNewLoggerInstance(String name) { + return new Logger(name); + } +} diff --git a/src/main/java/org/apache/log4j/Dispatcher.java b/src/main/java/org/apache/log4j/Dispatcher.java new file mode 100644 index 0000000000..e879ff0abf --- /dev/null +++ b/src/main/java/org/apache/log4j/Dispatcher.java @@ -0,0 +1,125 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import org.apache.log4j.helpers.AppenderAttachableImpl; +import org.apache.log4j.spi.LoggingEvent; + + +/** + * Obsolete AsyncAppender dispatcher provided for compatibility only. + * + * @deprecated Since 1.3. + */ +class Dispatcher extends Thread { + /** + * @deprecated + */ + private org.apache.log4j.helpers.BoundedFIFO bf; + private AppenderAttachableImpl aai; + private boolean interrupted = false; + AsyncAppender container; + + /** + * + * @param bf + * @param container + * @deprecated + */ + Dispatcher(org.apache.log4j.helpers.BoundedFIFO bf, AsyncAppender container) { + this.bf = bf; + this.container = container; + this.aai = container.aai; + + // It is the user's responsibility to close appenders before + // exiting. + this.setDaemon(true); + + // set the dispatcher priority to lowest possible value + this.setPriority(Thread.MIN_PRIORITY); + this.setName("Dispatcher-" + getName()); + + // set the dispatcher priority to MIN_PRIORITY plus or minus 2 + // depending on the direction of MIN to MAX_PRIORITY. + //+ (Thread.MAX_PRIORITY > Thread.MIN_PRIORITY ? 1 : -1)*2); + } + + void close() { + synchronized (bf) { + interrupted = true; + + // We have a waiting dispacther if and only if bf.length is + // zero. In that case, we need to give it a death kiss. + if (bf.length() == 0) { + bf.notify(); + } + } + } + + /** + * The dispatching strategy is to wait until there are events in the buffer + * to process. After having processed an event, we release the monitor + * (variable bf) so that new events can be placed in the buffer, instead of + * keeping the monitor and processing the remaining events in the buffer. + * + *

    + * Other approaches might yield better results. + *

    + */ + public void run() { + //Category cat = Category.getInstance(Dispatcher.class.getName()); + LoggingEvent event; + + while (true) { + synchronized (bf) { + if (bf.length() == 0) { + // Exit loop if interrupted but only if the the buffer is empty. + if (interrupted) { + //cat.info("Exiting."); + break; + } + + try { + //LogLog.debug("Waiting for new event to dispatch."); + bf.wait(); + } catch (InterruptedException e) { + break; + } + } + + event = bf.get(); + + if (bf.wasFull()) { + //LogLog.debug("Notifying AsyncAppender about freed space."); + bf.notify(); + } + } + + // synchronized + synchronized (container.aai) { + if ((aai != null) && (event != null)) { + aai.appendLoopOnAppenders(event); + } + } + } + + // while + // close and remove all appenders + aai.removeAllAppenders(); + } +} diff --git a/src/java/org/apache/log4j/FileAppender.java b/src/main/java/org/apache/log4j/FileAppender.java similarity index 76% rename from src/java/org/apache/log4j/FileAppender.java rename to src/main/java/org/apache/log4j/FileAppender.java index e3b212ec5f..8fe61d3eb0 100644 --- a/src/java/org/apache/log4j/FileAppender.java +++ b/src/main/java/org/apache/log4j/FileAppender.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; @@ -11,6 +21,8 @@ import java.io.Writer; import java.io.FileOutputStream; import java.io.BufferedWriter; +import java.io.FileNotFoundException; +import java.io.File; import org.apache.log4j.spi.ErrorCode; import org.apache.log4j.helpers.QuietWriter; @@ -20,24 +32,24 @@ // Ben Sandee /** - FileAppender appends log events to a file. - -

    Support for java.io.Writer and console appending - has been deprecated and then removed. See the replacement - solutions: {@link WriterAppender} and {@link ConsoleAppender}. - - - @author Ceki Gülcü */ + * FileAppender appends log events to a file. + * + *

    Support for java.io.Writer and console appending + * has been deprecated and then removed. See the replacement + * solutions: {@link WriterAppender} and {@link ConsoleAppender}. + * + * @author Ceki Gülcü + * */ public class FileAppender extends WriterAppender { - /** Append to or truncate the file? The default value for this - variable is true, meaning that by default a - FileAppender will append to an existing file and - not truncate it. - -

    This option is meaningful only if the FileAppender opens the - file. - */ + /** Controls file truncatation. The default value for this variable + * is true, meaning that by default a + * FileAppender will append to an existing file and not + * truncate it. + * + *

    This option is meaningful only if the FileAppender opens the + * file. + */ protected boolean fileAppend = true; /** @@ -49,7 +61,8 @@ public class FileAppender extends WriterAppender { protected boolean bufferedIO = false; /** - How big should the IO buffer be? Default is 8K. */ + * Determines the size of IO buffer be. Default is 8K. + */ protected int bufferSize = 8*1024; @@ -269,7 +282,31 @@ void setFile(String fileName, boolean append, boolean bufferedIO, int bufferSize } reset(); - Writer fw = createWriter(new FileOutputStream(fileName, append)); + FileOutputStream ostream = null; + try { + // + // attempt to create file + // + ostream = new FileOutputStream(fileName, append); + } catch(FileNotFoundException ex) { + // + // if parent directory does not exist then + // attempt to create it and try to create file + // see bug 9150 + // + String parentName = new File(fileName).getParent(); + if (parentName != null) { + File parentDir = new File(parentName); + if(!parentDir.exists() && parentDir.mkdirs()) { + ostream = new FileOutputStream(fileName, append); + } else { + throw ex; + } + } else { + throw ex; + } + } + Writer fw = createWriter(ostream); if(bufferedIO) { fw = new BufferedWriter(fw, bufferSize); } diff --git a/src/java/org/apache/log4j/HTMLLayout.java b/src/main/java/org/apache/log4j/HTMLLayout.java similarity index 79% rename from src/java/org/apache/log4j/HTMLLayout.java rename to src/main/java/org/apache/log4j/HTMLLayout.java index 013b7c59e4..f7020cf25d 100644 --- a/src/java/org/apache/log4j/HTMLLayout.java +++ b/src/main/java/org/apache/log4j/HTMLLayout.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; @@ -12,9 +22,14 @@ import org.apache.log4j.helpers.Transform; /** - This layout outputs events in a HTML table. - - @author Ceki Gülcü + * This layout outputs events in a HTML table. + * + * Appenders using this layout should have their encoding + * set to UTF-8 or UTF-16, otherwise events containing + * non ASCII characters could result in corrupted + * log files. + * + * @author Ceki Gülcü */ public class HTMLLayout extends Layout { @@ -122,30 +137,32 @@ String format(LoggingEvent event) { sbuf.append(Layout.LINE_SEP + "" + Layout.LINE_SEP); sbuf.append(""); - sbuf.append(event.timeStamp - event.getStartTime()); + sbuf.append(event.timeStamp - LoggingEvent.getStartTime()); sbuf.append("" + Layout.LINE_SEP); - sbuf.append(""); - sbuf.append(Transform.escapeTags(event.getThreadName())); + String escapedThread = Transform.escapeTags(event.getThreadName()); + sbuf.append(""); + sbuf.append(escapedThread); sbuf.append("" + Layout.LINE_SEP); sbuf.append(""); - if (event.level.equals(Level.DEBUG)) { + if (event.getLevel().equals(Level.DEBUG)) { sbuf.append(""); - sbuf.append(event.level); + sbuf.append(Transform.escapeTags(String.valueOf(event.getLevel()))); sbuf.append(""); } - else if(event.level.isGreaterOrEqual(Level.WARN)) { + else if(event.getLevel().isGreaterOrEqual(Level.WARN)) { sbuf.append(""); - sbuf.append(event.level); + sbuf.append(Transform.escapeTags(String.valueOf(event.getLevel()))); sbuf.append(""); } else { - sbuf.append(event.level); + sbuf.append(Transform.escapeTags(String.valueOf(event.getLevel()))); } sbuf.append("" + Layout.LINE_SEP); - sbuf.append(""); - sbuf.append(Transform.escapeTags(event.categoryName)); + String escapedLogger = Transform.escapeTags(event.getLoggerName()); + sbuf.append(""); + sbuf.append(escapedLogger); sbuf.append("" + Layout.LINE_SEP); if(locationInfo) { diff --git a/src/java/org/apache/log4j/Hierarchy.java b/src/main/java/org/apache/log4j/Hierarchy.java similarity index 94% rename from src/java/org/apache/log4j/Hierarchy.java rename to src/main/java/org/apache/log4j/Hierarchy.java index 5b605c1d45..2c5c0dd408 100644 --- a/src/java/org/apache/log4j/Hierarchy.java +++ b/src/main/java/org/apache/log4j/Hierarchy.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // WARNING This class MUST not have references to the Category or // WARNING RootCategory classes in its static initiliazation neither diff --git a/src/java/org/apache/log4j/Layout.java b/src/main/java/org/apache/log4j/Layout.java similarity index 67% rename from src/java/org/apache/log4j/Layout.java rename to src/main/java/org/apache/log4j/Layout.java index b4b92c5e78..798dd8ec0a 100644 --- a/src/java/org/apache/log4j/Layout.java +++ b/src/main/java/org/apache/log4j/Layout.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; diff --git a/src/java/org/apache/log4j/Level.java b/src/main/java/org/apache/log4j/Level.java similarity index 54% rename from src/java/org/apache/log4j/Level.java rename to src/main/java/org/apache/log4j/Level.java index 4bf4b00c9c..502886242a 100644 --- a/src/java/org/apache/log4j/Level.java +++ b/src/main/java/org/apache/log4j/Level.java @@ -1,15 +1,29 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Contributors: Kitching Simon // Nicholas Wolff package org.apache.log4j; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectStreamException; +import java.io.Serializable; /** Defines the minimum set of levels recognized by the system, that is @@ -23,8 +37,13 @@ @author Ceki Gülcü */ -public class Level extends Priority { +public class Level extends Priority implements Serializable { + /** + * TRACE level integer value. + * @since 1.2.12 + */ + public static final int TRACE_INT = 5000; /** The OFF has the highest possible rank and is @@ -59,11 +78,24 @@ public class Level extends Priority { application. */ final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7); + /** + * The TRACE Level designates finer-grained + * informational events than the DEBUGALL has the lowest possible rank and is intended to turn on all logging. */ final static public Level ALL = new Level(ALL_INT, "ALL", 7); + /** + * Serialization version id. + */ + static final long serialVersionUID = 3491141966387921974L; + /** Instantiate a Level object. */ @@ -109,6 +141,7 @@ Level toLevel(int val, Level defaultLevel) { case ERROR_INT: return Level.ERROR; case FATAL_INT: return Level.FATAL; case OFF_INT: return OFF; + case TRACE_INT: return Level.TRACE; default: return defaultLevel; } } @@ -128,12 +161,64 @@ Level toLevel(String sArg, Level defaultLevel) { if(s.equals("ALL")) return Level.ALL; if(s.equals("DEBUG")) return Level.DEBUG; - //if(s.equals("FINE")) return Level.FINE; if(s.equals("INFO")) return Level.INFO; if(s.equals("WARN")) return Level.WARN; if(s.equals("ERROR")) return Level.ERROR; if(s.equals("FATAL")) return Level.FATAL; if(s.equals("OFF")) return Level.OFF; + if(s.equals("TRACE")) return Level.TRACE; + // + // For Turkish i problem, see bug 40937 + // + if(s.equals("\u0130NFO")) return Level.INFO; return defaultLevel; } + + /** + * Custom deserialization of Level. + * @param s serialization stream. + * @throws IOException if IO exception. + * @throws ClassNotFoundException if class not found. + */ + private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException { + s.defaultReadObject(); + level = s.readInt(); + syslogEquivalent = s.readInt(); + levelStr = s.readUTF(); + if (levelStr == null) { + levelStr = ""; + } + } + + /** + * Serialize level. + * @param s serialization stream. + * @throws IOException if exception during serialization. + */ + private void writeObject(final ObjectOutputStream s) throws IOException { + s.defaultWriteObject(); + s.writeInt(level); + s.writeInt(syslogEquivalent); + s.writeUTF(levelStr); + } + + /** + * Resolved deserialized level to one of the stock instances. + * May be overriden in classes derived from Level. + * @return resolved object. + * @throws ObjectStreamException if exception during resolution. + */ + private Object readResolve() throws ObjectStreamException { + // + // if the deserizalized object is exactly an instance of Level + // + if (getClass() == Level.class) { + return toLevel(level); + } + // + // extension of Level can't substitute stock item + // + return this; + } + } diff --git a/src/java/org/apache/log4j/LogManager.java b/src/main/java/org/apache/log4j/LogManager.java similarity index 57% rename from src/java/org/apache/log4j/LogManager.java rename to src/main/java/org/apache/log4j/LogManager.java index 0189b8a4b8..9f129e7190 100644 --- a/src/java/org/apache/log4j/LogManager.java +++ b/src/main/java/org/apache/log4j/LogManager.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; @@ -11,7 +21,7 @@ import org.apache.log4j.spi.LoggerFactory; import org.apache.log4j.spi.RepositorySelector; import org.apache.log4j.spi.DefaultRepositorySelector; -import org.apache.log4j.spi.RootCategory; +import org.apache.log4j.spi.RootLogger; import org.apache.log4j.helpers.Loader; import org.apache.log4j.helpers.OptionConverter; import org.apache.log4j.helpers.LogLog; @@ -23,84 +33,40 @@ import java.util.Enumeration; /** - Use the LogManager to retreive instances of {@link Logger}. - - @author Ceki Gülcü -*/ + * Use the LogManager class to retreive {@link Logger} + * instances or to operate on the current {@link + * LoggerRepository}. When the LogManager class is loaded + * into memory the default initalzation procedure is inititated. The + * default intialization procedure is described in the short log4j manual. + * + * @author Ceki Gülcü */ public class LogManager { /** - This string constant is set to log4j.properties the name - of the file that will be searched by default in classpath. If the - file can be found, then it is fed to the {@link - PropertyConfigurator}. - - See also {@link #DEFAULT_CONFIGURATION_KEY} for a more general - alternative. - -

    See also the full description of default - intialization procedure. - - @since 0.8.5 */ - static public final String DEFAULT_CONFIGURATION_FILE = "log4j.properties"; - - /** - This string constant is set to log4j.configuration. - -

    It corresponds to name of a system property that, if set, - specifies the name of the resource containing the properties file - or {@link URL} with which log4j should configure itself. See - {@link OptionConverter#selectAndConfigure} for more detailed - information on the processing of this option. - -

    Setting the log4j.configuration system property - overrides the default search for the file log4j.properties. - -

    Note that all property keys are case sensitive. - -

    See also the full description of default - intialization procedure. - - @since 1.0 */ - static final public String DEFAULT_CONFIGURATION_KEY="log4j.configuration"; - - /** - This string constant is set to log4j.configuratorClass. - -

    It corresponds to name of a system property that, if set, - specifies the class name to use to automatically configure - log4j. See {@link OptionConverter#selectAndConfigure} for more - detailed information on the processing of this option. - -

    Setting the log4j.configuration system property - overrides the default search for the file log4j.properties. - -

    Note that all property keys are case sensitive. - -

    See also the full description of default - intialization procedure. + * @deprecated This variable is for internal use only. It will + * become package protected in future versions. + * */ + static public final String DEFAULT_CONFIGURATION_FILE = "log4j.properties"; + + static final String DEFAULT_XML_CONFIGURATION_FILE = "log4j.xml"; - @since 1.2 */ - static final public String CONFIGURATOR_CLASS_KEY="log4j.configuratorClass"; - /** - Setting the system property log4j.defaultInitOverride to - "true" or any other value than "false" will skip default - configuration process. - -

    The current value of the DEFAULT_INIT_OVERRIDE_KEY string - constant is log4j.defaultInitOverride. - -

    See also the full description of default - intialization procedure. + * @deprecated This variable is for internal use only. It will + * become private in future versions. + * */ + static final public String DEFAULT_CONFIGURATION_KEY="log4j.configuration"; -

    Note that all property keys are case sensitive. + /** + * @deprecated This variable is for internal use only. It will + * become private in future versions. + * */ + static final public String CONFIGURATOR_CLASS_KEY="log4j.configuratorClass"; - @since 0.8.5 */ + /** + * @deprecated This variable is for internal use only. It will + * become private in future versions. + */ public static final String DEFAULT_INIT_OVERRIDE_KEY = "log4j.defaultInitOverride"; @@ -110,42 +76,54 @@ specifies the class name to use to automatically configure static { // By default we use a DefaultRepositorySelector which always returns 'h'. - Hierarchy h = new Hierarchy(new RootCategory((Level) Level.DEBUG)); + Hierarchy h = new Hierarchy(new RootLogger((Level) Level.DEBUG)); repositorySelector = new DefaultRepositorySelector(h); /** Search for the properties file log4j.properties in the CLASSPATH. */ String override =OptionConverter.getSystemProperty(DEFAULT_INIT_OVERRIDE_KEY, null); - // if there is no default init override, them get the resource + // if there is no default init override, then get the resource // specified by the user or the default config file. if(override == null || "false".equalsIgnoreCase(override)) { - String resource = OptionConverter.getSystemProperty( - DEFAULT_CONFIGURATION_KEY, - DEFAULT_CONFIGURATION_FILE); + + String configurationOptionStr = OptionConverter.getSystemProperty( + DEFAULT_CONFIGURATION_KEY, + null); String configuratorClassName = OptionConverter.getSystemProperty( CONFIGURATOR_CLASS_KEY, null); URL url = null; - try { - // so, resource is not a URL: - // attempt to get the resource from the class path - url = new URL(resource); - } catch (MalformedURLException ex) { - url = Loader.getResource(resource); - } + + // if the user has not specified the log4j.configuration + // property, we search first for the file "log4j.xml" and then + // "log4j.properties" + if(configurationOptionStr == null) { + url = Loader.getResource(DEFAULT_XML_CONFIGURATION_FILE); + if(url == null) { + url = Loader.getResource(DEFAULT_CONFIGURATION_FILE); + } + } else { + try { + url = new URL(configurationOptionStr); + } catch (MalformedURLException ex) { + // so, resource is not a URL: + // attempt to get the resource from the class path + url = Loader.getResource(configurationOptionStr); + } + } // If we have a non-null url, then delegate the rest of the // configuration to the OptionConverter.selectAndConfigure // method. if(url != null) { - LogLog.debug("Using URL ["+url+"] for automatic log4j configuration."); + LogLog.debug("Using URL ["+url+"] for automatic log4j configuration."); OptionConverter.selectAndConfigure(url, configuratorClassName, LogManager.getLoggerRepository()); } else { - LogLog.debug("Could not find resource: ["+resource+"]."); + LogLog.debug("Could not find resource: ["+configurationOptionStr+"]."); } } } diff --git a/src/main/java/org/apache/log4j/Logger.java b/src/main/java/org/apache/log4j/Logger.java new file mode 100644 index 0000000000..aa4af73426 --- /dev/null +++ b/src/main/java/org/apache/log4j/Logger.java @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import org.apache.log4j.spi.LoggerFactory; +import org.apache.log4j.Level; + + +/** + This is the central class in the log4j package. Most logging + operations, except configuration, are done through this class. + + @since log4j 1.2 + + @author Ceki Gülcü */ +public class Logger extends Category { + + /** + The fully qualified name of the Logger class. See also the + getFQCN method. */ + private static final String FQCN = Logger.class.getName(); + + + protected + Logger(String name) { + super(name); + } + + /** + Log a message object with the {@link Level#FINE FINE} level which + is just an alias for the {@link Level#DEBUG DEBUG} level. + +

    This method first checks if this category is DEBUG + enabled by comparing the level of this category with the {@link + Level#DEBUG DEBUG} level. If this category is + DEBUG enabled, then it converts the message object + (passed as parameter) to a string by invoking the appropriate + {@link org.apache.log4j.or.ObjectRenderer}. It then proceeds to call all the + registered appenders in this category and also higher in the + hierarchy depending on the value of the additivity flag. + +

    WARNING Note that passing a {@link Throwable} to this + method will print the name of the Throwable but no + stack trace. To print a stack trace use the {@link #debug(Object, + Throwable)} form instead. + + @param message the message object to log. */ + //public + //void fine(Object message) { + // if(repository.isDisabled(Level.DEBUG_INT)) + // return; + // if(Level.DEBUG.isGreaterOrEqual(this.getChainedLevel())) { + // forcedLog(FQCN, Level.DEBUG, message, null); + // } + //} + + + /** + Log a message object with the FINE level including + the stack trace of the {@link Throwable} t passed as + parameter. + +

    See {@link #fine(Object)} form for more detailed information. + + @param message the message object to log. + @param t the exception to log, including its stack trace. */ + //public + //void fine(Object message, Throwable t) { + // if(repository.isDisabled(Level.DEBUG_INT)) + // return; + // if(Level.DEBUG.isGreaterOrEqual(this.getChainedLevel())) + // forcedLog(FQCN, Level.FINE, message, t); + //} + + /** + * Retrieve a logger named according to the value of the + * name parameter. If the named logger already exists, + * then the existing instance will be returned. Otherwise, a new + * instance is created. + * + *

    By default, loggers do not have a set level but inherit it + * from their neareast ancestor with a set level. This is one of the + * central features of log4j. + * + * @param name The name of the logger to retrieve. + */ + static + public + Logger getLogger(String name) { + return LogManager.getLogger(name); + } + + /** + * Shorthand for getLogger(clazz.getName()). + * + * @param clazz The name of clazz will be used as the + * name of the logger to retrieve. See {@link #getLogger(String)} + * for more detailed information. + */ + static + public + Logger getLogger(Class clazz) { + return LogManager.getLogger(clazz.getName()); + } + + + /** + * Return the root logger for the current logger repository. + *

    + * The {@link #getName Logger.getName()} method for the root logger always returns + * stirng value: "root". However, calling + * Logger.getLogger("root") does not retrieve the root + * logger but a logger just under root named "root". + *

    + * In other words, calling this method is the only way to retrieve the + * root logger. + */ + public + static + Logger getRootLogger() { + return LogManager.getRootLogger(); + } + + /** + Like {@link #getLogger(String)} except that the type of logger + instantiated depends on the type returned by the {@link + LoggerFactory#makeNewLoggerInstance} method of the + factory parameter. + +

    This method is intended to be used by sub-classes. + + @param name The name of the logger to retrieve. + + @param factory A {@link LoggerFactory} implementation that will + actually create a new Instance. + + @since 0.8.5 */ + public + static + Logger getLogger(String name, LoggerFactory factory) { + return LogManager.getLogger(name, factory); + } + + /** + * Log a message object with the {@link org.apache.log4j.Level#TRACE TRACE} level. + * + * @param message the message object to log. + * @see #debug(Object) for an explanation of the logic applied. + * @since 1.2.12 + */ + public void trace(Object message) { + if (repository.isDisabled(Level.TRACE_INT)) { + return; + } + + if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) { + forcedLog(FQCN, Level.TRACE, message, null); + } + } + + /** + * Log a message object with the TRACE level including the + * stack trace of the {@link Throwable}t passed as parameter. + * + *

    + * See {@link #debug(Object)} form for more detailed information. + *

    + * + * @param message the message object to log. + * @param t the exception to log, including its stack trace. + * @since 1.2.12 + */ + public void trace(Object message, Throwable t) { + if (repository.isDisabled(Level.TRACE_INT)) { + return; + } + + if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) { + forcedLog(FQCN, Level.TRACE, message, t); + } + } + + /** + * Check whether this category is enabled for the TRACE Level. + * @since 1.2.12 + * + * @return boolean - true if this category is enabled for level + * TRACE, false otherwise. + */ + public boolean isTraceEnabled() { + if (repository.isDisabled(Level.TRACE_INT)) { + return false; + } + + return Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel()); + } + +} diff --git a/src/java/org/apache/log4j/MDC.java b/src/main/java/org/apache/log4j/MDC.java similarity index 70% rename from src/java/org/apache/log4j/MDC.java rename to src/main/java/org/apache/log4j/MDC.java index 002b3994de..c770670b82 100644 --- a/src/java/org/apache/log4j/MDC.java +++ b/src/main/java/org/apache/log4j/MDC.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j; @@ -88,11 +97,10 @@ void remove(String key) { /** - Get the current thread's MDC as a hashtable. - */ - public - static - Hashtable getContext() { + * Get the current thread's MDC as a hashtable. This method is + * intended to be used internally. + * */ + public static Hashtable getContext() { return mdc.getContext0(); } @@ -104,8 +112,8 @@ void put0(String key, Object o) { } else { Hashtable ht = (Hashtable) ((ThreadLocalMap)tlm).get(); if(ht == null) { - ht = new Hashtable(HT_SIZE); - ((ThreadLocalMap)tlm).set(ht); + ht = new Hashtable(HT_SIZE); + ((ThreadLocalMap)tlm).set(ht); } ht.put(key, o); } @@ -117,10 +125,10 @@ Object get0(String key) { return null; } else { Hashtable ht = (Hashtable) ((ThreadLocalMap)tlm).get(); - if(ht != null) { - return ht.get(key); + if(ht != null && key != null) { + return ht.get(key); } else { - return null; + return null; } } } @@ -130,7 +138,7 @@ void remove0(String key) { if(!java1) { Hashtable ht = (Hashtable) ((ThreadLocalMap)tlm).get(); if(ht != null) { - ht.remove(key); + ht.remove(key); } } } diff --git a/src/java/org/apache/log4j/NDC.java b/src/main/java/org/apache/log4j/NDC.java similarity index 86% rename from src/java/org/apache/log4j/NDC.java rename to src/main/java/org/apache/log4j/NDC.java index aa4461518b..703cfc5b60 100644 --- a/src/java/org/apache/log4j/NDC.java +++ b/src/main/java/org/apache/log4j/NDC.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Contributors: Dan Milstein @@ -116,6 +125,17 @@ public class NDC { // No instances allowed. private NDC() {} + + /** + * Get NDC stack for current thread. + * @return NDC stack for current thread. + */ + private static Stack getCurrentStack() { + if (ht != null) { + return (Stack) ht.get(Thread.currentThread()); + } + return null; + } /** @@ -130,7 +150,7 @@ private NDC() {} public static void clear() { - Stack stack = (Stack) ht.get(Thread.currentThread()); + Stack stack = getCurrentStack(); if(stack != null) stack.setSize(0); } @@ -153,11 +173,10 @@ given thread can supply the stack (i.e. diagnostic context) to a public static Stack cloneStack() { - Object o = ht.get(Thread.currentThread()); - if(o == null) + Stack stack = getCurrentStack(); + if(stack == null) return null; else { - Stack stack = (Stack) o; return (Stack) stack.clone(); } } @@ -192,12 +211,13 @@ void inherit(Stack stack) { /** - Used when printing the diagnostic context. + Never use this method directly, use the {@link + org.apache.log4j.spi.LoggingEvent#getNDC} method instead. */ static public String get() { - Stack s = (Stack) ht.get(Thread.currentThread()); + Stack s = getCurrentStack(); if(s != null && !s.isEmpty()) return ((DiagnosticContext) s.peek()).fullMessage; else @@ -205,15 +225,15 @@ String get() { } /** - Get the current nesting depth of this diagnostic context. - - @see #setMaxDepth - @since 0.7.5 + * Get the current nesting depth of this diagnostic context. + * + * @see #setMaxDepth + * @since 0.7.5 */ public static int getDepth() { - Stack stack = (Stack) ht.get(Thread.currentThread()); + Stack stack = getCurrentStack(); if(stack == null) return 0; else @@ -223,6 +243,7 @@ int getDepth() { private static void lazyRemove() { + if (ht == null) return; // The synchronization on ht is necessary to prevent JDK 1.2.x from // throwing ConcurrentModificationExceptions at us. This sucks BIG-TIME. @@ -239,13 +260,13 @@ void lazyRemove() { int misses = 0; v = new Vector(); - Enumeration enum = ht.keys(); + Enumeration enumeration = ht.keys(); // We give up after 4 straigt missses. That is 4 consecutive // inspected threads in 'ht' that turn out to be alive. // The higher the proportion on dead threads in ht, the higher the // chances of removal. - while(enum.hasMoreElements() && (misses <= 4)) { - Thread t = (Thread) enum.nextElement(); + while(enumeration.hasMoreElements() && (misses <= 4)) { + Thread t = (Thread) enumeration.nextElement(); if(t.isAlive()) { misses++; } else { @@ -277,8 +298,7 @@ void lazyRemove() { public static String pop() { - Thread key = Thread.currentThread(); - Stack stack = (Stack) ht.get(key); + Stack stack = getCurrentStack(); if(stack != null && !stack.isEmpty()) return ((DiagnosticContext) stack.pop()).message; else @@ -298,8 +318,7 @@ String pop() { public static String peek() { - Thread key = Thread.currentThread(); - Stack stack = (Stack) ht.get(key); + Stack stack = getCurrentStack(); if(stack != null && !stack.isEmpty()) return ((DiagnosticContext) stack.peek()).message; else @@ -316,12 +335,12 @@ String peek() { public static void push(String message) { - Thread key = Thread.currentThread(); - Stack stack = (Stack) ht.get(key); + Stack stack = getCurrentStack(); if(stack == null) { DiagnosticContext dc = new DiagnosticContext(message, null); stack = new Stack(); + Thread key = Thread.currentThread(); ht.put(key, stack); stack.push(dc); } else if (stack.isEmpty()) { @@ -391,7 +410,7 @@ void foo() { static public void setMaxDepth(int maxDepth) { - Stack stack = (Stack) ht.get(Thread.currentThread()); + Stack stack = getCurrentStack(); if(stack != null && maxDepth < stack.size()) stack.setSize(maxDepth); } diff --git a/src/java/org/apache/log4j/PatternLayout.java b/src/main/java/org/apache/log4j/PatternLayout.java similarity index 93% rename from src/java/org/apache/log4j/PatternLayout.java rename to src/main/java/org/apache/log4j/PatternLayout.java index a276f257e3..3cfa286568 100644 --- a/src/java/org/apache/log4j/PatternLayout.java +++ b/src/main/java/org/apache/log4j/PatternLayout.java @@ -1,9 +1,18 @@ /* - * 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 file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j; @@ -222,8 +231,8 @@ number of right most components of the class name will be r - Used to output the number of milliseconds elapsed since the start - of the application until the creation of the logging event. + Used to output the number of milliseconds elapsed from the construction + of the layout until the creation of the logging event. @@ -361,10 +370,10 @@ reached. The default is to pad on the left (right justify) but you
    -

    %r [%t] %-5p %c %x - %m\n +

    %r [%t] %-5p %c %x - %m%n

    This is essentially the TTCC layout. -

    %-6r [%15.15t] %-5p %30.30c %x - %m\n +

    %-6r [%15.15t] %-5p %30.30c %x - %m%n

    Similar to the TTCC layout except that the relative time is right padded if less than 6 digits, thread name is right padded if @@ -408,8 +417,6 @@ public class PatternLayout extends Layout { private PatternConverter head; - private String timezone; - /** Constructs a PatternLayout using the DEFAULT_LAYOUT_PATTERN. diff --git a/src/java/org/apache/log4j/Priority.java b/src/main/java/org/apache/log4j/Priority.java similarity index 65% rename from src/java/org/apache/log4j/Priority.java rename to src/main/java/org/apache/log4j/Priority.java index fd2fe9858c..53e94b4d4e 100644 --- a/src/java/org/apache/log4j/Priority.java +++ b/src/main/java/org/apache/log4j/Priority.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Contributors: Kitching Simon @@ -12,14 +21,14 @@ /** Refrain from using this class directly, use - the {@link Level} class instead. + the {@link Level} class instead. @author Ceki Gülcü */ public class Priority { - int level; - String levelStr; - int syslogEquivalent; + transient int level; + transient String levelStr; + transient int syslogEquivalent; public final static int OFF_INT = Integer.MAX_VALUE; public final static int FATAL_INT = 50000; @@ -31,34 +40,40 @@ public class Priority { public final static int ALL_INT = Integer.MIN_VALUE; /** - The FATAL level designates very severe error - events that will presumably lead the application to abort. + * @deprecated Use {@link Level#FATAL} instead. */ final static public Priority FATAL = new Level(FATAL_INT, "FATAL", 0); /** - The ERROR level designates error events that - might still allow the application to continue running. */ + * @deprecated Use {@link Level#ERROR} instead. + */ final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3); /** - The WARN level designates potentially harmful situations. - */ + * @deprecated Use {@link Level#WARN} instead. + */ final static public Priority WARN = new Level(WARN_INT, "WARN", 4); /** - The INFO level designates informational messages - that highlight the progress of the application at coarse-grained - level. */ + * @deprecated Use {@link Level#INFO} instead. + */ final static public Priority INFO = new Level(INFO_INT, "INFO", 6); /** - The DEBUG priority designates fine-grained - informational events that are most useful to debug an - application. */ + * @deprecated Use {@link Level#DEBUG} instead. + */ final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7); - + + /** + * Default constructor for deserialization. + */ + protected Priority() { + level = DEBUG_INT; + levelStr = "DEBUG"; + syslogEquivalent = 7; + } + /** Instantiate a level object. */ @@ -141,12 +156,7 @@ int toInt() { } /** - Convert the string passed as argument to a priority. If the - conversion fails, then this method returns {@link #DEBUG}. - - @deprecated Please use the {@link Level#toLevel(String)} method instead.} - - + * @deprecated Please use the {@link Level#toLevel(String)} method instead. */ public static @@ -155,10 +165,8 @@ Priority toPriority(String sArg) { } /** - Convert an integer passed as argument to a priority. If the - conversion fails, then this method returns {@link #DEBUG}. - - */ + * @deprecated Please use the {@link Level#toLevel(int)} method instead. + */ public static Priority toPriority(int val) { @@ -166,8 +174,7 @@ Priority toPriority(int val) { } /** - Convert an integer passed as argument to a priority. If the - conversion fails, then this method returns the specified default. + * @deprecated Please use the {@link Level#toLevel(int, Level)} method instead. */ public static @@ -176,10 +183,8 @@ Priority toPriority(int val, Priority defaultPriority) { } /** - Convert the string passed as argument to a priority. If the - conversion fails, then this method returns the value of - defaultPriority. - */ + * @deprecated Please use the {@link Level#toLevel(String, Level)} method instead. + */ public static Priority toPriority(String sArg, Priority defaultPriority) { diff --git a/src/java/org/apache/log4j/PropertyConfigurator.java b/src/main/java/org/apache/log4j/PropertyConfigurator.java similarity index 90% rename from src/java/org/apache/log4j/PropertyConfigurator.java rename to src/main/java/org/apache/log4j/PropertyConfigurator.java index c15d438f26..05834b0e4c 100644 --- a/src/java/org/apache/log4j/PropertyConfigurator.java +++ b/src/main/java/org/apache/log4j/PropertyConfigurator.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // Contibutors: "Luke Blanshard" @@ -12,29 +22,27 @@ package org.apache.log4j; -import org.apache.log4j.DefaultCategoryFactory; import org.apache.log4j.config.PropertySetter; -//import org.apache.log4j.config.PropertySetterException; -import org.apache.log4j.spi.OptionHandler; +import org.apache.log4j.helpers.FileWatchdog; +import org.apache.log4j.helpers.LogLog; +import org.apache.log4j.helpers.OptionConverter; +import org.apache.log4j.or.RendererMap; import org.apache.log4j.spi.Configurator; import org.apache.log4j.spi.LoggerFactory; import org.apache.log4j.spi.LoggerRepository; +import org.apache.log4j.spi.OptionHandler; import org.apache.log4j.spi.RendererSupport; -import org.apache.log4j.or.RendererMap; -import org.apache.log4j.helpers.LogLog; -import org.apache.log4j.helpers.OptionConverter; -import org.apache.log4j.helpers.FileWatchdog; +import java.io.FileInputStream; +import java.io.InputStream; import java.util.Enumeration; +import java.util.Hashtable; import java.util.Properties; -import java.io.FileInputStream; -import java.io.IOException; import java.util.StringTokenizer; -import java.util.Hashtable; /** - Extends {@link BasicConfigurator} to provide configuration from an - external file. See {@link #doConfigure(String, LoggerRepository)} for the + Allows the configuration of log4j from an external file. See + {@link #doConfigure(String, LoggerRepository)} for the expected format.

    It is sometimes useful to see how log4j is reading configuration @@ -100,7 +108,7 @@ public class PropertyConfigurator implements Configurator { /** Read configuration from a file. The existing configuration is not cleared nor reset. If you require a different behavior, - then call {@link BasicConfigurator#resetConfiguration + then call {@link LogManager#resetConfiguration resetConfiguration} method before calling doConfigure. @@ -118,7 +126,7 @@ public class PropertyConfigurator implements Configurator {

    The level value can consist of the string values OFF, FATAL, - ERROR, WARN, INFO, DEBUG, ALL or a custom level value. A + ERROR, WARN, INFO, DEBUG, ALL or a custom level value. A custom level value can be specified in the form level#classname. By default the repository-wide threshold is set to the lowest possible value, namely the level ALL. @@ -175,7 +183,7 @@ public class PropertyConfigurator implements Configurator {

    For non-root categories the syntax is almost the same:

    -    log4j.logger.logger_name=[level|INHERITED], appenderName, appenderName, ...
    +    log4j.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName, ...
         

    The meaning of the optional level value is discussed above @@ -187,9 +195,10 @@ public class PropertyConfigurator implements Configurator { named logger remains untouched.

    By default categories inherit their level from the - hierarchy. However, if you set the level of a logger and - later decide that that logger should inherit its level, then - you should specify INHERITED as the value for the level value. + hierarchy. However, if you set the level of a logger and later + decide that that logger should inherit its level, then you should + specify INHERITED as the value for the level value. NULL is a + synonym for INHERITED.

    Similar to the root logger syntax, each appenderName (separated by commas) will be attached to the named logger. @@ -292,15 +301,24 @@ public class PropertyConfigurator implements Configurator { public void doConfigure(String configFileName, LoggerRepository hierarchy) { Properties props = new Properties(); + FileInputStream istream = null; try { - FileInputStream istream = new FileInputStream(configFileName); + istream = new FileInputStream(configFileName); props.load(istream); istream.close(); } - catch (IOException e) { + catch (Exception e) { LogLog.error("Could not read configuration file ["+configFileName+"].", e); LogLog.error("Ignoring configuration file [" + configFileName+"]."); return; + } finally { + if(istream != null) { + try { + istream.close(); + } catch(Throwable ignore) { + } + + } } // If we reach here, then the config file is alright. doConfigure(props, hierarchy); @@ -385,7 +403,7 @@ void doConfigure(Properties properties, LoggerRepository hierarchy) { String value = properties.getProperty(LogLog.DEBUG_KEY); if(value == null) { - value = properties.getProperty(LogLog.CONFIG_DEBUG_KEY); + value = properties.getProperty("log4j.configDebug"); if(value != null) LogLog.warn("[log4j.configDebug] is deprecated. Use [log4j.debug] instead."); } @@ -419,15 +437,25 @@ void doConfigure(Properties properties, LoggerRepository hierarchy) { void doConfigure(java.net.URL configURL, LoggerRepository hierarchy) { Properties props = new Properties(); LogLog.debug("Reading configuration from URL " + configURL); + InputStream istream = null; try { - props.load(configURL.openStream()); + istream = configURL.openStream(); + props.load(istream); } - catch (java.io.IOException e) { + catch (Exception e) { LogLog.error("Could not read configuration file from URL [" + configURL + "].", e); LogLog.error("Ignoring configuration file [" + configURL +"]."); return; } + finally { + if (istream != null) { + try { + istream.close(); + } catch(Exception ignore) { + } + } + } doConfigure(props, hierarchy); } @@ -507,9 +535,9 @@ void configureRootCategory(Properties props, LoggerRepository hierarchy) { */ protected void parseCatsAndRenderers(Properties props, LoggerRepository hierarchy) { - Enumeration enum = props.propertyNames(); - while(enum.hasMoreElements()) { - String key = (String) enum.nextElement(); + Enumeration enumeration = props.propertyNames(); + while(enumeration.hasMoreElements()) { + String key = (String) enumeration.nextElement(); if(key.startsWith(CATEGORY_PREFIX) || key.startsWith(LOGGER_PREFIX)) { String loggerName = null; if(key.startsWith(CATEGORY_PREFIX)) { @@ -576,9 +604,13 @@ void parseCategory(Properties props, Logger logger, String optionKey, // If the level value is inherited, set category level value to // null. We also check that the user has not specified inherited for the // root category. - if(levelStr.equalsIgnoreCase(INHERITED) && - !loggerName.equals(INTERNAL_ROOT_NAME)) { - logger.setLevel(null); + if(INHERITED.equalsIgnoreCase(levelStr) || + NULL.equalsIgnoreCase(levelStr)) { + if(loggerName.equals(INTERNAL_ROOT_NAME)) { + LogLog.warn("The root logger cannot be set to null."); + } else { + logger.setLevel(null); + } } else { logger.setLevel(OptionConverter.toLevel(levelStr, (Level) Level.DEBUG)); } diff --git a/src/main/java/org/apache/log4j/ProvisionNode.java b/src/main/java/org/apache/log4j/ProvisionNode.java new file mode 100644 index 0000000000..f1126822a1 --- /dev/null +++ b/src/main/java/org/apache/log4j/ProvisionNode.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import java.util.Vector; + +class ProvisionNode extends Vector { + private static final long serialVersionUID = -4479121426311014469L; + + ProvisionNode(Logger logger) { + super(); + this.addElement(logger); + } +} diff --git a/src/java/org/apache/log4j/RollingFileAppender.java b/src/main/java/org/apache/log4j/RollingFileAppender.java similarity index 75% rename from src/java/org/apache/log4j/RollingFileAppender.java rename to src/main/java/org/apache/log4j/RollingFileAppender.java index 89f680eb92..4ad42e9285 100644 --- a/src/java/org/apache/log4j/RollingFileAppender.java +++ b/src/main/java/org/apache/log4j/RollingFileAppender.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ @@ -37,6 +47,8 @@ public class RollingFileAppender extends FileAppender { */ protected int maxBackupIndex = 1; + private long nextRollover = 0; + /** The default constructor simply calls its {@link FileAppender#FileAppender parents constructor}. */ @@ -109,26 +121,34 @@ void rollOver() { File target; File file; - LogLog.debug("rolling over count=" + ((CountingQuietWriter) qw).getCount()); + if (qw != null) { + long size = ((CountingQuietWriter) qw).getCount(); + LogLog.debug("rolling over count=" + size); + // if operation fails, do not roll again until + // maxFileSize more bytes are written + nextRollover = size + maxFileSize; + } LogLog.debug("maxBackupIndex="+maxBackupIndex); + boolean renameSucceeded = true; // If maxBackups <= 0, then there is no file renaming to be done. if(maxBackupIndex > 0) { // Delete the oldest file, to keep Windows happy. file = new File(fileName + '.' + maxBackupIndex); if (file.exists()) - file.delete(); + renameSucceeded = file.delete(); // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} - for (int i = maxBackupIndex - 1; i >= 1; i--) { + for (int i = maxBackupIndex - 1; i >= 1 && renameSucceeded; i--) { file = new File(fileName + "." + i); if (file.exists()) { target = new File(fileName + '.' + (i + 1)); LogLog.debug("Renaming file " + file + " to " + target); - file.renameTo(target); + renameSucceeded = file.renameTo(target); } } + if(renameSucceeded) { // Rename fileName to fileName.1 target = new File(fileName + "." + 1); @@ -136,17 +156,35 @@ void rollOver() { file = new File(fileName); LogLog.debug("Renaming file " + file + " to " + target); - file.renameTo(target); + renameSucceeded = file.renameTo(target); + // + // if file rename failed, reopen file with append = true + // + if (!renameSucceeded) { + try { + this.setFile(fileName, true, bufferedIO, bufferSize); + } + catch(IOException e) { + LogLog.error("setFile("+fileName+", true) call failed.", e); + } + } + } } + // + // if all renames were successful, then + // + if (renameSucceeded) { try { // This will also close the file. This is OK since multiple // close operations are safe. this.setFile(fileName, false, bufferedIO, bufferSize); + nextRollover = 0; } catch(IOException e) { LogLog.error("setFile("+fileName+", false) call failed.", e); } + } } public @@ -223,8 +261,11 @@ void setQWForFiles(Writer writer) { protected void subAppend(LoggingEvent event) { super.subAppend(event); - if((fileName != null) && - ((CountingQuietWriter) qw).getCount() >= maxFileSize) - this.rollOver(); + if(fileName != null && qw != null) { + long size = ((CountingQuietWriter) qw).getCount(); + if (size >= maxFileSize && size >= nextRollover) { + rollOver(); + } + } } } diff --git a/src/java/org/apache/log4j/SimpleLayout.java b/src/main/java/org/apache/log4j/SimpleLayout.java similarity index 61% rename from src/java/org/apache/log4j/SimpleLayout.java rename to src/main/java/org/apache/log4j/SimpleLayout.java index 565ca5479b..5699661ba6 100644 --- a/src/java/org/apache/log4j/SimpleLayout.java +++ b/src/main/java/org/apache/log4j/SimpleLayout.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j; @@ -49,7 +58,7 @@ void activateOptions() { String format(LoggingEvent event) { sbuf.setLength(0); - sbuf.append(event.level.toString()); + sbuf.append(event.getLevel().toString()); sbuf.append(" - "); sbuf.append(event.getRenderedMessage()); sbuf.append(LINE_SEP); diff --git a/src/java/org/apache/log4j/TTCCLayout.java b/src/main/java/org/apache/log4j/TTCCLayout.java similarity index 86% rename from src/java/org/apache/log4j/TTCCLayout.java rename to src/main/java/org/apache/log4j/TTCCLayout.java index 5ce94e60b2..3b0e98f967 100644 --- a/src/java/org/apache/log4j/TTCCLayout.java +++ b/src/main/java/org/apache/log4j/TTCCLayout.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Contributors: Christopher Williams @@ -157,9 +166,7 @@ boolean getContextPrinting() {

    Time, thread, category and diagnostic context are printed depending on options. - @param category - @param level - @param message + @param event The event to format */ public @@ -175,11 +182,11 @@ String format(LoggingEvent event) { buf.append(event.getThreadName()); buf.append("] "); } - buf.append(event.level.toString()); + buf.append(event.getLevel().toString()); buf.append(' '); if(this.categoryPrefixing) { - buf.append(event.categoryName); + buf.append(event.getLoggerName()); buf.append(' '); } diff --git a/src/java/org/apache/log4j/WriterAppender.java b/src/main/java/org/apache/log4j/WriterAppender.java similarity index 86% rename from src/java/org/apache/log4j/WriterAppender.java rename to src/main/java/org/apache/log4j/WriterAppender.java index 50b33f4a02..5e197d9cf7 100644 --- a/src/java/org/apache/log4j/WriterAppender.java +++ b/src/main/java/org/apache/log4j/WriterAppender.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; @@ -45,7 +55,7 @@ public class WriterAppender extends AppenderSkeleton { protected boolean immediateFlush = true; /** - The encoding to use when opening an InputStream.

    The + The encoding to use when writing.

    The encoding variable is set to null by default which results in the utilization of the system's default encoding. */ @@ -194,17 +204,18 @@ void close() { writeFooter(); reset(); } + /** - Close the underlying {@link java.io.Writer}. - */ - protected - void closeWriter() { + * Close the underlying {@link java.io.Writer}. + * */ + protected void closeWriter() { if(qw != null) { try { qw.close(); } catch(IOException e) { - LogLog.error("Could not close " + qw, e); // do need to invoke an error handler - // at this late stage + // There is do need to invoke an error handler at this late + // stage. + LogLog.error("Could not close " + qw, e); } } } @@ -234,13 +245,11 @@ OutputStreamWriter createWriter(OutputStream os) { return retval; } - public - String getEncoding() { + public String getEncoding() { return encoding; } - public - void setEncoding(String value) { + public void setEncoding(String value) { encoding = value; } @@ -250,9 +259,7 @@ void setEncoding(String value) { /** Set the {@link ErrorHandler} for this WriterAppender and also the underlying {@link QuietWriter} if any. */ - public - synchronized - void setErrorHandler(ErrorHandler eh) { + public synchronized void setErrorHandler(ErrorHandler eh) { if(eh == null) { LogLog.warn("You have tried to set a null error-handler."); } else { @@ -275,9 +282,7 @@ void setErrorHandler(ErrorHandler eh) {

    WARNING: Logging to an unopened Writer will fail.

    @param writer An already opened Writer. */ - public - synchronized - void setWriter(Writer writer) { + public synchronized void setWriter(Writer writer) { reset(); this.qw = new QuietWriter(writer, errorHandler); //this.tp = new TracerPrintWriter(qw); diff --git a/src/java/org/apache/log4j/chainsaw/ControlPanel.java b/src/main/java/org/apache/log4j/chainsaw/ControlPanel.java similarity index 83% rename from src/java/org/apache/log4j/chainsaw/ControlPanel.java rename to src/main/java/org/apache/log4j/chainsaw/ControlPanel.java index 741edecad9..53b0b1b5fa 100644 --- a/src/java/org/apache/log4j/chainsaw/ControlPanel.java +++ b/src/main/java/org/apache/log4j/chainsaw/ControlPanel.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.chainsaw; import java.awt.GridBagConstraints; @@ -18,8 +28,9 @@ import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import org.apache.log4j.Category; +import org.apache.log4j.Logger; import org.apache.log4j.Priority; +import org.apache.log4j.Level; /** * Represents the controls for filtering, pausing, exiting, etc. @@ -28,8 +39,8 @@ */ class ControlPanel extends JPanel { /** use the log messages **/ - private static final Category LOG = - Category.getInstance(ControlPanel.class); + private static final Logger LOG = + Logger.getLogger(ControlPanel.class); /** * Creates a new ControlPanel instance. @@ -61,7 +72,7 @@ class ControlPanel extends JPanel { add(label); c.gridy++; - label = new JLabel("Filter Category:"); + label = new JLabel("Filter Logger:"); gridbag.setConstraints(label, c); add(label); @@ -82,9 +93,15 @@ class ControlPanel extends JPanel { c.anchor = GridBagConstraints.WEST; c.gridy = 0; - final Priority[] allPriorities = Priority.getAllPossiblePriorities(); + final Level[] allPriorities = new Level[] {Level.FATAL, + Level.ERROR, + Level.WARN, + Level.INFO, + Level.DEBUG, + Level.TRACE }; + final JComboBox priorities = new JComboBox(allPriorities); - final Priority lowest = allPriorities[allPriorities.length - 1]; + final Level lowest = allPriorities[allPriorities.length - 1]; priorities.setSelectedItem(lowest); aModel.setPriorityFilter(lowest); gridbag.setConstraints(priorities, c); diff --git a/src/java/org/apache/log4j/chainsaw/DetailPanel.java b/src/main/java/org/apache/log4j/chainsaw/DetailPanel.java similarity index 82% rename from src/java/org/apache/log4j/chainsaw/DetailPanel.java rename to src/main/java/org/apache/log4j/chainsaw/DetailPanel.java index c05198780f..1f5dfe2c83 100644 --- a/src/java/org/apache/log4j/chainsaw/DetailPanel.java +++ b/src/main/java/org/apache/log4j/chainsaw/DetailPanel.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.chainsaw; import java.awt.BorderLayout; @@ -17,7 +27,7 @@ import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import org.apache.log4j.Category; +import org.apache.log4j.Logger; /** * A panel for showing a stack trace. @@ -29,8 +39,8 @@ class DetailPanel implements ListSelectionListener { /** used to log events **/ - private static final Category LOG = - Category.getInstance(DetailPanel.class); + private static final Logger LOG = + Logger.getLogger(DetailPanel.class); /** used to format the logging event **/ private static final MessageFormat FORMATTER = new MessageFormat( @@ -38,7 +48,7 @@ class DetailPanel "  Priority: {1}" + "  Thread: {2}" + "  NDC: {3}" + - "
    Category: {4}" + + "
    Logger: {4}" + "
    Location: {5}" + "
    Message:" + "

    {6}
    " + diff --git a/src/java/org/apache/log4j/chainsaw/EventDetails.java b/src/main/java/org/apache/log4j/chainsaw/EventDetails.java similarity index 79% rename from src/java/org/apache/log4j/chainsaw/EventDetails.java rename to src/main/java/org/apache/log4j/chainsaw/EventDetails.java index 12ddc51c65..4b3ad94a6a 100644 --- a/src/java/org/apache/log4j/chainsaw/EventDetails.java +++ b/src/main/java/org/apache/log4j/chainsaw/EventDetails.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.chainsaw; import org.apache.log4j.Priority; @@ -73,8 +83,8 @@ class EventDetails { EventDetails(LoggingEvent aEvent) { this(aEvent.timeStamp, - aEvent.level, - aEvent.categoryName, + aEvent.getLevel(), + aEvent.getLoggerName(), aEvent.getNDC(), aEvent.getThreadName(), aEvent.getRenderedMessage(), diff --git a/src/main/java/org/apache/log4j/chainsaw/ExitAction.java b/src/main/java/org/apache/log4j/chainsaw/ExitAction.java new file mode 100644 index 0000000000..55a100e29f --- /dev/null +++ b/src/main/java/org/apache/log4j/chainsaw/ExitAction.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.log4j.chainsaw; + +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; +import org.apache.log4j.Logger; + +/** + * Encapsulates the action to exit. + * + * @author Oliver Burn + * @version 1.0 + */ +class ExitAction + extends AbstractAction +{ + /** use to log messages **/ + private static final Logger LOG = Logger.getLogger(ExitAction.class); + /** The instance to share **/ + public static final ExitAction INSTANCE = new ExitAction(); + + /** Stop people creating instances **/ + private ExitAction() {} + + /** + * Will shutdown the application. + * @param aIgnore ignored + */ + public void actionPerformed(ActionEvent aIgnore) { + LOG.info("shutting down"); + System.exit(0); + } +} diff --git a/src/java/org/apache/log4j/chainsaw/LoadXMLAction.java b/src/main/java/org/apache/log4j/chainsaw/LoadXMLAction.java similarity index 81% rename from src/java/org/apache/log4j/chainsaw/LoadXMLAction.java rename to src/main/java/org/apache/log4j/chainsaw/LoadXMLAction.java index 9912e7db52..33e5d13cf2 100644 --- a/src/java/org/apache/log4j/chainsaw/LoadXMLAction.java +++ b/src/main/java/org/apache/log4j/chainsaw/LoadXMLAction.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.chainsaw; import java.awt.event.ActionEvent; @@ -16,7 +26,7 @@ import javax.swing.JOptionPane; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; -import org.apache.log4j.Category; +import org.apache.log4j.Logger; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; @@ -31,8 +41,7 @@ class LoadXMLAction extends AbstractAction { /** use to log messages **/ - private static final Category LOG = - Category.getInstance(LoadXMLAction.class); + private static final Logger LOG = Logger.getLogger(LoadXMLAction.class); /** the parent frame **/ private final JFrame mParent; diff --git a/src/java/org/apache/log4j/chainsaw/LoggingReceiver.java b/src/main/java/org/apache/log4j/chainsaw/LoggingReceiver.java similarity index 63% rename from src/java/org/apache/log4j/chainsaw/LoggingReceiver.java rename to src/main/java/org/apache/log4j/chainsaw/LoggingReceiver.java index c69b3de1d5..ca087adcc0 100644 --- a/src/java/org/apache/log4j/chainsaw/LoggingReceiver.java +++ b/src/main/java/org/apache/log4j/chainsaw/LoggingReceiver.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.chainsaw; import java.io.EOFException; @@ -23,7 +33,7 @@ */ class LoggingReceiver extends Thread { /** used to log messages **/ - private static final Logger logger = Logger.getLogger(LoggingReceiver.class); + private static final Logger LOG = Logger.getLogger(LoggingReceiver.class); /** * Helper that actually processes a client connection. It receives events @@ -46,7 +56,7 @@ private class Slurper implements Runnable { /** loops getting the events **/ public void run() { - logger.debug("Starting to get data"); + LOG.debug("Starting to get data"); try { final ObjectInputStream ois = new ObjectInputStream(mClient.getInputStream()); @@ -55,29 +65,29 @@ public void run() { mModel.addEvent(new EventDetails(event)); } } catch (EOFException e) { - logger.info("Reached EOF, closing connection"); + LOG.info("Reached EOF, closing connection"); } catch (SocketException e) { - logger.info("Caught SocketException, closing connection"); + LOG.info("Caught SocketException, closing connection"); } catch (IOException e) { - logger.warn("Got IOException, closing connection", e); + LOG.warn("Got IOException, closing connection", e); } catch (ClassNotFoundException e) { - logger.warn("Got ClassNotFoundException, closing connection", e); + LOG.warn("Got ClassNotFoundException, closing connection", e); } try { mClient.close(); } catch (IOException e) { - logger.warn("Error closing connection", e); + LOG.warn("Error closing connection", e); } } } /** where to put the events **/ - private final MyTableModel mModel; + private MyTableModel mModel; /** server for listening for connections **/ - private final ServerSocket mSvrSock; - + private ServerSocket mSvrSock; + /** * Creates a new LoggingReceiver instance. * @@ -93,19 +103,19 @@ public void run() { /** Listens for client connections **/ public void run() { - logger.info("Thread started"); + LOG.info("Thread started"); try { while (true) { - logger.debug("Waiting for a connection"); + LOG.debug("Waiting for a connection"); final Socket client = mSvrSock.accept(); - logger.debug("Got a connection from " + + LOG.debug("Got a connection from " + client.getInetAddress().getHostName()); final Thread t = new Thread(new Slurper(client)); t.setDaemon(true); t.start(); } } catch (IOException e) { - logger.error("Error in accepting connections, stopping.", e); + LOG.error("Error in accepting connections, stopping.", e); } } } diff --git a/src/java/org/apache/log4j/chainsaw/Main.java b/src/main/java/org/apache/log4j/chainsaw/Main.java similarity index 85% rename from src/java/org/apache/log4j/chainsaw/Main.java rename to src/main/java/org/apache/log4j/chainsaw/Main.java index b67a9ae476..c0c9aad71a 100644 --- a/src/java/org/apache/log4j/chainsaw/Main.java +++ b/src/main/java/org/apache/log4j/chainsaw/Main.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.chainsaw; import java.awt.BorderLayout; @@ -23,7 +33,7 @@ import javax.swing.JSplitPane; import javax.swing.JTable; import javax.swing.ListSelectionModel; -import org.apache.log4j.Category; +import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; /** @@ -41,7 +51,7 @@ public class Main public static final String PORT_PROP_NAME = "chainsaw.port"; /** use to log messages **/ - private static final Category LOG = Category.getInstance(Main.class); + private static final Logger LOG = Logger.getLogger(Main.class); /** @@ -162,7 +172,7 @@ private void setupReceiver(MyTableModel aModel) { /** initialise log4j **/ private static void initLog4J() { final Properties props = new Properties(); - props.setProperty("log4j.rootCategory", "DEBUG, A1"); + props.setProperty("log4j.rootLogger", "DEBUG, A1"); props.setProperty("log4j.appender.A1", "org.apache.log4j.ConsoleAppender"); props.setProperty("log4j.appender.A1.layout", diff --git a/src/java/org/apache/log4j/chainsaw/MyTableModel.java b/src/main/java/org/apache/log4j/chainsaw/MyTableModel.java similarity index 92% rename from src/java/org/apache/log4j/chainsaw/MyTableModel.java rename to src/main/java/org/apache/log4j/chainsaw/MyTableModel.java index d1af076317..0d43272c9a 100644 --- a/src/java/org/apache/log4j/chainsaw/MyTableModel.java +++ b/src/main/java/org/apache/log4j/chainsaw/MyTableModel.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.chainsaw; import java.text.DateFormat; @@ -16,7 +26,7 @@ import java.util.TreeSet; import javax.swing.table.AbstractTableModel; import org.apache.log4j.Priority; -import org.apache.log4j.Category; +import org.apache.log4j.Logger; /** * Represents a list of EventDetails objects that are sorted on @@ -29,8 +39,7 @@ class MyTableModel { /** used to log messages **/ - private static final Category LOG = - Category.getInstance(MyTableModel.class); + private static final Logger LOG = Logger.getLogger(MyTableModel.class); /** use the compare logging events **/ private static final Comparator MY_COMP = new Comparator() diff --git a/src/java/org/apache/log4j/chainsaw/XMLFileHandler.java b/src/main/java/org/apache/log4j/chainsaw/XMLFileHandler.java similarity index 76% rename from src/java/org/apache/log4j/chainsaw/XMLFileHandler.java rename to src/main/java/org/apache/log4j/chainsaw/XMLFileHandler.java index 5ce82d0744..2f9af5125e 100644 --- a/src/java/org/apache/log4j/chainsaw/XMLFileHandler.java +++ b/src/main/java/org/apache/log4j/chainsaw/XMLFileHandler.java @@ -1,13 +1,23 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.chainsaw; import java.util.StringTokenizer; -import org.apache.log4j.Priority; +import org.apache.log4j.Level; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; @@ -37,13 +47,11 @@ class XMLFileHandler private final MyTableModel mModel; /** the number of events in the document **/ private int mNumEvents; - /** the current element being parsed **/ - private String mCurrentElement; /** the time of the event **/ private long mTimeStamp; - /** the priority of the event **/ - private Priority mPriority; + /** the priority (level) of the event **/ + private Level mLevel; /** the category of the event **/ private String mCategoryName; /** the NDC for the event **/ @@ -56,7 +64,8 @@ class XMLFileHandler private String[] mThrowableStrRep; /** the location details for the event **/ private String mLocationDetails; - + /** buffer for collecting text **/ + private final StringBuffer mBuf = new StringBuffer(); /** * Creates a new XMLFileHandler instance. @@ -76,21 +85,7 @@ public void startDocument() /** @see DefaultHandler **/ public void characters(char[] aChars, int aStart, int aLength) { - if (mCurrentElement == TAG_NDC) { - mNDC = new String(aChars, aStart, aLength); - } else if (mCurrentElement == TAG_MESSAGE) { - mMessage = new String(aChars, aStart, aLength); - } else if (mCurrentElement == TAG_THROWABLE) { - final StringTokenizer st = - new StringTokenizer(new String(aChars, aStart, aLength), "\t"); - mThrowableStrRep = new String[st.countTokens()]; - if (mThrowableStrRep.length > 0) { - mThrowableStrRep[0] = st.nextToken(); - for (int i = 1; i < mThrowableStrRep.length; i++) { - mThrowableStrRep[i] = "\t" + st.nextToken(); - } - } - } + mBuf.append(String.valueOf(aChars, aStart, aLength)); } /** @see DefaultHandler **/ @@ -101,8 +96,20 @@ public void endElement(String aNamespaceURI, if (TAG_EVENT.equals(aQName)) { addEvent(); resetData(); - } else if (mCurrentElement != TAG_EVENT) { - mCurrentElement = TAG_EVENT; // hack - but only thing I care about + } else if (TAG_NDC.equals(aQName)) { + mNDC = mBuf.toString(); + } else if (TAG_MESSAGE.equals(aQName)) { + mMessage = mBuf.toString(); + } else if (TAG_THROWABLE.equals(aQName)) { + final StringTokenizer st = + new StringTokenizer(mBuf.toString(), "\n\t"); + mThrowableStrRep = new String[st.countTokens()]; + if (mThrowableStrRep.length > 0) { + mThrowableStrRep[0] = st.nextToken(); + for (int i = 1; i < mThrowableStrRep.length; i++) { + mThrowableStrRep[i] = "\t" + st.nextToken(); + } + } } } @@ -112,22 +119,18 @@ public void startElement(String aNamespaceURI, String aQName, Attributes aAtts) { + mBuf.setLength(0); + if (TAG_EVENT.equals(aQName)) { mThreadName = aAtts.getValue("thread"); mTimeStamp = Long.parseLong(aAtts.getValue("timestamp")); - mCategoryName = aAtts.getValue("category"); - mPriority = Priority.toPriority(aAtts.getValue("level")); + mCategoryName = aAtts.getValue("logger"); + mLevel = Level.toLevel(aAtts.getValue("level")); } else if (TAG_LOCATION_INFO.equals(aQName)) { mLocationDetails = aAtts.getValue("class") + "." + aAtts.getValue("method") + "(" + aAtts.getValue("file") + ":" + aAtts.getValue("line") + ")"; - } else if (TAG_NDC.equals(aQName)) { - mCurrentElement = TAG_NDC; - } else if (TAG_MESSAGE.equals(aQName)) { - mCurrentElement = TAG_MESSAGE; - } else if (TAG_THROWABLE.equals(aQName)) { - mCurrentElement = TAG_THROWABLE; } } @@ -143,7 +146,7 @@ int getNumEvents() { /** Add an event to the model **/ private void addEvent() { mModel.addEvent(new EventDetails(mTimeStamp, - mPriority, + mLevel, mCategoryName, mNDC, mThreadName, @@ -156,7 +159,7 @@ private void addEvent() { /** Reset the data for an event **/ private void resetData() { mTimeStamp = 0; - mPriority = null; + mLevel = null; mCategoryName = null; mNDC = null; mThreadName = null; diff --git a/src/java/org/apache/log4j/chainsaw/doc-files/screen_01.png b/src/main/java/org/apache/log4j/chainsaw/doc-files/screen_01.png similarity index 100% rename from src/java/org/apache/log4j/chainsaw/doc-files/screen_01.png rename to src/main/java/org/apache/log4j/chainsaw/doc-files/screen_01.png diff --git a/src/java/org/apache/log4j/chainsaw/package.html b/src/main/java/org/apache/log4j/chainsaw/package.html similarity index 100% rename from src/java/org/apache/log4j/chainsaw/package.html rename to src/main/java/org/apache/log4j/chainsaw/package.html diff --git a/src/java/org/apache/log4j/config/PropertyGetter.java b/src/main/java/org/apache/log4j/config/PropertyGetter.java similarity index 74% rename from src/java/org/apache/log4j/config/PropertyGetter.java rename to src/main/java/org/apache/log4j/config/PropertyGetter.java index 3c6f8db373..01f7d775de 100644 --- a/src/java/org/apache/log4j/config/PropertyGetter.java +++ b/src/main/java/org/apache/log4j/config/PropertyGetter.java @@ -1,9 +1,18 @@ /* - * 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. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.config; diff --git a/src/java/org/apache/log4j/config/PropertyPrinter.java b/src/main/java/org/apache/log4j/config/PropertyPrinter.java similarity index 66% rename from src/java/org/apache/log4j/config/PropertyPrinter.java rename to src/main/java/org/apache/log4j/config/PropertyPrinter.java index 23c950cf10..6462e3a741 100644 --- a/src/java/org/apache/log4j/config/PropertyPrinter.java +++ b/src/main/java/org/apache/log4j/config/PropertyPrinter.java @@ -1,16 +1,31 @@ /* - * 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. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.config; -import java.io.*; -import java.util.*; -import org.apache.log4j.*; +import org.apache.log4j.Appender; +import org.apache.log4j.Category; +import org.apache.log4j.Level; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; + +import java.io.PrintWriter; +import java.util.Enumeration; +import java.util.Hashtable; /** Prints the configuration of the log4j default hierarchy @@ -46,8 +61,8 @@ String genAppName() { } /** - Returns true if the specified appender name is considered to have - been generated, i.e. if it is of the form A[0-9]+. + * Returns true if the specified appender name is considered to have + * been generated, that is, if it is of the form A[0-9]+. */ protected boolean isGenAppName(String name) { @@ -67,11 +82,11 @@ boolean isGenAppName(String name) { */ public void print(PrintWriter out) { - printOptions(out, Category.getRoot()); + printOptions(out, Logger.getRootLogger()); - Enumeration cats = Category.getCurrentCategories(); + Enumeration cats = LogManager.getCurrentLoggers(); while (cats.hasMoreElements()) { - printOptions(out, (Category) cats.nextElement()); + printOptions(out, (Logger) cats.nextElement()); } } @@ -100,12 +115,19 @@ void printOptions(PrintWriter out, Category cat) { } appenderString += ", " + name; } - String catKey = (cat == Category.getRoot()) - ? "log4j.rootCategory" - : "log4j.category." + cat.getName(); + String catKey = (cat == Logger.getRootLogger()) + ? "log4j.rootLogger" + : "log4j.logger." + cat.getName(); if (appenderString != "") { out.println(catKey + "=" + appenderString); } + if (!cat.getAdditivity() && cat != Logger.getRootLogger()) { + out.println("log4j.additivity." + cat.getName() + "=false"); + } + } + + protected void printOptions(PrintWriter out, Logger cat) { + printOptions(out, (Category) cat); } protected diff --git a/src/java/org/apache/log4j/config/PropertySetter.java b/src/main/java/org/apache/log4j/config/PropertySetter.java similarity index 89% rename from src/java/org/apache/log4j/config/PropertySetter.java rename to src/main/java/org/apache/log4j/config/PropertySetter.java index c1b2ec1ad9..559923df51 100644 --- a/src/java/org/apache/log4j/config/PropertySetter.java +++ b/src/main/java/org/apache/log4j/config/PropertySetter.java @@ -1,9 +1,18 @@ /* - * 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. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Contributors: Georg Lundesgaard @@ -156,7 +165,7 @@ void setProperty(String name, String value) { setProperty(prop, name, value); } catch (PropertySetterException ex) { LogLog.warn("Failed to set property [" + name + - "] to value \"" + value + "\". " + ex.getMessage()); + "] to value \"" + value + "\". ", ex.rootCause); } } } diff --git a/src/main/java/org/apache/log4j/config/PropertySetterException.java b/src/main/java/org/apache/log4j/config/PropertySetterException.java new file mode 100644 index 0000000000..c6314cca41 --- /dev/null +++ b/src/main/java/org/apache/log4j/config/PropertySetterException.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.config; + +/** + * Thrown when an error is encountered whilst attempting to set a property + * using the {@link PropertySetter} utility class. + * + * @author Anders Kristensen + * @since 1.1 + */ +public class PropertySetterException extends Exception { + private static final long serialVersionUID = -1352613734254235861L; + protected Throwable rootCause; + + public + PropertySetterException(String msg) { + super(msg); + } + + public + PropertySetterException(Throwable rootCause) + { + super(); + this.rootCause = rootCause; + } + + /** + Returns descriptive text on the cause of this exception. + */ + public + String getMessage() { + String msg = super.getMessage(); + if (msg == null && rootCause != null) { + msg = rootCause.getMessage(); + } + return msg; + } +} diff --git a/src/java/org/apache/log4j/config/package.html b/src/main/java/org/apache/log4j/config/package.html similarity index 100% rename from src/java/org/apache/log4j/config/package.html rename to src/main/java/org/apache/log4j/config/package.html diff --git a/src/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java b/src/main/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java similarity index 78% rename from src/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java rename to src/main/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java index c17bc8cf9e..4547ecea63 100644 --- a/src/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java +++ b/src/main/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.helpers; @@ -25,6 +35,7 @@ @since 0.7.5 */ public class AbsoluteTimeDateFormat extends DateFormat { + private static final long serialVersionUID = -388856345976723342L; /** String constant used to specify {@link diff --git a/src/java/org/apache/log4j/helpers/AppenderAttachableImpl.java b/src/main/java/org/apache/log4j/helpers/AppenderAttachableImpl.java similarity index 81% rename from src/java/org/apache/log4j/helpers/AppenderAttachableImpl.java rename to src/main/java/org/apache/log4j/helpers/AppenderAttachableImpl.java index ec01c769e7..0e8cd38283 100644 --- a/src/java/org/apache/log4j/helpers/AppenderAttachableImpl.java +++ b/src/main/java/org/apache/log4j/helpers/AppenderAttachableImpl.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.helpers; @@ -121,8 +130,8 @@ boolean isAttached(Appender appender) { /** - Remove all previously attached appenders. - */ + * Remove and close all previously attached appenders. + * */ public void removeAllAppenders() { if(appenderList != null) { diff --git a/src/java/org/apache/log4j/helpers/BoundedFIFO.java b/src/main/java/org/apache/log4j/helpers/BoundedFIFO.java similarity index 80% rename from src/java/org/apache/log4j/helpers/BoundedFIFO.java rename to src/main/java/org/apache/log4j/helpers/BoundedFIFO.java index 2a1796654a..e5ce96ce02 100644 --- a/src/java/org/apache/log4j/helpers/BoundedFIFO.java +++ b/src/main/java/org/apache/log4j/helpers/BoundedFIFO.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Contributors: Mathias Bogaert @@ -82,8 +91,8 @@ int getMaxSize() { } /** - Return true if the buffer is full, i.e. of the - number of elements in the buffer equals the buffer size. */ + Return true if the buffer is full, that is, whether + the number of elements in the buffer equals the buffer size. */ public boolean isFull() { return numElements == maxSize; diff --git a/src/java/org/apache/log4j/helpers/CountingQuietWriter.java b/src/main/java/org/apache/log4j/helpers/CountingQuietWriter.java similarity index 50% rename from src/java/org/apache/log4j/helpers/CountingQuietWriter.java rename to src/main/java/org/apache/log4j/helpers/CountingQuietWriter.java index 26cf132d7e..55199e47a3 100644 --- a/src/java/org/apache/log4j/helpers/CountingQuietWriter.java +++ b/src/main/java/org/apache/log4j/helpers/CountingQuietWriter.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.helpers; diff --git a/src/java/org/apache/log4j/helpers/CyclicBuffer.java b/src/main/java/org/apache/log4j/helpers/CyclicBuffer.java similarity index 79% rename from src/java/org/apache/log4j/helpers/CyclicBuffer.java rename to src/main/java/org/apache/log4j/helpers/CyclicBuffer.java index 91da4efa5f..9077847dc9 100644 --- a/src/java/org/apache/log4j/helpers/CyclicBuffer.java +++ b/src/main/java/org/apache/log4j/helpers/CyclicBuffer.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.helpers; diff --git a/src/java/org/apache/log4j/helpers/DateLayout.java b/src/main/java/org/apache/log4j/helpers/DateLayout.java similarity index 87% rename from src/java/org/apache/log4j/helpers/DateLayout.java rename to src/main/java/org/apache/log4j/helpers/DateLayout.java index 9dba0c6b26..2e0eca8e34 100644 --- a/src/java/org/apache/log4j/helpers/DateLayout.java +++ b/src/main/java/org/apache/log4j/helpers/DateLayout.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.helpers; diff --git a/src/java/org/apache/log4j/helpers/DateTimeDateFormat.java b/src/main/java/org/apache/log4j/helpers/DateTimeDateFormat.java similarity index 61% rename from src/java/org/apache/log4j/helpers/DateTimeDateFormat.java rename to src/main/java/org/apache/log4j/helpers/DateTimeDateFormat.java index e4db3f3aa5..559f731952 100644 --- a/src/java/org/apache/log4j/helpers/DateTimeDateFormat.java +++ b/src/main/java/org/apache/log4j/helpers/DateTimeDateFormat.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.helpers; @@ -15,13 +25,14 @@ import java.text.DateFormatSymbols; /** - Formats a {@link Date} in the format "dd MMM YYYY HH:mm:ss,SSS" for example, + Formats a {@link Date} in the format "dd MMM yyyy HH:mm:ss,SSS" for example, "06 Nov 1994 15:49:37,459". @author Ceki Gülcü @since 0.7.5 */ public class DateTimeDateFormat extends AbsoluteTimeDateFormat { + private static final long serialVersionUID = 5547637772208514971L; String[] shortMonths; @@ -38,7 +49,7 @@ public class DateTimeDateFormat extends AbsoluteTimeDateFormat { } /** - Appends to sbuf the date in the format "dd MMM YYYY + Appends to sbuf the date in the format "dd MMM yyyy HH:mm:ss,SSS" for example, "06 Nov 1994 08:49:37,459". @param sbuf the string buffer to write to diff --git a/src/java/org/apache/log4j/helpers/FileWatchdog.java b/src/main/java/org/apache/log4j/helpers/FileWatchdog.java similarity index 72% rename from src/java/org/apache/log4j/helpers/FileWatchdog.java rename to src/main/java/org/apache/log4j/helpers/FileWatchdog.java index 4579fbe33a..8fc86339ec 100644 --- a/src/java/org/apache/log4j/helpers/FileWatchdog.java +++ b/src/main/java/org/apache/log4j/helpers/FileWatchdog.java @@ -1,9 +1,18 @@ /* - * 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 file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Contributors: Mathias Bogaert @@ -92,7 +101,7 @@ void checkAndConfigure() { void run() { while(!interrupted) { try { - Thread.currentThread().sleep(delay); + Thread.sleep(delay); } catch(InterruptedException e) { // no interruption expected } diff --git a/src/main/java/org/apache/log4j/helpers/FormattingInfo.java b/src/main/java/org/apache/log4j/helpers/FormattingInfo.java new file mode 100644 index 0000000000..e158243235 --- /dev/null +++ b/src/main/java/org/apache/log4j/helpers/FormattingInfo.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.helpers; + + +/** + FormattingInfo instances contain the information obtained when parsing + formatting modifiers in conversion modifiers. + + @author Jim Cakalic + @author Ceki Gülcü + + @since 0.8.2 + */ +public class FormattingInfo { + int min = -1; + int max = 0x7FFFFFFF; + boolean leftAlign = false; + + void reset() { + min = -1; + max = 0x7FFFFFFF; + leftAlign = false; + } + + void dump() { + LogLog.debug("min="+min+", max="+max+", leftAlign="+leftAlign); + } +} + diff --git a/src/java/org/apache/log4j/helpers/ISO8601DateFormat.java b/src/main/java/org/apache/log4j/helpers/ISO8601DateFormat.java similarity index 78% rename from src/java/org/apache/log4j/helpers/ISO8601DateFormat.java rename to src/main/java/org/apache/log4j/helpers/ISO8601DateFormat.java index b4edd13c53..6a131db8fa 100644 --- a/src/java/org/apache/log4j/helpers/ISO8601DateFormat.java +++ b/src/main/java/org/apache/log4j/helpers/ISO8601DateFormat.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.helpers; @@ -17,7 +26,7 @@ // Contributors: Arndt Schoenewald /** - Formats a {@link Date} in the format "YYYY-mm-dd HH:mm:ss,SSS" for example + Formats a {@link Date} in the format "yyyy-MM-dd HH:mm:ss,SSS" for example "1999-11-27 15:49:37,459".

    Refer to the resource in different + places. The search order is as follows: + +

      + +

    1. Search for resource using the thread context + class loader under Java2. If that fails, search for + resource using the class loader that loaded this + class (Loader). Under JDK 1.1, only the the class + loader that loaded this class (Loader) is used. + +

    2. Try one last time with + ClassLoader.getSystemResource(resource), that is is + using the system class loader in JDK 1.2 and virtual machine's + built-in class loader in JDK 1.1. + +
    + */ + static public URL getResource(String resource) { + ClassLoader classLoader = null; + URL url = null; + + try { + if(!java1) { + classLoader = getTCL(); + if(classLoader != null) { + LogLog.debug("Trying to find ["+resource+"] using context classloader " + +classLoader+"."); + url = classLoader.getResource(resource); + if(url != null) { + return url; + } + } + } + + // We could not find resource. Ler us now try with the + // classloader that loaded this class. + classLoader = Loader.class.getClassLoader(); + if(classLoader != null) { + LogLog.debug("Trying to find ["+resource+"] using "+classLoader + +" class loader."); + url = classLoader.getResource(resource); + if(url != null) { + return url; + } + } + } catch(Throwable t) { + LogLog.warn(TSTR, t); + } + + // Last ditch attempt: get the resource from the class path. It + // may be the case that clazz was loaded by the Extentsion class + // loader which the parent of the system class loader. Hence the + // code below. + LogLog.debug("Trying to find ["+resource+ + "] using ClassLoader.getSystemResource()."); + return ClassLoader.getSystemResource(resource); + } + + /** + Are we running under JDK 1.x? + */ + public + static + boolean isJava1() { + return java1; + } + + /** + * Get the Thread Context Loader which is a JDK 1.2 feature. If we + * are running under JDK 1.1 or anything else goes wrong the method + * returns null. + * + * */ + private static ClassLoader getTCL() throws IllegalAccessException, + InvocationTargetException { + + // Are we running on a JDK 1.2 or later system? + Method method = null; + try { + method = Thread.class.getMethod("getContextClassLoader", null); + } catch (NoSuchMethodException e) { + // We are running on JDK 1.1 + return null; + } + + return (ClassLoader) method.invoke(Thread.currentThread(), null); + } + + + + /** + * If running under JDK 1.2 load the specified class using the + * Thread contextClassLoader if that + * fails try Class.forname. Under JDK 1.1 only Class.forName is + * used. + * + */ + static public Class loadClass (String clazz) throws ClassNotFoundException { + // Just call Class.forName(clazz) if we are running under JDK 1.1 + // or if we are instructed to ignore the TCL. + if(java1 || ignoreTCL) { + return Class.forName(clazz); + } else { + try { + return getTCL().loadClass(clazz); + } catch(Throwable e) { + // we reached here because tcl was null or because of a + // security exception, or because clazz could not be loaded... + // In any case we now try one more time + return Class.forName(clazz); + } + } + } +} diff --git a/src/java/org/apache/log4j/helpers/LogLog.java b/src/main/java/org/apache/log4j/helpers/LogLog.java similarity index 84% rename from src/java/org/apache/log4j/helpers/LogLog.java rename to src/main/java/org/apache/log4j/helpers/LogLog.java index 5c98715b0e..a7bd588ff1 100644 --- a/src/java/org/apache/log4j/helpers/LogLog.java +++ b/src/main/java/org/apache/log4j/helpers/LogLog.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.helpers; diff --git a/src/main/java/org/apache/log4j/helpers/NullEnumeration.java b/src/main/java/org/apache/log4j/helpers/NullEnumeration.java new file mode 100644 index 0000000000..0f4310ddfa --- /dev/null +++ b/src/main/java/org/apache/log4j/helpers/NullEnumeration.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.helpers; + +import java.util.Enumeration; +import java.util.NoSuchElementException; + +/** + + An always-empty Enumerator. + + @author Anders Kristensen + @since version 1.0 + */ +public class NullEnumeration implements Enumeration { + private static final NullEnumeration instance = new NullEnumeration(); + + private + NullEnumeration() { + } + + public static NullEnumeration getInstance() { + return instance; + } + + public + boolean hasMoreElements() { + return false; + } + + public + Object nextElement() { + throw new NoSuchElementException(); + } +} diff --git a/src/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java b/src/main/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java similarity index 70% rename from src/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java rename to src/main/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java index a793e09189..33ed0f9242 100644 --- a/src/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java +++ b/src/main/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.helpers; diff --git a/src/java/org/apache/log4j/helpers/OptionConverter.java b/src/main/java/org/apache/log4j/helpers/OptionConverter.java similarity index 91% rename from src/java/org/apache/log4j/helpers/OptionConverter.java rename to src/main/java/org/apache/log4j/helpers/OptionConverter.java index 2131b48d71..1d2d7dc18c 100644 --- a/src/java/org/apache/log4j/helpers/OptionConverter.java +++ b/src/main/java/org/apache/log4j/helpers/OptionConverter.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.helpers; @@ -174,6 +183,8 @@ significant for the class name part, if present. Level toLevel(String value, Level defaultValue) { if(value == null) return defaultValue; + + value = value.trim(); int hashIndex = value.indexOf('#'); if (hashIndex == -1) { @@ -199,7 +210,7 @@ Level toLevel(String value, Level defaultValue) { + ":pri=[" + levelName + "]"); try { - Class customLevel = Class.forName(clazz); + Class customLevel = Loader.loadClass(clazz); // get a ref to the specified class' static method // toLevel(String, org.apache.log4j.Level) @@ -218,7 +229,7 @@ Level toLevel(String value, Level defaultValue) { LogLog.warn("custom level class [" + clazz + "] not found."); } catch(NoSuchMethodException e) { LogLog.warn("custom level class [" + clazz + "]" - + " does not have a constructor which takes one string parameter", e); + + " does not have a class function toLevel(String, Level)", e); } catch(java.lang.reflect.InvocationTargetException e) { LogLog.warn("custom level class [" + clazz + "]" + " could not be instantiated", e); @@ -306,10 +317,14 @@ Object instantiateByClassName(String className, Class superClass, Object defaultValue) { if(className != null) { try { - Class classObj = Class.forName(className); + Class classObj = Loader.loadClass(className); if(!superClass.isAssignableFrom(classObj)) { LogLog.error("A \""+className+"\" object is not assignable to a \""+ superClass.getName() + "\" variable."); + LogLog.error("The class \""+ superClass.getName()+"\" was loaded by "); + LogLog.error("["+superClass.getClassLoader()+"] whereas object of type "); + LogLog.error("\"" +classObj.getName()+"\" was loaded by [" + +classObj.getClassLoader()+"]."); return defaultValue; } return classObj.newInstance(); diff --git a/src/java/org/apache/log4j/helpers/PatternConverter.java b/src/main/java/org/apache/log4j/helpers/PatternConverter.java similarity index 71% rename from src/java/org/apache/log4j/helpers/PatternConverter.java rename to src/main/java/org/apache/log4j/helpers/PatternConverter.java index d8b7bdfeda..2b46db7fee 100644 --- a/src/java/org/apache/log4j/helpers/PatternConverter.java +++ b/src/main/java/org/apache/log4j/helpers/PatternConverter.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.helpers; diff --git a/src/java/org/apache/log4j/helpers/PatternParser.java b/src/main/java/org/apache/log4j/helpers/PatternParser.java similarity index 94% rename from src/java/org/apache/log4j/helpers/PatternParser.java rename to src/main/java/org/apache/log4j/helpers/PatternParser.java index f6fecf39e5..73a35a582f 100644 --- a/src/java/org/apache/log4j/helpers/PatternParser.java +++ b/src/main/java/org/apache/log4j/helpers/PatternParser.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.helpers; @@ -40,7 +49,6 @@ public class PatternParser { private static final int LITERAL_STATE = 0; private static final int CONVERTER_STATE = 1; - private static final int MINUS_STATE = 2; private static final int DOT_STATE = 3; private static final int MIN_STATE = 4; private static final int MAX_STATE = 5; @@ -388,7 +396,7 @@ String convert(LoggingEvent event) { case THREAD_CONVERTER: return event.getThreadName(); case LEVEL_CONVERTER: - return event.level.toString(); + return event.getLevel().toString(); case NDC_CONVERTER: return event.getNDC(); case MESSAGE_CONVERTER: { @@ -538,7 +546,7 @@ private class CategoryPatternConverter extends NamedPatternConverter { } String getFullyQualifiedName(LoggingEvent event) { - return event.categoryName; + return event.getLoggerName(); } } } diff --git a/src/java/org/apache/log4j/helpers/QuietWriter.java b/src/main/java/org/apache/log4j/helpers/QuietWriter.java similarity index 61% rename from src/java/org/apache/log4j/helpers/QuietWriter.java rename to src/main/java/org/apache/log4j/helpers/QuietWriter.java index f000d0eef3..68a96da8d1 100644 --- a/src/java/org/apache/log4j/helpers/QuietWriter.java +++ b/src/main/java/org/apache/log4j/helpers/QuietWriter.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.helpers; diff --git a/src/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java b/src/main/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java similarity index 52% rename from src/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java rename to src/main/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java index 85b6394e00..ab81a34cf5 100644 --- a/src/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java +++ b/src/main/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.helpers; @@ -14,7 +24,7 @@ /** Formats a {@link Date} by printing the number of milliseconds - elapsed since the start of the application. This is the fastest + elapsed since construction of the format. This is the fastest printing DateFormat in the package. @author Ceki Gülcü @@ -22,6 +32,8 @@ @since 0.7.5 */ public class RelativeTimeDateFormat extends DateFormat { + private static final long serialVersionUID = 7055751607085611984L; + protected final long startTime; diff --git a/src/main/java/org/apache/log4j/helpers/SyslogQuietWriter.java b/src/main/java/org/apache/log4j/helpers/SyslogQuietWriter.java new file mode 100644 index 0000000000..62e933e40d --- /dev/null +++ b/src/main/java/org/apache/log4j/helpers/SyslogQuietWriter.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.helpers; + + + +import java.io.Writer; +import org.apache.log4j.spi.ErrorHandler; + +/** + SyslogQuietWriter extends QuietWriter by prepending the syslog + level code before each printed String. + + @since 0.7.3 +*/ +public class SyslogQuietWriter extends QuietWriter { + + int syslogFacility; + int level; + + public + SyslogQuietWriter(Writer writer, int syslogFacility, ErrorHandler eh) { + super(writer, eh); + this.syslogFacility = syslogFacility; + } + + public + void setLevel(int level) { + this.level = level; + } + + public + void setSyslogFacility(int syslogFacility) { + this.syslogFacility = syslogFacility; + } + + public + void write(String string) { + super.write("<"+(syslogFacility | level)+">" + string); + } +} diff --git a/src/main/java/org/apache/log4j/helpers/SyslogWriter.java b/src/main/java/org/apache/log4j/helpers/SyslogWriter.java new file mode 100644 index 0000000000..d6ce4bf6de --- /dev/null +++ b/src/main/java/org/apache/log4j/helpers/SyslogWriter.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.helpers; + + +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 java.net.URL; +import java.net.MalformedURLException; + +/** + SyslogWriter is a wrapper around the java.net.DatagramSocket class + so that it behaves like a java.io.Writer. + + @since 0.7.3 +*/ +public class SyslogWriter extends Writer { + + final int SYSLOG_PORT = 514; + /** + * Host string from last constructed SyslogWriter. + * @deprecated + */ + static String syslogHost; + + private InetAddress address; + private final int port; + private DatagramSocket ds; + + /** + * Constructs a new instance of SyslogWriter. + * @param syslogHost host name, may not be null. A port + * may be specified by following the name or IPv4 literal address with + * a colon and a decimal port number. To specify a port with an IPv6 + * address, enclose the IPv6 address in square brackets before appending + * the colon and decimal port number. + */ + public + SyslogWriter(final String syslogHost) { + SyslogWriter.syslogHost = syslogHost; + if (syslogHost == null) { + throw new NullPointerException("syslogHost"); + } + + String host = syslogHost; + int urlPort = -1; + + // + // If not an unbracketed IPv6 address then + // parse as a URL + // + if (host.indexOf("[") != -1 || host.indexOf(':') == host.lastIndexOf(':')) { + try { + URL url = new URL("http://" + host); + if (url.getHost() != null) { + host = url.getHost(); + // if host is a IPv6 literal, strip off the brackets + if(host.startsWith("[") && host.charAt(host.length() - 1) == ']') { + host = host.substring(1, host.length() - 1); + } + urlPort = url.getPort(); + } + } catch(MalformedURLException e) { + LogLog.error("Malformed URL: will attempt to interpret as InetAddress.", e); + } + } + + if (urlPort == -1) { + urlPort = SYSLOG_PORT; + } + port = urlPort; + + 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(final String string) throws IOException { + + if(this.ds != null && this.address != null) { + byte[] bytes = string.getBytes(); + // + // syslog packets must be less than 1024 bytes + // + int bytesLength = bytes.length; + if (bytesLength >= 1024) { + bytesLength = 1024; + } + DatagramPacket packet = new DatagramPacket(bytes, bytesLength, + address, port); + ds.send(packet); + } + + } + + public + void flush() {} + + public void close() { + if (ds != null) { + ds.close(); + } + } +} diff --git a/src/main/java/org/apache/log4j/helpers/ThreadLocalMap.java b/src/main/java/org/apache/log4j/helpers/ThreadLocalMap.java new file mode 100644 index 0000000000..da60c86ff4 --- /dev/null +++ b/src/main/java/org/apache/log4j/helpers/ThreadLocalMap.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.helpers; + +import java.util.Hashtable; + +/** + ThreadLocalMap extends {@link InheritableThreadLocal} + to bequeath a copy of the hashtable of the MDC of the parent + thread. + + @author Ceki Gülcü + @since 1.2 +*/ +final public class ThreadLocalMap extends InheritableThreadLocal { + + public + final + Object childValue(Object parentValue) { + Hashtable ht = (Hashtable) parentValue; + if(ht != null) { + return ht.clone(); + } else { + return null; + } + } +} diff --git a/src/main/java/org/apache/log4j/helpers/Transform.java b/src/main/java/org/apache/log4j/helpers/Transform.java new file mode 100644 index 0000000000..7626e71fb9 --- /dev/null +++ b/src/main/java/org/apache/log4j/helpers/Transform.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.helpers; + +/** + Utility class for transforming strings. + + @author Ceki Gülcü + @author Michael A. McAngus + */ +public class Transform { + + private static final String CDATA_START = ""; + private static final String CDATA_PSEUDO_END = "]]>"; + private static final String CDATA_EMBEDED_END = CDATA_END + CDATA_PSEUDO_END + CDATA_START; + private static final int CDATA_END_LEN = CDATA_END.length(); + + /** + * This method takes a string which may contain HTML tags (ie, + * <b>, <table>, etc) and replaces any + * '<', '>' , '&' or '"' + * characters with respective predefined entity references. + * + * @param input The text to be converted. + * @return The input string with the special characters replaced. + * */ + static public String escapeTags(final String input) { + //Check if the string is null, zero length or devoid of special characters + // if so, return what was sent in. + + if(input == null + || input.length() == 0 + || (input.indexOf('"') == -1 && + input.indexOf('&') == -1 && + input.indexOf('<') == -1 && + input.indexOf('>') == -1)) { + return input; + } + + //Use a StringBuffer in lieu of String concatenation -- it is + //much more efficient this way. + + StringBuffer buf = new StringBuffer(input.length() + 6); + char ch = ' '; + + int len = input.length(); + for(int i=0; i < len; i++) { + ch = input.charAt(i); + if (ch > '>') { + buf.append(ch); + } else if(ch == '<') { + buf.append("<"); + } else if(ch == '>') { + buf.append(">"); + } else if(ch == '&') { + buf.append("&"); + } else if(ch == '"') { + buf.append("""); + } else { + buf.append(ch); + } + } + return buf.toString(); + } + + /** + * Ensures that embeded CDEnd strings (]]>) are handled properly + * within message, NDC and throwable tag text. + * + * @param buf StringBuffer holding the XML data to this point. The + * initial CDStart () of the CDATA + * section are the responsibility of the calling method. + * @param str The String that is inserted into an existing CDATA Section within buf. + * */ + static public void appendEscapingCDATA(final StringBuffer buf, + final String str) { + if (str != null) { + int end = str.indexOf(CDATA_END); + if (end < 0) { + buf.append(str); + } else { + int start = 0; + while (end > -1) { + buf.append(str.substring(start, end)); + buf.append(CDATA_EMBEDED_END); + start = end + CDATA_END_LEN; + if (start < str.length()) { + end = str.indexOf(CDATA_END, start); + } else { + return; + } + } + buf.append(str.substring(start)); + } + } + } +} diff --git a/src/java/org/apache/log4j/helpers/package.html b/src/main/java/org/apache/log4j/helpers/package.html similarity index 100% rename from src/java/org/apache/log4j/helpers/package.html rename to src/main/java/org/apache/log4j/helpers/package.html diff --git a/src/java/org/apache/log4j/jdbc/JDBCAppender.java b/src/main/java/org/apache/log4j/jdbc/JDBCAppender.java similarity index 86% rename from src/java/org/apache/log4j/jdbc/JDBCAppender.java rename to src/main/java/org/apache/log4j/jdbc/JDBCAppender.java index 31bf000291..eca1a3821f 100644 --- a/src/java/org/apache/log4j/jdbc/JDBCAppender.java +++ b/src/main/java/org/apache/log4j/jdbc/JDBCAppender.java @@ -1,6 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.jdbc; -import org.apache.log4j.*; import org.apache.log4j.spi.*; import org.apache.log4j.PatternLayout; @@ -14,8 +29,13 @@ /** - The JDBCAppender provides for sending log events to a database. +

    WARNING: This version of JDBCAppender + is very likely to be completely replaced in the future. Moreoever, + it does not log exceptions. + The JDBCAppender provides for sending log events to a database. + +

    Each append call adds to an ArrayList buffer. When the buffer is filled each log event is placed in a sql statement (configurable) and executed. @@ -53,7 +73,7 @@ - @author: Kevin Steppe (ksteppe@pacbell.net) + @author Kevin Steppe (ksteppe@pacbell.net) */ public class JDBCAppender extends org.apache.log4j.AppenderSkeleton @@ -86,7 +106,7 @@ public class JDBCAppender extends org.apache.log4j.AppenderSkeleton /** * Stores the string given to the pattern layout for conversion into a SQL * statement, eg: insert into LogTable (Thread, Class, Message) values - * ("%t", "%c", "%m") + * ("%t", "%c", "%m"). * * Be careful of quotes in your messages! * @@ -235,8 +255,12 @@ public void flushBuffer() { ErrorCode.FLUSH_FAILURE); } } + + // remove from the buffer any events that were reported buffer.removeAll(removes); - //buffer.clear(); + + // clear the buffer of reported events + removes.clear(); } @@ -247,10 +271,10 @@ public void finalize() { /** - * JDBCAppender builds a layout internally if one is not provided. - */ + * JDBCAppender requires a layout. + * */ public boolean requiresLayout() { - return false; + return true; } diff --git a/src/java/org/apache/log4j/jdbc/package.html b/src/main/java/org/apache/log4j/jdbc/package.html similarity index 100% rename from src/java/org/apache/log4j/jdbc/package.html rename to src/main/java/org/apache/log4j/jdbc/package.html diff --git a/src/java/org/apache/log4j/jmx/AbstractDynamicMBean.java b/src/main/java/org/apache/log4j/jmx/AbstractDynamicMBean.java similarity index 79% rename from src/java/org/apache/log4j/jmx/AbstractDynamicMBean.java rename to src/main/java/org/apache/log4j/jmx/AbstractDynamicMBean.java index a9601e7ff2..b2674f5106 100644 --- a/src/java/org/apache/log4j/jmx/AbstractDynamicMBean.java +++ b/src/main/java/org/apache/log4j/jmx/AbstractDynamicMBean.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.jmx; diff --git a/src/main/java/org/apache/log4j/jmx/Agent.java b/src/main/java/org/apache/log4j/jmx/Agent.java new file mode 100644 index 0000000000..835af8f71a --- /dev/null +++ b/src/main/java/org/apache/log4j/jmx/Agent.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.jmx; + +import javax.management.ObjectName; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import com.sun.jdmk.comm.HtmlAdaptorServer; + +import org.apache.log4j.Logger; + + +public class Agent { + + static Logger log = Logger.getLogger(Agent.class); + + public Agent() { + } + + + public + void start() { + + MBeanServer server = MBeanServerFactory.createMBeanServer(); + HtmlAdaptorServer html = new HtmlAdaptorServer(); + + try { + log.info("Registering HtmlAdaptorServer instance."); + server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082")); + log.info("Registering HierarchyDynamicMBean instance."); + HierarchyDynamicMBean hdm = new HierarchyDynamicMBean(); + server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default")); + + } catch(Exception e) { + log.error("Problem while regitering MBeans instances.", e); + return; + } + html.start(); + } +} diff --git a/src/java/org/apache/log4j/jmx/AppenderDynamicMBean.java b/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java similarity index 88% rename from src/java/org/apache/log4j/jmx/AppenderDynamicMBean.java rename to src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java index 2b2aab0b45..55e38845a2 100644 --- a/src/java/org/apache/log4j/jmx/AppenderDynamicMBean.java +++ b/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.jmx; @@ -183,14 +193,11 @@ void registerLayoutMBean(Layout layout) { try { LayoutDynamicMBean appenderMBean = new LayoutDynamicMBean(layout); objectName = new ObjectName("log4j:appender="+name); - server.registerMBean(appenderMBean, objectName); - - dAttributes.add(new MBeanAttributeInfo("appender="+name, - "javax.management.ObjectName", - "The "+name+" layout.", - true, - true, - false)); + if (!server.isRegistered(objectName)) { + server.registerMBean(appenderMBean, objectName); + dAttributes.add(new MBeanAttributeInfo("appender=" + name, "javax.management.ObjectName", + "The " + name + " layout.", true, true, false)); + } } catch(Exception e) { cat.error("Could not add DynamicLayoutMBean for ["+name+"].", e); diff --git a/src/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java b/src/main/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java similarity index 84% rename from src/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java rename to src/main/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java index 361409b90a..66492e1698 100644 --- a/src/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java +++ b/src/main/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.jmx; @@ -93,7 +103,7 @@ void buildDynamicMBeanInfo() { public ObjectName addLoggerMBean(String name) { - Logger cat = Logger.exists(name); + Logger cat = LogManager.exists(name); if(cat != null) { return addLoggerMBean(cat); @@ -108,26 +118,22 @@ ObjectName addLoggerMBean(Logger logger) { try { LoggerDynamicMBean loggerMBean = new LoggerDynamicMBean(logger); objectName = new ObjectName("log4j", "logger", name); - server.registerMBean(loggerMBean, objectName); - - NotificationFilterSupport nfs = new NotificationFilterSupport(); - nfs.enableType(ADD_APPENDER+logger.getName()); - - log.debug("---Adding logger ["+name+"] as listener."); - - nbs.addNotificationListener(loggerMBean, nfs, null); - - - vAttributes.add(new MBeanAttributeInfo("logger="+name, - "javax.management.ObjectName", - "The "+name+" logger.", - true, - true, // this makes the object - // clickable - false)); + + if (!server.isRegistered(objectName)) { + server.registerMBean(loggerMBean, objectName); + NotificationFilterSupport nfs = new NotificationFilterSupport(); + nfs.enableType(ADD_APPENDER + logger.getName()); + log.debug("---Adding logger [" + name + "] as listener."); + nbs.addNotificationListener(loggerMBean, nfs, null); + vAttributes.add(new MBeanAttributeInfo("logger=" + name, "javax.management.ObjectName", + "The " + name + " logger.", true, true, // this makes the object + // clickable + false)); + + } } catch(Exception e) { - log.error("Couls not add loggerMBean for ["+name+"]."); + log.error("Could not add loggerMBean for ["+name+"].", e); } return objectName; } diff --git a/src/java/org/apache/log4j/jmx/LayoutDynamicMBean.java b/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java similarity index 89% rename from src/java/org/apache/log4j/jmx/LayoutDynamicMBean.java rename to src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java index d9f4ac5f4d..022b9f4152 100644 --- a/src/java/org/apache/log4j/jmx/LayoutDynamicMBean.java +++ b/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.jmx; diff --git a/src/java/org/apache/log4j/jmx/LoggerDynamicMBean.java b/src/main/java/org/apache/log4j/jmx/LoggerDynamicMBean.java similarity index 85% rename from src/java/org/apache/log4j/jmx/LoggerDynamicMBean.java rename to src/main/java/org/apache/log4j/jmx/LoggerDynamicMBean.java index 086f99c0b2..f97d948a93 100644 --- a/src/java/org/apache/log4j/jmx/LoggerDynamicMBean.java +++ b/src/main/java/org/apache/log4j/jmx/LoggerDynamicMBean.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.jmx; @@ -218,7 +234,7 @@ void setAttribute(Attribute attribute) throws AttributeNotFoundException, } else { p = OptionConverter.toLevel(s, p); } - logger.setPriority(p); + logger.setLevel(p); } } else { throw(new AttributeNotFoundException("Attribute " + name + @@ -228,9 +244,9 @@ void setAttribute(Attribute attribute) throws AttributeNotFoundException, } void appenderMBeanRegistration() { - Enumeration enum = logger.getAllAppenders(); - while(enum.hasMoreElements()) { - Appender appender = (Appender) enum.nextElement(); + Enumeration enumeration = logger.getAllAppenders(); + while(enumeration.hasMoreElements()) { + Appender appender = (Appender) enumeration.nextElement(); registerAppenderMBean(appender); } } @@ -242,14 +258,11 @@ void registerAppenderMBean(Appender appender) { try { AppenderDynamicMBean appenderMBean = new AppenderDynamicMBean(appender); objectName = new ObjectName("log4j", "appender", name); - server.registerMBean(appenderMBean, objectName); - - dAttributes.add(new MBeanAttributeInfo("appender="+name, - "javax.management.ObjectName", - "The "+name+" appender.", - true, - true, - false)); + if (!server.isRegistered(objectName)) { + server.registerMBean(appenderMBean, objectName); + dAttributes.add(new MBeanAttributeInfo("appender=" + name, "javax.management.ObjectName", + "The " + name + " appender.", true, true, false)); + } } catch(Exception e) { cat.error("Could not add appenderMBean for ["+name+"].", e); diff --git a/src/main/java/org/apache/log4j/jmx/MethodUnion.java b/src/main/java/org/apache/log4j/jmx/MethodUnion.java new file mode 100644 index 0000000000..e9f2fb2c52 --- /dev/null +++ b/src/main/java/org/apache/log4j/jmx/MethodUnion.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.jmx; + +import java.lang.reflect.Method; + +class MethodUnion { + + Method readMethod; + Method writeMethod; + + MethodUnion( Method readMethod, Method writeMethod) { + this.readMethod = readMethod; + this.writeMethod = writeMethod; + } + +} diff --git a/src/java/org/apache/log4j/jmx/package.html b/src/main/java/org/apache/log4j/jmx/package.html similarity index 100% rename from src/java/org/apache/log4j/jmx/package.html rename to src/main/java/org/apache/log4j/jmx/package.html diff --git a/src/java/org/apache/log4j/lf5/AppenderFinalizer.java b/src/main/java/org/apache/log4j/lf5/AppenderFinalizer.java similarity index 74% rename from src/java/org/apache/log4j/lf5/AppenderFinalizer.java rename to src/main/java/org/apache/log4j/lf5/AppenderFinalizer.java index a948b2fbc0..a2a7019208 100644 --- a/src/java/org/apache/log4j/lf5/AppenderFinalizer.java +++ b/src/main/java/org/apache/log4j/lf5/AppenderFinalizer.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5; diff --git a/src/java/org/apache/log4j/lf5/DefaultLF5Configurator.java b/src/main/java/org/apache/log4j/lf5/DefaultLF5Configurator.java similarity index 81% rename from src/java/org/apache/log4j/lf5/DefaultLF5Configurator.java rename to src/main/java/org/apache/log4j/lf5/DefaultLF5Configurator.java index 5932744712..31d7f5bfc5 100644 --- a/src/java/org/apache/log4j/lf5/DefaultLF5Configurator.java +++ b/src/main/java/org/apache/log4j/lf5/DefaultLF5Configurator.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5; diff --git a/src/java/org/apache/log4j/lf5/LF5Appender.java b/src/main/java/org/apache/log4j/lf5/LF5Appender.java similarity index 90% rename from src/java/org/apache/log4j/lf5/LF5Appender.java rename to src/main/java/org/apache/log4j/lf5/LF5Appender.java index 444b76e136..a577a4c330 100644 --- a/src/java/org/apache/log4j/lf5/LF5Appender.java +++ b/src/main/java/org/apache/log4j/lf5/LF5Appender.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5; @@ -88,11 +97,11 @@ public LF5Appender(LogBrokerMonitor monitor) { */ public void append(LoggingEvent event) { // Retrieve the information from the log4j LoggingEvent. - String category = event.categoryName; + String category = event.getLoggerName(); String logMessage = event.getRenderedMessage(); String nestedDiagnosticContext = event.getNDC(); String threadDescription = event.getThreadName(); - String level = event.level.toString(); + String level = event.getLevel().toString(); long time = event.timeStamp; LocationInfo locationInfo = event.getLocationInformation(); @@ -255,4 +264,4 @@ protected static int getDefaultMonitorHeight() { // Nested Top-Level Classes or Interfaces: //-------------------------------------------------------------------------- -} \ No newline at end of file +} diff --git a/src/java/org/apache/log4j/lf5/Log4JLogRecord.java b/src/main/java/org/apache/log4j/lf5/Log4JLogRecord.java similarity index 80% rename from src/java/org/apache/log4j/lf5/Log4JLogRecord.java rename to src/main/java/org/apache/log4j/lf5/Log4JLogRecord.java index 1df491e5af..4393eb586d 100644 --- a/src/java/org/apache/log4j/lf5/Log4JLogRecord.java +++ b/src/main/java/org/apache/log4j/lf5/Log4JLogRecord.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5; diff --git a/src/java/org/apache/log4j/lf5/LogLevel.java b/src/main/java/org/apache/log4j/lf5/LogLevel.java similarity index 90% rename from src/java/org/apache/log4j/lf5/LogLevel.java rename to src/main/java/org/apache/log4j/lf5/LogLevel.java index 82074f1230..b168cc9cf0 100644 --- a/src/java/org/apache/log4j/lf5/LogLevel.java +++ b/src/main/java/org/apache/log4j/lf5/LogLevel.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5; diff --git a/src/java/org/apache/log4j/lf5/LogLevelFormatException.java b/src/main/java/org/apache/log4j/lf5/LogLevelFormatException.java similarity index 70% rename from src/java/org/apache/log4j/lf5/LogLevelFormatException.java rename to src/main/java/org/apache/log4j/lf5/LogLevelFormatException.java index 384b829f51..1109e23836 100644 --- a/src/java/org/apache/log4j/lf5/LogLevelFormatException.java +++ b/src/main/java/org/apache/log4j/lf5/LogLevelFormatException.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5; diff --git a/src/java/org/apache/log4j/lf5/LogRecord.java b/src/main/java/org/apache/log4j/lf5/LogRecord.java similarity index 92% rename from src/java/org/apache/log4j/lf5/LogRecord.java rename to src/main/java/org/apache/log4j/lf5/LogRecord.java index 8d1cfa4a7a..4f4097f20a 100644 --- a/src/java/org/apache/log4j/lf5/LogRecord.java +++ b/src/main/java/org/apache/log4j/lf5/LogRecord.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5; @@ -350,7 +359,7 @@ public String getLocation() { /** * Set the location in code where this LogRecord originated. * - * @param ndc A string containing location information. + * @param location A string containing location information. */ public void setLocation(String location) { _location = location; diff --git a/src/java/org/apache/log4j/lf5/LogRecordFilter.java b/src/main/java/org/apache/log4j/lf5/LogRecordFilter.java similarity index 50% rename from src/java/org/apache/log4j/lf5/LogRecordFilter.java rename to src/main/java/org/apache/log4j/lf5/LogRecordFilter.java index 51fb78ee3e..25a3e53c2e 100644 --- a/src/java/org/apache/log4j/lf5/LogRecordFilter.java +++ b/src/main/java/org/apache/log4j/lf5/LogRecordFilter.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5; diff --git a/src/java/org/apache/log4j/lf5/PassingLogRecordFilter.java b/src/main/java/org/apache/log4j/lf5/PassingLogRecordFilter.java similarity index 70% rename from src/java/org/apache/log4j/lf5/PassingLogRecordFilter.java rename to src/main/java/org/apache/log4j/lf5/PassingLogRecordFilter.java index 6424a0e2f1..178f6cb67c 100644 --- a/src/java/org/apache/log4j/lf5/PassingLogRecordFilter.java +++ b/src/main/java/org/apache/log4j/lf5/PassingLogRecordFilter.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5; diff --git a/src/java/org/apache/log4j/lf5/StartLogFactor5.java b/src/main/java/org/apache/log4j/lf5/StartLogFactor5.java similarity index 73% rename from src/java/org/apache/log4j/lf5/StartLogFactor5.java rename to src/main/java/org/apache/log4j/lf5/StartLogFactor5.java index 45d09e873e..1ea28c3c72 100644 --- a/src/java/org/apache/log4j/lf5/StartLogFactor5.java +++ b/src/main/java/org/apache/log4j/lf5/StartLogFactor5.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5; diff --git a/src/java/org/apache/log4j/lf5/util/AdapterLogRecord.java b/src/main/java/org/apache/log4j/lf5/util/AdapterLogRecord.java similarity index 79% rename from src/java/org/apache/log4j/lf5/util/AdapterLogRecord.java rename to src/main/java/org/apache/log4j/lf5/util/AdapterLogRecord.java index 6a834a7b61..2e4ee6f02f 100644 --- a/src/java/org/apache/log4j/lf5/util/AdapterLogRecord.java +++ b/src/main/java/org/apache/log4j/lf5/util/AdapterLogRecord.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.util; diff --git a/src/java/org/apache/log4j/lf5/util/DateFormatManager.java b/src/main/java/org/apache/log4j/lf5/util/DateFormatManager.java similarity index 87% rename from src/java/org/apache/log4j/lf5/util/DateFormatManager.java rename to src/main/java/org/apache/log4j/lf5/util/DateFormatManager.java index 18c7beba10..6bed9cc862 100644 --- a/src/java/org/apache/log4j/lf5/util/DateFormatManager.java +++ b/src/main/java/org/apache/log4j/lf5/util/DateFormatManager.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.util; @@ -119,7 +128,7 @@ public synchronized TimeZone getTimeZone() { } public synchronized void setTimeZone(TimeZone timeZone) { - timeZone = timeZone; + _timeZone = timeZone; configure(); } diff --git a/src/java/org/apache/log4j/lf5/util/LogFileParser.java b/src/main/java/org/apache/log4j/lf5/util/LogFileParser.java similarity index 90% rename from src/java/org/apache/log4j/lf5/util/LogFileParser.java rename to src/main/java/org/apache/log4j/lf5/util/LogFileParser.java index 79bf721979..9fd1317d41 100644 --- a/src/java/org/apache/log4j/lf5/util/LogFileParser.java +++ b/src/main/java/org/apache/log4j/lf5/util/LogFileParser.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.util; diff --git a/src/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java b/src/main/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java similarity index 91% rename from src/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java rename to src/main/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java index 1e568e51b0..904c179dd3 100644 --- a/src/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java +++ b/src/main/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.util; diff --git a/src/java/org/apache/log4j/lf5/util/Resource.java b/src/main/java/org/apache/log4j/lf5/util/Resource.java similarity index 81% rename from src/java/org/apache/log4j/lf5/util/Resource.java rename to src/main/java/org/apache/log4j/lf5/util/Resource.java index 6ae81cfe67..66293cfcab 100644 --- a/src/java/org/apache/log4j/lf5/util/Resource.java +++ b/src/main/java/org/apache/log4j/lf5/util/Resource.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.util; diff --git a/src/java/org/apache/log4j/lf5/util/ResourceUtils.java b/src/main/java/org/apache/log4j/lf5/util/ResourceUtils.java similarity index 82% rename from src/java/org/apache/log4j/lf5/util/ResourceUtils.java rename to src/main/java/org/apache/log4j/lf5/util/ResourceUtils.java index 9c7ec62e1c..5f022b6729 100644 --- a/src/java/org/apache/log4j/lf5/util/ResourceUtils.java +++ b/src/main/java/org/apache/log4j/lf5/util/ResourceUtils.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.util; diff --git a/src/java/org/apache/log4j/lf5/util/StreamUtils.java b/src/main/java/org/apache/log4j/lf5/util/StreamUtils.java similarity index 80% rename from src/java/org/apache/log4j/lf5/util/StreamUtils.java rename to src/main/java/org/apache/log4j/lf5/util/StreamUtils.java index d9e0a3dbcf..0d673583ab 100644 --- a/src/java/org/apache/log4j/lf5/util/StreamUtils.java +++ b/src/main/java/org/apache/log4j/lf5/util/StreamUtils.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.util; diff --git a/src/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java b/src/main/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java similarity index 89% rename from src/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java rename to src/main/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java index f77a5bb4de..2c68180975 100644 --- a/src/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; diff --git a/src/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java b/src/main/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java similarity index 84% rename from src/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java rename to src/main/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java index 14c953a4d4..a00f2c30f5 100644 --- a/src/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; diff --git a/src/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java b/src/main/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java similarity index 97% rename from src/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java rename to src/main/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java index 5eacbedb35..550a7b93ed 100644 --- a/src/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/LogBrokerMonitor.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; @@ -12,7 +21,6 @@ import org.apache.log4j.lf5.LogRecordFilter; import org.apache.log4j.lf5.util.DateFormatManager; import org.apache.log4j.lf5.util.LogFileParser; -import org.apache.log4j.lf5.util.ProductProperties; import org.apache.log4j.lf5.util.StreamUtils; import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryExplorerTree; import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryPath; @@ -475,8 +483,6 @@ protected void initComponents() { // // Configure the Frame. // - ProductProperties props = ProductProperties.getInstance(); - _logMonitorFrame = new JFrame("LogFactor5"); _logMonitorFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); @@ -1070,8 +1076,6 @@ protected JMenu createHelpMenu() { JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('h'); helpMenu.add(createHelpProperties()); - helpMenu.addSeparator(); - helpMenu.add(createHelpAbout()); return helpMenu; } @@ -1096,25 +1100,6 @@ protected void showPropertiesDialog(String title) { ); } - protected JMenuItem createHelpAbout() { - JMenuItem aboutMI = new JMenuItem("About LogFactor5..."); - aboutMI.setMnemonic('a'); - //aboutMI.setAccelerator( KeyStroke.getKeyStroke("control A") ); - - aboutMI.addActionListener( - new ActionListener() { - protected LogFactor5AboutDialog dialog = - new LogFactor5AboutDialog(_logMonitorFrame); - - public void actionPerformed(ActionEvent e) { - dialog.show(); - } - } - - ); - return aboutMI; - } - protected JMenu createEditMenu() { JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic('e'); @@ -1216,7 +1201,10 @@ protected JToolBar createToolBar() { _fontSizeCombo = fontSizeCombo; ClassLoader cl = this.getClass().getClassLoader(); - URL newIconURL = cl.getResource("org/apache/log4j/viewer/" + + if(cl == null) { + cl = ClassLoader.getSystemClassLoader(); + } + URL newIconURL = cl.getResource("org/apache/log4j/lf5/viewer/" + "images/channelexplorer_new.gif"); ImageIcon newIcon = null; diff --git a/src/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java similarity index 84% rename from src/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java rename to src/main/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java index 0e5949e72c..bb203172d9 100644 --- a/src/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5Dialog.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; diff --git a/src/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java similarity index 75% rename from src/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java rename to src/main/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java index c0cb85b156..41ef07528a 100644 --- a/src/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5ErrorDialog.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; diff --git a/src/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java similarity index 83% rename from src/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java rename to src/main/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java index 8831d7e432..890e6dbfea 100644 --- a/src/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5InputDialog.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; diff --git a/src/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java similarity index 73% rename from src/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java rename to src/main/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java index 4ec70e2e61..a08bf329bd 100644 --- a/src/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/LogFactor5LoadingDialog.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; diff --git a/src/java/org/apache/log4j/lf5/viewer/LogTable.java b/src/main/java/org/apache/log4j/lf5/viewer/LogTable.java similarity index 89% rename from src/java/org/apache/log4j/lf5/viewer/LogTable.java rename to src/main/java/org/apache/log4j/lf5/viewer/LogTable.java index 7f108516c5..2198403738 100644 --- a/src/java/org/apache/log4j/lf5/viewer/LogTable.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/LogTable.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; @@ -32,6 +41,7 @@ // Contributed by ThoughtWorks Inc. public class LogTable extends JTable { + private static final long serialVersionUID = 4867085140195148458L; //-------------------------------------------------------------------------- // Constants: //-------------------------------------------------------------------------- diff --git a/src/java/org/apache/log4j/lf5/viewer/LogTableColumn.java b/src/main/java/org/apache/log4j/lf5/viewer/LogTableColumn.java similarity index 84% rename from src/java/org/apache/log4j/lf5/viewer/LogTableColumn.java rename to src/main/java/org/apache/log4j/lf5/viewer/LogTableColumn.java index 8a17b3df73..045212cd5b 100644 --- a/src/java/org/apache/log4j/lf5/viewer/LogTableColumn.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/LogTableColumn.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; @@ -22,6 +31,7 @@ // Contributed by ThoughtWorks Inc. public class LogTableColumn implements java.io.Serializable { + private static final long serialVersionUID = -4275827753626456547L; // log4j table columns. public final static LogTableColumn DATE = new LogTableColumn("Date"); diff --git a/src/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java b/src/main/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java similarity index 68% rename from src/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java rename to src/main/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java index 5ccd95433c..b161fe7bcb 100644 --- a/src/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/LogTableColumnFormatException.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; @@ -18,6 +27,7 @@ // Contributed by ThoughtWorks Inc. public class LogTableColumnFormatException extends Exception { + private static final long serialVersionUID = 6529165785030431653L; //-------------------------------------------------------------------------- // Constants: diff --git a/src/java/org/apache/log4j/lf5/viewer/LogTableModel.java b/src/main/java/org/apache/log4j/lf5/viewer/LogTableModel.java similarity index 68% rename from src/java/org/apache/log4j/lf5/viewer/LogTableModel.java rename to src/main/java/org/apache/log4j/lf5/viewer/LogTableModel.java index f48c0b4dbd..3b60000bfc 100644 --- a/src/java/org/apache/log4j/lf5/viewer/LogTableModel.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/LogTableModel.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; @@ -19,6 +28,7 @@ // Contributed by ThoughtWorks Inc. public class LogTableModel extends DefaultTableModel { + private static final long serialVersionUID = 3593300685868700894L; //-------------------------------------------------------------------------- // Constants: //-------------------------------------------------------------------------- diff --git a/src/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java b/src/main/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java similarity index 75% rename from src/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java rename to src/main/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java index 1947977a82..648b25d14c 100644 --- a/src/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/LogTableRowRenderer.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; @@ -25,6 +34,7 @@ // Contributed by ThoughtWorks Inc. public class LogTableRowRenderer extends DefaultTableCellRenderer { + private static final long serialVersionUID = -3951639953706443213L; //-------------------------------------------------------------------------- // Constants: //-------------------------------------------------------------------------- diff --git a/src/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java b/src/main/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java similarity index 77% rename from src/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java rename to src/main/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java index 8c14c79740..8d1408ffc9 100644 --- a/src/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/TrackingAdjustmentListener.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer; diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java similarity index 85% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java index 47c20a5ab4..f3fc522fea 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryAbstractCellEditor.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java similarity index 71% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java index 54dc31a127..1391fd574a 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryElement.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java similarity index 78% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java index 2b1b52e923..63f91aef2d 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerLogRecordFilter.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java similarity index 91% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java index 9d0c3fa364..67354690fe 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerModel.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; @@ -30,6 +39,8 @@ // Contributed by ThoughtWorks Inc. public class CategoryExplorerModel extends DefaultTreeModel { + private static final long serialVersionUID = -3413887384316015901L; + //-------------------------------------------------------------------------- // Constants: //-------------------------------------------------------------------------- diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java similarity index 81% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java index a607cca3da..b8416827eb 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryExplorerTree.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; @@ -24,6 +33,7 @@ // Contributed by ThoughtWorks Inc. public class CategoryExplorerTree extends JTree { + private static final long serialVersionUID = 8066257446951323576L; //-------------------------------------------------------------------------- // Constants: //-------------------------------------------------------------------------- diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java similarity index 82% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java index 25a63e77ab..f5bbfb3854 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryImmediateEditor.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java similarity index 84% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java index bc7b4a25d0..95bdc4280b 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; @@ -21,6 +30,7 @@ // Contributed by ThoughtWorks Inc. public class CategoryNode extends DefaultMutableTreeNode { + private static final long serialVersionUID = 5958994817693177319L; //-------------------------------------------------------------------------- // Constants: //-------------------------------------------------------------------------- diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java similarity index 89% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java index fbb6a9bfb6..a4a9bdc99e 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; @@ -241,9 +250,9 @@ protected void collapseDescendants(CategoryNode node) { protected int removeUnusedNodes() { int count = 0; CategoryNode root = _categoryModel.getRootCategoryNode(); - Enumeration enum = root.depthFirstEnumeration(); - while (enum.hasMoreElements()) { - CategoryNode node = (CategoryNode) enum.nextElement(); + Enumeration enumeration = root.depthFirstEnumeration(); + while (enumeration.hasMoreElements()) { + CategoryNode node = (CategoryNode) enumeration.nextElement(); if (node.isLeaf() && node.getNumberOfContainedRecords() == 0 && node.getParent() != null) { _categoryModel.removeNodeFromParent(node); diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java similarity index 71% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java index 0b901cd624..d439990850 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; @@ -20,6 +29,8 @@ // Contributed by ThoughtWorks Inc. public class CategoryNodeEditorRenderer extends CategoryNodeRenderer { + private static final long serialVersionUID = -6094804684259929574L; + //-------------------------------------------------------------------------- // Constants: //-------------------------------------------------------------------------- diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java similarity index 82% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java index 4de68fffd9..4eb461dd43 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; @@ -22,6 +31,8 @@ // Contributed by ThoughtWorks Inc. public class CategoryNodeRenderer extends DefaultTreeCellRenderer { + private static final long serialVersionUID = -6046702673278595048L; + //-------------------------------------------------------------------------- // Constants: //-------------------------------------------------------------------------- diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java similarity index 83% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java index f044c16f7c..3863c0b8b2 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; diff --git a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java similarity index 72% rename from src/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java rename to src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java index 4d548d4a28..7323dcc08e 100644 --- a/src/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.categoryexplorer; diff --git a/src/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java b/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java similarity index 94% rename from src/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java rename to src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java index 3e389d8d5a..2f9f95f005 100644 --- a/src/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.configure; @@ -57,7 +66,6 @@ public class ConfigurationManager extends Object { private static final String FIRST_CATEGORY_NAME = "Categories"; private static final String LEVEL = "level"; private static final String COLORLEVEL = "colorlevel"; - private static final String COLOR = "color"; private static final String RED = "red"; private static final String GREEN = "green"; private static final String BLUE = "blue"; @@ -216,7 +224,7 @@ protected void processLogLevels(Document doc) { protected void processLogLevelColors(Document doc) { NodeList nodeList = doc.getElementsByTagName(COLORLEVEL); - Map logLevelColors = LogLevel.getLogLevelColorMap(); + LogLevel.getLogLevelColorMap(); for (int i = 0; i < nodeList.getLength(); i++) { Node n = nodeList.item(i); @@ -330,8 +338,7 @@ protected void deleteConfigurationFile() { protected String getFilename() { String home = System.getProperty("user.home"); - String sep = (home.startsWith(MRUFileManager.UNIX_SEPARATOR)) - ? MRUFileManager.UNIX_SEPARATOR : MRUFileManager.DOS_SEPARATOR; + String sep = System.getProperty("file.separator"); return home + sep + "lf5" + sep + CONFIG_FILE_NAME; } diff --git a/src/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java b/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java similarity index 87% rename from src/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java rename to src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java index 5163a073cd..8c10ee28a1 100644 --- a/src/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java +++ b/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.lf5.viewer.configure; @@ -29,8 +38,6 @@ public class MRUFileManager { //-------------------------------------------------------------------------- private static final String CONFIG_FILE_NAME = "mru_file_manager"; private static final int DEFAULT_MAX_SIZE = 3; - public static final String UNIX_SEPARATOR = "/"; - public static final String DOS_SEPARATOR = "\\"; //-------------------------------------------------------------------------- // Protected Variables: @@ -74,7 +81,6 @@ public void save() { // do nothing e.printStackTrace(); } - } /** @@ -112,7 +118,6 @@ public InputStream getInputStream(int index) throws IOException, return null; } - /** * Adds a file name to the MRU file list. */ @@ -168,7 +173,7 @@ public void moveToTop(int index) { */ public static void createConfigurationDirectory() { String home = System.getProperty("user.home"); - String sep = (home.startsWith(UNIX_SEPARATOR)) ? UNIX_SEPARATOR : DOS_SEPARATOR; + String sep = System.getProperty("file.separator"); File f = new File(home + sep + "lf5"); if (!f.exists()) { try { @@ -253,7 +258,7 @@ protected void load() { protected String getFilename() { String home = System.getProperty("user.home"); - String sep = (home.startsWith(UNIX_SEPARATOR)) ? UNIX_SEPARATOR : DOS_SEPARATOR; + String sep = System.getProperty("file.separator"); return home + sep + "lf5" + sep + CONFIG_FILE_NAME; } @@ -264,7 +269,7 @@ protected String getFilename() { protected void setMaxSize(int maxSize) { if (maxSize < _mruFileList.size()) { for (int i = 0; i < _mruFileList.size() - maxSize; i++) { - _mruFileList.removeFirst(); + _mruFileList.removeLast(); } } diff --git a/src/main/java/org/apache/log4j/net/JMSAppender.java b/src/main/java/org/apache/log4j/net/JMSAppender.java new file mode 100644 index 0000000000..dd11a91b35 --- /dev/null +++ b/src/main/java/org/apache/log4j/net/JMSAppender.java @@ -0,0 +1,432 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.net; + +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.spi.ErrorCode; +import org.apache.log4j.helpers.LogLog; + +import java.util.Properties; +import javax.jms.TopicConnection; +import javax.jms.TopicConnectionFactory; +import javax.jms.Topic; +import javax.jms.TopicPublisher; +import javax.jms.TopicSession; +import javax.jms.Session; +import javax.jms.ObjectMessage; +import javax.naming.InitialContext; +import javax.naming.Context; +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; + +/** + * A simple appender that publishes events to a JMS Topic. The events + * are serialized and transmitted as JMS message type {@link + * ObjectMessage}. + + *

    JMS {@link Topic topics} and {@link TopicConnectionFactory topic + * connection factories} are administered objects that are retrieved + * using JNDI messaging which in turn requires the retreival of a JNDI + * {@link Context}. + + *

    There are two common methods for retrieving a JNDI {@link + * Context}. If a file resource named jndi.properties is + * available to the JNDI API, it will use the information found + * therein to retrieve an initial JNDI context. To obtain an initial + * context, your code will simply call: + +

    +   InitialContext jndiContext = new InitialContext();
    +   
    + + *

    Calling the no-argument InitialContext() method + * will also work from within Enterprise Java Beans (EJBs) because it + * is part of the EJB contract for application servers to provide each + * bean an environment naming context (ENC). + + *

    In the second approach, several predetermined properties are set + * and these properties are passed to the InitialContext + * contructor to connect to the naming service provider. For example, + * to connect to JBoss naming service one would write: + +

    +   Properties env = new Properties( );
    +   env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
    +   env.put(Context.PROVIDER_URL, "jnp://hostname:1099");
    +   env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
    +   InitialContext jndiContext = new InitialContext(env);
    +
    + + * where hostname is the host where the JBoss applicaiton + * server is running. + * + *

    To connect to the the naming service of Weblogic application + * server one would write: + +

    +   Properties env = new Properties( );
    +   env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    +   env.put(Context.PROVIDER_URL, "t3://localhost:7001");
    +   InitialContext jndiContext = new InitialContext(env);
    +
    + + *

    Other JMS providers will obviously require different values. + * + * The initial JNDI context can be obtained by calling the + * no-argument InitialContext() method in EJBs. Only + * clients running in a separate JVM need to be concerned about the + * jndi.properties file and calling {@link + * InitialContext#InitialContext()} or alternatively correctly + * setting the different properties before calling {@link + * InitialContext#InitialContext(java.util.Hashtable)} method. + + + @author Ceki Gülcü */ +public class JMSAppender extends AppenderSkeleton { + + String securityPrincipalName; + String securityCredentials; + String initialContextFactoryName; + String urlPkgPrefixes; + String providerURL; + String topicBindingName; + String tcfBindingName; + String userName; + String password; + boolean locationInfo; + + TopicConnection topicConnection; + TopicSession topicSession; + TopicPublisher topicPublisher; + + public + JMSAppender() { + } + + /** + The TopicConnectionFactoryBindingName option takes a + string value. Its value will be used to lookup the appropriate + TopicConnectionFactory from the JNDI context. + */ + public + void setTopicConnectionFactoryBindingName(String tcfBindingName) { + this.tcfBindingName = tcfBindingName; + } + + /** + Returns the value of the TopicConnectionFactoryBindingName option. + */ + public + String getTopicConnectionFactoryBindingName() { + return tcfBindingName; + } + + /** + The TopicBindingName option takes a + string value. Its value will be used to lookup the appropriate + Topic from the JNDI context. + */ + public + void setTopicBindingName(String topicBindingName) { + this.topicBindingName = topicBindingName; + } + + /** + Returns the value of the TopicBindingName option. + */ + public + String getTopicBindingName() { + return topicBindingName; + } + + + /** + Returns value of the LocationInfo property which + determines whether location (stack) info is sent to the remote + subscriber. */ + public + boolean getLocationInfo() { + return locationInfo; + } + + /** + * Options are activated and become effective only after calling + * this method.*/ + public void activateOptions() { + TopicConnectionFactory topicConnectionFactory; + + try { + Context jndi; + + LogLog.debug("Getting initial context."); + if(initialContextFactoryName != null) { + Properties env = new Properties( ); + env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactoryName); + if(providerURL != null) { + env.put(Context.PROVIDER_URL, providerURL); + } else { + LogLog.warn("You have set InitialContextFactoryName option but not the " + +"ProviderURL. This is likely to cause problems."); + } + if(urlPkgPrefixes != null) { + env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes); + } + + if(securityPrincipalName != null) { + env.put(Context.SECURITY_PRINCIPAL, securityPrincipalName); + if(securityCredentials != null) { + env.put(Context.SECURITY_CREDENTIALS, securityCredentials); + } else { + LogLog.warn("You have set SecurityPrincipalName option but not the " + +"SecurityCredentials. This is likely to cause problems."); + } + } + jndi = new InitialContext(env); + } else { + jndi = new InitialContext(); + } + + LogLog.debug("Looking up ["+tcfBindingName+"]"); + topicConnectionFactory = (TopicConnectionFactory) lookup(jndi, tcfBindingName); + LogLog.debug("About to create TopicConnection."); + if(userName != null) { + topicConnection = topicConnectionFactory.createTopicConnection(userName, + password); + } else { + topicConnection = topicConnectionFactory.createTopicConnection(); + } + + LogLog.debug("Creating TopicSession, non-transactional, " + +"in AUTO_ACKNOWLEDGE mode."); + topicSession = topicConnection.createTopicSession(false, + Session.AUTO_ACKNOWLEDGE); + + LogLog.debug("Looking up topic name ["+topicBindingName+"]."); + Topic topic = (Topic) lookup(jndi, topicBindingName); + + LogLog.debug("Creating TopicPublisher."); + topicPublisher = topicSession.createPublisher(topic); + + LogLog.debug("Starting TopicConnection."); + topicConnection.start(); + + jndi.close(); + } catch(Exception e) { + errorHandler.error("Error while activating options for appender named ["+name+ + "].", e, ErrorCode.GENERIC_FAILURE); + } + } + + protected Object lookup(Context ctx, String name) throws NamingException { + try { + return ctx.lookup(name); + } catch(NameNotFoundException e) { + LogLog.error("Could not find name ["+name+"]."); + throw e; + } + } + + protected boolean checkEntryConditions() { + String fail = null; + + if(this.topicConnection == null) { + fail = "No TopicConnection"; + } else if(this.topicSession == null) { + fail = "No TopicSession"; + } else if(this.topicPublisher == null) { + fail = "No TopicPublisher"; + } + + if(fail != null) { + errorHandler.error(fail +" for JMSAppender named ["+name+"]."); + return false; + } else { + return true; + } + } + + /** + Close this JMSAppender. Closing releases all resources used by the + appender. A closed appender cannot be re-opened. */ + public synchronized void close() { + // The synchronized modifier avoids concurrent append and close operations + + if(this.closed) + return; + + LogLog.debug("Closing appender ["+name+"]."); + this.closed = true; + + try { + if(topicSession != null) + topicSession.close(); + if(topicConnection != null) + topicConnection.close(); + } catch(Exception e) { + LogLog.error("Error while closing JMSAppender ["+name+"].", e); + } + // Help garbage collection + topicPublisher = null; + topicSession = null; + topicConnection = null; + } + + /** + This method called by {@link AppenderSkeleton#doAppend} method to + do most of the real appending work. */ + public void append(LoggingEvent event) { + if(!checkEntryConditions()) { + return; + } + + try { + ObjectMessage msg = topicSession.createObjectMessage(); + if(locationInfo) { + event.getLocationInformation(); + } + msg.setObject(event); + topicPublisher.publish(msg); + } catch(Exception e) { + errorHandler.error("Could not publish message in JMSAppender ["+name+"].", e, + ErrorCode.GENERIC_FAILURE); + } + } + + /** + * Returns the value of the InitialContextFactoryName option. + * See {@link #setInitialContextFactoryName} for more details on the + * meaning of this option. + * */ + public String getInitialContextFactoryName() { + return initialContextFactoryName; + } + + /** + * Setting the InitialContextFactoryName method will cause + * this JMSAppender instance to use the {@link + * InitialContext#InitialContext(Hashtable)} method instead of the + * no-argument constructor. If you set this option, you should also + * at least set the ProviderURL option. + * + *

    See also {@link #setProviderURL(String)}. + * */ + public void setInitialContextFactoryName(String initialContextFactoryName) { + this.initialContextFactoryName = initialContextFactoryName; + } + + public String getProviderURL() { + return providerURL; + } + + public void setProviderURL(String providerURL) { + this.providerURL = providerURL; + } + + String getURLPkgPrefixes( ) { + return urlPkgPrefixes; + } + + public void setURLPkgPrefixes(String urlPkgPrefixes ) { + this.urlPkgPrefixes = urlPkgPrefixes; + } + + public String getSecurityCredentials() { + return securityCredentials; + } + + public void setSecurityCredentials(String securityCredentials) { + this.securityCredentials = securityCredentials; + } + + + public String getSecurityPrincipalName() { + return securityPrincipalName; + } + + public void setSecurityPrincipalName(String securityPrincipalName) { + this.securityPrincipalName = securityPrincipalName; + } + + public String getUserName() { + return userName; + } + + /** + * The user name to use when {@link + * TopicConnectionFactory#createTopicConnection(String, String) + * creating a topic session}. If you set this option, you should + * also set the Password option. See {@link + * #setPassword(String)}. + * */ + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + /** + * The paswword to use when creating a topic session. + */ + public void setPassword(String password) { + this.password = password; + } + + + /** + If true, the information sent to the remote subscriber will + include caller's location information. By default no location + information is sent to the subscriber. */ + public void setLocationInfo(boolean locationInfo) { + this.locationInfo = locationInfo; + } + + /** + * Returns the TopicConnection used for this appender. Only valid after + * activateOptions() method has been invoked. + */ + protected TopicConnection getTopicConnection() { + return topicConnection; + } + + /** + * Returns the TopicSession used for this appender. Only valid after + * activateOptions() method has been invoked. + */ + protected TopicSession getTopicSession() { + return topicSession; + } + + /** + * Returns the TopicPublisher used for this appender. Only valid after + * activateOptions() method has been invoked. + */ + protected TopicPublisher getTopicPublisher() { + return topicPublisher; + } + + /** + * The JMSAppender sends serialized events and consequently does not + * require a layout. + */ + public boolean requiresLayout() { + return false; + } +} diff --git a/src/main/java/org/apache/log4j/net/JMSSink.java b/src/main/java/org/apache/log4j/net/JMSSink.java new file mode 100644 index 0000000000..78d657efbd --- /dev/null +++ b/src/main/java/org/apache/log4j/net/JMSSink.java @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.net; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.xml.DOMConfigurator; + +import javax.jms.JMSException; +import javax.jms.ObjectMessage; +import javax.jms.Session; +import javax.jms.Topic; +import javax.jms.TopicConnection; +import javax.jms.TopicConnectionFactory; +import javax.jms.TopicSession; +import javax.jms.TopicSubscriber; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; +import java.io.BufferedReader; +import java.io.InputStreamReader; + +/** + * A simple application that consumes logging events sent by a {@link + * JMSAppender}. + * + * + * @author Ceki Gülcü + * */ +public class JMSSink implements javax.jms.MessageListener { + + static Logger logger = Logger.getLogger(JMSSink.class); + + static public void main(String[] args) throws Exception { + if(args.length != 5) { + usage("Wrong number of arguments."); + } + + String tcfBindingName = args[0]; + String topicBindingName = args[1]; + String username = args[2]; + String password = args[3]; + + + String configFile = args[4]; + + if(configFile.endsWith(".xml")) { + DOMConfigurator.configure(configFile); + } else { + PropertyConfigurator.configure(configFile); + } + + new JMSSink(tcfBindingName, topicBindingName, username, password); + + BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); + // Loop until the word "exit" is typed + System.out.println("Type \"exit\" to quit JMSSink."); + while(true){ + String s = stdin.readLine( ); + if (s.equalsIgnoreCase("exit")) { + System.out.println("Exiting. Kill the application if it does not exit " + + "due to daemon threads."); + return; + } + } + } + + public JMSSink( String tcfBindingName, String topicBindingName, String username, + String password) { + + try { + Context ctx = new InitialContext(); + TopicConnectionFactory topicConnectionFactory; + topicConnectionFactory = (TopicConnectionFactory) lookup(ctx, + tcfBindingName); + + TopicConnection topicConnection = + topicConnectionFactory.createTopicConnection(username, + password); + topicConnection.start(); + + TopicSession topicSession = topicConnection.createTopicSession(false, + Session.AUTO_ACKNOWLEDGE); + + Topic topic = (Topic)ctx.lookup(topicBindingName); + + TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic); + + topicSubscriber.setMessageListener(this); + + } catch(Exception e) { + logger.error("Could not read JMS message.", e); + } + } + + public void onMessage(javax.jms.Message message) { + LoggingEvent event; + Logger remoteLogger; + + try { + if(message instanceof ObjectMessage) { + ObjectMessage objectMessage = (ObjectMessage) message; + event = (LoggingEvent) objectMessage.getObject(); + remoteLogger = Logger.getLogger(event.getLoggerName()); + remoteLogger.callAppenders(event); + } else { + logger.warn("Received message is of type "+message.getJMSType() + +", was expecting ObjectMessage."); + } + } catch(JMSException jmse) { + logger.error("Exception thrown while processing incoming message.", + jmse); + } + } + + + protected static Object lookup(Context ctx, String name) throws NamingException { + try { + return ctx.lookup(name); + } catch(NameNotFoundException e) { + logger.error("Could not find name ["+name+"]."); + throw e; + } + } + + static void usage(String msg) { + System.err.println(msg); + System.err.println("Usage: java " + JMSSink.class.getName() + + " TopicConnectionFactoryBindingName TopicBindingName username password configFile"); + System.exit(1); + } +} diff --git a/src/java/org/apache/log4j/net/SMTPAppender.java b/src/main/java/org/apache/log4j/net/SMTPAppender.java similarity index 64% rename from src/java/org/apache/log4j/net/SMTPAppender.java rename to src/main/java/org/apache/log4j/net/SMTPAppender.java index bca7acaa80..237facd69f 100644 --- a/src/java/org/apache/log4j/net/SMTPAppender.java +++ b/src/main/java/org/apache/log4j/net/SMTPAppender.java @@ -1,14 +1,25 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.net; import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.Level; +import org.apache.log4j.Layout; import org.apache.log4j.helpers.CyclicBuffer; import org.apache.log4j.helpers.OptionConverter; import org.apache.log4j.helpers.LogLog; @@ -19,6 +30,8 @@ import java.util.Date; import javax.mail.Session; +import javax.mail.Authenticator; +import javax.mail.PasswordAuthentication; import javax.mail.Transport; import javax.mail.Message; import javax.mail.MessagingException; @@ -44,9 +57,20 @@ @since 1.0 */ public class SMTPAppender extends AppenderSkeleton { private String to; + /** + * Comma separated list of cc recipients. + */ + private String cc; + /** + * Comma separated list of bcc recipients. + */ + private String bcc; private String from; private String subject; private String smtpHost; + private String smtpUsername; + private String smtpPassword; + private boolean smtpDebug = false; private int bufferSize = 512; private boolean locationInfo = false; @@ -81,28 +105,76 @@ public class SMTPAppender extends AppenderSkeleton { recipient, from, etc. */ public void activateOptions() { - Properties props = new Properties (System.getProperties()); - if (smtpHost != null) - props.put("mail.smtp.host", smtpHost); - - - Session session = Session.getInstance(props, null); - //session.setDebug(true); + Session session = createSession(); msg = new MimeMessage(session); try { - if (from != null) - msg.setFrom(getAddress(from)); - else - msg.setFrom(); - - msg.setRecipients(Message.RecipientType.TO, parseAddress(to)); - if(subject != null) - msg.setSubject(subject); + addressMessage(msg); + if(subject != null) { + msg.setSubject(subject); + } } catch(MessagingException e) { LogLog.error("Could not activate SMTPAppender options.", e ); } } + + /** + * Address message. + * @param msg message, may not be null. + * @throws MessagingException thrown if error addressing message. + */ + protected void addressMessage(final Message msg) throws MessagingException { + if (from != null) { + msg.setFrom(getAddress(from)); + } else { + msg.setFrom(); + } + + if (to != null && to.length() > 0) { + msg.setRecipients(Message.RecipientType.TO, parseAddress(to)); + } + + //Add CC receipients if defined. + if (cc != null && cc.length() > 0) { + msg.setRecipients(Message.RecipientType.CC, parseAddress(cc)); + } + + //Add BCC receipients if defined. + if (bcc != null && bcc.length() > 0) { + msg.setRecipients(Message.RecipientType.BCC, parseAddress(bcc)); + } + } + + /** + * Create mail session. + * @return mail session, may not be null. + */ + protected Session createSession() { + Properties props = null; + try { + props = new Properties (System.getProperties()); + } catch(SecurityException ex) { + props = new Properties(); + } + if (smtpHost != null) { + props.put("mail.smtp.host", smtpHost); + } + + Authenticator auth = null; + if(smtpPassword != null && smtpUsername != null) { + props.put("mail.smtp.auth", "true"); + auth = new Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(smtpUsername, smtpPassword); + } + }; + } + Session session = Session.getInstance(props, auth); + if (smtpDebug) { + session.setDebug(smtpDebug); + } + return session; + } /** Perform SMTPAppender specific appending actions, mainly adding @@ -117,6 +189,7 @@ void append(LoggingEvent event) { event.getThreadName(); event.getNDC(); + event.getMDCCopy(); if(locationInfo) { event.getLocationInformation(); } @@ -222,6 +295,7 @@ void sendBuffer() { if (s != null) { for(int j = 0; j < s.length; j++) { sbuf.append(s[j]); + sbuf.append(Layout.LINE_SEP); } } } @@ -375,6 +449,90 @@ void setLocationInfo(boolean locationInfo) { boolean getLocationInfo() { return locationInfo; } + + /** + Set the cc recipient addresses. + @param addresses recipient addresses as comma separated string, may be null. + */ + public void setCc(final String addresses) { + this.cc = addresses; + } + + /** + Get the cc recipient addresses. + @return recipient addresses as comma separated string, may be null. + */ + public String getCc() { + return cc; + } + + /** + Set the bcc recipient addresses. + @param addresses recipient addresses as comma separated string, may be null. + */ + public void setBcc(final String addresses) { + this.bcc = addresses; + } + + /** + Get the bcc recipient addresses. + @return recipient addresses as comma separated string, may be null. + */ + public String getBcc() { + return bcc; + } + + /** + * The SmtpPassword option takes a string value which should be the password required to authenticate against + * the mail server. + * @param password password, may be null. + */ + public void setSMTPPassword(final String password) { + this.smtpPassword = password; + } + + /** + * The SmtpUsername option takes a string value which should be the username required to authenticate against + * the mail server. + * @param username user name, may be null. + */ + public void setSMTPUsername(final String username) { + this.smtpUsername = username; + } + + /** + * Setting the SmtpDebug option to true will cause the mail session to log its server interaction to stdout. + * This can be useful when debuging the appender but should not be used during production because username and + * password information is included in the output. + * @param debug debug flag. + */ + public void setSMTPDebug(final boolean debug) { + this.smtpDebug = debug; + } + + /** + * Get SMTP password. + * @return SMTP password, may be null. + */ + public String getSMTPPassword() { + return smtpPassword; + } + + /** + * Get SMTP user name. + * @return SMTP user name, may be null. + */ + public String getSMTPUsername() { + return smtpUsername; + } + + /** + * Get SMTP debug. + * @return SMTP debug flag. + */ + public boolean getSMTPDebug() { + return smtpDebug; + } } class DefaultEvaluator implements TriggeringEventEvaluator { @@ -386,6 +544,6 @@ class DefaultEvaluator implements TriggeringEventEvaluator { false. */ public boolean isTriggeringEvent(LoggingEvent event) { - return event.level.isGreaterOrEqual(Level.ERROR); + return event.getLevel().isGreaterOrEqual(Level.ERROR); } } diff --git a/src/main/java/org/apache/log4j/net/SimpleSocketServer.java b/src/main/java/org/apache/log4j/net/SimpleSocketServer.java new file mode 100644 index 0000000000..d591bd01d1 --- /dev/null +++ b/src/main/java/org/apache/log4j/net/SimpleSocketServer.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.net; + +import java.net.Socket; +import java.net.ServerSocket; + +import org.apache.log4j.Logger; +import org.apache.log4j.LogManager; +import org.apache.log4j.PropertyConfigurator; +import org.apache.log4j.xml.DOMConfigurator; + + +/** + * A simple {@link SocketNode} based server. + * +

    +   Usage: java org.apache.log4j.net.SimpleSocketServer port configFile
    +
    +   where port is a part number where the server listens and
    +   configFile is a configuration file fed to the {@link
    +   PropertyConfigurator} or to {@link DOMConfigurator} if an XML file.
    +   
    + * + * @author Ceki Gülcü + * + * @since 0.8.4 + * */ +public class SimpleSocketServer { + + static Logger cat = Logger.getLogger(SimpleSocketServer.class); + + 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 SocketNode(socket, + LogManager.getLoggerRepository())).start(); + } + } catch(Exception e) { + e.printStackTrace(); + } + } + + + static void usage(String msg) { + System.err.println(msg); + System.err.println( + "Usage: java " +SimpleSocketServer.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 +"]."); + } + + if(configFile.endsWith(".xml")) { + DOMConfigurator.configure(configFile); + } else { + PropertyConfigurator.configure(configFile); + } + } +} diff --git a/src/java/org/apache/log4j/net/SocketAppender.java b/src/main/java/org/apache/log4j/net/SocketAppender.java similarity index 76% rename from src/java/org/apache/log4j/net/SocketAppender.java rename to src/main/java/org/apache/log4j/net/SocketAppender.java index 6b91beaa25..0a9bdb2894 100644 --- a/src/java/org/apache/log4j/net/SocketAppender.java +++ b/src/main/java/org/apache/log4j/net/SocketAppender.java @@ -1,24 +1,33 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // Contributors: Dan MacDonald package org.apache.log4j.net; -import java.net.InetAddress; -import java.net.Socket; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.io.ObjectOutputStream; - +import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.helpers.LogLog; +import org.apache.log4j.spi.ErrorCode; import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.AppenderSkeleton; + +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.net.InetAddress; +import java.net.Socket; /** Sends {@link LoggingEvent} objects to a remote a log server, @@ -93,8 +102,9 @@ public class SocketAppender extends AppenderSkeleton { /** The default port number of remote logging server (4560). + @since 1.2.15 */ - static final int DEFAULT_PORT = 4560; + static public final int DEFAULT_PORT = 4560; /** The default reconnection delay (30000 milliseconds or 30 seconds). @@ -128,8 +138,7 @@ public SocketAppender() { /** Connects to remote server at address and port. */ - public - SocketAppender(InetAddress address, int port) { + public SocketAppender(InetAddress address, int port) { this.address = address; this.remoteHost = address.getHostName(); this.port = port; @@ -139,8 +148,7 @@ public SocketAppender() { /** Connects to remote server at host and port. */ - public - SocketAppender(String host, int port) { + public SocketAppender(String host, int port) { this.port = port; this.address = getAddressByName(host); this.remoteHost = host; @@ -150,19 +158,17 @@ public SocketAppender() { /** Connect to the specified RemoteHost and Port. */ - public - void activateOptions() { + public void activateOptions() { connect(address, port); } /** - Close this appender. -

    This will mark the appender as closed and - call then {@link #cleanUp} method. - */ - synchronized - public - void close() { + * Close this appender. + * + *

    This will mark the appender as closed and call then {@link + * #cleanUp} method. + * */ + synchronized public void close() { if(closed) return; @@ -171,16 +177,14 @@ void close() { } /** - Drop the connection to the remote host and release the underlying - connector thread if it has been created - */ - public - void cleanUp() { + * Drop the connection to the remote host and release the underlying + * connector thread if it has been created + * */ + public void cleanUp() { if(oos != null) { try { oos.close(); - } - catch(IOException e) { + } catch(IOException e) { LogLog.error("Could not close oos.", e); } oos = null; @@ -199,17 +203,23 @@ void connect(InetAddress address, int port) { // First, close the previous connection if any. cleanUp(); oos = new ObjectOutputStream(new Socket(address, port).getOutputStream()); - } - catch(IOException e) { - LogLog.error("Could not connect to remote log4j server at [" - +address.getHostName()+"]. We will try again later.", e); - fireConnector(); + } catch(IOException e) { + + String msg = "Could not connect to remote log4j server at [" + +address.getHostName()+"]."; + if(reconnectionDelay > 0) { + msg += " We will try again later."; + fireConnector(); // fire the connector thread + } else { + msg += " We are not retrying."; + errorHandler.error(msg, e, ErrorCode.GENERIC_FAILURE); + } + LogLog.error(msg); } } - public - void append(LoggingEvent event) { + public void append(LoggingEvent event) { if(event == null) return; @@ -234,12 +244,14 @@ void append(LoggingEvent event) { //System.err.println("Doing oos.reset()"); oos.reset(); } - } - catch(IOException e) { + } catch(IOException e) { oos = null; LogLog.warn("Detected problem with connection: "+e); if(reconnectionDelay > 0) { fireConnector(); + } else { + errorHandler.error("Detected problem with connection, not reconnecting.", e, + ErrorCode.GENERIC_FAILURE); } } } @@ -259,28 +271,26 @@ void fireConnector() { InetAddress getAddressByName(String host) { try { return InetAddress.getByName(host); - } - catch(Exception e) { + } catch(Exception e) { LogLog.error("Could not find address of ["+host+"].", e); return null; } } /** - The SocketAppender does not use a layout. Hence, this method returns - false. - */ - public - boolean requiresLayout() { + * The SocketAppender does not use a layout. Hence, this method + * returns false. + * */ + public boolean requiresLayout() { return false; } /** - The RemoteHost option takes a string value which should be - the host name of the server where a {@link SocketNode} is running. - */ - public - void setRemoteHost(String host) { + * The RemoteHost option takes a string value which should be + * the host name of the server where a {@link SocketNode} is + * running. + * */ + public void setRemoteHost(String host) { address = getAddressByName(host); remoteHost = host; } @@ -288,8 +298,7 @@ void setRemoteHost(String host) { /** Returns value of the RemoteHost option. */ - public - String getRemoteHost() { + public String getRemoteHost() { return remoteHost; } @@ -297,16 +306,14 @@ String getRemoteHost() { The Port option takes a positive integer representing the port where the server is waiting for connections. */ - public - void setPort(int port) { + public void setPort(int port) { this.port = port; } /** Returns value of the Port option. */ - public - int getPort() { + public int getPort() { return port; } @@ -315,16 +322,14 @@ int getPort() { the information sent to the remote host will include location information. By default no location information is sent to the server. */ - public - void setLocationInfo(boolean locationInfo) { + public void setLocationInfo(boolean locationInfo) { this.locationInfo = locationInfo; } /** Returns value of the LocationInfo option. */ - public - boolean getLocationInfo() { + public boolean getLocationInfo() { return locationInfo; } @@ -337,16 +342,14 @@ boolean getLocationInfo() {

    Setting this option to zero turns off reconnection capability. */ - public - void setReconnectionDelay(int delay) { + public void setReconnectionDelay(int delay) { this.reconnectionDelay = delay; } /** Returns value of the ReconnectionDelay option. */ - public - int getReconnectionDelay() { + public int getReconnectionDelay() { return reconnectionDelay; } @@ -377,18 +380,16 @@ void run() { synchronized(this) { oos = new ObjectOutputStream(socket.getOutputStream()); connector = null; + LogLog.debug("Connection established. Exiting connector thread."); break; } - } - catch(InterruptedException e) { + } catch(InterruptedException e) { LogLog.debug("Connector interrupted. Leaving loop."); return; - } - catch(java.net.ConnectException e) { + } catch(java.net.ConnectException e) { LogLog.debug("Remote host "+address.getHostName() +" refused connection."); - } - catch(IOException e) { + } catch(IOException e) { LogLog.debug("Could not connect to " + address.getHostName()+ ". Exception is " + e); } diff --git a/src/java/org/apache/log4j/net/SocketHubAppender.java b/src/main/java/org/apache/log4j/net/SocketHubAppender.java similarity index 93% rename from src/java/org/apache/log4j/net/SocketHubAppender.java rename to src/main/java/org/apache/log4j/net/SocketHubAppender.java index bce55792c8..836e3ffb59 100644 --- a/src/java/org/apache/log4j/net/SocketHubAppender.java +++ b/src/main/java/org/apache/log4j/net/SocketHubAppender.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.net; diff --git a/src/main/java/org/apache/log4j/net/SocketNode.java b/src/main/java/org/apache/log4j/net/SocketNode.java new file mode 100644 index 0000000000..59edb38a1b --- /dev/null +++ b/src/main/java/org/apache/log4j/net/SocketNode.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.net; + +import java.net.Socket; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.BufferedInputStream; + + +import org.apache.log4j.*; +import org.apache.log4j.spi.*; + +// Contributors: Moses Hohman + +/** + 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. + +

    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 SocketNode implements Runnable { + + Socket socket; + LoggerRepository hierarchy; + ObjectInputStream ois; + + static Logger logger = Logger.getLogger(SocketNode.class); + + public SocketNode(Socket socket, LoggerRepository hierarchy) { + this.socket = socket; + this.hierarchy = hierarchy; + try { + ois = new ObjectInputStream( + new BufferedInputStream(socket.getInputStream())); + } + catch(Exception e) { + logger.error("Could not open ObjectInputStream to "+socket, e); + } + } + + //public + //void finalize() { + //System.err.println("-------------------------Finalize called"); + // System.err.flush(); + //} + + public void run() { + LoggingEvent event; + Logger remoteLogger; + + try { + if (ois != null) { + while(true) { + // read an event from the wire + event = (LoggingEvent) ois.readObject(); + // get a logger from the hierarchy. The name of the logger is taken to be the name contained in the event. + remoteLogger = hierarchy.getLogger(event.getLoggerName()); + //event.logger = remoteLogger; + // apply the logger-level filter + if(event.getLevel().isGreaterOrEqual(remoteLogger.getEffectiveLevel())) { + // finally log the event as if was generated locally + remoteLogger.callAppenders(event); + } + } + } + } catch(java.io.EOFException e) { + logger.info("Caught java.io.EOFException closing conneciton."); + } catch(java.net.SocketException e) { + logger.info("Caught java.net.SocketException closing conneciton."); + } catch(IOException e) { + logger.info("Caught java.io.IOException: "+e); + logger.info("Closing connection."); + } catch(Exception e) { + logger.error("Unexpected exception. Closing conneciton.", e); + } finally { + if (ois != null) { + try { + ois.close(); + } catch(Exception e) { + logger.info("Could not close connection.", e); + } + } + if (socket != null) { + try { + socket.close(); + } catch(IOException ex) { + } + } + } + } +} diff --git a/src/java/org/apache/log4j/net/SocketServer.java b/src/main/java/org/apache/log4j/net/SocketServer.java similarity index 85% rename from src/java/org/apache/log4j/net/SocketServer.java rename to src/main/java/org/apache/log4j/net/SocketServer.java index 41272588df..b30c9db0db 100644 --- a/src/java/org/apache/log4j/net/SocketServer.java +++ b/src/main/java/org/apache/log4j/net/SocketServer.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.net; @@ -75,7 +85,7 @@ public class SocketServer { static String GENERIC = "generic"; static String CONFIG_FILE_EXT = ".lcf"; - static Category cat = Category.getInstance(SocketServer.class); + static Logger cat = Logger.getLogger(SocketServer.class); static SocketServer server; static int port; @@ -167,7 +177,7 @@ LoggerRepository configureHierarchy(InetAddress inetAddress) { File configFile = new File(dir, key+CONFIG_FILE_EXT); if(configFile.exists()) { - Hierarchy h = new Hierarchy(new RootCategory((Level) Priority.DEBUG)); + Hierarchy h = new Hierarchy(new RootLogger(Level.DEBUG)); hierarchyMap.put(inetAddress, h); new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h); @@ -184,7 +194,7 @@ LoggerRepository genericHierarchy() { if(genericHierarchy == null) { File f = new File(dir, GENERIC+CONFIG_FILE_EXT); if(f.exists()) { - genericHierarchy = new Hierarchy(new RootCategory((Level) Priority.DEBUG)); + genericHierarchy = new Hierarchy(new RootLogger(Level.DEBUG)); new PropertyConfigurator().doConfigure(f.getAbsolutePath(), genericHierarchy); } else { cat.warn("Could not find config file ["+f+ diff --git a/src/java/org/apache/log4j/net/SyslogAppender.java b/src/main/java/org/apache/log4j/net/SyslogAppender.java similarity index 58% rename from src/java/org/apache/log4j/net/SyslogAppender.java rename to src/main/java/org/apache/log4j/net/SyslogAppender.java index d3c2d83396..fb9ae75939 100644 --- a/src/java/org/apache/log4j/net/SyslogAppender.java +++ b/src/main/java/org/apache/log4j/net/SyslogAppender.java @@ -1,17 +1,33 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.net; import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.spi.LoggingEvent; import org.apache.log4j.Layout; -import org.apache.log4j.helpers.SyslogWriter; import org.apache.log4j.helpers.SyslogQuietWriter; +import org.apache.log4j.helpers.SyslogWriter; +import org.apache.log4j.spi.LoggingEvent; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.net.InetAddress; +import java.net.UnknownHostException; // Contributors: Yves Bossel // Christopher Taylor @@ -85,6 +101,28 @@ public class SyslogAppender extends AppenderSkeleton { SyslogQuietWriter sqw; String syslogHost; + /** + * If true, the appender will generate the HEADER (timestamp and host name) + * part of the syslog packet. + * @since 1.2.15 + */ + private boolean header = false; + /** + * Date format used if header = true. + * @since 1.2.15 + */ + private final SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd HH:mm:ss ", Locale.ENGLISH); + /** + * Host name used to identify messages from this appender. + * @since 1.2.15 + */ + private String localHostname; + + /** + * Set to true after the header of the layout has been sent or if it has none. + */ + private boolean layoutHeaderChecked = false; + public SyslogAppender() { this.initSyslogFacilityStr(); @@ -112,9 +150,17 @@ public class SyslogAppender extends AppenderSkeleton { public void close() { closed = true; - // A SyslogWriter is UDP based and needs no opening. Hence, it - // can't be closed. We just unset the variables here. - sqw = null; + if (sqw != null) { + try { + if (layoutHeaderChecked && layout != null && layout.getFooter() != null) { + sendLayoutMessage(layout.getFooter()); + } + sqw.close(); + sqw = null; + } catch(java.io.IOException ex) { + sqw = null; + } + } } private @@ -225,10 +271,27 @@ int getFacility(String facilityName) { } } + + private void splitPacket(final String header, final String packet) { + int byteCount = packet.getBytes().length; + // + // if packet is less than RFC 3164 limit + // of 1024 bytes, then write it + // (must allow for up 5to 5 characters in the PRI section + // added by SyslogQuietWriter) + if (byteCount <= 1019) { + sqw.write(packet); + } else { + int split = header.length() + (packet.length() - header.length())/2; + splitPacket(header, packet.substring(0, split) + "..."); + splitPacket(header, header + "..." + packet.substring(split)); + } + } + public void append(LoggingEvent event) { - if(!isAsSevereAsThreshold(event.level)) + if(!isAsSevereAsThreshold(event.getLevel())) return; // We must not attempt to append if sqw is null. @@ -238,23 +301,45 @@ void append(LoggingEvent event) { return; } - String buffer = (facilityPrinting? facilityStr : "") + - layout.format(event); + if (!layoutHeaderChecked) { + if (layout != null && layout.getHeader() != null) { + sendLayoutMessage(layout.getHeader()); + } + layoutHeaderChecked = true; + } - sqw.setLevel(event.level.getSyslogEquivalent()); - sqw.write(buffer); + String hdr = getPacketHeader(event.timeStamp); + String packet = layout.format(event); + if(facilityPrinting || hdr.length() > 0) { + StringBuffer buf = new StringBuffer(hdr); + if(facilityPrinting) { + buf.append(facilityStr); + } + buf.append(packet); + packet = buf.toString(); + } - String[] s = event.getThrowableStrRep(); - if (s != null) { - int len = s.length; - if(len > 0) { - sqw.write(s[0]); + sqw.setLevel(event.getLevel().getSyslogEquivalent()); + // + // if message has a remote likelihood of exceeding 1024 bytes + // when encoded, consider splitting message into multiple packets + if (packet.length() > 256) { + splitPacket(hdr, packet); + } else { + sqw.write(packet); + } - for(int i = 1; i < len; i++) { - sqw.write(TAB+s[i].substring(1)); - } + if (layout.ignoresThrowable()) { + String[] s = event.getThrowableStrRep(); + if (s != null) { + for(int i = 0; i < s.length; i++) { + if (s[i].startsWith("\t")) { + sqw.write(hdr+TAB+s[i].substring(1)); + } else { + sqw.write(hdr+s[i]); + } + } } - } } @@ -264,6 +349,13 @@ void append(LoggingEvent event) { */ public void activateOptions() { + if (header) { + getLocalHostname(); + } + if (layout != null && layout.getHeader() != null) { + sendLayoutMessage(layout.getHeader()); + } + layoutHeaderChecked = true; } /** @@ -278,13 +370,15 @@ boolean requiresLayout() { /** The SyslogHost option is the name of the the syslog host - where log output should go. + where log output should go. A non-default port can be specified by + appending a colon and port number to a host name, + an IPv4 address or an IPv6 address enclosed in square brackets. WARNING If the SyslogHost is not set, then this appender will fail. */ public - void setSyslogHost(String syslogHost) { + void setSyslogHost(final String syslogHost) { this.sqw = new SyslogQuietWriter(new SyslogWriter(syslogHost), syslogFacility, errorHandler); //this.stp = new SyslogTracerPrintWriter(sqw); @@ -353,4 +447,81 @@ void setFacilityPrinting(boolean on) { boolean getFacilityPrinting() { return facilityPrinting; } + + /** + * If true, the appender will generate the HEADER part (that is, timestamp and host name) + * of the syslog packet. Default value is false for compatibility with existing behavior, + * however should be true unless there is a specific justification. + * @since 1.2.15 + */ + public final boolean getHeader() { + return header; + } + + /** + * Returns whether the appender produces the HEADER part (that is, timestamp and host name) + * of the syslog packet. + * @since 1.2.15 + */ + public final void setHeader(final boolean val) { + header = val; + } + + /** + * Get the host name used to identify this appender. + * @return local host name + * @since 1.2.15 + */ + private String getLocalHostname() { + if (localHostname == null) { + try { + InetAddress addr = InetAddress.getLocalHost(); + localHostname = addr.getHostName(); + } catch (UnknownHostException uhe) { + localHostname = "UNKNOWN_HOST"; + } + } + return localHostname; + } + + /** + * Gets HEADER portion of packet. + * @param timeStamp number of milliseconds after the standard base time. + * @return HEADER portion of packet, will be zero-length string if header is false. + * @since 1.2.15 + */ + private String getPacketHeader(final long timeStamp) { + if (header) { + StringBuffer buf = new StringBuffer(dateFormat.format(new Date(timeStamp))); + // RFC 3164 says leading space, not leading zero on days 1-9 + if (buf.charAt(4) == '0') { + buf.setCharAt(4, ' '); + } + buf.append(getLocalHostname()); + buf.append(' '); + return buf.toString(); + } + return ""; + } + + /** + * Set header or footer of layout. + * @param msg message body, may not be null. + */ + private void sendLayoutMessage(final String msg) { + if (sqw != null) { + String packet = msg; + String hdr = getPacketHeader(new Date().getTime()); + if(facilityPrinting || hdr.length() > 0) { + StringBuffer buf = new StringBuffer(hdr); + if(facilityPrinting) { + buf.append(facilityStr); + } + buf.append(msg); + packet = buf.toString(); + } + sqw.setLevel(6); + sqw.write(packet); + } + } } diff --git a/src/java/org/apache/log4j/net/TelnetAppender.java b/src/main/java/org/apache/log4j/net/TelnetAppender.java similarity index 85% rename from src/java/org/apache/log4j/net/TelnetAppender.java rename to src/main/java/org/apache/log4j/net/TelnetAppender.java index 7b203fe5d9..b4dbe14b3c 100644 --- a/src/java/org/apache/log4j/net/TelnetAppender.java +++ b/src/main/java/org/apache/log4j/net/TelnetAppender.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.net; diff --git a/src/java/org/apache/log4j/net/package.html b/src/main/java/org/apache/log4j/net/package.html similarity index 100% rename from src/java/org/apache/log4j/net/package.html rename to src/main/java/org/apache/log4j/net/package.html diff --git a/src/java/org/apache/log4j/nt/NTEventLogAppender.java b/src/main/java/org/apache/log4j/nt/NTEventLogAppender.java similarity index 72% rename from src/java/org/apache/log4j/nt/NTEventLogAppender.java rename to src/main/java/org/apache/log4j/nt/NTEventLogAppender.java index 0f663a3524..5921d29270 100644 --- a/src/java/org/apache/log4j/nt/NTEventLogAppender.java +++ b/src/main/java/org/apache/log4j/nt/NTEventLogAppender.java @@ -1,18 +1,27 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.nt; -import org.apache.log4j.*; -import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.Level; +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.Layout; +import org.apache.log4j.TTCCLayout; import org.apache.log4j.helpers.LogLog; - -import java.io.*; +import org.apache.log4j.spi.LoggingEvent; /** @@ -33,11 +42,6 @@ public class NTEventLogAppender extends AppenderSkeleton { private String source = null; private String server = null; - private static final int FATAL = Level.FATAL.toInt(); - private static final int ERROR = Level.ERROR.toInt(); - private static final int WARN = Level.WARN.toInt(); - private static final int INFO = Level.INFO.toInt(); - private static final int DEBUG = Level.DEBUG.toInt(); public NTEventLogAppender() { this(null, null, null); @@ -86,10 +90,10 @@ void close() { void activateOptions() { if (source != null) { try { - _handle = registerEventSource(server, source); + _handle = registerEventSource(server, source); } catch (Exception e) { - LogLog.error("Could not register event source.", e); - _handle = 0; + LogLog.error("Could not register event source.", e); + _handle = 0; } } } @@ -103,14 +107,14 @@ public void append(LoggingEvent event) { if(layout.ignoresThrowable()) { String[] s = event.getThrowableStrRep(); if (s != null) { - int len = s.length; - for(int i = 0; i < len; i++) { - sbuf.append(s[i]); - } + int len = s.length; + for(int i = 0; i < len; i++) { + sbuf.append(s[i]); + } } } // Normalize the log message level into the supported categories - int nt_category = event.level.toInt(); + int nt_category = event.getLevel().toInt(); // Anything above FATAL or below DEBUG is labeled as INFO. //if (nt_category > FATAL || nt_category < DEBUG) { diff --git a/src/java/org/apache/log4j/nt/package.html b/src/main/java/org/apache/log4j/nt/package.html similarity index 100% rename from src/java/org/apache/log4j/nt/package.html rename to src/main/java/org/apache/log4j/nt/package.html diff --git a/src/main/java/org/apache/log4j/or/DefaultRenderer.java b/src/main/java/org/apache/log4j/or/DefaultRenderer.java new file mode 100644 index 0000000000..bf6ee79320 --- /dev/null +++ b/src/main/java/org/apache/log4j/or/DefaultRenderer.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.or; + +/** + The default Renderer renders objects by calling their + toString method. + + @author Ceki Gülcü + @since 1.0 */ +class DefaultRenderer implements ObjectRenderer { + + DefaultRenderer() { + } + + /** + Render the object passed as parameter by calling its + toString method. */ + public + String doRender(Object o) { + return o.toString(); + } +} diff --git a/src/main/java/org/apache/log4j/or/ObjectRenderer.java b/src/main/java/org/apache/log4j/or/ObjectRenderer.java new file mode 100644 index 0000000000..8ad99439e8 --- /dev/null +++ b/src/main/java/org/apache/log4j/or/ObjectRenderer.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.or; + +/** + Implement this interface in order to render objects as strings. + + @author Ceki Gülcü + @since 1.0 */ +public interface ObjectRenderer { + + /** + Render the object passed as parameter as a String. + */ + public + String doRender(Object o); +} diff --git a/src/java/org/apache/log4j/or/RendererMap.java b/src/main/java/org/apache/log4j/or/RendererMap.java similarity index 84% rename from src/java/org/apache/log4j/or/RendererMap.java rename to src/main/java/org/apache/log4j/or/RendererMap.java index 79094786a4..f60bd5a967 100644 --- a/src/java/org/apache/log4j/or/RendererMap.java +++ b/src/main/java/org/apache/log4j/or/RendererMap.java @@ -1,14 +1,25 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.or; import org.apache.log4j.spi.RendererSupport; import org.apache.log4j.helpers.LogLog; +import org.apache.log4j.helpers.Loader; import org.apache.log4j.helpers.OptionConverter; import java.util.Hashtable; @@ -46,7 +57,7 @@ void addRenderer(RendererSupport repository, String renderedClassName, return; } else { try { - Class renderedClass = Class.forName(renderedClassName); + Class renderedClass = Loader.loadClass(renderedClassName); repository.setRenderer(renderedClass, renderer); } catch(ClassNotFoundException e) { LogLog.error("Could not find class ["+renderedClassName+"].", e); diff --git a/src/java/org/apache/log4j/or/ThreadGroupRenderer.java b/src/main/java/org/apache/log4j/or/ThreadGroupRenderer.java similarity index 66% rename from src/java/org/apache/log4j/or/ThreadGroupRenderer.java rename to src/main/java/org/apache/log4j/or/ThreadGroupRenderer.java index db00814b4e..8dd70ccc59 100644 --- a/src/java/org/apache/log4j/or/ThreadGroupRenderer.java +++ b/src/main/java/org/apache/log4j/or/ThreadGroupRenderer.java @@ -1,9 +1,19 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.or; diff --git a/src/java/org/apache/log4j/or/jms/MessageRenderer.java b/src/main/java/org/apache/log4j/or/jms/MessageRenderer.java similarity index 69% rename from src/java/org/apache/log4j/or/jms/MessageRenderer.java rename to src/main/java/org/apache/log4j/or/jms/MessageRenderer.java index b1da5f8518..e3140cbba5 100644 --- a/src/java/org/apache/log4j/or/jms/MessageRenderer.java +++ b/src/main/java/org/apache/log4j/or/jms/MessageRenderer.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.or.jms; diff --git a/src/java/org/apache/log4j/or/jms/package.html b/src/main/java/org/apache/log4j/or/jms/package.html similarity index 100% rename from src/java/org/apache/log4j/or/jms/package.html rename to src/main/java/org/apache/log4j/or/jms/package.html diff --git a/src/java/org/apache/log4j/or/package.html b/src/main/java/org/apache/log4j/or/package.html similarity index 100% rename from src/java/org/apache/log4j/or/package.html rename to src/main/java/org/apache/log4j/or/package.html diff --git a/src/java/org/apache/log4j/or/sax/AttributesRenderer.java b/src/main/java/org/apache/log4j/or/sax/AttributesRenderer.java similarity index 51% rename from src/java/org/apache/log4j/or/sax/AttributesRenderer.java rename to src/main/java/org/apache/log4j/or/sax/AttributesRenderer.java index 73f006f8f7..136fa97abb 100644 --- a/src/java/org/apache/log4j/or/sax/AttributesRenderer.java +++ b/src/main/java/org/apache/log4j/or/sax/AttributesRenderer.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.or.sax; diff --git a/src/java/org/apache/log4j/or/sax/package.html b/src/main/java/org/apache/log4j/or/sax/package.html similarity index 100% rename from src/java/org/apache/log4j/or/sax/package.html rename to src/main/java/org/apache/log4j/or/sax/package.html diff --git a/src/java/org/apache/log4j/package.html b/src/main/java/org/apache/log4j/package.html similarity index 100% rename from src/java/org/apache/log4j/package.html rename to src/main/java/org/apache/log4j/package.html diff --git a/src/java/org/apache/log4j/spi/AppenderAttachable.java b/src/main/java/org/apache/log4j/spi/AppenderAttachable.java similarity index 57% rename from src/java/org/apache/log4j/spi/AppenderAttachable.java rename to src/main/java/org/apache/log4j/spi/AppenderAttachable.java index 3b4cde3f11..89d7ef4209 100644 --- a/src/java/org/apache/log4j/spi/AppenderAttachable.java +++ b/src/main/java/org/apache/log4j/spi/AppenderAttachable.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.spi; diff --git a/src/main/java/org/apache/log4j/spi/Configurator.java b/src/main/java/org/apache/log4j/spi/Configurator.java new file mode 100644 index 0000000000..32ff72dcea --- /dev/null +++ b/src/main/java/org/apache/log4j/spi/Configurator.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.spi; + +import org.apache.log4j.spi.LoggerRepository; +import java.net.URL; + +/** + Implemented by classes capable of configuring log4j using a URL. + + @since 1.0 + @author Anders Kristensen + */ +public interface Configurator { + + /** + Special level value signifying inherited behaviour. The current + value of this string constant is inherited. {@link #NULL} + is a synonym. */ + public static final String INHERITED = "inherited"; + + /** + Special level signifying inherited behaviour, same as {@link + #INHERITED}. The current value of this string constant is + null. */ + public static final String NULL = "null"; + + + + /** + Interpret a resource pointed by a URL and set up log4j accordingly. + + The configuration is done relative to the hierarchy + parameter. + + @param url The URL to parse + @param repository The hierarchy to operation upon. + */ + void doConfigure(URL url, LoggerRepository repository); +} diff --git a/src/main/java/org/apache/log4j/spi/DefaultRepositorySelector.java b/src/main/java/org/apache/log4j/spi/DefaultRepositorySelector.java new file mode 100644 index 0000000000..4b307524e4 --- /dev/null +++ b/src/main/java/org/apache/log4j/spi/DefaultRepositorySelector.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +package org.apache.log4j.spi; + + +public class DefaultRepositorySelector implements RepositorySelector { + + final LoggerRepository repository; + + public + DefaultRepositorySelector(LoggerRepository repository) { + this.repository = repository; + } + + public + LoggerRepository getLoggerRepository() { + return repository; + } +} + diff --git a/src/main/java/org/apache/log4j/spi/ErrorCode.java b/src/main/java/org/apache/log4j/spi/ErrorCode.java new file mode 100644 index 0000000000..b0e57f1fe7 --- /dev/null +++ b/src/main/java/org/apache/log4j/spi/ErrorCode.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.spi; + + +/** + This interface defines commonly encoutered error codes. + + @author Ceki Gülcü + @since 0.9.0 + */ +public interface ErrorCode { + + public final int GENERIC_FAILURE = 0; + public final int WRITE_FAILURE = 1; + public final int FLUSH_FAILURE = 2; + public final int CLOSE_FAILURE = 3; + public final int FILE_OPEN_FAILURE = 4; + public final int MISSING_LAYOUT = 5; + public final int ADDRESS_PARSE_FAILURE = 6; +} diff --git a/src/java/org/apache/log4j/spi/ErrorHandler.java b/src/main/java/org/apache/log4j/spi/ErrorHandler.java similarity index 72% rename from src/java/org/apache/log4j/spi/ErrorHandler.java rename to src/main/java/org/apache/log4j/spi/ErrorHandler.java index 9eb70a2884..d629a2dbd2 100644 --- a/src/java/org/apache/log4j/spi/ErrorHandler.java +++ b/src/main/java/org/apache/log4j/spi/ErrorHandler.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.spi; diff --git a/src/java/org/apache/log4j/spi/Filter.java b/src/main/java/org/apache/log4j/spi/Filter.java similarity index 72% rename from src/java/org/apache/log4j/spi/Filter.java rename to src/main/java/org/apache/log4j/spi/Filter.java index 3f12dbd699..b54d875ce9 100644 --- a/src/java/org/apache/log4j/spi/Filter.java +++ b/src/main/java/org/apache/log4j/spi/Filter.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.spi; @@ -53,6 +63,8 @@ public abstract class Filter implements OptionHandler { /** Points to the next filter in the filter chain. + + @deprecated As of 1.2.12, use {@link #getNext} and {@link #setNext} instead */ public Filter next; @@ -91,9 +103,23 @@ void activateOptions() { the chain. @param event The LoggingEvent to decide upon. - @param decision The decision of the filter. */ + @return decision The decision of the filter. */ abstract public int decide(LoggingEvent event); + /** + * Set the next filter pointer. + */ + public void setNext(Filter next) { + this.next = next; + } + + /** + * Return the pointer to the next filter; + */ + public Filter getNext() { + return next; + } + } diff --git a/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java b/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java new file mode 100644 index 0000000000..9215926913 --- /dev/null +++ b/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.spi; + +import org.apache.log4j.*; + +/** + Listen to events occuring within a {@link + org.apache.log4j.Hierarchy Hierarchy}. + + @author Ceki Gülcü + @since 1.2 + + */ +public interface HierarchyEventListener { + + + //public + //void categoryCreationEvent(Category cat); + + + public + void addAppenderEvent(Category cat, Appender appender); + + public + void removeAppenderEvent(Category cat, Appender appender); + + +} diff --git a/src/java/org/apache/log4j/spi/LocationInfo.java b/src/main/java/org/apache/log4j/spi/LocationInfo.java similarity index 70% rename from src/java/org/apache/log4j/spi/LocationInfo.java rename to src/main/java/org/apache/log4j/spi/LocationInfo.java index eb0d505aa4..80df1d02fe 100644 --- a/src/java/org/apache/log4j/spi/LocationInfo.java +++ b/src/main/java/org/apache/log4j/spi/LocationInfo.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // Contributors: Mathias Rupprecht @@ -54,13 +64,20 @@ public class LocationInfo implements java.io.Serializable { static final long serialVersionUID = -1325822038990805636L; + /** + * NA_LOCATION_INFO is provided for compatibility with log4j 1.3. + * @since 1.2.15 + */ + public static final LocationInfo NA_LOCATION_INFO = + new LocationInfo(NA, NA, NA, NA); + + // Check if we are running in IBM's visual age. static boolean inVisualAge = false; static { try { - Class dummy = Class.forName("com.ibm.uvm.tools.DebugSupport"); - inVisualAge = true; + inVisualAge = Class.forName("com.ibm.uvm.tools.DebugSupport") != null; LogLog.debug("Detected IBM VisualAge environment."); } catch(Throwable e) { // nothing to do @@ -87,7 +104,7 @@ public class LocationInfo implements java.io.Serializable { */ public LocationInfo(Throwable t, String fqnOfCallingClass) { - if(t == null) + if(t == null || fqnOfCallingClass == null) return; String s; @@ -136,6 +153,53 @@ public LocationInfo(Throwable t, String fqnOfCallingClass) { this.fullInfo = s.substring(ibegin, iend); } + /** + * Appends a location fragment to a buffer to build the + * full location info. + * @param buf StringBuffer to receive content. + * @param fragment fragment of location (class, method, file, line), + * if null the value of NA will be appended. + * @since 1.2.15 + */ + private static final void appendFragment(final StringBuffer buf, + final String fragment) { + if (fragment == null) { + buf.append(NA); + } else { + buf.append(fragment); + } + } + + /** + * Create new instance. + * @param file source file name + * @param classname class name + * @param method method + * @param line source line number + * + * @since 1.2.15 + */ + public LocationInfo( + final String file, + final String classname, + final String method, + final String line) { + this.fileName = file; + this.className = classname; + this.methodName = method; + this.lineNumber = line; + StringBuffer buf = new StringBuffer(); + appendFragment(buf, classname); + buf.append("."); + appendFragment(buf, method); + buf.append("("); + appendFragment(buf, file); + buf.append(":"); + appendFragment(buf, line); + buf.append(")"); + this.fullInfo = buf.toString(); + } + /** Return the fully qualified class name of the caller making the logging request. diff --git a/src/main/java/org/apache/log4j/spi/LoggerFactory.java b/src/main/java/org/apache/log4j/spi/LoggerFactory.java new file mode 100644 index 0000000000..568c41fe19 --- /dev/null +++ b/src/main/java/org/apache/log4j/spi/LoggerFactory.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.spi; + +import org.apache.log4j.Logger; + +/** + + Implement this interface to create new instances of Logger or + a sub-class of Logger. + +

    See examples/subclass/MyLogger.java for an example. + + @author Ceki Gülcü + @since version 0.8.5 + + */ +public interface LoggerFactory { + + public + Logger makeNewLoggerInstance(String name); + +} diff --git a/src/java/org/apache/log4j/spi/LoggerRepository.java b/src/main/java/org/apache/log4j/spi/LoggerRepository.java similarity index 63% rename from src/java/org/apache/log4j/spi/LoggerRepository.java rename to src/main/java/org/apache/log4j/spi/LoggerRepository.java index 22ce2b32fc..46701a61c8 100644 --- a/src/java/org/apache/log4j/spi/LoggerRepository.java +++ b/src/main/java/org/apache/log4j/spi/LoggerRepository.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.spi; @@ -31,9 +41,10 @@ public interface LoggerRepository { void addHierarchyEventListener(HierarchyEventListener listener); /** - Is the repository disabled for a given level? The answer depends - on the repository threshold and the level - parameter. See also {@link #setThreshold} method. */ + Returns whether this repository is disabled for a given + level. The answer depends on the repository threshold and the + level parameter. See also {@link #setThreshold} + method. */ boolean isDisabled(int level); /** @@ -79,7 +90,7 @@ public interface LoggerRepository { Enumeration getCurrentLoggers(); /** - @deprecated Please use {@link #getCurrentLoggers} instead. */ + Deprecated. Please use {@link #getCurrentLoggers} instead. */ public Enumeration getCurrentCategories(); diff --git a/src/java/org/apache/log4j/spi/LoggingEvent.java b/src/main/java/org/apache/log4j/spi/LoggingEvent.java similarity index 51% rename from src/java/org/apache/log4j/spi/LoggingEvent.java rename to src/main/java/org/apache/log4j/spi/LoggingEvent.java index 5cd6e42dc7..57c8a53c82 100644 --- a/src/java/org/apache/log4j/spi/LoggingEvent.java +++ b/src/main/java/org/apache/log4j/spi/LoggingEvent.java @@ -1,20 +1,34 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.spi; import org.apache.log4j.*; import org.apache.log4j.helpers.LogLog; - +import org.apache.log4j.helpers.Loader; import java.lang.reflect.Method; import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.util.Hashtable; +import java.util.Set; +import java.util.Collections; +import java.util.Map; +import java.util.HashMap; // Contributors: Nelson Minar // Wolf Siberski @@ -39,19 +53,40 @@ public class LoggingEvent implements java.io.Serializable { /** Fully qualified name of the calling category class. */ transient public final String fqnOfCategoryClass; - /** The category of the logging event. The category field is not - serialized for performance reasons. - -

    It is set by the LoggingEvent constructor or set by a remote - entity after deserialization. */ - transient public Category logger; - - /** The category (logger) name. */ - public final String categoryName; - - /** Level of logging event. Level cannot be serializable - because it is a flyweight. Due to its special seralization it - cannot be declared final either. */ + /** + * The category of the logging event. This field is not serialized + * for performance reasons. + * + *

    It is set by the LoggingEvent constructor or set by a remote + * entity after deserialization. + * + * @deprecated This field will be marked as private or be completely + * removed in future releases. Please do not use it. + * */ + transient private Category logger; + + /** + *

    The category (logger) name. + * + * @deprecated This field will be marked as private in future + * releases. Please do not access it directly. Use the {@link + * #getLoggerName} method instead. + + * */ + final public String categoryName; + + /** + * Level of logging event. Level cannot be serializable because it + * is a flyweight. Due to its special seralization it cannot be + * declared final either. + * + *

    This field should not be accessed directly. You shoud use the + * {@link #getLevel} method instead. + * + * @deprecated This field will be marked as private in future + * releases. Please do not access it directly. Use the {@link + * #getLevel} method instead. + * */ transient public Priority level; /** The nested diagnostic context (NDC) of logging event. */ @@ -62,18 +97,16 @@ public class LoggingEvent implements java.io.Serializable { /** Have we tried to do an NDC lookup? If we did, there is no need - to do it again. Note that its value is always false when - serialized. Thus, a receiving SocketNode will never use it's own - (incorrect) NDC. See also writeObject method. */ + * to do it again. Note that its value is always false when + * serialized. Thus, a receiving SocketNode will never use it's own + * (incorrect) NDC. See also writeObject method. */ private boolean ndcLookupRequired = true; - /** Have we tried to do an MDC lookup? If we did, there is no need to - do it again. Note that its value is always false when - serialized. Thus, a receiving SocketNode will never use it's own - (incorrect) MDC. See also writeObject method. */ - private boolean mdcLookupRequired = true; - + /** Have we tried to do an MDC lookup? If we did, there is no need + * to do it again. Note that its value is always false when + * serialized. See also the getMDC and getMDCCopy methods. */ + private boolean mdcCopyLookupRequired = true; /** The application supplied message of logging event. */ transient private Object message; @@ -111,16 +144,16 @@ public class LoggingEvent implements java.io.Serializable {

    Except {@link #timeStamp} all the other fields of LoggingEvent are filled when actually needed.

    - @param category The category of this event. + @param logger The logger generating this event. @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LoggingEvent(String fqnOfCategoryClass, Category logger, - Priority priority, Object message, Throwable throwable) { + Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); - this.level = priority; + this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable); @@ -134,18 +167,18 @@ public LoggingEvent(String fqnOfCategoryClass, Category logger,

    Except {@link #timeStamp} all the other fields of LoggingEvent are filled when actually needed.

    - @param category The category of this event. + @param logger The logger generating this event. @param timeStamp the timestamp of this logging event @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LoggingEvent(String fqnOfCategoryClass, Category logger, - long timeStamp, Priority priority, Object message, + long timeStamp, Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); - this.level = priority; + this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable); @@ -154,20 +187,91 @@ public LoggingEvent(String fqnOfCategoryClass, Category logger, this.timeStamp = timeStamp; } + /** + Create new instance. + @since 1.2.15 + @param fqnOfCategoryClass Fully qualified class name + of Logger implementation. + @param logger The logger generating this event. + @param timeStamp the timestamp of this logging event + @param level The level of this event. + @param message The message of this event. + @param threadName thread name + @param throwable The throwable of this event. + @param ndc Nested diagnostic context + @param info Location info + @param properties MDC properties + */ + public LoggingEvent(final String fqnOfCategoryClass, + final Category logger, + final long timeStamp, + final Level level, + final Object message, + final String threadName, + final ThrowableInformation throwable, + final String ndc, + final LocationInfo info, + final java.util.Map properties) { + super(); + this.fqnOfCategoryClass = fqnOfCategoryClass; + this.logger = logger; + if (logger != null) { + categoryName = logger.getName(); + } else { + categoryName = null; + } + this.level = level; + this.message = message; + if(throwable != null) { + this.throwableInfo = throwable; + } + + this.timeStamp = timeStamp; + this.threadName = threadName; + ndcLookupRequired = false; + this.ndc = ndc; + this.locationInfo = info; + mdcCopyLookupRequired = false; + if (properties != null) { + mdcCopy = new java.util.Hashtable(properties); + } + } /** Set the location information for this logging event. The collected information is cached for future use. */ - public - LocationInfo getLocationInformation() { + public LocationInfo getLocationInformation() { if(locationInfo == null) { locationInfo = new LocationInfo(new Throwable(), fqnOfCategoryClass); } return locationInfo; } + /** + * Return the level of this event. Use this form instead of directly + * accessing the level field. */ + public Level getLevel() { + return (Level) level; + } + + /** + * Return the name of the logger. Use this form instead of directly + * accessing the categoryName field. + */ + public String getLoggerName() { + return categoryName; + } + + /** + * Gets the logger of the event. + * Use should be restricted to cloning events. + * @since 1.2.15 + */ + public Category getLogger() { + return logger; + } /** Return the message for this logging event. @@ -187,6 +291,11 @@ Object getMessage() { } } + /** + * This method returns the NDC for this event. It will return the + * correct content even if the event was generated in a different + * thread or even on a different machine. The {@link NDC#get} method + * should never be called directly. */ public String getNDC() { if(ndcLookupRequired) { @@ -199,9 +308,11 @@ String getNDC() { /** Returns the the context corresponding to the key - parameter. If there is a local MDC copy (probably from a remote - machine, the we use it, if that fails then the current thread's - MDC is used. + parameter. If there is a local MDC copy, possibly because we are + in a logging server or running inside AsyncAppender, then we + search for the key in MDC copy, if a value is found it is + returned. Otherwise, if the search in MDC copy returns a null + result, then the current thread's MDC is used.

    Note that both the local MDC copy and the current thread's MDC are searched. @@ -223,11 +334,12 @@ Object getMDC(String key) { /** Obtain a copy of this thread's MDC prior to serialization or - asynchronous logging. */ + asynchronous logging. + */ public void getMDCCopy() { - if(mdcLookupRequired) { - ndcLookupRequired = false; + if(mdcCopyLookupRequired) { + mdcCopyLookupRequired = false; // the clone call is required for asynchronous logging. // See also bug #5932. Hashtable t = (Hashtable) MDC.getContext(); @@ -243,7 +355,7 @@ String getRenderedMessage() { if(message instanceof String) renderedMessage = (String) message; else { - LoggerRepository repository = logger.getHierarchy(); + LoggerRepository repository = logger.getLoggerRepository(); if(repository instanceof RendererSupport) { RendererSupport rs = (RendererSupport) repository; @@ -259,9 +371,7 @@ String getRenderedMessage() { /** Returns the time when the application started, in milliseconds elapsed since 01.01.1970. */ - public - static - long getStartTime() { + public static long getStartTime() { return startTime; } @@ -310,7 +420,7 @@ void readLevel(ObjectInputStream ois) } else { Method m = (Method) methodCache.get(className); if(m == null) { - Class clazz = Class.forName(className); + Class clazz = Loader.loadClass(className); // Note that we use Class.getDeclaredMethod instead of // Class.getMethod. This assumes that the Level subclass // implements the toLevel(int) method which is a @@ -381,4 +491,114 @@ void writeLevel(ObjectOutputStream oos) throws java.io.IOException { } } + /** + * Set value for MDC property. + * This adds the specified MDC property to the event. + * Access to the MDC is not synchronized, so this + * method should only be called when it is known that + * no other threads are accessing the MDC. + * @since 1.2.15 + * @param propName + * @param propValue + */ + public final void setProperty(final String propName, + final String propValue) { + if (mdcCopy == null) { + getMDCCopy(); + } + if (mdcCopy == null) { + mdcCopy = new Hashtable(); + } + mdcCopy.put(propName, propValue); + } + + /** + * Return a property for this event. The return value can be null. + * + * Equivalent to getMDC(String) in log4j 1.2. Provided + * for compatibility with log4j 1.3. + * + * @param key property name + * @return property value or null if property not set + * @since 1.2.15 + */ + public final String getProperty(final String key) { + Object value = getMDC(key); + String retval = null; + if (value != null) { + retval = value.toString(); + } + return retval; + } + + /** + * Check for the existence of location information without creating it + * (a byproduct of calling getLocationInformation). + * @return true if location information has been extracted. + * @since 1.2.15 + */ + public final boolean locationInformationExists() { + return (locationInfo != null); + } + + /** + * Getter for the event's time stamp. The time stamp is calculated starting + * from 1970-01-01 GMT. + * @return timestamp + * + * @since 1.2.15 + */ + public final long getTimeStamp() { + return timeStamp; + } + + /** + * Returns the set of the key values in the properties + * for the event. + * + * The returned set is unmodifiable by the caller. + * + * Provided for compatibility with log4j 1.3 + * + * @return Set an unmodifiable set of the property keys. + * @since 1.2.15 + */ + public Set getPropertyKeySet() { + return getProperties().keySet(); + } + + /** + * Returns the set of properties + * for the event. + * + * The returned set is unmodifiable by the caller. + * + * Provided for compatibility with log4j 1.3 + * + * @return Set an unmodifiable map of the properties. + * @since 1.2.15 + */ + public Map getProperties() { + getMDCCopy(); + Map properties; + if (mdcCopy == null) { + properties = new HashMap(); + } else { + properties = mdcCopy; + } + return Collections.unmodifiableMap(properties); + } + + /** + * Get the fully qualified name of the calling logger sub-class/wrapper. + * Provided for compatibility with log4j 1.3 + * @return fully qualified class name, may be null. + * @since 1.2.15 + */ + public String getFQNOfLoggerClass() { + return fqnOfCategoryClass; + } + + + } diff --git a/src/main/java/org/apache/log4j/spi/NullWriter.java b/src/main/java/org/apache/log4j/spi/NullWriter.java new file mode 100644 index 0000000000..a578910893 --- /dev/null +++ b/src/main/java/org/apache/log4j/spi/NullWriter.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.log4j.spi; +import java.io.Writer; + +/** + * NullWriter is an obsolete class provided only for + * binary compatibility with earlier versions of log4j and should not be used. + * + * @deprecated + */ +class NullWriter extends Writer { + + public void close() { + // blank + } + + public void flush() { + // blank + } + + public void write(char[] cbuf, int off, int len) { + // blank + } +} diff --git a/src/java/org/apache/log4j/spi/OptionHandler.java b/src/main/java/org/apache/log4j/spi/OptionHandler.java similarity index 62% rename from src/java/org/apache/log4j/spi/OptionHandler.java rename to src/main/java/org/apache/log4j/spi/OptionHandler.java index 9f952323eb..2c90226825 100644 --- a/src/java/org/apache/log4j/spi/OptionHandler.java +++ b/src/main/java/org/apache/log4j/spi/OptionHandler.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.spi; diff --git a/src/main/java/org/apache/log4j/spi/RendererSupport.java b/src/main/java/org/apache/log4j/spi/RendererSupport.java new file mode 100644 index 0000000000..9d69faa731 --- /dev/null +++ b/src/main/java/org/apache/log4j/spi/RendererSupport.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.log4j.spi; + +import org.apache.log4j.or.ObjectRenderer; +import org.apache.log4j.or.RendererMap; + + +public interface RendererSupport { + + public + RendererMap getRendererMap(); + + public + void setRenderer(Class renderedClass, ObjectRenderer renderer); + +} diff --git a/src/java/org/apache/log4j/spi/RepositorySelector.java b/src/main/java/org/apache/log4j/spi/RepositorySelector.java similarity index 50% rename from src/java/org/apache/log4j/spi/RepositorySelector.java rename to src/main/java/org/apache/log4j/spi/RepositorySelector.java index 2d0818a0c0..9a70d6203c 100644 --- a/src/java/org/apache/log4j/spi/RepositorySelector.java +++ b/src/main/java/org/apache/log4j/spi/RepositorySelector.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/src/java/org/apache/log4j/spi/RootCategory.java b/src/main/java/org/apache/log4j/spi/RootCategory.java similarity index 54% rename from src/java/org/apache/log4j/spi/RootCategory.java rename to src/main/java/org/apache/log4j/spi/RootCategory.java index 7ec80b4170..1682751811 100644 --- a/src/java/org/apache/log4j/spi/RootCategory.java +++ b/src/main/java/org/apache/log4j/spi/RootCategory.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.spi; @@ -13,16 +23,7 @@ // Contibutors: Mathias Bogaert /** - RootCategory sits at the top of the category hierachy. It is a - regular category except that it provides several guarantees. - -

    First, it cannot be assigned a null - priority. Second, since root category cannot have a parent, the - {@link #getChainedLevel} method always returns the value of the - level field without walking the hierarchy. - - @author Ceki Gülcü - + * @deprecated Replaced by {@link RootLogger}. */ final public class RootCategory extends Logger { diff --git a/src/main/java/org/apache/log4j/spi/RootLogger.java b/src/main/java/org/apache/log4j/spi/RootLogger.java new file mode 100644 index 0000000000..02f7cd31e8 --- /dev/null +++ b/src/main/java/org/apache/log4j/spi/RootLogger.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.spi; + +import org.apache.log4j.*; +import org.apache.log4j.helpers.LogLog; + + +// Contibutors: Mathias Bogaert + +/** + RootLogger sits at the top of the logger hierachy. It is a + regular logger except that it provides several guarantees. + +

    First, it cannot be assigned a null + level. Second, since root logger cannot have a parent, the + {@link #getChainedLevel} method always returns the value of the + level field without walking the hierarchy. + + @author Ceki Gülcü + + */ +public final class RootLogger extends Logger { + /** + The root logger names itself as "root". However, the root + logger cannot be retrieved by name. + */ + public RootLogger(Level level) { + super("root"); + setLevel(level); + } + + /** + Return the assigned level value without walking the logger + hierarchy. + */ + public final Level getChainedLevel() { + return level; + } + + /** + Setting a null value to the level of the root logger may have catastrophic + results. We prevent this here. + + @since 0.8.3 */ + public final void setLevel(Level level) { + if (level == null) { + LogLog.error( + "You have tried to set a null level to root.", new Throwable()); + } else { + this.level = level; + } + } + +} diff --git a/src/main/java/org/apache/log4j/spi/ThrowableInformation.java b/src/main/java/org/apache/log4j/spi/ThrowableInformation.java new file mode 100644 index 0000000000..b98d0f5d1f --- /dev/null +++ b/src/main/java/org/apache/log4j/spi/ThrowableInformation.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.spi; + +import java.io.IOException; +import java.io.LineNumberReader; +import java.io.PrintWriter; +import java.io.StringReader; +import java.io.StringWriter; +import java.util.ArrayList; + +/** + * ThrowableInformation is log4j's internal representation of + * throwables. It essentially consists of a string array, called + * 'rep', where the first element, that is rep[0], represents the + * string representation of the throwable (i.e. the value you get + * when you do throwable.toString()) and subsequent elements + * correspond the stack trace with the top most entry of the stack + * corresponding to the second entry of the 'rep' array that is + * rep[1]. + * + * @author Ceki Gülcü + * + * */ +public class ThrowableInformation implements java.io.Serializable { + + static final long serialVersionUID = -4748765566864322735L; + + private transient Throwable throwable; + private String[] rep; + + public + ThrowableInformation(Throwable throwable) { + this.throwable = throwable; + } + + /** + * Create new instance. + * @since 1.2.15 + * @param r String representation of throwable. + */ + public ThrowableInformation(final String[] r) { + if (r != null) { + rep = (String[]) r.clone(); + } + } + + + public + Throwable getThrowable() { + return throwable; + } + + public + String[] getThrowableStrRep() { + if(rep != null) { + return (String[]) rep.clone(); + } else { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + throwable.printStackTrace(pw); + pw.flush(); + LineNumberReader reader = new LineNumberReader( + new StringReader(sw.toString())); + ArrayList lines = new ArrayList(); + try { + String line = reader.readLine(); + while(line != null) { + lines.add(line); + line = reader.readLine(); + } + } catch(IOException ex) { + lines.add(ex.toString()); + } + rep = new String[lines.size()]; + lines.toArray(rep); + } + return rep; + } +} + + diff --git a/src/main/java/org/apache/log4j/spi/TriggeringEventEvaluator.java b/src/main/java/org/apache/log4j/spi/TriggeringEventEvaluator.java new file mode 100644 index 0000000000..67f4fcd01d --- /dev/null +++ b/src/main/java/org/apache/log4j/spi/TriggeringEventEvaluator.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.spi; + +/** + + Implementions of this interface allow certain appenders to decide + when to perform an appender specific action. + +

    For example the {@link org.apache.log4j.net.SMTPAppender} sends + an email when the {@link #isTriggeringEvent} method returns + true and adds the event to an internal buffer when the + returned result is false. + + @author Ceki Gülcü + @since version 1.0 + + */ +public interface TriggeringEventEvaluator { + + /** + Is this the triggering event? + */ + public boolean isTriggeringEvent(LoggingEvent event); +} diff --git a/src/main/java/org/apache/log4j/spi/VectorWriter.java b/src/main/java/org/apache/log4j/spi/VectorWriter.java new file mode 100644 index 0000000000..3e288605ac --- /dev/null +++ b/src/main/java/org/apache/log4j/spi/VectorWriter.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.log4j.spi; + +import java.io.PrintWriter; +import java.util.Vector; + +/** + * VectorWriter is an obsolete class provided only for + * binary compatibility with earlier versions of log4j and should not be used. + * + * @deprecated + */ +class VectorWriter extends PrintWriter { + + private Vector v; + + /** + * @deprecated + */ + VectorWriter() { + super(new NullWriter()); + v = new Vector(); + } + + public void print(Object o) { + v.addElement(String.valueOf(o)); + } + + public void print(char[] chars) { + v.addElement(new String(chars)); + } + + public void print(String s) { + v.addElement(s); + } + + public void println(Object o) { + v.addElement(String.valueOf(o)); + } + + // JDK 1.1.x apprenly uses this form of println while in + // printStackTrace() + public + void println(char[] chars) { + v.addElement(new String(chars)); + } + + public + void println(String s) { + v.addElement(s); + } + + public void write(char[] chars) { + v.addElement(new String(chars)); + } + + public void write(char[] chars, int off, int len) { + v.addElement(new String(chars, off, len)); + } + + public void write(String s, int off, int len) { + v.addElement(s.substring(off, off+len)); + } + + public void write(String s) { + v.addElement(s); + } + + public String[] toStringArray() { + int len = v.size(); + String[] sa = new String[len]; + for(int i = 0; i < len; i++) { + sa[i] = (String) v.elementAt(i); + } + return sa; + } + +} + diff --git a/src/java/org/apache/log4j/spi/package.html b/src/main/java/org/apache/log4j/spi/package.html similarity index 100% rename from src/java/org/apache/log4j/spi/package.html rename to src/main/java/org/apache/log4j/spi/package.html diff --git a/src/java/org/apache/log4j/varia/DenyAllFilter.java b/src/main/java/org/apache/log4j/varia/DenyAllFilter.java similarity index 61% rename from src/java/org/apache/log4j/varia/DenyAllFilter.java rename to src/main/java/org/apache/log4j/varia/DenyAllFilter.java index 9e59f4b33a..6c9e949396 100644 --- a/src/java/org/apache/log4j/varia/DenyAllFilter.java +++ b/src/main/java/org/apache/log4j/varia/DenyAllFilter.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.varia; diff --git a/src/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java b/src/main/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java similarity index 80% rename from src/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java rename to src/main/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java index 736abe1baf..7e284b7e83 100644 --- a/src/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java +++ b/src/main/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java @@ -1,20 +1,30 @@ /* - * 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. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.varia; -import java.io.*; -import java.net.Socket; -import java.net.ServerSocket; -import org.apache.log4j.helpers.LogLog; import org.apache.log4j.RollingFileAppender; import org.apache.log4j.helpers.LogLog; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.net.ServerSocket; +import java.net.Socket; + /** This appender listens on a socket on the port specified by the Port property for a "RollOver" message. When such a message diff --git a/src/java/org/apache/log4j/varia/FallbackErrorHandler.java b/src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java similarity index 51% rename from src/java/org/apache/log4j/varia/FallbackErrorHandler.java rename to src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java index a7ebb9f00a..dc51347e38 100644 --- a/src/java/org/apache/log4j/varia/FallbackErrorHandler.java +++ b/src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.varia; @@ -16,16 +25,17 @@ import java.util.Vector; /** - - The FallbackErrorHandler implements the ErrorHandler - interface such that a secondary appender may be specified. This - secondary appender takes over if the primary appender fails for - whatever reason. - -

    The error message is printed on System.err, and - logged in the new secondary appender. - -*/ + * + * The FallbackErrorHandler implements the ErrorHandler + * interface such that a secondary appender may be specified. This + * secondary appender takes over if the primary appender fails for + * whatever reason. + * + *

    The error message is printed on System.err, and + * logged in the new secondary appender. + * + * @author Ceki Gücü + * */ public class FallbackErrorHandler implements ErrorHandler { @@ -73,17 +83,20 @@ void error(String message, Exception e, int errorCode) { */ public void error(String message, Exception e, int errorCode, LoggingEvent event) { - for(int i = 0; i < loggers.size(); i++) { - Logger l = (Logger) loggers.elementAt(i); - LogLog.debug("FB: Searching for ["+primary.getName()+"] in logger" - +l.getName()); - //if(l.isAttached(primary)) { - LogLog.debug("FB: Replacing ["+primary.getName()+"] by [" - + backup.getName() + " in logger"+ l); - l.removeAppender(primary); - LogLog.debug("FB: Adding appender ["+backup.getName()+"] to logger " - + l.getName()); - l.addAppender(backup); + LogLog.debug("FB: The following error reported: " + message, e); + LogLog.debug("FB: INITIATING FALLBACK PROCEDURE."); + if (loggers != null) { + for(int i = 0; i < loggers.size(); i++) { + Logger l = (Logger) loggers.elementAt(i); + LogLog.debug("FB: Searching for ["+primary.getName()+"] in logger [" + +l.getName() + "]."); + LogLog.debug("FB: Replacing ["+primary.getName()+"] by [" + + backup.getName() + "] in logger ["+ l.getName() +"]."); + l.removeAppender(primary); + LogLog.debug("FB: Adding appender ["+backup.getName()+"] to logger " + + l.getName()); + l.addAppender(backup); + } } } diff --git a/src/java/org/apache/log4j/varia/LevelMatchFilter.java b/src/main/java/org/apache/log4j/varia/LevelMatchFilter.java similarity index 72% rename from src/java/org/apache/log4j/varia/LevelMatchFilter.java rename to src/main/java/org/apache/log4j/varia/LevelMatchFilter.java index b028c83674..832ca29f2c 100644 --- a/src/java/org/apache/log4j/varia/LevelMatchFilter.java +++ b/src/main/java/org/apache/log4j/varia/LevelMatchFilter.java @@ -1,9 +1,18 @@ /* - * 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. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.varia; @@ -79,7 +88,7 @@ int decide(LoggingEvent event) { } boolean matchOccured = false; - if(this.levelToMatch.equals(event.level)) { + if(this.levelToMatch.equals(event.getLevel())) { matchOccured = true; } diff --git a/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java b/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java new file mode 100644 index 0000000000..9dfacb1be5 --- /dev/null +++ b/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java @@ -0,0 +1,144 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.varia; + +import org.apache.log4j.Level; +import org.apache.log4j.spi.Filter; +import org.apache.log4j.spi.LoggingEvent; + +/** + This is a very simple filter based on level matching, which can be + used to reject messages with priorities outside a certain range. + +

    The filter admits three options LevelMin, LevelMax + and AcceptOnMatch. + +

    If the level of the {@link LoggingEvent} is not between Min and Max + (inclusive), then {@link Filter#DENY} is returned. + +

    If the Logging event level is within the specified range, then if + AcceptOnMatch is true, {@link Filter#ACCEPT} is returned, and if + AcceptOnMatch is false, {@link Filter#NEUTRAL} is returned. + +

    If LevelMinw is not defined, then there is no + minimum acceptable level (ie a level is never rejected for + being too "low"/unimportant). If LevelMax is not + defined, then there is no maximum acceptable level (ie a + level is never rejected for beeing too "high"/important). + +

    Refer to the {@link + org.apache.log4j.AppenderSkeleton#setThreshold setThreshold} method + available to all appenders extending {@link + org.apache.log4j.AppenderSkeleton} for a more convenient way to + filter out events by level. + + @author Simon Kitching + @author based on code by Ceki Gülcü +*/ +public class LevelRangeFilter extends Filter { + + /** + Do we return ACCEPT when a match occurs. Default is + false, so that later filters get run by default */ + boolean acceptOnMatch = false; + + Level levelMin; + Level levelMax; + + + /** + Return the decision of this filter. + */ + public + int decide(LoggingEvent event) { + if(this.levelMin != null) { + if (event.getLevel().isGreaterOrEqual(levelMin) == false) { + // level of event is less than minimum + return Filter.DENY; + } + } + + if(this.levelMax != null) { + if (event.getLevel().toInt() > levelMax.toInt()) { + // level of event is greater than maximum + // Alas, there is no Level.isGreater method. and using + // a combo of isGreaterOrEqual && !Equal seems worse than + // checking the int values of the level objects.. + return Filter.DENY; + } + } + + if (acceptOnMatch) { + // this filter set up to bypass later filters and always return + // accept if level in range + return Filter.ACCEPT; + } + else { + // event is ok for this filter; allow later filters to have a look.. + return Filter.NEUTRAL; + } + } + + /** + Get the value of the LevelMax option. */ + public + Level getLevelMax() { + return levelMax; + } + + + /** + Get the value of the LevelMin option. */ + public + Level getLevelMin() { + return levelMin; + } + + /** + Get the value of the AcceptOnMatch option. + */ + public + boolean getAcceptOnMatch() { + return acceptOnMatch; + } + + /** + Set the LevelMax option. + */ + public + void setLevelMax(Level levelMax) { + this.levelMax = levelMax; + } + + /** + Set the LevelMin option. + */ + public + void setLevelMin(Level levelMin) { + this.levelMin = levelMin; + } + + /** + Set the AcceptOnMatch option. + */ + public + void setAcceptOnMatch(boolean acceptOnMatch) { + this.acceptOnMatch = acceptOnMatch; + } +} + diff --git a/src/main/java/org/apache/log4j/varia/NullAppender.java b/src/main/java/org/apache/log4j/varia/NullAppender.java new file mode 100644 index 0000000000..5ef78dc3ce --- /dev/null +++ b/src/main/java/org/apache/log4j/varia/NullAppender.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.varia; + +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.spi.LoggingEvent; + +/** + * A NullAppender merely exists, it never outputs a message to any + * device. + * @author Ceki Gülc¨ + */ +public class NullAppender extends AppenderSkeleton { + + private static NullAppender instance = new NullAppender(); + + public NullAppender() { + } + + /** + * There are no options to acticate. + * */ + public void activateOptions() { + } + + /** + * Whenever you can, use this method to retreive an instance instead + * of instantiating a new one with new. + * */ + public NullAppender getInstance() { + return instance; + } + + public void close() { + } + + /** + * Does not do anything. + * */ + public void doAppend(LoggingEvent event) { + } + + /** + * Does not do anything. + * */ + protected void append(LoggingEvent event) { + } + + /** + * NullAppenders do not need a layout. + * */ + public boolean requiresLayout() { + return false; + } +} diff --git a/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java b/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java new file mode 100644 index 0000000000..b29e84761b --- /dev/null +++ b/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.varia; + +import org.apache.log4j.PropertyConfigurator; +import org.apache.log4j.spi.Configurator; +import java.net.URL; +import org.apache.log4j.spi.LoggerRepository; + +public class ReloadingPropertyConfigurator implements Configurator { + + + PropertyConfigurator delegate = new PropertyConfigurator(); + + + public ReloadingPropertyConfigurator() { + } + + public + void doConfigure(URL url, LoggerRepository repository) { + } + +} diff --git a/src/java/org/apache/log4j/varia/Roller.java b/src/main/java/org/apache/log4j/varia/Roller.java similarity index 71% rename from src/java/org/apache/log4j/varia/Roller.java rename to src/main/java/org/apache/log4j/varia/Roller.java index d416896a40..7ef3aee610 100644 --- a/src/java/org/apache/log4j/varia/Roller.java +++ b/src/main/java/org/apache/log4j/varia/Roller.java @@ -1,14 +1,23 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.varia; -import org.apache.log4j.Category; +import org.apache.log4j.Logger; import org.apache.log4j.BasicConfigurator; import java.io.IOException; @@ -29,7 +38,7 @@ @since version 0.9.0 */ public class Roller { - static Category cat = Category.getInstance(Roller.class.getName()); + static Logger cat = Logger.getLogger(Roller.class); static String host; diff --git a/src/java/org/apache/log4j/varia/StringMatchFilter.java b/src/main/java/org/apache/log4j/varia/StringMatchFilter.java similarity index 61% rename from src/java/org/apache/log4j/varia/StringMatchFilter.java rename to src/main/java/org/apache/log4j/varia/StringMatchFilter.java index 457eddf31a..6ee7ec473b 100644 --- a/src/java/org/apache/log4j/varia/StringMatchFilter.java +++ b/src/main/java/org/apache/log4j/varia/StringMatchFilter.java @@ -1,9 +1,18 @@ /* - * 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.txt file. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.varia; @@ -13,29 +22,19 @@ import org.apache.log4j.helpers.OptionConverter; /** - This is a very simple filter based on string matching. - - -

    The filter admits two options StringToMatch and - AcceptOnMatch. If there is a match between the value of the - StringToMatch option and the message of the {@link LoggingEvent}, - then the {@link #decide} method returns {@link Filter#ACCEPT} if - the AcceptOnMatch option value is true, if it is false then - {@link Filter#DENY} is returned. If there is no match, {@link - Filter#NEUTRAL} is returned. - -

    See configuration files test6.xml, test7.xml, test8.xml, test9.xml, and test10.xml for examples of - seeting up a StringMatchFilter. - - - @author Ceki Gülcü - - @since 0.9.0 */ + * This is a very simple filter based on string matching. + * + *

    The filter admits two options StringToMatch and + * AcceptOnMatch. If there is a match between the value of the + * StringToMatch option and the message of the {@link org.apache.log4j.spi.LoggingEvent}, + * then the {@link #decide(LoggingEvent)} method returns {@link org.apache.log4j.spi.Filter#ACCEPT} if + * the AcceptOnMatch option value is true, if it is false then + * {@link org.apache.log4j.spi.Filter#DENY} is returned. If there is no match, {@link + * org.apache.log4j.spi.Filter#NEUTRAL} is returned. + * + * @author Ceki Gülcü + * @since 0.9.0 + */ public class StringMatchFilter extends Filter { /** diff --git a/src/java/org/apache/log4j/varia/package.html b/src/main/java/org/apache/log4j/varia/package.html similarity index 100% rename from src/java/org/apache/log4j/varia/package.html rename to src/main/java/org/apache/log4j/varia/package.html diff --git a/src/java/org/apache/log4j/xml/DOMConfigurator.java b/src/main/java/org/apache/log4j/xml/DOMConfigurator.java similarity index 65% rename from src/java/org/apache/log4j/xml/DOMConfigurator.java rename to src/main/java/org/apache/log4j/xml/DOMConfigurator.java index 8060989d80..15b04661da 100644 --- a/src/java/org/apache/log4j/xml/DOMConfigurator.java +++ b/src/main/java/org/apache/log4j/xml/DOMConfigurator.java @@ -1,33 +1,60 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.xml; -import java.util.*; - -import java.net.URL; - -import org.w3c.dom.*; -import java.lang.reflect.Method; -import org.apache.log4j.*; -import org.apache.log4j.spi.*; -import org.apache.log4j.or.RendererMap; -import org.apache.log4j.helpers.*; +import org.apache.log4j.Appender; +import org.apache.log4j.Layout; +import org.apache.log4j.Level; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; import org.apache.log4j.config.PropertySetter; - +import org.apache.log4j.helpers.FileWatchdog; +import org.apache.log4j.helpers.Loader; +import org.apache.log4j.helpers.LogLog; +import org.apache.log4j.helpers.OptionConverter; +import org.apache.log4j.or.RendererMap; +import org.apache.log4j.spi.AppenderAttachable; +import org.apache.log4j.spi.Configurator; +import org.apache.log4j.spi.ErrorHandler; +import org.apache.log4j.spi.Filter; +import org.apache.log4j.spi.LoggerFactory; +import org.apache.log4j.spi.LoggerRepository; +import org.apache.log4j.spi.OptionHandler; +import org.apache.log4j.spi.RendererSupport; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import org.xml.sax.InputSource; -import java.io.FileInputStream; +import org.xml.sax.SAXException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.FactoryConfigurationError; +import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.io.Reader; -import java.io.IOException; +import java.lang.reflect.Method; import java.net.URL; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.FactoryConfigurationError; +import java.util.Hashtable; +import java.util.Properties; // Contributors: Mark Womack // Arun Katkere @@ -36,7 +63,7 @@ Use this class to initialize the log4j environment using a DOM tree.

    The DTD is specified in log4j.dtd. + href="log4j.dtd">log4j.dtd.

    Sometimes it is useful to see how log4j is reading configuration files. You can enable log4j internal logging by defining the @@ -69,6 +96,7 @@ public class DOMConfigurator implements Configurator { static final String LOGGER = "logger"; static final String LOGGER_REF = "logger-ref"; static final String CATEGORY_FACTORY_TAG = "categoryFactory"; + static final String LOGGER_FACTORY_TAG = "loggerFactory"; static final String NAME_ATTR = "name"; static final String CLASS_ATTR = "class"; static final String VALUE_ATTR = "value"; @@ -98,6 +126,8 @@ public class DOMConfigurator implements Configurator { Properties props; LoggerRepository repository; + protected LoggerFactory catFactory = null; + /** No argument constructor. */ @@ -153,6 +183,48 @@ Appender findAppenderByReference(Element appenderRef) { return findAppenderByName(doc, appenderName); } + /** + * Delegates unrecognized content to created instance if + * it supports UnrecognizedElementParser. + * @since 1.2.15 + * @param instance instance, may be null. + * @param element element, may not be null. + * @param props properties + * @throws IOException thrown if configuration of owner object + * should be abandoned. + */ + private static void parseUnrecognizedElement(final Object instance, + final Element element, + final Properties props) throws Exception { + boolean recognized = false; + if (instance instanceof UnrecognizedElementHandler) { + recognized = ((UnrecognizedElementHandler) instance).parseUnrecognizedElement( + element, props); + } + if (!recognized) { + LogLog.warn("Unrecognized element " + element.getNodeName()); + } + } + + /** + * Delegates unrecognized content to created instance if + * it supports UnrecognizedElementParser and catches and + * logs any exception. + * @since 1.2.15 + * @param instance instance, may be null. + * @param element element, may not be null. + * @param props properties + */ + private static void quietParseUnrecognizedElement(final Object instance, + final Element element, + final Properties props) { + try { + parseUnrecognizedElement(instance, element, props); + } catch (Exception ex) { + LogLog.error("Error in extension content: ", ex); + } + } + /** Used internally to parse an appender element. */ @@ -161,7 +233,7 @@ Appender parseAppender (Element appenderElement) { String className = subst(appenderElement.getAttribute(CLASS_ATTR)); LogLog.debug("Class name: [" + className+']'); try { - Object instance = Class.forName(className).newInstance(); + Object instance = Loader.loadClass(className).newInstance(); Appender appender = (Appender)instance; PropertySetter propSetter = new PropertySetter(appender); @@ -204,7 +276,9 @@ else if (currentElement.getTagName().equals(APPENDER_REF_TAG)) { refName+ "] to appender named ["+ appender.getName()+ "] which does not implement org.apache.log4j.spi.AppenderAttachable."); } - } + } else { + parseUnrecognizedElement(instance, currentElement, props); + } } } propSetter.activate(); @@ -247,12 +321,15 @@ void parseErrorHandler(Element element, Appender appender) { eh.setBackupAppender(findAppenderByReference(currentElement)); } else if(tagName.equals(LOGGER_REF)) { String loggerName = currentElement.getAttribute(REF_ATTR); - Logger logger = repository.getLogger(loggerName); + Logger logger = (catFactory == null) ? repository.getLogger(loggerName) + : repository.getLogger(loggerName, catFactory); eh.setLogger(logger); } else if(tagName.equals(ROOT_REF)) { Logger root = repository.getRootLogger(); eh.setLogger(root); - } + } else { + quietParseUnrecognizedElement(eh, currentElement, props); + } } } propSetter.activate(); @@ -281,7 +358,9 @@ void parseFilters(Element element, Appender appender) { String tagName = currentElement.getTagName(); if(tagName.equals(PARAM_TAG)) { setParameter(currentElement, propSetter); - } + } else { + quietParseUnrecognizedElement(filter, currentElement, props); + } } } propSetter.activate(); @@ -306,12 +385,12 @@ void parseCategory (Element loggerElement) { if(EMPTY_STR.equals(className)) { LogLog.debug("Retreiving an instance of org.apache.log4j.Logger."); - cat = repository.getLogger(catName); + cat = (catFactory == null) ? repository.getLogger(catName) : repository.getLogger(catName, catFactory); } else { LogLog.debug("Desired logger sub-class: ["+className+']'); try { - Class clazz = Class.forName(className); + Class clazz = Loader.loadClass(className); Method getInstanceMethod = clazz.getMethod("getLogger", ONE_STRING_PARAM); cat = (Logger) getInstanceMethod.invoke(null, new Object[] {catName}); @@ -350,10 +429,15 @@ void parseCategoryFactory(Element factoryElement) { } else { LogLog.debug("Desired category factory: ["+className+']'); - Object catFactory = OptionConverter.instantiateByClassName(className, + Object factory = OptionConverter.instantiateByClassName(className, LoggerFactory.class, null); - PropertySetter propSetter = new PropertySetter(catFactory); + if (factory instanceof LoggerFactory) { + catFactory = (LoggerFactory) factory; + } else { + LogLog.error("Category Factory class " + className + " does not implement org.apache.log4j.LoggerFactory"); + } + PropertySetter propSetter = new PropertySetter(factory); Element currentElement = null; Node currentNode = null; @@ -366,7 +450,9 @@ void parseCategoryFactory(Element factoryElement) { currentElement = (Element)currentNode; if (currentElement.getTagName().equals(PARAM_TAG)) { setParameter(currentElement, propSetter); - } + } else { + quietParseUnrecognizedElement(factory, currentElement, props); + } } } } @@ -428,7 +514,9 @@ void parseChildrenOfLoggerElement(Element catElement, parseLevel(currentElement, cat, isRoot); } else if(tagName.equals(PARAM_TAG)) { setParameter(currentElement, propSetter); - } + } else { + quietParseUnrecognizedElement(cat, currentElement, props); + } } } propSetter.activate(); @@ -442,7 +530,7 @@ Layout parseLayout (Element layout_element) { String className = subst(layout_element.getAttribute(CLASS_ATTR)); LogLog.debug("Parsing layout of class: \""+className+"\""); try { - Object instance = Class.forName(className).newInstance(); + Object instance = Loader.loadClass(className).newInstance(); Layout layout = (Layout)instance; PropertySetter propSetter = new PropertySetter(layout); @@ -456,7 +544,9 @@ Layout parseLayout (Element layout_element) { String tagName = currentElement.getTagName(); if(tagName.equals(PARAM_TAG)) { setParameter(currentElement, propSetter); - } + } else { + parseUnrecognizedElement(instance, currentElement, props); + } } } @@ -493,7 +583,7 @@ void parseLevel(Element element, Logger logger, boolean isRoot) { String priStr = subst(element.getAttribute(VALUE_ATTR)); LogLog.debug("Level value for "+catName+" is ["+priStr+"]."); - if(INHERITED.equals(priStr)) { + if(INHERITED.equalsIgnoreCase(priStr) || NULL.equalsIgnoreCase(priStr)) { if(isRoot) { LogLog.error("Root level cannot be inherited. Ignoring directive."); } else { @@ -506,7 +596,7 @@ void parseLevel(Element element, Logger logger, boolean isRoot) { } else { LogLog.debug("Desired Level sub-class: ["+className+']'); try { - Class clazz = Class.forName(className); + Class clazz = Loader.loadClass(className); Method toLevelMethod = clazz.getMethod("toLevel", ONE_STRING_PARAM); Level pri = (Level) toLevelMethod.invoke(null, @@ -524,10 +614,7 @@ void parseLevel(Element element, Logger logger, boolean isRoot) { protected void setParameter(Element elem, PropertySetter propSetter) { - String name = subst(elem.getAttribute(NAME_ATTR)); - String value = (elem.getAttribute(VALUE_ATTR)); - value = subst(OptionConverter.convertSpecialChars(value)); - propSetter.setProperty(name, value); + setParameter(elem, propSetter, props); } @@ -575,34 +662,37 @@ void configureAndWatch(String configFilename, long delay) { xdog.setDelay(delay); xdog.start(); } + + private interface ParseAction { + Document parse(final DocumentBuilder parser) throws SAXException, IOException; + } + public - void doConfigure(String filename, LoggerRepository repository) { - FileInputStream fis = null; - try { - fis = new FileInputStream(filename); - doConfigure(fis, repository); - } catch(IOException e) { - LogLog.error("Could not open ["+filename+"].", e); - } finally { - if (fis != null) { - try { - fis.close(); - } catch(java.io.IOException e) { - LogLog.error("Could not close ["+filename+"].", e); - } - } - } + void doConfigure(final String filename, LoggerRepository repository) { + ParseAction action = new ParseAction() { + public Document parse(final DocumentBuilder parser) throws SAXException, IOException { + return parser.parse(new File(filename)); + } + public String toString() { + return "file [" + filename + "]"; + } + }; + doConfigure(action, repository); } public - void doConfigure(URL url, LoggerRepository repository) { - try { - doConfigure(url.openStream(), repository); - } catch(IOException e) { - LogLog.error("Could not open ["+url+"].", e); - } + void doConfigure(final URL url, LoggerRepository repository) { + ParseAction action = new ParseAction() { + public Document parse(final DocumentBuilder parser) throws SAXException, IOException { + return parser.parse(url.toString()); + } + public String toString() { + return "url [" + url.toString() + "]"; + } + }; + doConfigure(action, repository); } /** @@ -611,9 +701,19 @@ void doConfigure(URL url, LoggerRepository repository) { */ public - void doConfigure(InputStream inputStream, LoggerRepository repository) + void doConfigure(final InputStream inputStream, LoggerRepository repository) throws FactoryConfigurationError { - doConfigure(new InputSource(inputStream), repository); + ParseAction action = new ParseAction() { + public Document parse(final DocumentBuilder parser) throws SAXException, IOException { + InputSource inputSource = new InputSource(inputStream); + inputSource.setSystemId("dummy://log4j.dtd"); + return parser.parse(inputSource); + } + public String toString() { + return "input stream [" + inputStream.toString() + "]"; + } + }; + doConfigure(action, repository); } /** @@ -622,9 +722,19 @@ void doConfigure(InputStream inputStream, LoggerRepository repository) */ public - void doConfigure(Reader reader, LoggerRepository repository) + void doConfigure(final Reader reader, LoggerRepository repository) throws FactoryConfigurationError { - doConfigure(new InputSource(reader), repository); + ParseAction action = new ParseAction() { + public Document parse(final DocumentBuilder parser) throws SAXException, IOException { + InputSource inputSource = new InputSource(reader); + inputSource.setSystemId("dummy://log4j.dtd"); + return parser.parse(inputSource); + } + public String toString() { + return "reader [" + reader.toString() + "]"; + } + }; + doConfigure(action, repository); } /** @@ -633,8 +743,25 @@ void doConfigure(Reader reader, LoggerRepository repository) */ protected - void doConfigure(InputSource inputSource, LoggerRepository repository) + void doConfigure(final InputSource inputSource, LoggerRepository repository) throws FactoryConfigurationError { + if (inputSource.getSystemId() == null) { + inputSource.setSystemId("dummy://log4j.dtd"); + } + ParseAction action = new ParseAction() { + public Document parse(final DocumentBuilder parser) throws SAXException, IOException { + return parser.parse(inputSource); + } + public String toString() { + return "input source [" + inputSource.toString() + "]"; + } + }; + doConfigure(action, repository); + } + + + private final void doConfigure(final ParseAction action, final LoggerRepository repository) + throws FactoryConfigurationError { DocumentBuilderFactory dbf = null; this.repository = repository; try { @@ -651,39 +778,28 @@ void doConfigure(InputSource inputSource, LoggerRepository repository) } try { - // This makes ID/IDREF attributes to have a meaning. Don't ask - // me why. dbf.setValidating(true); - //dbf.setNamespaceAware(true); DocumentBuilder docBuilder = dbf.newDocumentBuilder(); - docBuilder.setErrorHandler(new SAXErrorHandler()); - Class clazz = this.getClass(); - URL dtdURL = clazz.getResource("/org/apache/log4j/xml/log4j.dtd"); - if(dtdURL == null) { - LogLog.error("Could not find [log4j.dtd]. Used ["+clazz.getClassLoader()+ - "] class loader in the search."); - } - else { - LogLog.debug("URL to log4j.dtd is [" + dtdURL.toString()+"]."); - inputSource.setSystemId(dtdURL.toString()); - } - Document doc = docBuilder.parse(inputSource); + docBuilder.setErrorHandler(new SAXErrorHandler()); + docBuilder.setEntityResolver(new Log4jEntityResolver()); + + Document doc = action.parse(docBuilder); parse(doc.getDocumentElement()); } catch (Exception e) { // I know this is miserable... - LogLog.error("Could not parse input source ["+inputSource+"].", e); + LogLog.error("Could not parse "+ action.toString() + ".", e); } } - /** - Configure by taking in an DOM element. - */ - public void doConfigure(Element element, LoggerRepository repository) { - this.repository = repository; - parse(element); - } + /** + Configure by taking in an DOM element. + */ + public void doConfigure(Element element, LoggerRepository repository) { + this.repository = repository; + parse(element); + } /** @@ -733,9 +849,9 @@ void parse(Element element) { // "debug" attribute is returned as the empty string. if(!debugAttrib.equals("") && !debugAttrib.equals("null")) { LogLog.setInternalDebugging(OptionConverter.toBoolean(debugAttrib, true)); - } - else + } else { LogLog.debug("Ignoring " + INTERNAL_DEBUG_ATTR + " attribute."); + } String confDebug = subst(element.getAttribute(CONFIG_DEBUG_ATTR)); @@ -772,7 +888,7 @@ void parse(Element element) { currentElement = (Element) currentNode; tagName = currentElement.getTagName(); - if (tagName.equals(CATEGORY_FACTORY_TAG)) { + if (tagName.equals(CATEGORY_FACTORY_TAG) || tagName.equals(LOGGER_FACTORY_TAG)) { parseCategoryFactory(currentElement); } } @@ -790,32 +906,112 @@ void parse(Element element) { parseRoot(currentElement); } else if(tagName.equals(RENDERER_TAG)) { parseRenderer(currentElement); - } + } else if (!(tagName.equals(APPENDER_TAG) + || tagName.equals(CATEGORY_FACTORY_TAG) + || tagName.equals(LOGGER_FACTORY_TAG))) { + quietParseUnrecognizedElement(repository, currentElement, props); + } } } } protected - String subst(String value) { - try { - return OptionConverter.substVars(value, props); - } catch(IllegalArgumentException e) { - LogLog.warn("Could not perform variable substitution.", e); - return value; - } + String subst(final String value) { + return subst(value, props); } + + /** + * Substitutes property value for any references in expression. + * + * @param value value from configuration file, may contain + * literal text, property references or both + * @param props properties. + * @return evaluated expression, may still contain expressions + * if unable to expand. + * @since 1.2.15 + */ + public static String subst(final String value, final Properties props) { + try { + return OptionConverter.substVars(value, props); + } catch (IllegalArgumentException e) { + LogLog.warn("Could not perform variable substitution.", e); + return value; + } + } + + + /** + * Sets a parameter based from configuration file content. + * + * @param elem param element, may not be null. + * @param propSetter property setter, may not be null. + * @param props properties + * @since 1.2.15 + */ + public static void setParameter(final Element elem, + final PropertySetter propSetter, + final Properties props) { + String name = subst(elem.getAttribute("name"), props); + String value = (elem.getAttribute("value")); + value = subst(OptionConverter.convertSpecialChars(value), props); + propSetter.setProperty(name, value); + } + + /** + * Creates an object and processes any nested param elements + * but does not call activateOptions. If the class also supports + * UnrecognizedElementParser, the parseUnrecognizedElement method + * will be call for any child elements other than param. + * + * @param element element, may not be null. + * @param props properties + * @param expectedClass interface or class expected to be implemented + * by created class + * @return created class or null. + * @throws Exception thrown if the contain object should be abandoned. + * @since 1.2.15 + */ + public static Object parseElement(final Element element, + final Properties props, + final Class expectedClass) throws Exception { + String clazz = subst(element.getAttribute("class"), props); + Object instance = OptionConverter.instantiateByClassName(clazz, + expectedClass, null); + + if (instance != null) { + PropertySetter propSetter = new PropertySetter(instance); + NodeList children = element.getChildNodes(); + final int length = children.getLength(); + + for (int loop = 0; loop < length; loop++) { + Node currentNode = children.item(loop); + if (currentNode.getNodeType() == Node.ELEMENT_NODE) { + Element currentElement = (Element) currentNode; + String tagName = currentElement.getTagName(); + if (tagName.equals("param")) { + setParameter(currentElement, propSetter, props); + } else { + parseUnrecognizedElement(instance, currentElement, props); + } + } + } + return instance; + } + return null; + } + } class XMLWatchdog extends FileWatchdog { - XMLWatchdog(String filename) { + XMLWatchdog(String filename) { super(filename); } /** - Call {@link PropertyConfigurator#configure(String)} with the + Call {@link DOMConfigurator#configure(String)} with the filename to reconfigure log4j. */ public void doOnChange() { diff --git a/src/main/java/org/apache/log4j/xml/Log4jEntityResolver.java b/src/main/java/org/apache/log4j/xml/Log4jEntityResolver.java new file mode 100644 index 0000000000..a1b939e1e5 --- /dev/null +++ b/src/main/java/org/apache/log4j/xml/Log4jEntityResolver.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.xml; + +import org.apache.log4j.helpers.LogLog; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; + +import java.io.InputStream; + +/** + * An {@link EntityResolver} specifically designed to return + * log4j.dtd which is embedded within the log4j jar + * file. + * + * @author Paul Austin + * */ +public class Log4jEntityResolver implements EntityResolver { + + public InputSource resolveEntity (String publicId, String systemId) { + if (systemId.endsWith("log4j.dtd")) { + Class clazz = getClass(); + InputStream in = clazz.getResourceAsStream("/org/apache/log4j/xml/log4j.dtd"); + if (in == null) { + LogLog.error("Could not find [log4j.dtd]. Used [" + clazz.getClassLoader() + + "] class loader in the search."); + return null; + } else { + return new InputSource(in); + } + } else { + return null; + } + } +} diff --git a/src/main/java/org/apache/log4j/xml/SAXErrorHandler.java b/src/main/java/org/apache/log4j/xml/SAXErrorHandler.java new file mode 100644 index 0000000000..43e851bb6c --- /dev/null +++ b/src/main/java/org/apache/log4j/xml/SAXErrorHandler.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.xml; + +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXParseException; +import org.apache.log4j.helpers.LogLog; + +public class SAXErrorHandler implements ErrorHandler { + + public + void error(final SAXParseException ex) { + emitMessage("Continuable parsing error ", ex); + } + + public + void fatalError(final SAXParseException ex) { + emitMessage("Fatal parsing error ", ex); + } + + public + void warning(final SAXParseException ex) { + emitMessage("Parsing warning ", ex); + } + + private static void emitMessage(final String msg, final SAXParseException ex) { + LogLog.warn(msg +ex.getLineNumber()+" and column " + +ex.getColumnNumber()); + LogLog.warn(ex.getMessage(), ex.getException()); + } +} diff --git a/src/main/java/org/apache/log4j/xml/UnrecognizedElementHandler.java b/src/main/java/org/apache/log4j/xml/UnrecognizedElementHandler.java new file mode 100644 index 0000000000..463d5d989d --- /dev/null +++ b/src/main/java/org/apache/log4j/xml/UnrecognizedElementHandler.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.log4j.xml; + +import org.w3c.dom.Element; +import java.util.Properties; + +/** + * When implemented by an object configured by DOMConfigurator, + * the handle method will be called when an unrecognized child + * element is encountered. Unrecognized child elements of + * the log4j:configuration element will be dispatched to + * the logger repository if it supports this interface. + * + * @since 1.2.15 + */ +public interface UnrecognizedElementHandler { + /** + * Called to inform a configured object when + * an unrecognized child element is encountered. + * @param element element, may not be null. + * @param props properties in force, may be null. + * @return true if configured object recognized the element + * @throws Exception throw an exception to prevent activation + * of the configured object. + */ + boolean parseUnrecognizedElement(Element element, Properties props) throws Exception; +} \ No newline at end of file diff --git a/src/main/java/org/apache/log4j/xml/XMLLayout.java b/src/main/java/org/apache/log4j/xml/XMLLayout.java new file mode 100644 index 0000000000..62cc5d8f29 --- /dev/null +++ b/src/main/java/org/apache/log4j/xml/XMLLayout.java @@ -0,0 +1,214 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Contributors: Mathias Bogaert + +package org.apache.log4j.xml; + +import org.apache.log4j.Layout; +import org.apache.log4j.helpers.Transform; +import org.apache.log4j.spi.LocationInfo; +import org.apache.log4j.spi.LoggingEvent; + +import java.util.Set; +import java.util.Arrays; + +/** + * The output of the XMLLayout consists of a series of log4j:event + * elements as defined in the log4j.dtd. It does not output a + * complete well-formed XML file. The output is designed to be + * included as an external entity in a separate file to form + * a correct XML file. + * + *

    For example, if abc is the name of the file where + * the XMLLayout ouput goes, then a well-formed XML file would be: + * +

    +   <?xml version="1.0" ?>
    + 
    +  <!DOCTYPE log4j:eventSet SYSTEM "log4j.dtd" [<!ENTITY data SYSTEM "abc">]>
    + 
    +  <log4j:eventSet version="1.2" xmlns:log4j="http://jakarta.apache.org/log4j/">
    + 	  &data;
    +  </log4j:eventSet>
    +  
    + + *

    This approach enforces the independence of the XMLLayout and the + * appender where it is embedded. + * + *

    The version attribute helps components to correctly + * intrepret output generated by XMLLayout. The value of this + * attribute should be "1.1" for output generated by log4j versions + * prior to log4j 1.2 (final release) and "1.2" for relase 1.2 and + * later. + * + * Appenders using this layout should have their encoding + * set to UTF-8 or UTF-16, otherwise events containing + * non ASCII characters could result in corrupted + * log files. + * + * @author Ceki Gülcü + * @since 0.9.0 + * */ +public class XMLLayout extends Layout { + + private final int DEFAULT_SIZE = 256; + private final int UPPER_LIMIT = 2048; + + private StringBuffer buf = new StringBuffer(DEFAULT_SIZE); + private boolean locationInfo = false; + private boolean properties = false; + + /** + * The LocationInfo option takes a boolean value. By default, + * it is set to false which means there will be no location + * information output by this layout. If the the option is set to + * true, then the file name and line number of the statement at the + * origin of the log statement will be output. + * + *

    If you are embedding this layout within an {@link + * org.apache.log4j.net.SMTPAppender} then make sure to set the + * LocationInfo option of that appender as well. + * */ + public void setLocationInfo(boolean flag) { + locationInfo = flag; + } + + /** + Returns the current value of the LocationInfo option. + */ + public boolean getLocationInfo() { + return locationInfo; + } + + /** + * Sets whether MDC key-value pairs should be output, default false. + * @param flag new value. + */ + public void setProperties(final boolean flag) { + properties = flag; + } + + /** + * Gets whether MDC key-value pairs should be output. + * @return true if MDC key-value pairs are output. + */ + public boolean getProperties() { + return properties; + } + + /** No options to activate. */ + public void activateOptions() { + } + + + /** + * Formats a {@link org.apache.log4j.spi.LoggingEvent} in conformance with the log4j.dtd. + * */ + public String format(final LoggingEvent event) { + + // Reset working buffer. If the buffer is too large, then we need a new + // one in order to avoid the penalty of creating a large array. + if(buf.capacity() > UPPER_LIMIT) { + buf = new StringBuffer(DEFAULT_SIZE); + } else { + buf.setLength(0); + } + + // We yield to the \r\n heresy. + + buf.append("\r\n"); + + buf.append("\r\n"); + + String ndc = event.getNDC(); + if(ndc != null) { + buf.append("\r\n"); + } + + String[] s = event.getThrowableStrRep(); + if(s != null) { + buf.append("\r\n"); + } + + if(locationInfo) { + LocationInfo locationInfo = event.getLocationInformation(); + buf.append("\r\n"); + } + + if (properties) { + Set keySet = event.getPropertyKeySet(); + if (keySet.size() > 0) { + buf.append("\r\n"); + Object[] keys = keySet.toArray(); + Arrays.sort(keys); + for (int i = 0; i < keys.length; i++) { + String key = keys[i].toString(); + Object val = event.getMDC(key); + if (val != null) { + buf.append("\r\n"); + } + } + buf.append("\r\n"); + } + } + + buf.append("\r\n\r\n"); + + return buf.toString(); + } + + /** + The XMLLayout prints and does not ignore exceptions. Hence the + return value false. + */ + public boolean ignoresThrowable() { + return false; + } +} diff --git a/src/java/org/apache/log4j/xml/package.html b/src/main/java/org/apache/log4j/xml/package.html similarity index 100% rename from src/java/org/apache/log4j/xml/package.html rename to src/main/java/org/apache/log4j/xml/package.html diff --git a/src/main/javadoc/org/apache/log4j/xml/examples/XMLSample.java b/src/main/javadoc/org/apache/log4j/xml/examples/XMLSample.java new file mode 100644 index 0000000000..8ea09f2844 --- /dev/null +++ b/src/main/javadoc/org/apache/log4j/xml/examples/XMLSample.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.xml.examples; + +import org.apache.log4j.xml.DOMConfigurator; +import org.apache.log4j.Logger; + +/** + + This example code shows how to + read an XML based configuration file using a DOM parser. + +

    Sample XML files sample1.xml + and sample2.xml are provided. + + +

    Note that the log4j.dtd is not in the local directory. + It is found by the class loader. + + @author Ceki Gülcü + +*/ +public class XMLSample { + + static Logger cat = Logger.getLogger(XMLSample.class); + + public + static + void main(String argv[]) { + + if(argv.length == 1) + init(argv[0]); + else + Usage("Wrong number of arguments."); + sample(); + } + + static + void Usage(String msg) { + System.err.println(msg); + System.err.println( "Usage: java " + XMLSample.class.getName() + + "configFile"); + System.exit(1); + } + + static + void init(String configFile) { + DOMConfigurator.configure(configFile); + } + + static + void sample() { + int i = -1; + cat.debug("Message " + ++i); + cat.warn ("Message " + ++i); + cat.error("Message " + ++i); + Exception e = new Exception("Just testing"); + cat.debug("Message " + ++i, e); + } +} diff --git a/src/java/org/apache/log4j/xml/examples/sample1.xml b/src/main/javadoc/org/apache/log4j/xml/examples/sample1.xml similarity index 100% rename from src/java/org/apache/log4j/xml/examples/sample1.xml rename to src/main/javadoc/org/apache/log4j/xml/examples/sample1.xml diff --git a/src/java/org/apache/log4j/xml/examples/sample2.xml b/src/main/javadoc/org/apache/log4j/xml/examples/sample2.xml similarity index 100% rename from src/java/org/apache/log4j/xml/examples/sample2.xml rename to src/main/javadoc/org/apache/log4j/xml/examples/sample2.xml diff --git a/src/java/org/apache/log4j/xml/examples/sample3.xml b/src/main/javadoc/org/apache/log4j/xml/examples/sample3.xml similarity index 100% rename from src/java/org/apache/log4j/xml/examples/sample3.xml rename to src/main/javadoc/org/apache/log4j/xml/examples/sample3.xml diff --git a/src/java/org/apache/log4j/xml/examples/sample4.xml b/src/main/javadoc/org/apache/log4j/xml/examples/sample4.xml similarity index 100% rename from src/java/org/apache/log4j/xml/examples/sample4.xml rename to src/main/javadoc/org/apache/log4j/xml/examples/sample4.xml diff --git a/src/java/org/apache/log4j/xml/examples/sample5.xml b/src/main/javadoc/org/apache/log4j/xml/examples/sample5.xml similarity index 100% rename from src/java/org/apache/log4j/xml/examples/sample5.xml rename to src/main/javadoc/org/apache/log4j/xml/examples/sample5.xml diff --git a/src/java/org/apache/log4j/xml/log4j.dtd b/src/main/javadoc/org/apache/log4j/xml/log4j.dtd similarity index 66% rename from src/java/org/apache/log4j/xml/log4j.dtd rename to src/main/javadoc/org/apache/log4j/xml/log4j.dtd index 12f373cdba..66f8fcb36a 100644 --- a/src/java/org/apache/log4j/xml/log4j.dtd +++ b/src/main/javadoc/org/apache/log4j/xml/log4j.dtd @@ -8,23 +8,25 @@ elements,appender elements, categories and an optional root element. --> - + - - - + + - - - - - + + + + + + + + @@ -40,9 +42,11 @@ element. --> - + @@ -68,7 +72,7 @@ element. --> @@ -106,7 +110,7 @@ element. --> @@ -115,11 +119,45 @@ element. --> + + + + + + + + + + + + + + + + + + + + @@ -143,8 +181,8 @@ element. --> diff --git a/src/main/resources/META-INF/LICENSE b/src/main/resources/META-INF/LICENSE new file mode 100644 index 0000000000..6279e5206d --- /dev/null +++ b/src/main/resources/META-INF/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2005 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..0375732360 --- /dev/null +++ b/src/main/resources/META-INF/NOTICE @@ -0,0 +1,5 @@ +Apache log4j +Copyright 2007 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties b/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties new file mode 100644 index 0000000000..10e30ba828 --- /dev/null +++ b/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties @@ -0,0 +1,16 @@ +# For the general syntax of property based configuration files see the +# documenation of org.apache.log4j.PropertyConfigurator. + +# The root category uses the appender called A1. Since no priority is +# specified, the root category assumes the default priority for root +# which is DEBUG in log4j. The root category is the only category that +# has a default priority. All other categories need not be assigned a +# priority in which case they inherit their priority from the +# hierarchy. + +log4j.rootCategory=, A1 + +# A1 is set to be a LogMonitorAppender which outputs to a swing +# logging console. + +log4j.appender.A1=org.apache.log4j.lf5.LF5Appender diff --git a/src/java/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif b/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif similarity index 100% rename from src/java/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif rename to src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif diff --git a/src/java/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif b/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif similarity index 100% rename from src/java/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif rename to src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif diff --git a/src/java/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif b/src/main/resources/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif similarity index 100% rename from src/java/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif rename to src/main/resources/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif diff --git a/src/main/resources/org/apache/log4j/xml/log4j.dtd b/src/main/resources/org/apache/log4j/xml/log4j.dtd new file mode 100644 index 0000000000..63d28c990f --- /dev/null +++ b/src/main/resources/org/apache/log4j/xml/log4j.dtd @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/apache/log4j/xml/logger.dtd b/src/main/resources/org/apache/log4j/xml/logger.dtd new file mode 100644 index 0000000000..d5f40b78e7 --- /dev/null +++ b/src/main/resources/org/apache/log4j/xml/logger.dtd @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ntdll/EventLogCategories.mc b/src/ntdll/EventLogCategories.mc new file mode 100644 index 0000000000..f017900055 --- /dev/null +++ b/src/ntdll/EventLogCategories.mc @@ -0,0 +1,46 @@ +; +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. +; +MessageId=1 +Language=English +Trace +. +MessageId=2 +Language=English +Debug +. +MessageId=3 +Language=English +Info +. +MessageId=4 +Language=English +Warn +. +MessageId=5 +Language=English +Error +. +MessageId=6 +Language=English +Fatal +. +MessageId=0x1000 +Language=English +%1 +. diff --git a/src/ntdll/MSG00001.bin b/src/ntdll/MSG00001.bin new file mode 100644 index 0000000000..b6a1996851 Binary files /dev/null and b/src/ntdll/MSG00001.bin differ diff --git a/src/ntdll/NTEventLogAppender.rc b/src/ntdll/NTEventLogAppender.rc new file mode 100755 index 0000000000..f5e2eb1e5f --- /dev/null +++ b/src/ntdll/NTEventLogAppender.rc @@ -0,0 +1,125 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// +// Message file include +// +LANGUAGE 0x9,0x1 +1 11 MSG00001.bin +// Microsoft Visual C++ generated resource script. +// +#include "windows.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +//#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1, 2, 15, 1 + PRODUCTVERSION 1, 2, 15, 1 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Apache Software Foundation" + VALUE "FileDescription", "Platform methods for NTEventLogAppender" + VALUE "FileVersion", "1, 2, 15, 1" + VALUE "InternalName", "NTEventLogAppender" + VALUE "LegalCopyright", "Licensed to the Apache Software Foundation (ASF) under one or more\ncontributor license agreements. See the NOTICE file distributed with\nthis work for additional information regarding copyright ownership.\nThe ASF licenses this file to You under the Apache License, Version 2.0\n(the ""License""); you may not use this file except in compliance with\nthe License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an ""AS IS"" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License." + VALUE "OriginalFilename", "NTEventLogAppender.dll" + VALUE "ProductName", "Apache log4j" + VALUE "ProductVersion", "1, 2, 15, 1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/ntdll/build.xml b/src/ntdll/build.xml new file mode 100755 index 0000000000..3a26b86c20 --- /dev/null +++ b/src/ntdll/build.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -Dclasses.dir=/path/to/log4j/classes must be specified + + + + + + + + + + + + + + + + + + + + + + ${mingw-prefix}windres could not be found or failed, NTEventLogAppender.dll build skipped. + + + + ${jni.win32.include.dir}/jni_md.h not found, NTEventLogAppender.dll build skipped. + + + + + + diff --git a/src/ntdll/nteventlog.cpp b/src/ntdll/nteventlog.cpp new file mode 100644 index 0000000000..e5a9e12fed --- /dev/null +++ b/src/ntdll/nteventlog.cpp @@ -0,0 +1,259 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NtEventLogAppender_h +#define NtEventLogAppender_h + +#ifdef __GNUC__ +typedef long long __int64; +#endif + +#include "org_apache_log4j_Priority.h" +#include "org_apache_log4j_nt_NTEventLogAppender.h" +#include +#include + + +/* + * Convert log4j Priority to an EventLog category. Each category is + * backed by a message resource so that proper category names will + * be displayed in the NT Event Viewer. + */ +WORD getCategory(jint priority) { + WORD category = 1; + if (priority >= org_apache_log4j_Priority_DEBUG_INT) { + category = 2; + if (priority >= org_apache_log4j_Priority_INFO_INT) { + category = 3; + if (priority >= org_apache_log4j_Priority_WARN_INT) { + category = 4; + if (priority >= org_apache_log4j_Priority_ERROR_INT) { + category = 5; + if (priority >= org_apache_log4j_Priority_FATAL_INT) { + category = 6; + } + } + } + } + } + return category; +} + +/* + * Convert log4j Priority to an EventLog type. The log4j package + * supports 8 defined priorites, but the NT EventLog only knows + * 3 event types of interest to us: ERROR, WARNING, and INFO. + */ +WORD getType(jint priority) { + WORD type = EVENTLOG_SUCCESS; + if (priority >= org_apache_log4j_Priority_INFO_INT) { + type = EVENTLOG_INFORMATION_TYPE; + if (priority >= org_apache_log4j_Priority_WARN_INT) { + type = EVENTLOG_WARNING_TYPE; + if (priority >= org_apache_log4j_Priority_ERROR_INT) { + type = EVENTLOG_ERROR_TYPE; + } + } + } + return type; +} + +HKEY regGetKey(wchar_t *subkey, DWORD *disposition) { + HKEY hkey = 0; + RegCreateKeyExW(HKEY_LOCAL_MACHINE, subkey, 0, NULL, + REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, + &hkey, disposition); + return hkey; +} + +void regSetString(HKEY hkey, wchar_t *name, wchar_t *value) { + RegSetValueExW(hkey, name, 0, REG_EXPAND_SZ, + (LPBYTE)value, (wcslen(value) + 1) * sizeof(wchar_t)); +} + +void regSetDword(HKEY hkey, wchar_t *name, DWORD value) { + RegSetValueExW(hkey, name, 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD)); +} + +/* + * Add this source with appropriate configuration keys to the registry. + */ +void addRegistryInfo(wchar_t *source) { + const wchar_t *prefix = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\"; + DWORD disposition; + HKEY hkey = 0; + wchar_t subkey[256]; + + wcscpy(subkey, prefix); + wcscat(subkey, source); + hkey = regGetKey(subkey, &disposition); + if (disposition == REG_CREATED_NEW_KEY) { + HMODULE hmodule = GetModuleHandleW(L"NTEventLogAppender.dll"); + if (hmodule != NULL) { + wchar_t modpath[_MAX_PATH]; + DWORD modlen = GetModuleFileNameW(hmodule, modpath, _MAX_PATH - 1); + if (modlen > 0) { + modpath[modlen] = 0; + regSetString(hkey, L"EventMessageFile", modpath); + regSetString(hkey, L"CategoryMessageFile", modpath); + } + } + regSetDword(hkey, L"TypesSupported", (DWORD)7); + regSetDword(hkey, L"CategoryCount", (DWORD) 6); + } + RegCloseKey(hkey); + return; +} + +/* + * Class: org.apache.log4j.nt.NTEventLogAppender + * Method: registerEventSource + * Signature: (Ljava/lang/String;Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_org_apache_log4j_nt_NTEventLogAppender_registerEventSource( + JNIEnv *env, jobject java_this, jstring server, jstring source) { + + jchar *nserver = 0; + jchar *nsource = 0; + + if (server != 0) { + jsize serverLen = env->GetStringLength(server); + nserver = (jchar*) malloc((serverLen +1) * sizeof(jchar)); + env->GetStringRegion(server, 0, serverLen, nserver); + nserver[serverLen] = 0; + } + if (source != 0) { + jsize sourceLen = env->GetStringLength(source); + nsource = (jchar*) malloc((sourceLen +1) * sizeof(jchar)); + env->GetStringRegion(source, 0, sourceLen, nsource); + nsource[sourceLen] = 0; + } + addRegistryInfo((wchar_t*) nsource); + jint handle = (jint)RegisterEventSourceW((const wchar_t*) nserver, (const wchar_t*) nsource); + free(nserver); + free(nsource); + return handle; +} + +/* + * Class: org_apache_log4j_nt_NTEventLogAppender + * Method: reportEvent + * Signature: (ILjava/lang/String;I)V + */ +JNIEXPORT void JNICALL Java_org_apache_log4j_nt_NTEventLogAppender_reportEvent( + JNIEnv *env, jobject java_this, jint handle, jstring jstr, jint priority) { + + jboolean localHandle = JNI_FALSE; + if (handle == 0) { + // Client didn't give us a handle so make a local one. + handle = (jint)RegisterEventSourceW(NULL, L"Log4j"); + localHandle = JNI_TRUE; + } + + // convert Java String to character array + jsize msgLen = env->GetStringLength(jstr); + jchar* msg = (jchar*) malloc((msgLen + 1) * sizeof(jchar)); + env->GetStringRegion(jstr, 0, msgLen, msg); + msg[msgLen] = 0; + + // This is the only message supported by the package. It is backed by + // a message resource which consists of just '%1' which is replaced + // by the string we just created. + const DWORD messageID = 0x1000; + ReportEventW((HANDLE)handle, getType(priority), + getCategory(priority), + messageID, NULL, 1, 0, (const wchar_t**) &msg, NULL); + + free((void *)msg); + if (localHandle == JNI_TRUE) { + // Created the handle here so free it here too. + DeregisterEventSource((HANDLE)handle); + } + return; +} + +/* + * Class: org_apache_log4j_nt_NTEventLogAppender + * Method: deregisterEventSource + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_org_apache_log4j_nt_NTEventLogAppender_deregisterEventSource( +JNIEnv *env, +jobject java_this, +jint handle) +{ + DeregisterEventSource((HANDLE)handle); +} + + +// +// Entry point which registers default event source (Log4j) +// when invoked using regsvr32 tool. +// +// +STDAPI __declspec(dllexport) DllRegisterServer(void) { + HRESULT hr = E_FAIL; + HMODULE hmodule = GetModuleHandleW(L"NTEventLogAppender.dll"); + if (hmodule != NULL) { + wchar_t modpath[_MAX_PATH]; + DWORD modlen = GetModuleFileNameW(hmodule, modpath, _MAX_PATH - 1); + if (modlen > 0) { + modpath[modlen] = 0; + const wchar_t key[] = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\Log4j"; + DWORD disposition; + HKEY hkey = 0; + + LONG stat = RegCreateKeyExW(HKEY_LOCAL_MACHINE, key, 0, NULL, + REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, + &hkey, &disposition); + if (stat == ERROR_SUCCESS) { + stat = RegSetValueExW(hkey, L"EventMessageFile", 0, REG_EXPAND_SZ, + (LPBYTE) modpath, (wcslen(modpath) + 1) * sizeof(wchar_t)); + if(stat == ERROR_SUCCESS) { + stat = RegSetValueExW(hkey, L"CategoryMessageFile", 0, REG_EXPAND_SZ, + (LPBYTE) modpath, (wcslen(modpath) + 1) * sizeof(wchar_t)); + } + if(stat == ERROR_SUCCESS) { + DWORD value = 7; + stat == RegSetValueExW(hkey, L"TypesSupported", 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD)); + } + if(stat == ERROR_SUCCESS) { + DWORD value = 6; + stat == RegSetValueExW(hkey, L"CategoryCount", 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD)); + } + LONG closeStat = RegCloseKey(hkey); + if (stat == ERROR_SUCCESS && closeStat == ERROR_SUCCESS) { + hr = S_OK; + } + } + } + } + return hr; +} + + +// +// Entry point which unregisters default event source (Log4j) +// when invoked using regsvr32 tool with /u option. +// +// +STDAPI __declspec(dllexport) DllUnregisterServer(void) { + LONG stat = RegDeleteKeyW(HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\Log4j"); + return (stat == ERROR_SUCCESS || stat == ERROR_FILE_NOT_FOUND) ? S_OK : E_FAIL; +} +#endif diff --git a/src/java/org/apache/log4j/performance/ListVsVector.java b/src/performance/java/org/apache/log4j/performance/ListVsVector.java similarity index 68% rename from src/java/org/apache/log4j/performance/ListVsVector.java rename to src/performance/java/org/apache/log4j/performance/ListVsVector.java index 16440ceae9..7f9c8a4486 100644 --- a/src/java/org/apache/log4j/performance/ListVsVector.java +++ b/src/performance/java/org/apache/log4j/performance/ListVsVector.java @@ -1,9 +1,19 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.performance; diff --git a/src/performance/java/org/apache/log4j/performance/NOPWriter.java b/src/performance/java/org/apache/log4j/performance/NOPWriter.java new file mode 100644 index 0000000000..14e932bbf8 --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/NOPWriter.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.performance; + +import java.io.Writer; +import java.io.IOException; + +/** + *

    Extends {@link Writer} with methods that return immediately + * without doing anything. This class is used to measure the cost of + * constructing a log message but not actually writing to any device. + *

    + + *

    The + * org.apache.log4j.performance.NOPWriter class is + * intended for internal use only. Consequently, it is not + * included in the log4j.jar file.

    + * + * @author Ceki Gülcü + * */ +public class NOPWriter extends Writer { + + public void write(char[] cbuf) throws IOException {} + + public void write(char[] cbuf, int off, int len) throws IOException {} + + + public void write(int b) throws IOException {} + + public void write(String s) throws IOException {} + + public void write(String s, int off, int len) throws IOException {} + + public void flush() throws IOException { + } + + public void close() throws IOException { + System.err.println("Close called."); + } +} diff --git a/src/java/org/apache/log4j/performance/NewVsSetLen.java b/src/performance/java/org/apache/log4j/performance/NewVsSetLen.java similarity index 85% rename from src/java/org/apache/log4j/performance/NewVsSetLen.java rename to src/performance/java/org/apache/log4j/performance/NewVsSetLen.java index 07f96e789d..3275bdb1a9 100644 --- a/src/java/org/apache/log4j/performance/NewVsSetLen.java +++ b/src/performance/java/org/apache/log4j/performance/NewVsSetLen.java @@ -1,9 +1,19 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.performance; @@ -160,7 +170,7 @@ void main(String[] args) { for(int second = 0; second < 16;) { System.out.println("SECOND loop="+second +", RUN_LENGTH=" +RUN_LENGTH+", len="+len); - t = (int)newBuffer(len, second);; + t = (int)newBuffer(len, second); System.out.print("" + t); t = (int)setLen(len, second); diff --git a/src/performance/java/org/apache/log4j/performance/NullAppender.java b/src/performance/java/org/apache/log4j/performance/NullAppender.java new file mode 100644 index 0000000000..32c057ad3b --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/NullAppender.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.performance; + +import org.apache.log4j.Layout; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.AppenderSkeleton; + +/** + * A bogus appender which calls the format method of its layout object + * but does not write the result anywhere. + * + *

    The + * org.apache.log4j.performance.NullAppender class is + * intended for internal use only. Consequently, it is not + * included in the log4j.jar file.

    + * */ +public class NullAppender extends AppenderSkeleton { + + public static String s; + public String t; + + public + NullAppender() {} + + public + NullAppender(Layout layout) { + this.layout = layout; + } + + public + void close() {} + + public + void doAppend(LoggingEvent event) { + if(layout != null) { + t = layout.format(event); + s = t; + } + } + + public + void append(LoggingEvent event) { + } + + /** + This is a bogus appender but it still uses a layout. + */ + public + boolean requiresLayout() { + return true; + } +} diff --git a/src/java/org/apache/log4j/performance/SystemTime.java b/src/performance/java/org/apache/log4j/performance/SystemTime.java similarity index 57% rename from src/java/org/apache/log4j/performance/SystemTime.java rename to src/performance/java/org/apache/log4j/performance/SystemTime.java index aff304c065..f5ef4d12b5 100644 --- a/src/java/org/apache/log4j/performance/SystemTime.java +++ b/src/performance/java/org/apache/log4j/performance/SystemTime.java @@ -1,9 +1,19 @@ /* - * 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. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.performance; @@ -36,9 +46,8 @@ void main(String[] args) { static double systemCurrentTimeLoop() { long before = System.currentTimeMillis(); - long l; for(int i = 0; i < RUN_LENGTH; i++) { - l = System.currentTimeMillis(); + System.currentTimeMillis(); } return (System.currentTimeMillis() - before)*1000.0/RUN_LENGTH; } @@ -46,9 +55,8 @@ void main(String[] args) { static double currentThreadNameloop() { long before = System.currentTimeMillis(); - String t; for(int i = 0; i < RUN_LENGTH; i++) { - t = Thread.currentThread().getName(); + Thread.currentThread().getName(); } return (System.currentTimeMillis() - before)*1000.0/RUN_LENGTH; } diff --git a/src/java/org/apache/log4j/performance/history/FALKNIS.logging b/src/performance/java/org/apache/log4j/performance/history/FALKNIS.logging similarity index 100% rename from src/java/org/apache/log4j/performance/history/FALKNIS.logging rename to src/performance/java/org/apache/log4j/performance/history/FALKNIS.logging diff --git a/src/java/org/apache/log4j/performance/history/GIL.logging b/src/performance/java/org/apache/log4j/performance/history/GIL.logging similarity index 100% rename from src/java/org/apache/log4j/performance/history/GIL.logging rename to src/performance/java/org/apache/log4j/performance/history/GIL.logging diff --git a/src/java/org/apache/log4j/performance/history/NAPOLI.logging b/src/performance/java/org/apache/log4j/performance/history/NAPOLI.logging similarity index 100% rename from src/java/org/apache/log4j/performance/history/NAPOLI.logging rename to src/performance/java/org/apache/log4j/performance/history/NAPOLI.logging diff --git a/src/java/org/apache/log4j/performance/history/TORINO.logging b/src/performance/java/org/apache/log4j/performance/history/TORINO.logging similarity index 100% rename from src/java/org/apache/log4j/performance/history/TORINO.logging rename to src/performance/java/org/apache/log4j/performance/history/TORINO.logging diff --git a/src/java/org/apache/log4j/performance/logging b/src/performance/java/org/apache/log4j/performance/logging similarity index 85% rename from src/java/org/apache/log4j/performance/logging rename to src/performance/java/org/apache/log4j/performance/logging index 20da7cb040..adec4f415a 100644 --- a/src/java/org/apache/log4j/performance/logging +++ b/src/performance/java/org/apache/log4j/performance/logging @@ -251,6 +251,56 @@ if [ $TEST -ge $start ]; then multiRun xml/logging$TEST.xml 8 "PatternLayout \"$format\"" $SHORTRUN fi +echo ------------------------------------- +echo "FileAppender: BufferedIO=true" +echo ------------------------------------- + +TEST=220 +if [ $TEST -ge $start ]; then + multiRun xml/logging$TEST.xml 8 "SimpleLayout" $LONGRUN +fi + +TEST=221 +if [ $TEST -ge $start ]; then + format="%p - %m%n" + multiRun xml/logging$TEST.xml 8 "PatternLayout \"$format\"" $LONGRUN +fi + +TEST=222 +if [ $TEST -ge $start ]; then + multiRun xml/logging$TEST.xml 8 "TTCC/RELATIVE" $LONGRUN +fi + +TEST=223 +if [ $TEST -ge $start ]; then + format="%r [%t] %-5p %c - %m%n" + multiRun xml/logging$TEST.xml 8 "PatternLayout \"$format\"" $LONGRUN +fi + +TEST=224 +if [ $TEST -ge $start ]; then + multiRun xml/logging$TEST.xml 8 "TTCCLayout/ISO8601" $LONGRUN +fi + +TEST=225 +if [ $TEST -ge $start ]; then + format="%d{ISO8601} [%t] %-5p %c %x - %m%n" + multiRun xml/logging$TEST.xml 8 "PatternLayout \"$format\"" $LONGRUN +fi + +TEST=226 +if [ $TEST -ge $start ]; then + format="%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n" + multiRun xml/logging$TEST.xml 8 "PatternLayout \"$format\"" $LONGRUN +fi + +TEST=227 +if [ $TEST -ge $start ]; then + format="%l - %m%n" + multiRun xml/logging$TEST.xml 8 "PatternLayout \"$format\"" $SHORTRUN +fi + + echo ================================== echo Async appender echo ================================== diff --git a/src/performance/java/org/apache/log4j/performance/package.html b/src/performance/java/org/apache/log4j/performance/package.html new file mode 100644 index 0000000000..e57b59e1f6 --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/package.html @@ -0,0 +1,19 @@ + + + + + + + +

    Package to measure the performance of the different log4j + components. +

    + +

    The + org.apache.log4j.performance package is intended + for internal use only. Consequently, the classes in this + package are not included in the log4j.jar file. +

    + + + diff --git a/src/java/org/apache/log4j/performance/xml/logging1.xml b/src/performance/java/org/apache/log4j/performance/xml/logging1.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging1.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging1.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging10.xml b/src/performance/java/org/apache/log4j/performance/xml/logging10.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging10.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging10.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging100.xml b/src/performance/java/org/apache/log4j/performance/xml/logging100.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging100.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging100.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging1000.xml b/src/performance/java/org/apache/log4j/performance/xml/logging1000.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging1000.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging1000.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging101.xml b/src/performance/java/org/apache/log4j/performance/xml/logging101.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging101.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging101.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging102.xml b/src/performance/java/org/apache/log4j/performance/xml/logging102.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging102.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging102.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging103.xml b/src/performance/java/org/apache/log4j/performance/xml/logging103.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging103.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging103.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging104.xml b/src/performance/java/org/apache/log4j/performance/xml/logging104.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging104.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging104.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging105.xml b/src/performance/java/org/apache/log4j/performance/xml/logging105.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging105.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging105.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging106.xml b/src/performance/java/org/apache/log4j/performance/xml/logging106.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging106.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging106.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging107.xml b/src/performance/java/org/apache/log4j/performance/xml/logging107.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging107.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging107.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging11.xml b/src/performance/java/org/apache/log4j/performance/xml/logging11.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging11.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging11.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging12.xml b/src/performance/java/org/apache/log4j/performance/xml/logging12.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging12.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging12.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging13.xml b/src/performance/java/org/apache/log4j/performance/xml/logging13.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging13.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging13.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging2.xml b/src/performance/java/org/apache/log4j/performance/xml/logging2.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging2.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging2.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging200.xml b/src/performance/java/org/apache/log4j/performance/xml/logging200.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging200.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging200.xml diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging201.xml b/src/performance/java/org/apache/log4j/performance/xml/logging201.xml new file mode 100644 index 0000000000..5b8fcb2dd0 --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging201.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging202.xml b/src/performance/java/org/apache/log4j/performance/xml/logging202.xml new file mode 100644 index 0000000000..ff93a004da --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging202.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging203.xml b/src/performance/java/org/apache/log4j/performance/xml/logging203.xml new file mode 100644 index 0000000000..741c49e46d --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging203.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging204.xml b/src/performance/java/org/apache/log4j/performance/xml/logging204.xml new file mode 100644 index 0000000000..ceaa45c5e2 --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging204.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging205.xml b/src/performance/java/org/apache/log4j/performance/xml/logging205.xml new file mode 100644 index 0000000000..63093dd779 --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging205.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging206.xml b/src/performance/java/org/apache/log4j/performance/xml/logging206.xml new file mode 100644 index 0000000000..cb80b32b6b --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging206.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging207.xml b/src/performance/java/org/apache/log4j/performance/xml/logging207.xml new file mode 100644 index 0000000000..22fce853cd --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging207.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging220.xml b/src/performance/java/org/apache/log4j/performance/xml/logging220.xml new file mode 100644 index 0000000000..12faaabf6e --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging220.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging221.xml b/src/performance/java/org/apache/log4j/performance/xml/logging221.xml new file mode 100644 index 0000000000..0833be0419 --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging221.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging222.xml b/src/performance/java/org/apache/log4j/performance/xml/logging222.xml new file mode 100644 index 0000000000..57ee68a3c6 --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging222.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging223.xml b/src/performance/java/org/apache/log4j/performance/xml/logging223.xml new file mode 100644 index 0000000000..ca7dc8e82e --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging223.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging224.xml b/src/performance/java/org/apache/log4j/performance/xml/logging224.xml new file mode 100644 index 0000000000..a79ff1c0b9 --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging224.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging225.xml b/src/performance/java/org/apache/log4j/performance/xml/logging225.xml new file mode 100644 index 0000000000..94c45a699b --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging225.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging226.xml b/src/performance/java/org/apache/log4j/performance/xml/logging226.xml new file mode 100644 index 0000000000..13117e4f0b --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging226.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/performance/java/org/apache/log4j/performance/xml/logging227.xml b/src/performance/java/org/apache/log4j/performance/xml/logging227.xml new file mode 100644 index 0000000000..c3a61e2c7b --- /dev/null +++ b/src/performance/java/org/apache/log4j/performance/xml/logging227.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/apache/log4j/performance/xml/logging3.xml b/src/performance/java/org/apache/log4j/performance/xml/logging3.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging3.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging3.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging300.xml b/src/performance/java/org/apache/log4j/performance/xml/logging300.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging300.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging300.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging301.xml b/src/performance/java/org/apache/log4j/performance/xml/logging301.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging301.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging301.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging302.xml b/src/performance/java/org/apache/log4j/performance/xml/logging302.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging302.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging302.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging303.xml b/src/performance/java/org/apache/log4j/performance/xml/logging303.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging303.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging303.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging304.xml b/src/performance/java/org/apache/log4j/performance/xml/logging304.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging304.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging304.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging305.xml b/src/performance/java/org/apache/log4j/performance/xml/logging305.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging305.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging305.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging306.xml b/src/performance/java/org/apache/log4j/performance/xml/logging306.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging306.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging306.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging307.xml b/src/performance/java/org/apache/log4j/performance/xml/logging307.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging307.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging307.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging4.xml b/src/performance/java/org/apache/log4j/performance/xml/logging4.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging4.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging4.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging5.xml b/src/performance/java/org/apache/log4j/performance/xml/logging5.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging5.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging5.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging6.xml b/src/performance/java/org/apache/log4j/performance/xml/logging6.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging6.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging6.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging7.xml b/src/performance/java/org/apache/log4j/performance/xml/logging7.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging7.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging7.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging8.xml b/src/performance/java/org/apache/log4j/performance/xml/logging8.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging8.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging8.xml diff --git a/src/java/org/apache/log4j/performance/xml/logging9.xml b/src/performance/java/org/apache/log4j/performance/xml/logging9.xml similarity index 100% rename from src/java/org/apache/log4j/performance/xml/logging9.xml rename to src/performance/java/org/apache/log4j/performance/xml/logging9.xml diff --git a/src/site/apt/download.apt b/src/site/apt/download.apt new file mode 100644 index 0000000000..e74df75839 --- /dev/null +++ b/src/site/apt/download.apt @@ -0,0 +1,44 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one or more +~~ contributor license agreements. See the NOTICE file distributed with +~~ this work for additional information regarding copyright ownership. +~~ The ASF licenses this file to You under the Apache License, Version 2.0 +~~ (the "License"); you may not use this file except in compliance with +~~ the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, software +~~ distributed under the License is distributed on an "AS IS" BASIS, +~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +~~ See the License for the specific language governing permissions and +~~ limitations under the License. + ------ +Download Apache log4j 1.2 + ------ + ------ + ------ + +Download Apache log4j 1.2.15 + + Apache log4j 1.2.15 is distributed under the {{{http://www.apache.org/licenses/LICENSE-2.0.html} Apache License, version 2.0}}. + + The link in the Mirrors column should display a list of available mirrors with a + default selection based on your inferred location. If you do not see that page, + try a different browser. The checksum and signature are links to + the originals on the main distribution server. + +*-------------------------+---------+----------+-----------+ +| | Mirrors | Checksum | Signature | +*-------------------------+---------+----------+-----------+ +| Apache log4j 1.2.15 (tar.gz) | {{{http://www.apache.org/dyn/closer.cgi/logging/log4j/1.2.15/apache-log4j-1.2.15.tar.gz} apache-log4j-1.2.15.tar.gz}} | {{{http://www.apache.org/dist/logging/log4j/1.2.15/apache-log4j-1.2.15.tar.gz.md5} apache-log4j-1.2.15.tar.gz.md5}} | {{{http://www.apache.org/dist/logging/log4j/1.2.15/apache-log4j-1.2.15.tar.gz.asc} apache-log4j-1.2.15.tar.gz.asc}} | +*-------------------------+---------+----------+-----------+ +| Apache log4j 1.2.15 (zip) | {{{http://www.apache.org/dyn/closer.cgi/logging/log4j/1.2.15/apache-log4j-1.2.15.zip} apache-log4j-1.2.15.zip}} | {{{http://www.apache.org/dist/logging/log4j/1.2.15/apache-log4j-1.2.15.zip.md5} apache-log4j-1.2.15.zip.md5}} | {{{http://www.apache.org/dist/logging/log4j/1.2.15/apache-log4j-1.2.15.zip.asc} apache-log4j-1.2.15.zip.asc}} | +*-------------------------+---------+----------+-----------+ + + Please read {{{http://httpd.apache.org/dev/verification.html}Verifying Apache HTTP Server Releases}} + for more information on why you should verify our releases. + + +* Previous Releases + + All previous releases of Apache log4j can be found in the {{{http://archive.apache.org/dist/logging/log4j}archive repository}}. diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt new file mode 100644 index 0000000000..238e417313 --- /dev/null +++ b/src/site/apt/index.apt @@ -0,0 +1,70 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one or more +~~ contributor license agreements. See the NOTICE file distributed with +~~ this work for additional information regarding copyright ownership. +~~ The ASF licenses this file to You under the Apache License, Version 2.0 +~~ (the "License"); you may not use this file except in compliance with +~~ the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, software +~~ distributed under the License is distributed on an "AS IS" BASIS, +~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +~~ See the License for the specific language governing permissions and +~~ limitations under the License. + ------ + log4j 1.2 + ------ + ------ + ------ + + Inserting log statements into your code is a low-tech method + for debugging it. It may also be the only way because + debuggers are not always available or applicable. This is + often the case for distributed applications. + + On the other hand, some people argue that log statements + pollute source code and decrease legibility. (We believe that + the contrary is true). In the Java language where a + preprocessor is not available, log statements increase the + size of the code and reduce its speed, even when logging is + turned off. Given that a reasonably sized application may + contain thousands of log statements, speed is of particular + importance. + + + With log4j it is possible to enable logging at runtime + without modifying the application binary. The log4j package is + designed so that these statements can remain in shipped code + without incurring a heavy performance cost. Logging behavior + can be controlled by editing a configuration file, without + touching the application binary. + + Logging equips the developer with detailed context for + application failures. On the other hand, testing provides + quality assurance and confidence in the application. Logging + and testing should not be confused. They are + complementary. When logging is wisely used, it can prove to be + an essential tool. + + One of the distinctive features of log4j is the notion of + inheritance in loggers. Using a logger + hierarchy it is possible to control which log + statements are output at arbitrarily fine granularity but also + great ease. This helps reduce the volume of logged output and + minimize the cost of logging. + + The target of the log output can be a file, an + OutputStream, a java.io.Writer, a + remote log4j server, a remote Unix Syslog daemon, or many other output targets. + + On an AMD Duron clocked at 800Mhz running JDK 1.3.1, it costs + about 5 nanoseconds to determine if a logging statement should + be logged or not. Actual logging is also quite fast, ranging + from 21 microseconds using the SimpleLayout, 37 + microseconds using the TTCCLayout. The performance of the + PatternLayout is almost as good as the dedicated layouts, + except that it is much more flexible. + + The package is being constantly improved thanks to input from + users and code contributed by authors in the community. diff --git a/src/site/apt/publications.apt b/src/site/apt/publications.apt new file mode 100644 index 0000000000..2a7b7989f6 --- /dev/null +++ b/src/site/apt/publications.apt @@ -0,0 +1,81 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one or more +~~ contributor license agreements. See the NOTICE file distributed with +~~ this work for additional information regarding copyright ownership. +~~ The ASF licenses this file to You under the Apache License, Version 2.0 +~~ (the "License"); you may not use this file except in compliance with +~~ the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, software +~~ distributed under the License is distributed on an "AS IS" BASIS, +~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +~~ See the License for the specific language governing permissions and +~~ limitations under the License. + ------ + log4j 1.2 Publications + ------ + ------ + ------ + + +Books + + * Ceki G\xFClc\xFC. 2004. The complete log4j manual. QoS.ch. {{{http://www.qos.ch/shop/products/eclm/}http://www.qos.ch/shop/products/eclm/}}. + + * Samudra Gupta. 2007. Pro Apache log4j, Second Edition. APress. + +Articles: + + * Vipan Singla. Don't Use System.out.println! Use Log4j. + {{{http://www.vipan.com/htdocs/log4jhelp.html}http://www.vipan.com/htdocs/log4jhelp.html}}. + + * Vikran Goyal. Build Flexible Logs With log4j. + {{{http://www.onjava.com/pub/a/onjava/2002/08/07/log4j.html}http://www.onjava.com/pub/a/onjava/2002/08/07/log4j.html}}. + + * Ashley J.S. Mills. Log4J. + {{{http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/log4j.html}http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/log4j.html}}. + + * Kevin Brown. Add logging to your Java Applications. + {{{http://www.builder.com.com/article.jhtml?id=u00820020124kev01.htm} + http://www.builder.com.com/article.jhtml?id=u00820020124kev01.htm}} + + * Kevin Brown. How does the Java logging API stack up against log4j? + {{{http://www.builder.com.com/article.jhtml?id=u00220020724kev01.htm} + http://www.builder.com.com/article.jhtml?id=u00220020724kev01.htm}}. + + * Michael Canzoneri. Log4J FAQ. {{{http://www.jguru.com/faq/Log4j}http://www.jguru.com/faq/Log4j}}. + + * Ceki G\xFClc\xFC. Think Again. + {{{http://www.qos.ch/logging/thinkAgain.html}http://www.qos.ch/logging/thinkAgain.html}}. + + * Ceki G\xFClc\xFC. Supporting the log4j RepositorySelector. + {{{http://www.qos.ch/logging/sc.html}http://www.qos.ch/logging/sc.html}}. + + * Ceki G\xFClc\xFC. Log4j delivers control over logging. + {{{http://www.javaworld.com/jw-11-2000/jw-1122-log4j.html}http://www.javaworld.com/jw-11-2000/jw-1122-log4j.html}}. + + * Vikram Goyal. Understanding Classloaders: log4j in a J2EE Environment. + {{{http://www.onjava.com/pub/a/onjava/2003/04/02/log4j_ejb.html}http://www.onjava.com/pub/a/onjava/2003/04/02/log4j_ejb.html}}. + + * Ruth Zamorano and Rafeal Luque. Instant logging: Harness the power of log4j with Jabber. + {{{http://www-106.ibm.com/developerworks/java/library/j-instlog/}http://www-106.ibm.com/developerworks/java/library/j-instlog/}}. + + * Matthew Litkey, Jay Galvin, and Marina Sum. + Developer Tip: Adding the log4j API to Applications on Sun Java System Application Server 7 + {{{http://developers.sun.com/prodtech/appserver/reference/techart/log4j.html}http://developers.sun.com/prodtech/appserver/reference/techart/log4j.html}}. + + * Sean C. Sullivan. Reporting Application Errors by Email. + {{{http://www.onjava.com/pub/a/onjava/2004/09/29/smtp-logging.html}http://www.onjava.com/pub/a/onjava/2004/09/29/smtp-logging.html}}. + + +Presentations: + + * John Munsch. Log4J In 30 Minutes Or Less. + {{{http://www.johnmunsch.com/projects/Presentations/}http://www.johnmunsch.com/projects/Presentations/}}. + + * Ceki G\xFClc\xFC. Log4j, a logging package for the Java language. + {{{http://www.qos.ch/ac2001/F11-10.html}http://www.qos.ch/ac2001/F11-10.html}}. + + * Brent Twenter. Log4j. {{{http://www.ociweb.com/javasig/knowledgebase/January2001/Log4J.ppt}http://www.ociweb.com/javasig/knowledgebase/January2001/Log4J.ppt}}. + \ No newline at end of file diff --git a/src/site/apt/roadmap.apt b/src/site/apt/roadmap.apt new file mode 100644 index 0000000000..84f712d6c3 --- /dev/null +++ b/src/site/apt/roadmap.apt @@ -0,0 +1,26 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one or more +~~ contributor license agreements. See the NOTICE file distributed with +~~ this work for additional information regarding copyright ownership. +~~ The ASF licenses this file to You under the Apache License, Version 2.0 +~~ (the "License"); you may not use this file except in compliance with +~~ the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, software +~~ distributed under the License is distributed on an "AS IS" BASIS, +~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +~~ See the License for the specific language governing permissions and +~~ limitations under the License. + ------ + log4j 1.2 Roadmap + ------ + ------ + ------ + +log4j 1.2 Roadmap + + log4j 1.2 is mature and future development on the log4j 1.2 branch + is expected to be limited to bug fixes and minor enhancements. + Any major new features for log4j 1.2 are likely to be developed + as companion products for log4j 1.2. diff --git a/src/site/fml/faq.fml b/src/site/fml/faq.fml new file mode 100644 index 0000000000..546d8b6a21 --- /dev/null +++ b/src/site/fml/faq.fml @@ -0,0 +1,781 @@ + + + + + + + What is log4j? +

    log4j is a tool to help the programmer output log statements to a + variety of output targets. +

    + +

    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 shipped code without + incurring a high performance cost. It follows that the speed + of logging (or rather not logging) is capital. +

    + +

    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 hierarchical loggers. Using loggers it is + possible to selectively control which log statements are output at + arbitrary granularity. +

    + +

    log4j is designed with two three goals in mind: + reliability, speed and flexibility. There is a tight balance + between these requirements. We believe that log4j strikes the + right balance. +

    +
    +
    + + + Is log4j a reliable logging system? +

    No. log4j is not reliable. It is a best-effort + fail-stop logging system. +

    + +

    By fail-stop, we mean that log4j will not throw unexpected + exceptions at run-time potentially causing your application to + crash. If for any reason, log4j throws an uncaught exception, + please send an email to the log4j-user@logging.apache.org + mailing list. Uncaught exceptions are handled as serious bugs + requiring immediate attention. +

    + +

    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. +

    + + What are the prerequisites for log4j? + +

    Log4j versions upto and including 1.2.8 are + compatible with JDK 1.1.x and later. Log4j version 1.3 will + be compatilble with JDK 1.2 and later. +

    + +

    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 XML parser, for example Xerces or Sun's + parser. Compiling the DOMConfigurator requires the presence of a + JAXP parser in the classpath. +

    + +

    The org.apache.log4j.net.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. +

    + +

    The org.apache.log4j.net.JMSAppender + requires the presence of the JMS API as well as JNDI. +

    + +

    log4j test code relies on the JUnit testing framework. +

    +
    + + What are the features of log4j? + +

    log4j is optimized for speed.

    + +

    log4j is based on a named logger hierarchy.

    + +

    log4j is fail-stop. However, altough it certainly + strives to ensure delivery, log4j does not guarantee that + each log statement will be delivered to its destination. +

    + +

    log4j is thread-safe.

    + +

    log4j is not restricted to a predefined set of + facilities.

    + +

    Logging behavior can be set at runtime using a + configuration file. Configuration files can be property + files or in XML format.

    + +

    log4j is designed to handle Java Exceptions from the + start.

    + +

    log4j can direct its output to a file, the console, + an java.io.OutputStream, + java.io.Writer, 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.

    + +

    log4j uses 5 levels, namely DEBUG, INFO, WARN, ERROR and + FATAL. +

    + +

    The format of the log output can be easily changed by + extending the Layout + class.

    + +

    The target of the log output as well as the writing + strategy can be altered by implementations of the + Appender interface.

    + +

    log4j supports multiple output appenders per logger. +

    + +

    log4j supports internationalization.

    +
    + + Is there example code for using log4j? + +

    See the examples/ directory.

    +
    +
    + + + What documentation should I read to learn more about + log4j? +

    Make sure to read the short + manual. It is also recommended to you read The complete + log4j manual which is much more detailed and up to + date. Both documents were written by Ceki Gülcü. +

    +
    + + Is log4j thread-safe? + +

    Yes, log4j is thread-safe. Log4j components are designed to + be used in heavily multithreaded systems.

    + +
    + + What does log output look like? + +

    The log output can be customized in many ways. Moreover, + one can completely override the output format by implementing + one's own Layout. +

    + +

    Here is an example output using PatternLayout with + the conversion pattern "%r [%t] %-5p %c{2} %x - %m%n" +

    + +
    +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.
    +	
    + +

    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 level of + the log statement. The fourth field is the rightmost two + components of the logger making the log request. The fifth + field (just before the '-') is the nested diagnostic + context (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. +

    +
    + + Why should I use log4j when JDK 1.4 already ships with a + logging API? + + +

    + Although both APIs are conceptually similar, the log4j API is + significantly more flexible and offers many more features, too + numerous to be listed here. You will discover that the + additional features and flexibility turn out to be + indispensable in the context of a mission-critical + application. +

    + +

    The open and collaborative way in which log4j is developped + ensures that it continues to preserve and even widen its + competitive edge. At some point, input from bright developers + from all over the world is bound to make a difference. +

    +
    +
    + + + What are Loggers? + + +

    Lggers lie at the heart of log4j. Loggers define a hierarchy and give + the programmer run-time control on which statements are + printed or not. +

    + +

    Loggers are assigned levels. A log statement is printed + depending on its level and its logger. +

    + +

    Make sure to read the log4j manual + for more information. +

    +
    + +How can I change log behavior at runtime? + +

    Log behavior can be set using configuration files which are parsed + at runtime. Using configuration files the programmer can define + loggers and set their levels. +

    + +

    The PropertyConfigurator defines a particular format + of a configuration file. See also the examples/Sort.java + example and associated configuration files. +

    + +

    Configuration files can be specified in XML. See + log4j.dtd and + org.log4j.xml.DOMConfigurator for more details. +

    + +

    See the various Layout and Appender components for specific + configuration options. +

    + +

    In addition to configuration files, the user may disable all + messages belonging to a set of levels. See next item. +

    + +
    + + What is the fastest way of (not) logging? + +

    For some logger l, writing, +

    + +
    + l.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
    +	
    + +

    incurs the cost of constructing the message parameter, that is + converting both integer i and entry[i] to a + String, and concatenating intermediate strings. This, regardless of + whether the message will be logged or not. +

    + +

    If you are worried about speed, then write

    +
    +   if(l.isDebugEnabled()) {
    +     l.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
    +   }
    +	
    + +

    This way you will not incur the cost of parameter + construction if debugging is disabled for logger + l. On the other hand, if the logger is debug + enabled, you will incur the cost of evaluating whether the + logger is enabled or not, twice: once in + debugEnabled and once in debug. + This is an insignificant overhead since evaluating a logger + takes less than 1% of the time it takes to actually log a + statement. +

    +
    + + Are there any suggested ways for naming loggers? + +

    Yes, there are.

    + +

    You can name loggers by locality. It turns out + that instantiating a logger in each class, with the logger name + equal to the fully-qualified name of the class, is a useful and + straightforward approach of defining loggers. This approach has + many benefits: +

    + +
      +
    • It is very simple to implement.
    • + +
    • It is very simple to explain to new developers.
    • + +
    • It automatically mirrors your application's own modular design. +
    • +
    • It can be further refined at will.
    • + +
    • Printing the logger automatically gives information on the locality + of the log statement.
    • +
    + +

    However, this is not the only way for naming loggers. A + common alternative is to name loggers by functional + areas. For example, the "database" logger, "RMI" + logger, "security" logger, or the "XML" logger. +

    + +

    You may choose to name loggers by functionality and + subcategorize by locality, as in "DATABASE.com.foo.some.package.someClass" or + "DATABASE.com.foo.some.other.package.someOtherClass". +

    + +

    You are totally free in choosing the names of your + loggers. The log4j package merely allows you to manage your + names in a hierarchy. However, it is your responsibility to define + this hierarchy. +

    + +

    Note by naming loggers by locality one tends to name things by + functionality, since in most cases the locality relates closely to + functionality. +

    +
    + + How do I get the fully-qualified name of a class in a static block? + +

    You can easily retrieve the fully-qualified name of a class in a + static block for class X, with the statement + X.class.getName(). Note that X is the class + name and not an instance. The X.class statement does + not create a new instance of class X. +

    + +

    Here is the suggested usage template:

    + +
    +package a.b.c;
    +
    +public class Foo {
    +  final static Logger logger = Logger.getLogger(Foo.class);
    +  ... other code
    +
    +}
    +	
    +
    + + Can the log output format be customized? + +

    Yes, you can extend the Layout class to create + you own customized log format. Appenders can be parameterized + to use the layout of your choice. +

    +
    + + What are the configurable options for FooBarAppender? + +

    Log4j uses JavaBeans style configuration.

    + +

    Thus, any setter method in FooBarAppender + corresponds to a configurable option. For example, in RollingFileAppender + the setMaxBackupIndex(int + maxBackups) method corresponds to the + maxBackupIndex option. The first letter of the + option can be upper case, i.e. MaxBackupIndex + and maxBackupIndex are equivalent but not + MAXBACKUPIndex nor mAXBackupIndex. +

    + +

    Layouts options are also defined by their setter methods. The same goes + for most other log4j components. +

    +
    + + What is the recommended way of migrating from + java.util.logging to log4j? + + +

    We suggest to just use global file search/replace. You should be able + to replace all the "java.util.Logger" references with + "org.apache.log4j.Logger", and you should be on your way. +

    + +

    If you're on a Win32 platform, we recommend Textpad. You can use the + CTRL+SHIFT+O to open all *.java files from a directory including all + its sub-directories, and then use the search/replace function to + replace in all files, and then CTRL+SHIFT+S to save all. Should take + about 60 seconds! :) +

    +
    + + Is it possible to direct log output to + different appenders by level? +

    Yes it is. Setting the Threshold option of any appender + extending AppenderSkeleton, + (most log4j appenders extend AppenderSkeleton) to filter out all log + events with lower level than the value of the threshold + option. +

    + +

    For example, setting the threshold of an appender to DEBUG + also allow INFO, WARN, ERROR and FATAL messages to log along + with DEBUG messages. 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 WARN messages but not ERROR or FATAL messages. +

    + +

    This policy usually best encapsulates what the user + actually wants to do, as opposed to her mind-projected + solution. +

    +

    See examples/sort4.lcf for an example threshold + configuration.

    + +

    If you must filter events by exact level match, then you can + attach a LevelMatchFilter + to any appender to filter out logging events by exact level match. +

    +
    + + + What does the Windows NT Event Viewer complain about + missing descriptions for my event messages when I use the + NTEventLogAppender? + + +

    The NT Event Viewer relies on message resource 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. +

    +
    + + Why can't I map my logger names to the loggers that + appear in the NT Event Log when I use the + NTEventLogAppender? + + +

    Unfotunately, the logger 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 + Logger column anyway... +

    +
    + + Are there suggested approaches for logging in JSP pages? + +

    + The suggested approach depends on your design requirements. If you or + your organization has no constraints on the use of Java in JSP pages, + simply use log4j normally in <% ... %> statements + as indicated in the Short Manual and the rest of the documentation. +

    +

    + However, if your design calls for a minimum amount of Java in your JSP + pages, consider using the + Log Taglib + from the Jakarta Taglibs project. It provides logging JSP tags that invoke + log4j. +

    +
    +
    + + Can the outputs of multiple client request go to + different log files? + +

    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. +

    + +

    It is simpler to use a nested diagnostic context + (NDC). Typically, one would NDC.push() 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. +

    + +

    See the NDC and the PatternLayout + classes for more information. The NumberCruncher + example shows how the NDC can be used to distinguish the log + output from multiple clients even if they share the same log + file. +

    + +

    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 logger + depending on the current context. +

    +
    + + + Logger instances seem to be create only. Why isn't + there a method to remove logger instances? + +

    It is quite nontrivial to define the semantics of a + "removed" logger escecially if it is still referenced by the + user. Future releases may include a remove method in + the Logger class.

    + + How do I get multiple process to log to the same file? + +

    You may have each process log to a + SocketAppender. + The receiving + SocketServer + (or + SimpleSocketServer) + can receive all the events and send them to a single + log file. +

    +
    + + How about the timesamps of events generated by multiple + processes across multiple hosts (possibly across multiple + timezones)? + +

    The timestamp is created when the logging event is created. + That is so say, when the debug, + info, warn, error or + fatal method is invoked. Thus, the timestamp is + unaffected by the time at which event arrive at a remote + socket server. +

    + +

    Timestamps are stored in UTC format inside the + event. Consequently, when displayed or written to a log file, + timestamps appear in the same timezone as the host displaying + or creating the logfile. Note that because the clocks of + various machines may not be synchronized, there may be + timestamp inconsistencies between events generated on + different hosts. +

    +
    + + Why can't log4j find my properties file in a J2EE or WAR + application? +

    The short answer: the log4j classes and the properties file + are not within the scope of the same classloader. +

    + +

    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. +

    + +

    Log4j only uses the default Class.forName() + mechanism for loading classes. Resources are handled + similarly. See the documentation for + java.lang.ClassLoader for more details. +

    + +

    So, if you're having problems, try loading the class or + resource yourself. If you can't find it, neither will + log4j. ;) +

    + + + Is there a way to get log4j to automatically reload a + configuration file if it changes? + +

    Yes. Both the DOMConfigurator and the PropertyConfigurator support + automatic reloading through the configureAndWatch method. + See the API documentation for more details. +

    + + +

    Because the configureAndWatch launches a + separate wathdog thread, and because there is no way to stop + this thread in log4j 1.2, the configureAndWatch + method is unsafe for use in J2EE envrironments where + applications are recycled. +

    + + + Why should I donate my extensions to log4j back to the + project? +

    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. You are free to do + whatever you wish with your proprietary log4j extensions. + In particular, you may choose to never release your extensions + to the wider public. +

    + +

    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 n, then when log4j + release version n+1 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. +

    + +

    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. Unless + the proprietary log4j extension is business critical, there is + little reason for not donating your extensions back to the + project. +

    + + What should I keep in mind when contributing code? + +
      + +
    1. +

      Write a test case for your contribution.

      + +

      There is nothing more irritating than finding the bugs + in debugging (i.e. logging) code. Writing a test case + takes some effort but is crucial for a widely used library + such as log4j. Writing a test case will go a long way in + earning you the respect of fellow developers. See the + tests/ directory for exiting test cases. +

      +
    2. + + +
    3. +

      Stick to the existing indentation style even if you hate it.

      + +

      Alternating between indentation styles makes it hard to + understand the source code. Make it a little harder on + yourself but easier on others. +

      + +

      Log4j has adopted a rather conservative approach by + following the Code Conventions + for the JavaTM Programming Language. We use 2 (two) + spaces for indentation and no tabs. +

      +
    4. + +
    5. +

      Please do not both modify the code and change the + indentation in a single commit.

      + +

      If you change the code and reformat it at the same time + and then commit, the commit notification message will be + hard to read. It will contain many diffs associated with + the reformatting in addition to logical changes. +

      + +

      If you must reformat and change the code, then perform + each step separately. For example, reformat the code and + commit. Following that, you can change the logic and + commit. The two steps can be performed in the reverse + order just as well. You can first change the logic and + commit and only later reformat and commit. +

      + +
    6. +
    7. +

      Make every effort to stick to the JDK 1.1 API.

      + +

      One of the important advantages of log4j is its + compatibility with JDK 1.1.x. +

      +
    8. + +
    9. +

      Always keep it simple, small and fast when + possible.

      + +

      It's all about the application not about logging.

      +
    10. + +
    11. +

      Identify yourself as a contributor at the top of the + relevant file. +

      +
    12. +
    13. +

      Take responsibility for your code.

      + +

      Authoring software is very much like running a marathon. It + takes time and endurance. +

      +
    14. +
    15. +

      Did we mention sticking with the indentation style?

      +
    16. +
    17. Did we mention writing test cases?

      +
    18. + +
    +
    + + + + Why am I getting multiple copies of messages in my log file? + +

    There are several reasons this can occur: +

      +
    • Repeated configuration of log4j: By default, each call to + PropertyConfigurator.configure or DOMConfigurator.configure is + culmulative. If your configuration file defines a file appender, + calling PropertyConfigurator.configure three times will create + three distinct instances and connect each of them to the specified logger.
    • +
    • Attaching the same appender to multiple loggers: if an appender is + attached to the root logger and child logger, then any message + sent to the child logger will go to the appender twice (unless + additivity is set to false).
    • +

    +
    +
    + + How do I add a custom level? + +

    It is possible, but rarely appropriate. The + request is commonly for a level named something like "audit" + that doesn't obviously fit in the progression "trace", "debug", + "info", "warn", "error" and "fatal". In that case, the request + for a level is really a request for a mechanism to specify + a different audience. The appropriate mechanism is to use a distinct + logger name (or tree) for "audit" related messages.

    +
    +
    +
    +
    diff --git a/src/site/resources/css/site.css b/src/site/resources/css/site.css new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/src/site/resources/css/site.css @@ -0,0 +1 @@ + diff --git a/docs/images/logo.jpg b/src/site/resources/images/logo.jpg similarity index 100% rename from docs/images/logo.jpg rename to src/site/resources/images/logo.jpg diff --git a/src/site/resources/images/ls-logo.jpg b/src/site/resources/images/ls-logo.jpg new file mode 100755 index 0000000000..611c5c3654 Binary files /dev/null and b/src/site/resources/images/ls-logo.jpg differ diff --git a/docs/od.gif b/src/site/resources/images/od.gif similarity index 100% rename from docs/od.gif rename to src/site/resources/images/od.gif diff --git a/src/site/site.xml b/src/site/site.xml new file mode 100644 index 0000000000..69a565a5b3 --- /dev/null +++ b/src/site/site.xml @@ -0,0 +1,76 @@ + + + + Apache Logging Services Project + images/ls-logo.jpg + http://logging.apache.org/ + + + Apache log4j + images/logo.jpg + http://logging.apache.org/log4j + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/manual.html b/src/site/xdoc/manual.xml similarity index 71% rename from docs/manual.html rename to src/site/xdoc/manual.xml index 50c5331a1d..0806f758bd 100644 --- a/docs/manual.html +++ b/src/site/xdoc/manual.xml @@ -1,33 +1,42 @@ - - -log4j manual - - - - -
    -

    Short introduction to log4j

    - - Ceki Gülcü -

    - March 2002 -
    -
    + + + + + Ceki Gülcü + Short introduction to log4j + + +

    - Copyright © 2000-2002 The Apache Software Foundation. All + Copyright © 2000-2002 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 in the LICENSE.txt file shipped with the log4j + the Apache Software License version 2.0, a copy of which has + been included in the LICENSE file shipped with the log4j distribution. This document is based on the article "Log4j delivers control over logging" published in November 2000 - edition of JavaWorld. However, the - present article contains more detailed and up to date - information. The short manual also borrows some text from the - book "log4j: the Manual" by the same author (yours truly). - + edition of JavaWorld. However, the present article contains more + detailed and up to date information. The present short manual + also borrows some text from "The + complete log4j manual" by the same author (yours + truly).

    Abstract

    @@ -37,7 +46,7 @@

    Abstract

    are output with arbitrary granularity. It is fully configurable at runtime using external configuration files. Best of all, log4j has a gentle learning curve. Beware: judging from user feedback, it is also -quite addictive. +quite addictive.

    Introduction

    @@ -47,19 +56,19 @@

    Introduction

    own tracing API. This was in early 1996. After countless enhancements, several incarnations and much work that API has evolved to become log4j, a popular logging package for Java. The package is distributed -under the Apache Software License, a +under the Apache Software License, a fully-fledged open source license certified by the open source initiative. The latest log4j version, including full-source code, class files and documentation can be found at http://jakarta.apache.org/log4j/. -By the way, log4j has been ported to the C, C++, C#, Python, Ruby, and -Eiffel languages. +href="http://logging.apache.org/log4j/">http://logging.apache.org/log4j/. +By the way, log4j has been ported to the C, C++, C#, Perl, Python, +Ruby, and Eiffel languages.

    Inserting log statements into code is a low-tech method for debugging it. It may also be the only way because debuggers are not always available or applicable. This is usually the case for -multithreaded applications and distributed applications at large. +multithreaded applications and distributed applications at large.

    Experience indicates that logging was an important component of the development cycle. It offeres several advantages. It provides precise @@ -68,9 +77,9 @@

    Introduction

    intervention. Moreover, log output can be saved in persistent medium to be studied at a later time. In addition to its use in the development cycle, a sufficiently rich logging package can also be -viewed as an auditing tool. +viewed as an auditing tool.

    -

    As Brian W. Kernigan and Rob Pike put it in their truly excellent +

    As Brian W. Kernighan and Rob Pike put it in their truly excellent book "The Practice of Programming"

       As personal choice, we tend not to use debuggers beyond getting a
    @@ -84,13 +93,13 @@ 

    Introduction

    the critical section of code, even assuming we know where that is. More important, debugging statements stay with the program; debugging sessions are transient. -
    +

    Logging does have its drawbacks. It can slow down an application. If too verbose, it can cause scrolling blindness. To alleviate these concerns, log4j is designed to be reliable, fast and extensible. Since logging is rarely the main focus of an application, -log4j API strives to be simple to understand and to use. +the log4j API strives to be simple to understand and to use.

    Loggers, Appenders and Layouts

    @@ -98,7 +107,7 @@

    Loggers, Appenders and Layouts

    appenders and layouts. These three types of components work together to enable developers to log messages according to message type and level, and to control at runtime how these -messages are formatted and where they are reported. +messages are formatted and where they are reported.

    Logger hierarchy

    @@ -112,225 +121,232 @@

    Logger hierarchy

    package. However, since log4j version 1.2, Logger class has replaced the Category class. For those familiar with earlier versions of log4j, the Logger class can be -considered as a mere alias to the Category class. +considered as a mere alias to the Category class.

    -

    Loggers are named entities. Logger names are case-sensitive and -they follow the hierarchical naming rule: +

    Loggers are named entities. Logger names are case-sensitive and +they follow the hierarchical naming rule:

    -
    +
    -
    Named Hierarchy +
    Named Hierarchy
    -

    A logger is said to be an ancestor of another +

    A logger is said to be an ancestor of another logger if its name followed by a dot is a prefix of the descendant logger name. A logger is said to be a parent of a child logger if there are no - ancestors between itself and the descendant logger. + ancestors between itself and the descendant logger.
    -
    +

    For example, the logger named "com.foo" is a parent of the logger named "com.foo.Bar". Similarly, "java" is a parent of "java.util" and an ancestor of "java.util.Vector". This naming scheme -should be familiar to most developers. +should be familiar to most developers.

    The root logger resides at the top of the logger hierarchy. It -is exceptional in two ways: +is exceptional in two ways:

      -
    1. it always exists, -
    2. it cannot be retrieved by name. -
    +
  3. it always exists,
  4. +
  5. it cannot be retrieved by name.
  6. +

Invoking the class static Logger.getRootLogger +href="apidocs/org/apache/log4j/Logger.html#getRootLogger()">Logger.getRootLogger method retrieves it. All other loggers are instantiated and retrieved with the class static Logger.getLogger +href="apidocs/org/apache/log4j/Logger.html#getLogger()">Logger.getLogger method. This method takes the name of the desired logger as a parameter. Some of the basic methods in the Logger class are listed -below. +below.

-
   package org.apache.log4j;
-  
+
   public class Logger {
-  
-    // Creation & retrieval methods:
+
+    // Creation & retrieval methods:
     public static Logger getRootLogger();
     public static Logger getLogger(String name);
-    
+
     // printing methods:
+    public void trace(Object message);
     public void debug(Object message);
     public void info(Object message);
     public void warn(Object message);
     public void error(Object message);
+    public void fatal(Object message);
 
     // generic printing method:
     public void log(Level l, Object message);
 }
 
+ +

Loggers may be assigned levels. The set of possible -levels, that is +levels, that is:

-DEBUG, -INFO, -WARN, -ERROR and -FATAL +TRACE,
+DEBUG,
+INFO,
+WARN,
+ERROR and
+FATAL
+
are defined in the org.apache.log4j.Level -class. Although we do not encourage you from doing so, you may define +href="apidocs/org/apache/log4j/Level.html">org.apache.log4j.Level
+class. Although we do not encourage you to do so, you may define your own levels by sub-classing the Level class. A -perhaps better approach is will be explained later on. +perhaps better approach will be explained later on.

If a given logger is not assigned a level, then it inherits one from its closest ancestor with an assigned level. More -formally: +formally:

-
+
-
Level Inheritance +
Level Inheritance

The inherited level for a given logger C, is equal to the first non-null level in the logger hierarchy, starting at C and proceeding upwards in the -hierarchy towards the root logger. +hierarchy towards the root logger.

-
+ + +

To ensure that all loggers can eventually inherit a level, -the root logger always has an assigned level. +the root logger always has an assigned level.

Below are four tables with various assigned level values and the -resulting inherited levels according to the above rule. +resulting inherited levels according to the above rule.

- - - - - - - -
Logger
name
Assigned
level
Inherited
level
root Proot Proot
X none Proot
X.Y none Proot
X.Y.Z none Proot
Example 1
- -

In example 1 above, only the root logger is assinged a + Logger
nameAssigned
level + Inherited
level + root Proot Proot + X none Proot + X.Y none Proot + X.Y.Z none Proot + Example 1 +

+ +

In example 1 above, only the root logger is assigned a level. This level value, Proot, is inherited by the other loggers X, X.Y and -X.Y.Z. +X.Y.Z.

- - - - - - - -
Logger
name
Assigned
level
Inherited
level
root Proot Proot
X Px Px
X.Y Pxy Pxy
X.Y.Z Pxyz Pxyz
Example 2
+ Logger
nameAssigned
level + Inherited
level + root Proot Proot + X Px Px + X.Y Pxy Pxy + X.Y.Z Pxyz Pxyz + Example 2 +

In example 2, all loggers have an assigned level value. There -is no need for level inheritence. +is no need for level inheritence.

- - - - - - - -
Logger
name
Assigned
level
Inherited
level
root Proot Proot
X Px Px
X.Y none Px
X.Y.Z Pxyz Pxyz
Example 3
+ Logger
nameAssigned
level + Inherited
level + root Proot Proot + X Px Px + X.Y none Px + X.Y.Z Pxyz Pxyz + Example 3 +

In example 3, the loggers root, X and X.Y.Z are assigned the levels Proot, Px and Pxyz respectively. The logger X.Y inherits its level value from its parent -X. - - - - - - - - - +X.

+ +
Logger
name
Assigned
level
Inherited
level
root Proot Proot
X Px Px
X.Y none Px
X.Y.Z none Px
Example 4
+ + + + + + +
Logger
name
Assigned
level
Inherited
level
root Proot Proot
X Px Px
X.Y none Px
X.Y.Z none Px
Example 4

In example 4, the loggers root and X and are assigned the levels Proot and Px respectively. The loggers X.Y and X.Y.Z inherits their level value from their nearest parent X -having an assigned level.. +having an assigned level..

Logging requests are made by invoking one of the printing methods -of a logger instance. These printing methods are +of a logger instance. These printing methods are -debug, +debug, -info, +info, -warn, -error, -fatal - and log. +warn, +error, +fatal + and log.

By definition, the printing method determines the level of a logging request. For example, if c is a logger instance, then the statement c.info("..") is a logging -request of level INFO. +request of level INFO.

A logging request is said to be enabled if its level is higher than or equal to the level of its logger. Otherwise, the request is said to be disabled. A logger without an assigned level will inherit one from the hierarchy. This rule is -summarized below. +summarized below.

- +
-
Basic Selection Rule +
Basic Selection Rule

A log request of level p in a logger with - inherited level q, is enabled if p >= - q. + (either assigned or inherited, whichever is appropriate) level q, is enabled if p >= + q.

-
+

This rule is at the heart of log4j. It assumes that levels are ordered. For the standard levels, we have DEBUG < INFO -< WARN < ERROR < FATAL. +< WARN < ERROR < FATAL.

-

Here is an example of this rule. +

Here is an example of this rule.

@@ -339,45 +355,46 @@

Logger hierarchy

// get a logger instance named "com.foo" Logger logger = Logger.getLogger("com.foo"); - // Now set its level. Normally you do not need to set the - // level of a logger progamitcally. This is usually done + // Now set its level. Normally you do not need to set the + // level of a logger programmatically. This is usually done // in configuration files. logger.setLevel(Level.INFO); Logger barlogger = Logger.getLogger("com.foo.Bar"); - + // This request is enabled, because WARN >= INFO. logger.warn("Low fuel level."); - + // This request is disabled, because DEBUG < INFO. - logger.debug("Starting search for nearest gas station."); - + logger.debug("Starting search for nearest gas station."); + // The logger instance barlogger, named "com.foo.Bar", - // will inherit its level from the logger named - // "com.foo" Thus, the following request is enabled - // because INFO >= INFO. - barlogger.info("Located nearest gas station."); + // will inherit its level from the logger named + // "com.foo" Thus, the following request is enabled + // because INFO >= INFO. + barlogger.info("Located nearest gas station."); // This request is disabled, because DEBUG < INFO. - barlogger.debug("Exiting gas station search"); + barlogger.debug("Exiting gas station search"); -
+ +

Calling the getLogger method with the same name will -always return a reference to the exact same logger object. +always return a reference to the exact same logger object.

-

For example, in +

For example, in +
    Logger x = Logger.getLogger("wombat");
    Logger y = Logger.getLogger("wombat");
-
x and y refer to exactly the same -logger object. +logger object.

Thus, it is possible to configure a logger and then to retrieve the same instance somewhere else in the code without passing around @@ -385,11 +402,11 @@

Logger hierarchy

where parents always preceed their children, log4j loggers can be created and configured in any order. In particular, a "parent" logger will find and link to its descendants even if it is -instantiated after them. +instantiated after them.

Configuration of the log4j environment is typically done at application initialization. The preferred way is by reading a -configuration file. This approach will be discussed shortly. +configuration file. This approach will be discussed shortly.

Log4j makes it easy to name loggers by software component. This can be accomplished by statically instantiating @@ -400,10 +417,10 @@

Logger hierarchy

the origin of a log message. However, this is only one possible, albeit common, strategy for naming loggers. Log4j does not restrict the possible set of loggers. The developer is free to name the -loggers as desired. +loggers as desired.

Nevertheless, naming loggers after the class where they are -located seems to be the best strategy known so far. +located seems to be the best strategy known so far.

Appenders and Layouts

@@ -411,22 +428,22 @@

Appenders and Layouts

on their logger is only part of the picture. Log4j allows logging requests to print to multiple destinations. In log4j speak, an output destination is called an appender. Currently, appenders exist -for the
console, files, GUI +for the console, files, GUI components, remote socket +href="apidocs/org/apache/log4j/net/SocketAppender.html">remote socket servers, JMS, +href="apidocs/org/apache/log4j/net/JMSAppender.html">JMS, - NT + NT Event Loggers, and remote UNIX Syslog -daemons. It is also possible to log asynchronously. - -

More than one appender can be attached to a logger. +href="apidocs/org/apache/log4j/net/SyslogAppender.html">Syslog +daemons. It is also possible to log asynchronously.

+ +

More than one appender can be attached to a logger.

The addAppender +href="apidocs/org/apache/log4j/Logger.html#addAppender(org.apache.log4j.Appender)">addAppender method adds an appender to a given logger. Each enabled logging @@ -440,64 +457,64 @@

Appenders and Layouts

C's children will print on a file and on the console. It is possible to override this default behavior so that appender accumulation is no longer additive by setting -the additivity flag to false. +href="apidocs/org/apache/log4j/Logger.html#setAdditivity(boolean)">setting +the additivity flag to false.

-

The rules governing appender additivity are summarized below. +

The rules governing appender additivity are summarized below.

- +
-
Appender Additivity +
Appender Additivity

The output of a log statement of logger C will go to all the appenders in C and its ancestors. This is - the meaning of the term "appender additivity". + the meaning of the term "appender additivity".

However, if an ancestor of logger C, say P, has the additivity flag set to false, then C's output will be directed to all the appenders in C and it's ancestors upto and including P but - not the appenders in any of the ancestors of P. + not the appenders in any of the ancestors of P.

Loggers have their additivity flag set to - true by default. -

-
+ true by default.

+ +

-

The table below shows an example: +

The table below shows an example:

-

+

- + + - + - + - + - + -
Logger
Name
Added
Appenders
Additivity
Flag
Output Targets Comment - -
root A1 not applicable A1 + Logger
Name
Added
Appenders
Additivity
Flag
Output Targets Comment
root A1 not applicable A1 The root logger is anonymous but can be accessed with the Logger.getRootLogger() method. There is no default appender - attached to root. + attached to root.
x A-x1, A-x2 true A1, A-x1, A-x2 - Appenders of "x" and root. +
x A-x1, A-x2 true A1, A-x1, A-x2Appenders of "x" and root.
x.y none true A1, A-x1, A-x2 - Appenders of "x" and root. +
x.y none true A1, A-x1, A-x2Appenders of "x" and root.
x.y.z A-xyz1 true A1, A-x1, A-x2, A-xyz1 - Appenders in "x.y.z", "x" and root. +
x.y.z A-xyz1 true A1, A-x1, A-x2, A-xyz1Appenders in "x.y.z", "x" and root.
security A-sec false - A-sec +
security A-sec falseA-sec No appender accumulation since the additivity flag is set to - false. + false.
security.access none true A-sec Only +
security.access none true A-sec Only appenders of "security" because the additivity flag in "security" is - set to false. + set to false.
@@ -507,43 +524,43 @@

Appenders and Layouts

associating a layout with an appender. The layout is responsible for formatting the logging request according to the user's wishes, whereas an appender takes care of sending the formatted output -to its destination. +to its destination.

The
PatternLayout, part +href="apidocs/org/apache/log4j/PatternLayout.html">PatternLayout, part of the standard log4j distribution, lets the user specify the output format according to conversion patterns similar to the C language -printf function. +printf function.

For example, the PatternLayout with the conversion pattern "%r [%t] -%-5p %c - %m%n" will output something akin to: +%-5p %c - %m%n" will output something akin to:

 176 [main] INFO  org.foo.Bar - Located nearest gas station.
-
+

The first field is the number of milliseconds elapsed since the start of the program. The second field is the thread making the log request. The third field is the level of the log statement. The fourth field is the name of the logger associated with the log -request. The text after the '-' is the message of the statement. +request. The text after the '-' is the message of the statement.

Just as importantly, log4j will render the content of the log message according to user specified criteria. For example, if you frequently need to log Oranges, an object type used in your current project, then you can register an OrangeRenderer that will be invoked whenever an orange -needs to be logged. +needs to be logged.

Object rendering follows the class hierarchy. For example, assuming oranges are fruits, if you register an FruitRenderer, all fruits including oranges will be rendered by the FruitRenderer, unless of course you registered an orange -specific OrangeRenderer. +specific OrangeRenderer.

Object renderers have to implement the -ObjectRenderer -interface. +ObjectRenderer +interface.

Configuration

@@ -553,15 +570,15 @@

Configuration

percent of code is dedicated to logging. Consequently, even moderately sized applications will have thousands of logging statements embedded within their code. Given their number, it becomes imperative to -manage these log statements without the need to modify them manually. +manage these log statements without the need to modify them manually.

The log4j environment is fully configurable programmatically. However, it is far more flexible to configure log4j using configuration files. Currently, configuration files can be written in -XML or in Java properties (key=value) format. +XML or in Java properties (key=value) format.

Let us give a taste of how this is done with the help of an -imaginary application MyApp that uses log4j. +imaginary application MyApp that uses log4j.

@@ -570,7 +587,7 @@ 

Configuration

// Import log4j classes. import org.apache.log4j.Logger; import org.apache.log4j.BasicConfigurator; - + public class MyApp { // Define a static logger variable so that it references the @@ -585,80 +602,82 @@

Configuration

logger.info("Entering application."); Bar bar = new Bar(); bar.doIt(); - logger.info("Exiting application."); + logger.info("Exiting application."); } }
-
+ +

MyApp begins by importing log4j related classes. It then defines a static logger variable with the name MyApp which happens to be the fully qualified name of the -class. +class.

MyApp uses the Bar class defined in the -package com.foo. +package com.foo.

  package com.foo;
  import org.apache.log4j.Logger;
- 
+
  public class Bar {
    static Logger logger = Logger.getLogger(Bar.class);
-  
+
    public void doIt() {
-     logger.debug("Did it again!");    
+     logger.debug("Did it again!");
    }
  }
 
-
+ +

The invocation of the BasicConfigurator.configure +href="apidocs/org/apache/log4j/BasicConfigurator.html#configure()">BasicConfigurator.configure method creates a rather simple log4j setup. This method is hardwired to add to the root logger a +href="apidocs/org/apache/log4j/ConsoleAppender.html"> ConsoleAppender. The output will be formatted using a PatternLayout set -to the pattern "%-4r [%t] %-5p %c %x - %m%n". +href="apidocs/org/apache/log4j/PatternLayout.html">PatternLayout set +to the pattern "%-4r [%t] %-5p %c %x - %m%n".

Note that by default, the root logger is assigned to -Level.DEBUG. +Level.DEBUG.

The output of MyApp is:

 0    [main] INFO  MyApp  - Entering application.
 36   [main] DEBUG com.foo.Bar  - Did it again!
 51   [main] INFO  MyApp  - Exiting application.
-
+

The figure below depicts the object diagram of MyApp after just having called the BasicConfigurator.configure -method. +method.

- -
+ +

As a side note, let me mention that in log4j child loggers link only to their existing ancestors. In particular, the logger named com.foo.Bar is linked directly to the root logger, thereby circumventing the unused com or com.foo loggers. This significantly increases -performance and reduces log4j's memory footprint. +performance and reduces log4j's memory footprint.

The MyApp class configures log4j by invoking BasicConfigurator.configure method. Other classes only need to import the org.apache.log4j.Logger class, -retrieve the loggers they wish to use, and log away. +retrieve the loggers they wish to use, and log away.

The previous example always outputs the same log information. Fortunately, it is easy to modify MyApp so that the log output can be controlled at run-time. Here is a slightly modified -version. +version.

@@ -666,46 +685,47 @@ 

Configuration

import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; - + public class MyApp { static Logger logger = Logger.getLogger(MyApp.class.getName()); public static void main(String[] args) { - + // BasicConfigurator replaced with PropertyConfigurator. PropertyConfigurator.configure(args[0]); logger.info("Entering application."); Bar bar = new Bar(); bar.doIt(); - logger.info("Exiting application."); + logger.info("Exiting application."); } }
+

This version of MyApp instructs PropertyConfigurator to parse a configuration file and -set up logging accordingly. +set up logging accordingly.

Here is a sample configuration file that results in exactly same -output as the previous BasicConfigurator based example. +output as the previous BasicConfigurator based example.

 # Set root logger level to DEBUG and its only appender to A1.
 log4j.rootLogger=DEBUG, A1
-  
-# A1 is set to be a ConsoleAppender. 
+
+# A1 is set to be a ConsoleAppender.
 log4j.appender.A1=org.apache.log4j.ConsoleAppender
-  
+
 # A1 uses PatternLayout.
 log4j.appender.A1.layout=org.apache.log4j.PatternLayout
 log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
 
-
+

- -
Chainsaw
-
Chainsaw is now integrated with log4j and ships with the - official distribution. Chainsaw is a graphical log viewer and - filter for the log4j package. It listens for LoggingEvent - objects sent using the SocketAppender - and displays them in a table. Chainsaw also supports loading - events from files in XMLLayout format. -
- - - -
configLog4j
- -
A graphical log4j configuration editor by Tobias - Dezulian.
- - - -
- JDBCAppender - -
A JDBCAppender by Thomas Fenner. Note - that log4j 1.2 ships with another JDBCAppender - written by Kevin Steppe. -
- - - -
JINI - logging service (registration required)
- -
A log4j wrapper for JINI by Jerome Bernard.
- - - -
log4jME
- -
Log4jME, or log4j MiniEdition, is based on the - same code as log4j. However, as the name indicates the - mini-edition is much smaller. It offers the same client - interface such that code compiled for log4jME is 100% - compatible with log4j standard edition. You can choose to - upgrade to log4j standard edition at any time by replacing - log4jME.jar with log4j.jar in your - classpath. -
- - - -
LogWeb (commercial)
- -
Log4Web is a J2EE web application, designed to web-enable - system log files that have been generated by log4j. -
- - - -
Lumbermill
-
Lumbermill is a Swing(tm) log processing and distribution - system for Log4j.
- - - -
- LogFactor5 - (commercial) -
- -
Another full-featured graphical log viewer. After a merger - with a service-orinted company and a change in - business-orientation, the owners of LogFactor5 have decided - to donate their product to the log4j project. -
- - - -
- Log Tag -
-
A custom log tag library from the Jakarta - Taglibs project.
- - - -
- SNMPTrapAppender -
- -
An appender to send formatted logging event strings to a - specified managment host (typically, a MLM of some sort, but - could also be an SNMP management console) in the form of an - SNMP trap. -
- - - - - - -
- -
- -
log4c
- -
ANSI C functions and macros for flexible logging to files - and other destinations. It is modeled after log4j. It follows - the log4j API within the limits of reason. Intended for use in time-space - critical environments.
- - - -
log4cpp
-
A library of C++ classes for flexible logging to files, - syslog, IDSA and other destinations modeled after log4j.
- - - -
log4cplus
-
A competing port to C++.
- - - -
log4E
- -
The Goanna project (Eiffel Web Services) now includes - log4E, a complete port of log4j. -
- - - -
log4net
- -
The .NET implementation of the popular log4j Java API - providing flexible and arbitrarily granular control over log - management and configuration.
- - -
log4py
- -
Log4Py is a python logging module similar to log4j. It - supports logging to files or to stdout/stderr, variable - log-levels, configurable output formats and configuration via - configuration files. -
- - - -
log4p
-
Another Python translation of log4j. This project no - longer seems to be maintained.
- - - -
log4plsql
- -
Log4plsql is a Oracle PL/SQL logging module similar to - log4j. It supports logging out-off transaction. It is useful - for logging, benchmarking and monitoring PL/SQL applications. -
- - - -
log4r
-
A Powerful Logger for Ruby. -

Log4r features an extremely flexible logging library for - Ruby. Killer features include a heiarchial logging system - of any number of levels, logger inheritance, multiple - output destinations, tracing, custom formatting and more. - Log4r was inspired by log4j. Log4r provides the defining - features of log4j and some of its own features that just - might make log4j users envious.

-
- - -
- - -

If you would like your software to be listed here, then send a note to the log4j-user@jakarta.apache.org - list.

- -
- - - \ No newline at end of file diff --git a/src/xdocs/earlier.xml b/src/xdocs/earlier.xml deleted file mode 100644 index f97feb4e96..0000000000 --- a/src/xdocs/earlier.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - Ceki Gulcu - Older distributions - - - - -
- -
- -

BEWARE: For some reason Internet Explorer decides to - rename ".tar.gz" files as ".tar". You should rename the files back to - tar.gz after the download completes. -

-
- -
-
jakarta-log4j-1.0.4
-
- Download full package in TAR.GZ - format. -
- -
jakarta-log4j-1.1.3
-
- Download full package in TAR.GZ - format. -
-
- -
- - -
- diff --git a/src/xdocs/history.xml b/src/xdocs/history.xml deleted file mode 100644 index a59d7a6757..0000000000 --- a/src/xdocs/history.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - Ceki Gulcu - Project history - - - - -
- -

The project history gives a - brief summary of changes and additions. Users frequently - report bugs that are solved in newer versions of log4j. Please - have a look at the history file before asking for help. -

- -

The project's official URL is http://jakarta.apache.org/log4j. -

- -

Many thanks to all the log4j users who keep sending us input - and sometimes even praise for our collective effort. The first - ancestor of log4j was written for the E.U. sponsored SEMPER project. N. Asokan, - Ceki Gülcü and Michael Steiner came up with the idea - of hierarchical loggers back in 1996. Their idea is still - at the heart of log4j. The package was considerably improved - over the years at the IBM Zurich Research - Laboratory. However, log4j is no longer associated nor - supported by IBM. -

- -

Special thanks to M. Niksch from ZRL for his assistance on - many large and small matters. The Apache members, Pier - Fumagalli and Sam Ruby in particular, have been extremely - helpful in easing the move to Apache. -

- -

The log4j logo was designed and kindly donated by Cyberlab S.A. of Switzerland. -

- -
- -
diff --git a/src/xdocs/index.xml b/src/xdocs/index.xml deleted file mode 100644 index 61cc1bd460..0000000000 --- a/src/xdocs/index.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - Ceki Gulcu - Introduction - - - - - - -
- -

Inserting log statements into your code is a low-tech method - for debugging it. It may also be the only way because - debuggers are not always available or applicable. This is - often the case for distributed applications.

- -

On the other hand, some people argue that log statements - pollute source code and decrease legibility. (We believe that - the contrary is true). In the Java language where a - preprocessor is not available, log statements increase the - size of the code and reduce its speed, even when logging is - turned off. Given that a reasonably sized application may - contain thousands of log statements, speed is of particular - importance.

- - -

With log4j it is possible to enable logging at runtime - without modifying the application binary. The log4j package is - designed so that these statements can remain in shipped code - without incurring a heavy performance cost. Logging behavior - can be controlled by editing a configuration file, without - touching the application binary.

- -

Logging equips the developer with detailed context for - application failures. On the other hand, testing provides - quality assurance and confidence in the application. Logging - and testing should not be confused. They are - complementary. When logging is wisely used, it can prove to be - an essential tool.

- -

One of the distinctive features of log4j is the notion of - inheritance in loggers. Using a logger - hierarchy it is possible to control which log - statements are output at arbitrarily fine granularity but also - great ease. This helps reduce the volume of logged output and - minimize the cost of logging.

- -

The target of the log output can be a file, an - OutputStream, a java.io.Writer, a - remote log4j server, a remote Unix Syslog daemon, or even a NT - Event logger among many other output targets.

- -

On a 233 MHz ThinkPad running JDK 1.1.7B, it costs about 46 - nanoseconds to determine if that statement should be logged or - not. Actual logging is also quite fast, ranging from 79 - microseconds using the SimpleLayout, 164 microseconds using - the TTCCLayout and around a millisecond when printing - exceptions. The performance of the PatternLayout is almost as - good as the dedicated layouts, except that it is a lot more - flexible.

- -

The package is being constantly improved thanks to input from - users and code contributed by authors in the community. -

- -
- -
- diff --git a/src/xdocs/plan.xml b/src/xdocs/plan.xml deleted file mode 100644 index 72a51a640c..0000000000 --- a/src/xdocs/plan.xml +++ /dev/null @@ -1,401 +0,0 @@ - - - - - Ceki Gulcu - Release plan for log4j 1.2 - - - - -
- -

The following paragragh was adapted from the Cactus - project's roadmap with the author's permission. -

- -

Our users keep inventing better ways and adding new - requirements. The downside is that our todo list keeps - growing. The upside is that there is plenty of work to go - around. If you are interested in participating, send an email - on the log4j-dev@ mailing list stating your interest. You'll - be promptly enrolled. We're always looking for help! Don't be - put off if in the "Volunteer" column already has a person - listed. Programming is fun, especially if it is done in a - team. -

- -

- -

- - -
- -
- -

With log4j 1.2 still in beta, the workplan for log4j 1.3 is - obviously not final. It is included here to give you an idea - of the future. The items are not listed in any particular - order. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LabelCommentVolunteerStatus
test cases -

Writing test cases is not the most sexy part of - software development but it is one of the most - important. Automated test cases allow us to catch bugs - as early is possible. It is strongly recommended to add - a new test case with each new feature or component.

- -

Existing Perl language based test cases are - gradually being migrated to junit (all-Java)based test - cases. The new tests are placed under the - tests/ directory. It should be thus - possible for participants in the project to understand - the stucture of our tests and add tests for their - components. -

-
All committersongoing effort
Extensible XML configuration files -

The DOMConfigurator is complex and not very - flexible. It can only deal with elements that the - developer knew about at compilation time. This has been - an important drawback in the design of several appenders - such as the the SMTPAppender and the - RollingFileAppenders and its variants. These appenders - need to delegate certain task to sub-components which - are configured separately. -

- -

The support for extensible configuration files will be - based on the code in commons-digester authored by Craig - McClanahan and Scott Sanders. They graciously granted - permission for the modification of their code and its - inclusion in log4j.

-
Cekidesign board
Log4j Domains -

This is a very powerful and innovative concept that - extends the notion of hierarchical loggers. It will also - allow dynamic logging with pin-point accuracy. It was - first suggested to me by Scott Stark of JBoss fame. -

-
Cekidesign board
Multiple implementations of Logger -

Based on RepositorySelectors introduced in - log4j 1.2, the user will be able to replace the - Logger implementation. Several - implementations will be provided offering different - properties and functionality although none of the - implementations will add new public methods. -

-
?vaporware
Improvements to Chainsaw -

Visualisation and dynamic filtering of logging event is - bound to be a very important area of activity in the - future. A number of important improvements to chainsaw - have been suggested. -

- -
Oliver Burnunder discusison
Custom conversion characters in PatternLayoutUsers often want to add new conversions characters or - override the existing ones. This should be made easy using - new configuration directives. This feature would use the - extensions to XML configuration language mentioned - above.?not started
Overture to other programming languagesIt is higly desriable to allow log4j ports in other languages - to access log4j services in a language independent way. - ?not started
Strategy based rollovers -

Contrary to our own DailyRollingFileAppender, Avalon's - logkit has a nice and clean implementation for rolling - files. See the - org.apache.log.output.io.rotate package for - exact details. -

- -

Their implementation is based on strategies which are - sub-components of appender. We will be able to configure - such sub-components with the new XML configuration - scripts. -

-
Kevin Steppenot started
Redesign of configure and watch architecture in - configuratorsThis is a very useful feature and the current architecture is not very good. - -

Contributions have been received by Mark Womack and others.

- -

See -

-     http://www.mail-archive.com/log4j-dev@jakarta.apache.org/msg01390.html
-     http://www.mail-archive.com/log4j-user@jakarta.apache.org/msg00666.html
-     http://marc.theaimsgroup.com/?t=101010070500002&r=1&w=2
-              
-

-
Mark Womackinitial implementation
Performance improvements to LoggingEvent serialization -

Ole Dalgaard has shown that by implementing the - java.io.Externalizable interface instead of - java.io.Serializable in the LoggingEvent class, the - speed of serialiazation is increased by a factor of 4 or - more. -

- -
Ole Dalgaard?initial implementation
-
- - - -
-

- Here is workplan for the 1.2 release. As always, there is no - scheduled release date. The lack of schedule suprises and - disturbs some people. Writing good software, like good - cooking, takes time. If we make you wait, it is to create a - better and more reliable product. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LabelCommentVolunteerStatus
More test casesWe need more automated test cases to catch bugs as early - is possible.It is highly recommended to add a new test case - with each new feature or component.All committersongoing effort
Removal of deprecated methodsDeprecated setOption and getOption - methods in appender and layouts should be removed.Cekidone
JDBCAppender -

We currently have two competing JDBCAppenders: one by - Thomas Fenner and the other by Kevin Steppe.

- -

Kevin Steppe stood up and did it.

-
Kevin Steppedone
Log4j in appletsIn order to minimize network traffic, the size of log4j-core.jar - needs to be reduced to at most 50KB. - -

Log4jME has been released. It's less than 20KB.

-
Cekidone
Improved documentationLog4j documentation needs to be enhanced with configuration - examples and much more hand-holding.Cekiongoing effort
Mapped Diagnostic ContextsMapped Diagnostic Contexts are similar to the NDC - except that the MDC is a string to string map instead of - a stack that the user sets when entering a special - context. The PatternLayout has to be - enhanced to support this by extending the %x pattern to - accept an argument. Here is an example: - -
-    ConversionPattern=3D%d %p %c %x{server} %x{host} - %m%n
-	    
- - User code: -
-    {
-       MDC.put("server", "totoServer");
-       MDC.put("host", "someHost");
-	      
-       logger.debug("Hello");
-	      
-    }
-
- will print: -
2000-01-24 10:00:00,000 DEBUG totoServer someHost - Hello
- -

To make MDCs truly user friendly - ThreadLocal variables are required. This - will allow the MDC to be inherited by child - threads. ThreadLocal are only supported - under JDK 1.2 and above. In JDK 1.1, the MDC will not - work but won't harm the user application either.

-
Cekidone
Enhanced variable substitution support in DOMConfiguratorCekidone
FallbackErrorHandlerThe FallbackErrorHandler implements the ErrorHandler - interface such that a secondary appender may be - specified. This secondary appender takes over if the primary - appender fails for whatever reason. - -

The DOMConfigurator needs to be extended to support the - FallbackErrorHandler

- -
Cekiimplemented, requires further testing
Ensure backward compatibility of LoggingEvent - objectsTo avoid deployment problems we must ensure that - LoggingEvent objects are compatible between 1.2 and 1.1.3. - -

Robert Bushman has proposed a very innovative way for - solving this problem. See - http://www.mail-archive.com/log4j-dev@jakarta.apache.org/msg01397.html - for further details. -

-
Cekiimplemented, manually tested, requires automated test cases
-
- - - -
diff --git a/src/xdocs/srtw.xml b/src/xdocs/srtw.xml deleted file mode 100644 index 2c6ba837da..0000000000 --- a/src/xdocs/srtw.xml +++ /dev/null @@ -1,468 +0,0 @@ - - - - - Ceki Gulcu - Is JSR47 reinventing the wheel? - - - - - -
- -

As of version 0.8 of the JSR47 specification the - java.util.logging API resembles log4j even more - than was the case previously. The way the two APIs name their - components may differ but otherwise their degree of - resemblance is quite striking. -

- -

Changes introduced in the latest 0.8 draft include - configuration order independence, appender inheritance, - resource bundle inheritance, error handlers and lazy inference - of caller information. In other words, even if the priority - levels remain unchanged and somewhat bogus, the majority of - the points raised in my critique - of JSR47 are now obsolete. -

- -

Consequently, it is fair to say that our campaign to - influence the JSR47 API handsomely bore fruit. I wish to thank - the hundreds of concerned users who have expressed their - support for log4j. My gratitude goes to Jason Hunter for - arranging the appropriate communication channel to Sun. Graham - Hamilton, the JSR47 specification lead, was very open and - receptive during our exchanges. -

- -

From the user standpoint, there remain two critical - differences. First, JSR47 requires JDK 1.4 whereas log4j is - compatible with JDK 1.1 and later. Second, log4j offers much - more functionality. It supports a rich configuration language, - at least a dozen appenders and layouts as well as many other - useful features.

- -

Efforts to backport JSR47 to earlier JDKs are doomed to fail - because the java.util.logging package is located - under the java namespace. This will cause - backported code to systematically throw a - SecurityException under JDK 1.3. Moreover, Java - is a trademark owned by Sun Microsystems. As such, the - backported code will be under the threat of litigation as long - as Sun can be expected to defend its trademark. -

- -

If you take the time to study the terms of the final draft of - the JSR47 specification, you will discover a copyright notice - containing the following text.

- -
-  
-  Sun hereby grants you a fully-paid, non-exclusive, non-transferable,
-  worldwide, limited license (without the right to sublicense), under
-  Sun's intellectual property rights that are essential to practice
-  the Specification, to internally practice the Specification solely
-  for the purpose of creating a clean room implementation of the
-  Specification that: (i) includes a complete implementation of
-  the current version of the Specification, without subsetting or
-  superset-ting; (ii) implements all of the interfaces and
-  functionality of the Specification, as defined by Sun, without
-  sub-setting or supersetting; (iii) includes a complete
-  implementation of any optional components (as defined by Sun in the
-  Specification) which you choose to implement, without subsetting or
-  supersetting; (iv) implements all of the interfaces and
-  functionality of such optional components, without subsetting or
-  supersetting; (v) does not add any additional packages,
-  classes or interfaces to the "java.*" or "javax.*" packages or
-  subpackages (or other pack-ages defined by Sun); (vi)
-  satisfies all testing requirements available from Sun relating to
-  the most recently pub-lished version of the Specification six (6)
-  months prior to any release of the clean room implementation or
-  upgrade thereto; (vii) does not derive from any Sun source
-  code or binary code materials; and (viii) does not include
-  any Sun source code or binary code materials without an appropriate
-  and separate license from Sun. The Specification contains the
-  proprietary information of Sun and may only be used in accordance
-  with the license terms set forth herein. This license will terminate
-  immediately without notice from Sun if you fail to comply with any
-  provision of this license. Upon termination or expiration of this
-  license, you must cease use of or destroy the Specification.
-
- -

Given these business terms it is not possible for log4j or - other independent parties to implement the JSR47 - specification. Here is how the Apache Software foundation, a - member of the JCP Executive Committee, voted on this - JSR.

- -
- - The Apache Software Foundation is grateful for the significant - efforts of the JSR 47 spec lead, Graham Hamilton, toward addressing - the technical concerns raised by the members and lead of Apache's - log4j project. Regretfully, under the Merlin business terms, log4j - (or any other potential independent implementation of this - specification) cannot make use of the Specification, not can anyone - implement this specification for earlier J2SE platforms (J2SE 1.2, - 1.3), and it is on this basis that Apache cannot support this JSR. -
- -

This problems is not specific to JSR47. Most other JSR - specifications contain similar business terms which are not - exactly designed to facilitate independent implementations. -

- -
- -
- -

Log4j is the de facto standard logging API in Java. It has - been ported to Python, Ruby, C, C++, Eiffel and the much - maligned C#. By adopting log4j, you simultaneously benefit - from much richer functionality and wider JDK - compatibility. With the support of the log4j community, the - log4j project will continue to innovate and lead the way. As - such, many of the features that you need will be first - available in log4j.

- -

There are many other details in which log4j differs from - JSR47. Even if the log4j core is small, the project contains a - total of over 30'000 lines of well-tested code. JSR47 contains - about 5'000 lines of code. -

- -

It is likely that you will need an additional logging library - to fill in the functionality gap, the JDK compatibility gap, - or both. If you are going to install one or more logging APIs, - then why not install log4j which offers a lot more than JSR47 - and is backward compatible with JDK 1.1? -

- -

Log4j has been around for a number of years, enjoys the - support of an active community and is being used in thousands - of projects. Our site gets over 600 downloads each and every - day, and the numbers are on the rise. Companies are also - offering commercial products extending log4j. -

- -

Here is a short list of open source projects or sites that are - known to use log4j.

- - - -

Sun is setting a dangerous precedent by ignoring a rather - successful open source project. If it happens to log4j, can it - happen to other open source projects?

- -

Contact Sun

- -

If you feel that Sun is reinventing the wheel and setting a - dangerous precedent, then this the time to ask Sun to adopt - log4j as the official logging API for the Java language.

- -

Please direct your polite and personalized request to jsr-47-comments@jcp.org with Bcc: to ceki@apache.org. -

- -

Many individuals have written to Sun to express their - concern, in their vast majority pushing for the adoption of - log4j. Their names and the content of their request are listed - below. We are very grateful for their support. Some of these - requests are quite detailed and insightful. -

- - - -

Most of the e-mail notes are reproduced with - permission. However, do not hesitate to contact ceki@apache.org in case you are - uncomfortable seeing your name or the contents of your request - reproduced publicly.

-
- - -
diff --git a/src/xdocs/stylesheets/project.xml b/src/xdocs/stylesheets/project.xml deleted file mode 100644 index c5640aa79e..0000000000 --- a/src/xdocs/stylesheets/project.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - Log4j project - The log4j project - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/build.properties.sample b/tests/build.properties.sample index 49128767a9..5f0f1b879d 100644 --- a/tests/build.properties.sample +++ b/tests/build.properties.sample @@ -1,4 +1,48 @@ -jakarta.oro.jar=../../jakarta-oro-2.0.5/jakarta-oro-2.0.5.jar +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# by default assume that all necessary dependencies +# are relative to the user's home directory +# +lib.home.dir=/java + +# The jaxp interface and a jaxp parser are required +# to build the DOMConfigurator. +# +# modern equivalents are xml-commons-apis.jar +# and xercesImpl.jar +jaxp.home=${lib.home.dir}/crimson-1.1.3 +jaxp.jaxp.jar=${jaxp.home}/crimson.jar +jaxp.parser.jar=${jaxp.home}/crimson.jar + +jakarta.oro.jar=${lib.home.dir}/jakarta-oro-2.0.8/jakarta-oro-2.0.8.jar +clover.jar=${lib.home.dir}/clover-1.3.8/lib/clover.jar deprecation=on -# junit must be on the classpath! It can't be handled as a property. +# junit must be on the classpath or specified with -lib +# only needs to be set here for JDK 1.1. +junit.jar=${lib.home.dir}/junit3.8.1/junit.jar + +# +# Jalopy source code reformatter +# +# +jalopy-ant.dir=${lib.home.dir}/jalopy-ant-0.6.2 + +# +# Checkstyle coding convention checker +# +checkstyle.jar=${lib.home.dir}/checkstyle-4.0-beta2/checkstyle-all-4.0-beta2.jar diff --git a/tests/build.xml b/tests/build.xml index a249bdd70c..527282f372 100644 --- a/tests/build.xml +++ b/tests/build.xml @@ -1,6 +1,23 @@ + - + @@ -10,6 +27,15 @@ + + + + + + + + @@ -18,19 +44,28 @@ - + - + + + + + + + + + + @@ -49,30 +84,58 @@ 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. + then the compilation of its dependents are skipped. - regression - Run regression ests which check large parts of log4j. - unit - Run unit tests which check one component at a time. - longUnit - Run long unit tests which check one component at a time. + regression - Run regression tests which check large parts of log4j. runAll - run all available tests + + Specify the log4j.jar property to test an arbitrary jar, + otherwise the parent log4j will be built and tested. + + + + + + + + + + + + + + + + + + + + + + - + + + target="${javac.target}" + source="${javac.source}" + debug="on" + excludes="${excludes}"> @@ -96,13 +159,15 @@ - + CyclicBuffer, OR, + LevelMatchFilter, PatternParser, + PatternLayout, RFA, ERFA, DRFA, + NTEventLogAppender, Syslog, Socket"/> @@ -112,8 +177,19 @@ + + + + + + + + + - + @@ -121,7 +197,8 @@ - + @@ -129,7 +206,8 @@ - + @@ -138,7 +216,8 @@ - + @@ -146,7 +225,8 @@ - + @@ -154,7 +234,8 @@ - + @@ -162,34 +243,93 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - + + + + + + + - + @@ -197,7 +337,8 @@ - + @@ -205,16 +346,26 @@ - + + + + + + + + - + @@ -222,7 +373,8 @@ - + @@ -230,16 +382,27 @@ - + + + + + + + + + - + @@ -247,18 +410,137 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + clover.jar must be in the classpath and should also be + placed in the lib directory. A version of clover + (http://www.cenqua.com/clover) for use with ASF projects + is available from the committers/donated-licenses/clover module + in the SVN repository. + + + + + + + + + + + + + + + + + + + + + + + +Specify files to reformat with -Djalopy.files=PATTERN. + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/input/RFA1.properties b/tests/input/RFA1.properties new file mode 100644 index 0000000000..d4e3fa331c --- /dev/null +++ b/tests/input/RFA1.properties @@ -0,0 +1,12 @@ +log4j.rootLogger=DEBUG, testAppender +log4j.appender.testAppender=org.apache.log4j.RollingFileAppender +log4j.appender.testAppender.file=output/RFA-test1.log +log4j.appender.testAppender.Append=false +log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout +log4j.appender.testAppender.layout.ConversionPattern=%m\n +log4j.appender.testAppender.maxFileSize=100 + +# Prevent internal log4j DEBUG messages from polluting the output. +log4j.logger.org.apache.log4j.PropertyConfigurator=INFO +log4j.logger.org.apache.log4j.config.PropertySetter=INFO +log4j.logger.org.apache.log4j.FileAppender=INFO diff --git a/tests/input/defaultInit3.properties b/tests/input/defaultInit3.properties new file mode 100644 index 0000000000..ce38951cac --- /dev/null +++ b/tests/input/defaultInit3.properties @@ -0,0 +1,7 @@ + +log4j.rootCategory=DEBUG, D3 +log4j.appender.D3=org.apache.log4j.FileAppender +log4j.appender.D3.File=output/temp +log4j.appender.D3.Append=false +log4j.appender.D3.layout=org.apache.log4j.PatternLayout +log4j.appender.D3.layout.ConversionPattern=%d [%t] %-5p %.16c - %m%n \ No newline at end of file diff --git a/tests/input/patternLayout1.properties b/tests/input/patternLayout1.properties index 28dcfd0210..1e50266e42 100644 --- a/tests/input/patternLayout1.properties +++ b/tests/input/patternLayout1.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File=output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/patternLayout10.properties b/tests/input/patternLayout10.properties index a137a7e8e2..ac729acf92 100644 --- a/tests/input/patternLayout10.properties +++ b/tests/input/patternLayout10.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File= output/temp log4j.appender.testAppender.Append= false diff --git a/tests/input/patternLayout11.properties b/tests/input/patternLayout11.properties index af739f6cdf..e3bcfec9af 100644 --- a/tests/input/patternLayout11.properties +++ b/tests/input/patternLayout11.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File=output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/patternLayout12.properties b/tests/input/patternLayout12.properties index acc45d3311..37c829b7e2 100644 --- a/tests/input/patternLayout12.properties +++ b/tests/input/patternLayout12.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File=output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/patternLayout13.properties b/tests/input/patternLayout13.properties index 15a00762e8..54be2123ce 100644 --- a/tests/input/patternLayout13.properties +++ b/tests/input/patternLayout13.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File= output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/patternLayout14.properties b/tests/input/patternLayout14.properties index 479d4c504c..fb4f8636f8 100644 --- a/tests/input/patternLayout14.properties +++ b/tests/input/patternLayout14.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File= output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/patternLayout2.properties b/tests/input/patternLayout2.properties index 1e286f6ebf..7d0081baab 100644 --- a/tests/input/patternLayout2.properties +++ b/tests/input/patternLayout2.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File=output/temp log4j.appender.testAppender.Append= false diff --git a/tests/input/patternLayout3.properties b/tests/input/patternLayout3.properties index f606740b37..1390a60c3b 100644 --- a/tests/input/patternLayout3.properties +++ b/tests/input/patternLayout3.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File=output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/patternLayout4.properties b/tests/input/patternLayout4.properties index 49cc887927..f220c7d658 100644 --- a/tests/input/patternLayout4.properties +++ b/tests/input/patternLayout4.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File=output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/patternLayout5.properties b/tests/input/patternLayout5.properties index 84caecd83f..f10b8321be 100644 --- a/tests/input/patternLayout5.properties +++ b/tests/input/patternLayout5.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File=output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/patternLayout6.properties b/tests/input/patternLayout6.properties index 529c856ab5..5dcff9b323 100644 --- a/tests/input/patternLayout6.properties +++ b/tests/input/patternLayout6.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File=output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/patternLayout7.properties b/tests/input/patternLayout7.properties index 789dcce737..811caa842c 100644 --- a/tests/input/patternLayout7.properties +++ b/tests/input/patternLayout7.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File=output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/patternLayout8.properties b/tests/input/patternLayout8.properties index 3fbef7bcbb..1b08d57c5a 100644 --- a/tests/input/patternLayout8.properties +++ b/tests/input/patternLayout8.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File=output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/patternLayout9.properties b/tests/input/patternLayout9.properties index 2551500d79..138e95d61f 100644 --- a/tests/input/patternLayout9.properties +++ b/tests/input/patternLayout9.properties @@ -1,4 +1,4 @@ -log4j.rootCategory=DEBUG, testAppender +log4j.rootCategory=TRACE, testAppender log4j.appender.testAppender=org.apache.log4j.FileAppender log4j.appender.testAppender.File=output/temp log4j.appender.testAppender.Append=false diff --git a/tests/input/socketServer1.properties b/tests/input/socketServer1.properties index c1d478524e..406bcec7a7 100644 --- a/tests/input/socketServer1.properties +++ b/tests/input/socketServer1.properties @@ -1,4 +1,4 @@ -log4j.rootLogger=DEBUG, A +log4j.rootLogger=TRACE, A log4j.logger.org.apache.log4j.test.ShortSocketServer=WARN log4j.logger.org.apache.log4j.net.SocketNode=WARN log4j.appender.A=org.apache.log4j.FileAppender diff --git a/tests/input/socketServer2.properties b/tests/input/socketServer2.properties index 5e6cd2c312..0eb0898529 100644 --- a/tests/input/socketServer2.properties +++ b/tests/input/socketServer2.properties @@ -1,4 +1,4 @@ -log4j.rootLogger=DEBUG, A +log4j.rootLogger=TRACE, A log4j.logger.org.apache.log4j.test.ShortSocketServer=WARN log4j.logger.org.apache.log4j.net.SocketNode=WARN log4j.appender.A=org.apache.log4j.FileAppender diff --git a/tests/input/socketServer3.properties b/tests/input/socketServer3.properties index c19530172c..406b6d2135 100644 --- a/tests/input/socketServer3.properties +++ b/tests/input/socketServer3.properties @@ -1,4 +1,4 @@ -log4j.rootLogger=DEBUG, A +log4j.rootLogger=TRACE, A log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN log4j.Logger.org.apache.log4j.net.SocketNode=WARN log4j.appender.A=org.apache.log4j.FileAppender diff --git a/tests/input/socketServer4.properties b/tests/input/socketServer4.properties index 6d8001ba51..dcb7619aeb 100644 --- a/tests/input/socketServer4.properties +++ b/tests/input/socketServer4.properties @@ -1,4 +1,4 @@ -log4j.rootLogger=DEBUG, A +log4j.rootLogger=TRACE, A log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN log4j.Logger.org.apache.log4j.net.SocketNode=WARN log4j.appender.A=org.apache.log4j.FileAppender diff --git a/tests/input/socketServer5.properties b/tests/input/socketServer5.properties new file mode 100644 index 0000000000..152964dba8 --- /dev/null +++ b/tests/input/socketServer5.properties @@ -0,0 +1,8 @@ +log4j.rootLogger=TRACE, A +log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN +log4j.Logger.org.apache.log4j.net.SocketNode=WARN +log4j.appender.A=org.apache.log4j.FileAppender +log4j.appender.A.file=output/temp +log4j.appender.A.Append=false +log4j.appender.A.layout=org.apache.log4j.PatternLayout +log4j.appender.A.layout.ConversionPattern=%5p %x %X{key1}%X{key5} [%t] %c{1} - %m%n diff --git a/tests/input/socketServer6.properties b/tests/input/socketServer6.properties new file mode 100644 index 0000000000..52e36a57a4 --- /dev/null +++ b/tests/input/socketServer6.properties @@ -0,0 +1,8 @@ +log4j.rootLogger=TRACE, A +log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN +log4j.Logger.org.apache.log4j.net.SocketNode=WARN +log4j.appender.A=org.apache.log4j.FileAppender +log4j.appender.A.file=output/temp +log4j.appender.A.Append=false +log4j.appender.A.layout=org.apache.log4j.PatternLayout +log4j.appender.A.layout.ConversionPattern=%5p %x %X{hostID} %X{key6} [%t] %c{1} - %m%n diff --git a/tests/input/socketServer7.properties b/tests/input/socketServer7.properties new file mode 100644 index 0000000000..4bf902877e --- /dev/null +++ b/tests/input/socketServer7.properties @@ -0,0 +1,8 @@ +log4j.rootLogger=TRACE, A +log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN +log4j.Logger.org.apache.log4j.net.SocketNode=WARN +log4j.appender.A=org.apache.log4j.FileAppender +log4j.appender.A.file=output/temp +log4j.appender.A.Append=false +log4j.appender.A.layout=org.apache.log4j.PatternLayout +log4j.appender.A.layout.ConversionPattern=%5p %x %X{hostID} %X{key7} [%t] %c{1} - %m%n diff --git a/tests/input/socketServer8.properties b/tests/input/socketServer8.properties new file mode 100644 index 0000000000..77dbff0916 --- /dev/null +++ b/tests/input/socketServer8.properties @@ -0,0 +1,8 @@ +log4j.rootLogger=TRACE, A +log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN +log4j.Logger.org.apache.log4j.net.SocketNode=WARN +log4j.appender.A=org.apache.log4j.FileAppender +log4j.appender.A.file=output/temp +log4j.appender.A.Append=false +log4j.appender.A.layout=org.apache.log4j.PatternLayout +log4j.appender.A.layout.ConversionPattern=%5p %x %X{hostID} %X{key8} [%t] %c{1} - %m%n diff --git a/tests/input/xml/DOMTest4.xml b/tests/input/xml/DOMTest4.xml new file mode 100644 index 0000000000..82efe1ee35 --- /dev/null +++ b/tests/input/xml/DOMTest4.xml @@ -0,0 +1,29 @@ + + + +]> + + + &a1; + &a2; + + + + + + + + + + + + + + + + + + + + diff --git a/tests/input/xml/DOMTest4_A1.xml b/tests/input/xml/DOMTest4_A1.xml new file mode 100644 index 0000000000..cd408ae08f --- /dev/null +++ b/tests/input/xml/DOMTest4_A1.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/input/xml/DOMTest4_A2.xml b/tests/input/xml/DOMTest4_A2.xml new file mode 100644 index 0000000000..302f0d88ab --- /dev/null +++ b/tests/input/xml/DOMTest4_A2.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/input/xml/DOMTestCase1.xml b/tests/input/xml/DOMTestCase1.xml index 514fd0ea09..c8314ea858 100644 --- a/tests/input/xml/DOMTestCase1.xml +++ b/tests/input/xml/DOMTestCase1.xml @@ -21,12 +21,12 @@ - + - + diff --git a/tests/input/xml/SocketAppenderTestConfig.xml b/tests/input/xml/SocketAppenderTestConfig.xml new file mode 100644 index 0000000000..2930b7b258 --- /dev/null +++ b/tests/input/xml/SocketAppenderTestConfig.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/input/xml/categoryfactory1.xml b/tests/input/xml/categoryfactory1.xml new file mode 100644 index 0000000000..369e7c9474 --- /dev/null +++ b/tests/input/xml/categoryfactory1.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/input/xml/categoryfactory2.xml b/tests/input/xml/categoryfactory2.xml new file mode 100644 index 0000000000..146e5f2429 --- /dev/null +++ b/tests/input/xml/categoryfactory2.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/input/xml/defaultInit.xml b/tests/input/xml/defaultInit.xml new file mode 100644 index 0000000000..58adbd40c3 --- /dev/null +++ b/tests/input/xml/defaultInit.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/src/java/org/apache/log4j/test/xml/fallback1.xml b/tests/input/xml/fallback1.xml similarity index 83% rename from src/java/org/apache/log4j/test/xml/fallback1.xml rename to tests/input/xml/fallback1.xml index 2ba20018e4..e11e95baf8 100644 --- a/src/java/org/apache/log4j/test/xml/fallback1.xml +++ b/tests/input/xml/fallback1.xml @@ -14,15 +14,15 @@ - + - + - + diff --git a/tests/input/xml/loggerfactory1.xml b/tests/input/xml/loggerfactory1.xml new file mode 100644 index 0000000000..c2514a7631 --- /dev/null +++ b/tests/input/xml/loggerfactory1.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/log4j-coding-convention.xml b/tests/log4j-coding-convention.xml new file mode 100644 index 0000000000..602c04638b --- /dev/null +++ b/tests/log4j-coding-convention.xml @@ -0,0 +1,225 @@ + + + + + 14 + + + + + 6 + + + + true + false + true + false + false + + + +
1
+
+ +
0
+
+
+ + + false + false + + + false + false + true + false + + + true + false + false + false + false + + + false + false + + + + + false + + + + false + false + false + + false + + 0 + 0 + 0 + 0 + + false + + + + + + + false + false + false + + +
+ +
+
+ * Copyright|The Apache Software License, Version 1.1| * Copyright (C) The Apache Software Foundation. All rights reserved. + 0 + /*| * Copyright 1999,2005 The Apache Software Foundation.| *| * Licensed under the Apache License, Version 2.0 (the "License");| * you may not use this file except in compliance with the License.| * You may obtain a copy of the License at| *| * http://www.apache.org/licenses/LICENSE-2.0| *| * Unless required by applicable law or agreed to in writing, software| * distributed under the License is distributed on an "AS IS" BASIS,| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.| * See the License for the specific language governing permissions and| * limitations under the License.| */ + true +
+ + timestamp + disabled + + + disabled + + + false + + true + false + + true + + + false + + + 1 + 1 + 0 + 1 + 2 + 55 + -1 + 2 + -1 + 0 + 8 + -1 + 1 + + + false + false + + + + + static|field|initializer|constructor|method|interface|class + + + true + public|protected|private|abstract|static|final|synchronized|transient|volatile|native|strictfp + + + + + true + true + true + + + true + false + false + false + + false + + + false + false + true + + + + true + false + + true + true + true + true + true + true + + false + false + + + + + + 0 + false + false + false + + false + + false + false + + false + + + false + false + false + false + + + false + false + false + + + + true + true + 79 + + + + true + true + false + + false + false + false + + + + false + + false + + +
+
+ diff --git a/tests/run-tests.bat b/tests/run-tests.bat new file mode 100755 index 0000000000..504a10593d --- /dev/null +++ b/tests/run-tests.bat @@ -0,0 +1,97 @@ +rem Batch file for running tests on JDK 1.1 +rem +SET CLASSPATH=\java\junit3.8.1\junit.jar;\java\crimson-1.1.3\crimson.jar;\java\jakarta-oro-2.0.8\jakarta-oro-2.0.8.jar;target\classes;..\..\target\classes;resources;%log4j.jar% +mkdir target +mkdir target\classes +cd src\java +javac -d ..\..\target\classes org\apache\log4j\util\SerializationTestHelper.java +javac -d ..\..\target\classes org\apache\log4j\spi\LoggingEventTest.java +javac -d ..\..\target\classes org\apache\log4j\LevelTest.java +javac -d ..\..\target\classes org\apache\log4j\FileAppenderTest.java +javac -d ..\..\target\classes org\apache\log4j\PriorityTest.java +javac -d ..\..\target\classes org\apache\log4j\CategoryTest.java +javac -d ..\..\target\classes org\apache\log4j\LogManagerTest.java +javac -d ..\..\target\classes org\apache\log4j\helpers\LogLogTest.java +javac -d ..\..\target\classes org\apache\log4j\LayoutTest.java +javac -d ..\..\target\classes org\apache\log4j\helpers\DateLayoutTest.java +javac -d ..\..\target\classes org\apache\log4j\TTCCLayoutTest.java +javac -d ..\..\target\classes org\apache\log4j\xml\XMLLayoutTest.java +javac -d ..\..\target\classes org\apache\log4j\HTMLLayoutTest.java +javac -d ..\..\target\classes org\apache\log4j\PatternLayoutTest.java +javac -d ..\..\target\classes org\apache\log4j\spi\ThrowableInformationTest.java +javac -d ..\..\target\classes org\apache\log4j\spi\LocationInfoTest.java +javac -d ..\..\target\classes org\apache\log4j\PropertyConfiguratorTest.java +javac -d ..\..\target\classes org\apache\log4j\CoreTestSuite.java +javac -d ..\..\target\classes org\apache\log4j\util\UnexpectedFormatException.java +javac -d ..\..\target\classes org\apache\log4j\util\Filter.java +javac -d ..\..\target\classes org\apache\log4j\util\Compare.java +javac -d ..\..\target\classes org\apache\log4j\util\ControlFilter.java +javac -d ..\..\target\classes org\apache\log4j\util\Transformer.java +javac -d ..\..\target\classes org\apache\log4j\util\LineNumberFilter.java +javac -d ..\..\target\classes org\apache\log4j\util\AbsoluteDateAndTimeFilter.java +javac -d ..\..\target\classes org\apache\log4j\MinimumTestCase.java +javac -d ..\..\target\classes org\apache\log4j\VectorAppender.java +javac -d ..\..\target\classes org\apache\log4j\LoggerTestCase.java +javac -d ..\..\target\classes org\apache\log4j\util\ISO8601Filter.java +javac -d ..\..\target\classes org\apache\log4j\util\SunReflectFilter.java +javac -d ..\..\target\classes org\apache\log4j\util\JunitTestRunnerFilter.java +javac -d ..\..\target\classes org\apache\log4j\xml\DOMTestCase.java +javac -d ..\..\target\classes org\apache\log4j\xml\XLevel.java +javac -d ..\..\target\classes org\apache\log4j\xml\CustomLevelTestCase.java +javac -d ..\..\target\classes org\apache\log4j\customLogger\XLogger.java +javac -d ..\..\target\classes org\apache\log4j\customLogger\XLoggerTestCase.java +javac -d ..\..\target\classes org\apache\log4j\defaultInit\TestCase1.java +javac -d ..\..\target\classes org\apache\log4j\defaultInit\TestCase3.java +javac -d ..\..\target\classes org\apache\log4j\defaultInit\TestCase4.java +javac -d ..\..\target\classes org\apache\log4j\util\XMLTimestampFilter.java +javac -d ..\..\target\classes org\apache\log4j\util\XMLLineAttributeFilter.java +javac -d ..\..\target\classes org\apache\log4j\xml\XMLLayoutTestCase.java +javac -d ..\..\target\classes org\apache\log4j\AsyncAppenderTestCase.java +javac -d ..\..\target\classes org\apache\log4j\helpers\OptionConverterTestCase.java +javac -d ..\..\target\classes org\apache\log4j\helpers\BoundedFIFOTestCase.java +javac -d ..\..\target\classes org\apache\log4j\helpers\CyclicBufferTestCase.java +javac -d ..\..\target\classes org\apache\log4j\or\ORTestCase.java +javac -d ..\..\target\classes org\apache\log4j\varia\LevelMatchFilterTestCase.java +javac -d ..\..\target\classes org\apache\log4j\helpers\PatternParserTestCase.java +javac -d ..\..\target\classes org\apache\log4j\util\AbsoluteTimeFilter.java +javac -d ..\..\target\classes org\apache\log4j\util\RelativeTimeFilter.java +javac -d ..\..\target\classes org\apache\log4j\PatternLayoutTestCase.java +javac -d ..\..\target\classes org\apache\log4j\MyPatternParser.java +javac -d ..\..\target\classes org\apache\log4j\MyPatternLayout.java +javac -d ..\..\target\classes org\apache\log4j\VectorErrorHandler.java +javac -d ..\..\target\classes org\apache\log4j\DRFATestCase.java +cd ..\.. +mkdir output +java junit.textui.TestRunner org.apache.log4j.CoreTestSuite +java junit.textui.TestRunner org.apache.log4j.MinimumTestCase +java junit.textui.TestRunner org.apache.log4j.LoggerTestCase +java junit.textui.TestRunner org.apache.log4j.xml.DOMTestCase +java junit.textui.TestRunner org.apache.log4j.xml.CustomLevelTestCase +java junit.textui.TestRunner org.apache.log4j.customLogger.XLoggerTestCase +del target\classes\log4j.xml +del target\classes\log4j.properties +java junit.textui.TestRunner org.apache.log4j.defaultInit.TestCase1 +copy input\xml\defaultInit.xml target\classes\log4j.xml +java junit.textui.TestRunner org.apache.log4j.defaultInit.TestCase2 +del target\classes\log4j.xml +copy input\xml\defaultInit.xml target\classes\log4j.xml +java -Dlog4j.defaultInitOverride=true junit.textui.TestRunner org.apache.log4j.defaultInit.TestCase1 +del target\classes\log4j.xml +copy input\defaultInit3.properties target\classes\log4j.properties +java junit.textui.TestRunner org.apache.log4j.defaultInit.TestCase3 +del target\classes\log4j.properties +copy input\xml\defaultInit.xml target\classes\log4j.xml +copy input\defaultInit3.properties target\classes\log4j.properties +java junit.textui.TestRunner org.apache.log4j.defaultInit.TestCase4 +del target\classes\log4j.xml +del target\classes\log4j.properties +java junit.textui.TestRunner org.apache.log4j.xml.XMLLayoutTestCase +java junit.textui.TestRunner org.apache.log4j.AsyncAppenderTestCase +java junit.textui.TestRunner org.apache.log4j.helpers.OptionConverterTestCase +java junit.textui.TestRunner org.apache.log4j.helpers.BoundedFIFOTestCase +java junit.textui.TestRunner org.apache.log4j.helpers.CyclicBufferTestCase +java junit.textui.TestRunner org.apache.log4j.or.ORTestCase +java junit.textui.TestRunner org.apache.log4j.varia.LevelMatchFilterTestCase +java junit.textui.TestRunner org.apache.log4j.helpers.PatternParserTestCase +java junit.textui.TestRunner org.apache.log4j.PatternLayoutTestCase +java junit.textui.TestRunner org.apache.log4j.DRFATestCase diff --git a/tests/src/java/org/apache/log4j/AsyncAppenderTestCase.java b/tests/src/java/org/apache/log4j/AsyncAppenderTestCase.java index 7d42aca8ab..85e75be33d 100644 --- a/tests/src/java/org/apache/log4j/AsyncAppenderTestCase.java +++ b/tests/src/java/org/apache/log4j/AsyncAppenderTestCase.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; @@ -14,7 +24,8 @@ import java.util.Vector; import org.apache.log4j.*; -import org.apache.log4j.performance.NullAppender; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.varia.NullAppender; /** A superficial but general test of log4j. @@ -28,14 +39,17 @@ public AsyncAppenderTestCase(String name) { public void setUp() { } - public void tearDown() { + public void tearDown() { + LogManager.shutdown(); } + // this test checks whether it is possible to write to a closed AsyncAppender public void closeTest() throws Exception { Logger root = Logger.getRootLogger(); Layout layout = new SimpleLayout(); VectorAppender vectorAppender = new VectorAppender(); AsyncAppender asyncAppender = new AsyncAppender(); + asyncAppender.setName("async-CloseTest"); asyncAppender.addAppender(vectorAppender); root.addAppender(asyncAppender); @@ -45,14 +59,271 @@ public void closeTest() throws Exception { Vector v = vectorAppender.getVector(); assertEquals(v.size(), 1); - + } + + // this test checks whether appenders embedded within an AsyncAppender are also + // closed + public void test2() { + Logger root = Logger.getRootLogger(); + Layout layout = new SimpleLayout(); + VectorAppender vectorAppender = new VectorAppender(); + AsyncAppender asyncAppender = new AsyncAppender(); + asyncAppender.setName("async-test2"); + asyncAppender.addAppender(vectorAppender); + root.addAppender(asyncAppender); + root.debug("m1"); + asyncAppender.close(); + root.debug("m2"); + + Vector v = vectorAppender.getVector(); + assertEquals(v.size(), 1); + assertTrue(vectorAppender.isClosed()); } - public static Test suite() { - TestSuite suite = new TestSuite(); - suite.addTest(new AsyncAppenderTestCase("closeTest")); - return suite; + // this test checks whether appenders embedded within an AsyncAppender are also + // closed + public void test3() { + int LEN = 200; + Logger root = Logger.getRootLogger(); + Layout layout = new SimpleLayout(); + VectorAppender vectorAppender = new VectorAppender(); + AsyncAppender asyncAppender = new AsyncAppender(); + asyncAppender.setName("async-test3"); + asyncAppender.addAppender(vectorAppender); + root.addAppender(asyncAppender); + + for(int i = 0; i < LEN; i++) { + root.debug("message"+i); + } + + System.out.println("Done loop."); + System.out.flush(); + asyncAppender.close(); + root.debug("m2"); + + Vector v = vectorAppender.getVector(); + assertEquals(v.size(), LEN); + assertTrue(vectorAppender.isClosed()); } + private static class NullPointerAppender extends AppenderSkeleton { + public NullPointerAppender() { + } + + + /** + This method is called by the {@link org.apache.log4j.AppenderSkeleton#doAppend} + method. + + */ + public void append(org.apache.log4j.spi.LoggingEvent event) { + throw new NullPointerException(); + } + + public void close() { + } + + public boolean requiresLayout() { + return false; + } + } + + + /** + * Tests that a bad appender will switch async back to sync. + * See bug 23021 + * @since 1.2.12 + * @throws Exception thrown if Thread.sleep is interrupted + */ + public void testBadAppender() throws Exception { + Appender nullPointerAppender = new NullPointerAppender(); + AsyncAppender asyncAppender = new AsyncAppender(); + asyncAppender.addAppender(nullPointerAppender); + asyncAppender.setBufferSize(5); + asyncAppender.activateOptions(); + Logger root = Logger.getRootLogger(); + root.addAppender(nullPointerAppender); + try { + root.info("Message"); + Thread.sleep(10); + root.info("Message"); + fail("Should have thrown exception"); + } catch(NullPointerException ex) { + + } + } + + /** + * Tests location processing when buffer is full and locationInfo=true. + * See bug 41186. + */ + public void testLocationInfoTrue() { + BlockableVectorAppender blockableAppender = new BlockableVectorAppender(); + AsyncAppender async = new AsyncAppender(); + async.addAppender(blockableAppender); + async.setBufferSize(5); + async.setLocationInfo(true); + async.setBlocking(false); + async.activateOptions(); + Logger rootLogger = Logger.getRootLogger(); + rootLogger.addAppender(async); + Greeter greeter = new Greeter(rootLogger, 100); + synchronized(blockableAppender.getMonitor()) { + greeter.run(); + rootLogger.error("That's all folks."); + } + async.close(); + Vector events = blockableAppender.getVector(); + LoggingEvent initialEvent = (LoggingEvent) events.get(0); + LoggingEvent discardEvent = (LoggingEvent) events.get(events.size() - 1); + PatternLayout layout = new PatternLayout(); + layout.setConversionPattern("%C:%L %m%n"); + layout.activateOptions(); + String initialStr = layout.format(initialEvent); + assertEquals(AsyncAppenderTestCase.class.getName(), + initialStr.substring(0, AsyncAppenderTestCase.class.getName().length())); + String discardStr = layout.format(discardEvent); + assertEquals("?:? ", discardStr.substring(0, 4)); + } + + + /** + * Tests location processing when buffer is full and locationInfo=false. + * See bug 41186. + */ + public void testLocationInfoFalse() { + BlockableVectorAppender blockableAppender = new BlockableVectorAppender(); + AsyncAppender async = new AsyncAppender(); + async.addAppender(blockableAppender); + async.setBufferSize(5); + async.setLocationInfo(false); + async.setBlocking(false); + async.activateOptions(); + Logger rootLogger = Logger.getRootLogger(); + rootLogger.addAppender(async); + Greeter greeter = new Greeter(rootLogger, 100); + synchronized(blockableAppender.getMonitor()) { + greeter.run(); + rootLogger.error("That's all folks."); + } + async.close(); + Vector events = blockableAppender.getVector(); + LoggingEvent initialEvent = (LoggingEvent) events.get(0); + LoggingEvent discardEvent = (LoggingEvent) events.get(events.size() - 1); + PatternLayout layout = new PatternLayout(); + layout.setConversionPattern("%C:%L %m%n"); + layout.activateOptions(); + String initialStr = layout.format(initialEvent); + assertEquals("?:? ", initialStr.substring(0, 4)); + String discardStr = layout.format(discardEvent); + assertEquals("?:? ", discardStr.substring(0, 4)); + } + + /** + * Logging request runnable. + */ + private static final class Greeter implements Runnable { + /** + * Logger. + */ + private final Logger logger; + + /** + * Repetitions. + */ + private final int repetitions; + + /** + * Create new instance. + * @param logger logger, may not be null. + * @param repetitions repetitions. + */ + public Greeter(final Logger logger, final int repetitions) { + if (logger == null) { + throw new IllegalArgumentException("logger"); + } + + this.logger = logger; + this.repetitions = repetitions; + } + + /** + * {@inheritDoc} + */ + public void run() { + try { + for (int i = 0; i < repetitions; i++) { + logger.info("Hello, World"); + Thread.sleep(1); + } + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } + } + } + + + + /** + * Vector appender that can be explicitly blocked. + */ + private static final class BlockableVectorAppender extends VectorAppender { + /** + * Monitor object used to block appender. + */ + private final Object monitor = new Object(); + + /** + * Thread of last call to append. + */ + private Thread dispatcher; + + /** + * Create new instance. + */ + public BlockableVectorAppender() { + super(); + } + + /** + * {@inheritDoc} + */ + public void append(final LoggingEvent event) { + synchronized (monitor) { + dispatcher = Thread.currentThread(); + super.append(event); + // + // if fatal, echo messages for testLoggingInDispatcher + // + if (event.getLevel() == Level.FATAL) { + Logger logger = Logger.getLogger(event.getLoggerName()); + logger.error(event.getMessage().toString()); + logger.warn(event.getMessage().toString()); + logger.info(event.getMessage().toString()); + logger.debug(event.getMessage().toString()); + } + } + } + + /** + * Get monitor object. + * @return monitor. + */ + public Object getMonitor() { + return monitor; + } + + /** + * Get thread of previous call to append. + * @return thread, may be null. + */ + public Thread getDispatcher() { + synchronized (monitor) { + return dispatcher; + } + } + } + + } diff --git a/tests/src/java/org/apache/log4j/CategoryTest.java b/tests/src/java/org/apache/log4j/CategoryTest.java new file mode 100644 index 0000000000..cd65e2703c --- /dev/null +++ b/tests/src/java/org/apache/log4j/CategoryTest.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import junit.framework.TestCase; + +import java.lang.reflect.Method; + + +/** + * Tests of Category. + * + * @author Curt Arnold + * @since 1.2.14 + */ +public class CategoryTest extends TestCase { + /** + * Constructs new instance of test. + * @param name test name. + */ + public CategoryTest(final String name) { + super(name); + } + + /** + * Tests Category.forcedLog. + */ + public void testForcedLog() { + MockCategory category = new MockCategory("org.example.foo"); + category.setAdditivity(false); + category.addAppender(new VectorAppender()); + category.info("Hello, World"); + } + + /** + * Tests that the return type of getChainedPriority is Priority. + * @throws Exception thrown if Category.getChainedPriority can not be found. + */ + public void testGetChainedPriorityReturnType() throws Exception { + Method method = Category.class.getMethod("getChainedPriority", (Class[]) null); + assertTrue(method.getReturnType() == Priority.class); + } + + /** + * Tests l7dlog(Priority, String, Throwable). + */ + public void testL7dlog() { + Logger logger = Logger.getLogger("org.example.foo"); + logger.setLevel(Level.ERROR); + Priority debug = Level.DEBUG; + logger.l7dlog(debug, "Hello, World", null); + } + + /** + * Tests l7dlog(Priority, String, Object[], Throwable). + */ + public void testL7dlog4Param() { + Logger logger = Logger.getLogger("org.example.foo"); + logger.setLevel(Level.ERROR); + Priority debug = Level.DEBUG; + logger.l7dlog(debug, "Hello, World", new Object[0], null); + } + + /** + * Tests setPriority(Priority). + * @deprecated + */ + public void testSetPriority() { + Logger logger = Logger.getLogger("org.example.foo"); + Priority debug = Level.DEBUG; + logger.setPriority(debug); + } + + /** + * Derived category to check method signature of forcedLog. + */ + private static class MockCategory extends Logger { + /** + * Create new instance of MockCategory. + * @param name category name + */ + public MockCategory(final String name) { + super(name); + repository = new Hierarchy(this); + } + + /** + * Request an info level message. + * @param msg message + */ + public void info(final String msg) { + Priority info = Level.INFO; + forcedLog(MockCategory.class.toString(), info, msg, null); + } + } +} diff --git a/tests/src/java/org/apache/log4j/CoreTestSuite.java b/tests/src/java/org/apache/log4j/CoreTestSuite.java new file mode 100644 index 0000000000..cf2f3a15b3 --- /dev/null +++ b/tests/src/java/org/apache/log4j/CoreTestSuite.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.log4j; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.apache.log4j.spi.LoggingEventTest; + + +/** + * Suite of log4j class level unit tests. + * + * @author Curt Arnold + */ +public class CoreTestSuite { + /** + * Constructs test suite. + * @return test suite + */ + public static Test suite() { + TestSuite s = new TestSuite(); + s.addTestSuite(LoggingEventTest.class); + s.addTestSuite(org.apache.log4j.LevelTest.class); + s.addTestSuite(org.apache.log4j.PriorityTest.class); + s.addTestSuite(org.apache.log4j.CategoryTest.class); + s.addTestSuite(org.apache.log4j.FileAppenderTest.class); + s.addTestSuite(org.apache.log4j.LogManagerTest.class); + s.addTestSuite(org.apache.log4j.helpers.LogLogTest.class); + s.addTestSuite(org.apache.log4j.LayoutTest.class); + s.addTestSuite(org.apache.log4j.helpers.DateLayoutTest.class); + s.addTestSuite(org.apache.log4j.TTCCLayoutTest.class); + s.addTestSuite(org.apache.log4j.xml.XMLLayoutTest.class); + s.addTestSuite(org.apache.log4j.HTMLLayoutTest.class); + s.addTestSuite(org.apache.log4j.PatternLayoutTest.class); + s.addTestSuite(org.apache.log4j.spi.LoggingEventTest.class); + s.addTestSuite(org.apache.log4j.spi.ThrowableInformationTest.class); + s.addTestSuite(org.apache.log4j.spi.LocationInfoTest.class); + s.addTestSuite(org.apache.log4j.PropertyConfiguratorTest.class); + return s; + } +} diff --git a/tests/src/java/org/apache/log4j/DRFATestCase.java b/tests/src/java/org/apache/log4j/DRFATestCase.java index 82be49ae30..e6f80d89bc 100644 --- a/tests/src/java/org/apache/log4j/DRFATestCase.java +++ b/tests/src/java/org/apache/log4j/DRFATestCase.java @@ -1,109 +1,138 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; - import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.framework.TestFailure; -import junit.framework.Test; -import org.apache.log4j.*; +import java.io.File; +import java.io.IOException; +import java.util.Calendar; +import java.util.TimeZone; +import java.util.Date; +import java.text.SimpleDateFormat; /** Exhaustive test of the DailyRollingFileAppender compute algorithm. - + @author Ceki Gülcü + @author Curt Arnold */ public class DRFATestCase extends TestCase { - public DRFATestCase(String name) { + /** + * Create new test. + * @param name test name. + */ + public DRFATestCase(final String name) { super(name); } + /** + * Reset configuration after every test. + */ + public void tearDown() { + LogManager.resetConfiguration(); + } + + /** + * Test prediction of check period. + */ public void testComputeCheckPeriod() { DailyRollingFileAppender drfa = new DailyRollingFileAppender(); drfa.setName("testComputeCheckPeriod"); drfa.setDatePattern("yyyy-MM-dd.'log'"); drfa.activateOptions(); - + int x = drfa.computeCheckPeriod(); int y = DailyRollingFileAppender.TOP_OF_DAY; - assertEquals(drfa.computeCheckPeriod(), - DailyRollingFileAppender.TOP_OF_DAY); + assertEquals(drfa.computeCheckPeriod(), + DailyRollingFileAppender.TOP_OF_DAY); drfa.setDatePattern("yyyy-MM-dd mm.'log'"); - assertEquals(drfa.computeCheckPeriod(), - DailyRollingFileAppender.TOP_OF_MINUTE); + assertEquals(drfa.computeCheckPeriod(), + DailyRollingFileAppender.TOP_OF_MINUTE); drfa.setDatePattern("yyyy-MM-dd a.'log'"); - assertEquals(drfa.computeCheckPeriod(), - DailyRollingFileAppender.HALF_DAY); + assertEquals(drfa.computeCheckPeriod(), + DailyRollingFileAppender.HALF_DAY); drfa.setDatePattern("yyyy-MM-dd HH.'log'"); - assertEquals(drfa.computeCheckPeriod(), - DailyRollingFileAppender.TOP_OF_HOUR); + assertEquals(drfa.computeCheckPeriod(), + DailyRollingFileAppender.TOP_OF_HOUR); drfa.setDatePattern("yyyy-MM.'log'"); - assertEquals(drfa.computeCheckPeriod(), - DailyRollingFileAppender.TOP_OF_MONTH); + assertEquals(drfa.computeCheckPeriod(), + DailyRollingFileAppender.TOP_OF_MONTH); drfa.setDatePattern("'log'HH'log'"); - assertEquals(drfa.computeCheckPeriod(), - DailyRollingFileAppender.TOP_OF_HOUR); + assertEquals(drfa.computeCheckPeriod(), + DailyRollingFileAppender.TOP_OF_HOUR); } + /** + * Test of RollingCalendar. + */ public - void testRC1() { + void testRC1() { RollingCalendar rc = new RollingCalendar(); rc.setType(DailyRollingFileAppender.TOP_OF_DAY); Calendar c = Calendar.getInstance(); // jan, mar, may, july, aug, oct, dec have 31 days - int [] M31 = {0,2,4,6,7,9,11}; + int [] M31 = {0,2,4,6,7,9,11}; for(int i = 0; i < M31.length; i ++) { for(int d = 1; d <=31; d++) { - for(int h = 0; h < 23; h++) { - c.clear(); - c.set(Calendar.YEAR, 20); - c.set(Calendar.MONTH, Calendar.JANUARY + M31[i]); - c.set(Calendar.DAY_OF_MONTH, d); - c.set(Calendar.HOUR_OF_DAY, h); - c.set(Calendar.MINUTE, 10); - c.set(Calendar.SECOND, 10); - c.set(Calendar.MILLISECOND, 88); - - c.setTime(rc.getNextCheckDate(c.getTime())); - if(d == 31) { - assertEquals(c.get(Calendar.MONTH),(Calendar.JANUARY+M31[i]+1)%12); - assertEquals(c.get(Calendar.DAY_OF_MONTH), 1); - } else { - assertEquals(c.get(Calendar.MONTH), Calendar.JANUARY+M31[i]); - assertEquals(c.get(Calendar.DAY_OF_MONTH), d+1); - } - assertEquals(c.get(Calendar.HOUR_OF_DAY), 0); - assertEquals(c.get(Calendar.MINUTE), 0); - assertEquals(c.get(Calendar.SECOND), 0); - assertEquals(c.get(Calendar.MILLISECOND), 0); - } + for(int h = 0; h < 23; h++) { + c.clear(); + c.set(Calendar.YEAR, 20); + c.set(Calendar.MONTH, Calendar.JANUARY + M31[i]); + c.set(Calendar.DAY_OF_MONTH, d); + c.set(Calendar.HOUR_OF_DAY, h); + c.set(Calendar.MINUTE, 10); + c.set(Calendar.SECOND, 10); + c.set(Calendar.MILLISECOND, 88); + + c.setTime(rc.getNextCheckDate(c.getTime())); + if(d == 31) { + assertEquals(c.get(Calendar.MONTH),(Calendar.JANUARY+M31[i]+1)%12); + assertEquals(c.get(Calendar.DAY_OF_MONTH), 1); + } else { + assertEquals(c.get(Calendar.MONTH), Calendar.JANUARY+M31[i]); + assertEquals(c.get(Calendar.DAY_OF_MONTH), d+1); + } + assertEquals(c.get(Calendar.HOUR_OF_DAY), 0); + assertEquals(c.get(Calendar.MINUTE), 0); + assertEquals(c.get(Calendar.SECOND), 0); + assertEquals(c.get(Calendar.MILLISECOND), 0); + } } } } + /** + * RollingCalendar test. + */ public - void testRC2() { + void testRC2() { RollingCalendar rc = new RollingCalendar(); rc.setType(DailyRollingFileAppender.TOP_OF_HOUR); @@ -112,67 +141,69 @@ void testRC2() { TimeZone tz = c.getTimeZone(); // jan, mar, may, july, aug, oct, dec have 31 days - int [] M31 = {0,2,4,6,7,9,11}; + int [] M31 = {0,2,4,6,7,9,11}; for(int i = 0; i < M31.length; i ++) { System.out.println("Month = "+(M31[i]+1)); for(int d = 1; d <= 31; d++) { - for(int h = 0; h < 23; h++) { - for(int m = 0; m <= 59; m++) { - c.clear(); - c.set(Calendar.YEAR, 20); - c.set(Calendar.MONTH, Calendar.JANUARY + M31[i]); - c.set(Calendar.DAY_OF_MONTH, d); - c.set(Calendar.HOUR_OF_DAY, h); - c.set(Calendar.MINUTE, m); - c.set(Calendar.SECOND, 12); - c.set(Calendar.MILLISECOND, 88); - - boolean dltState0 = c.getTimeZone().inDaylightTime(c.getTime()); - c.setTime(rc.getNextCheckDate(c.getTime())); - boolean dltState1 = c.getTimeZone().inDaylightTime(c.getTime()); - - assertEquals(c.get(Calendar.MILLISECOND), 0); - assertEquals(c.get(Calendar.SECOND), 0); - assertEquals(c.get(Calendar.MINUTE), 0); - - if(dltState0 == dltState1) { - assertEquals(c.get(Calendar.HOUR_OF_DAY), (h+1)%24); - } else { - // returning to standard time - if(dltState0) { - assertEquals(c.get(Calendar.HOUR_OF_DAY), h); - } else { // switching to day light saving time - //System.err.println("m="+m+", h="+h+", d="+d+", i="+i); - //if(h==2) { - // System.err.println(c); - //} - //assertEquals(c.get(Calendar.HOUR_OF_DAY), (h+2)%24); - } - } - - if(h == 23) { - assertEquals(c.get(Calendar.DAY_OF_MONTH), (d+1)%32); - if(d == 31) { - assertEquals(c.get(Calendar.MONTH), - (Calendar.JANUARY+M31[i]+1)%12); - } else { - assertEquals(c.get(Calendar.MONTH), - Calendar.JANUARY+M31[i]); - } - } else { - assertEquals(c.get(Calendar.DAY_OF_MONTH), d); - assertEquals(c.get(Calendar.MONTH), Calendar.JANUARY+M31[i]); - } - } - } + for(int h = 0; h < 23; h++) { + for(int m = 0; m <= 59; m++) { + c.clear(); + c.set(Calendar.YEAR, 20); + c.set(Calendar.MONTH, Calendar.JANUARY + M31[i]); + c.set(Calendar.DAY_OF_MONTH, d); + c.set(Calendar.HOUR_OF_DAY, h); + c.set(Calendar.MINUTE, m); + c.set(Calendar.SECOND, 12); + c.set(Calendar.MILLISECOND, 88); + + boolean dltState0 = c.getTimeZone().inDaylightTime(c.getTime()); + c.setTime(rc.getNextCheckDate(c.getTime())); + boolean dltState1 = c.getTimeZone().inDaylightTime(c.getTime()); + + assertEquals(c.get(Calendar.MILLISECOND), 0); + assertEquals(c.get(Calendar.SECOND), 0); + assertEquals(c.get(Calendar.MINUTE), 0); + + if(dltState0 == dltState1) { + assertEquals(c.get(Calendar.HOUR_OF_DAY), (h+1)%24); + } else { + // returning to standard time + if(dltState0) { + assertEquals(c.get(Calendar.HOUR_OF_DAY), h); + } else { // switching to day light saving time + //System.err.println("m="+m+", h="+h+", d="+d+", i="+i); + //if(h==2) { + // System.err.println(c); + //} + //assertEquals(c.get(Calendar.HOUR_OF_DAY), (h+2)%24); + } + } + + if(h == 23) { + assertEquals(c.get(Calendar.DAY_OF_MONTH), (d+1)%32); + if(d == 31) { + assertEquals(c.get(Calendar.MONTH), + (Calendar.JANUARY+M31[i]+1)%12); + } else { + assertEquals(c.get(Calendar.MONTH), + Calendar.JANUARY+M31[i]); + } + } else { + assertEquals(c.get(Calendar.DAY_OF_MONTH), d); + assertEquals(c.get(Calendar.MONTH), Calendar.JANUARY+M31[i]); + } + } + } } } } - + /** + * RollingCalendar test. + */ public - void testRC3() { + void testRC3() { RollingCalendar rc = new RollingCalendar(); rc.setType(DailyRollingFileAppender.TOP_OF_MINUTE); @@ -182,80 +213,213 @@ void testRC3() { Calendar c = Calendar.getInstance(); // jan, mar, may, july, aug, oct, dec have 31 days - int [] M31 = {2,9,0,4,6,7,11}; + int [] M31 = {2,9,0,4,6,7,11}; for(int i = 0; i < M31.length; i ++) { System.out.println("Month = "+(M31[i]+1)); for(int d = 1; d <= 31; d++) { - for(int h = 0; h < 23; h++) { - for(int m = 0; m < M.length; m++) { - for(int s = 0; s < S.length; s++) { - c.clear(); - c.set(Calendar.YEAR, 20); - c.set(Calendar.MONTH, Calendar.JANUARY + M31[i]); - c.set(Calendar.DAY_OF_MONTH, d); - c.set(Calendar.HOUR_OF_DAY, h); - c.set(Calendar.MINUTE, M[m]); - c.set(Calendar.SECOND, S[s]); - c.set(Calendar.MILLISECOND, 88); - c.add(Calendar.MILLISECOND, 1); - - boolean dltState0 = c.getTimeZone().inDaylightTime(c.getTime()); - - c.setTime(rc.getNextCheckDate(c.getTime())); - c.add(Calendar.MILLISECOND, 0); - boolean dltState1 = c.getTimeZone().inDaylightTime(c.getTime()); - - assertEquals(c.get(Calendar.MILLISECOND), 0); - assertEquals(c.get(Calendar.SECOND), 0); - assertEquals(c.get(Calendar.MINUTE), (M[m]+1)%60); - - if(M[m] == 59) { - if(dltState0 == dltState1) { - assertEquals(c.get(Calendar.HOUR_OF_DAY), (h+1)%24); - } - if(h == 23) { - assertEquals(c.get(Calendar.DAY_OF_MONTH), (d+1)%32); - if(d == 31) { - assertEquals(c.get(Calendar.MONTH), - (Calendar.JANUARY+M31[i]+1)%12); - } else { - assertEquals(c.get(Calendar.MONTH), - Calendar.JANUARY+M31[i]); - } - } else { - assertEquals(c.get(Calendar.DAY_OF_MONTH), d); - } - } else { - // allow discrepancies only if we are switching from std to dls time - if(c.get(Calendar.HOUR_OF_DAY) != h) { - c.add(Calendar.HOUR_OF_DAY, +1); - boolean dltState2 = c.getTimeZone().inDaylightTime(c.getTime()); - if(dltState1 == dltState2) { - fail("No switch"); - } - } - assertEquals(c.get(Calendar.DAY_OF_MONTH), d); - assertEquals(c.get(Calendar.MONTH), Calendar.JANUARY+M31[i]); - } - } - } - } + for(int h = 0; h < 23; h++) { + for(int m = 0; m < M.length; m++) { + for(int s = 0; s < S.length; s++) { + c.clear(); + c.set(Calendar.YEAR, 20); + c.set(Calendar.MONTH, Calendar.JANUARY + M31[i]); + c.set(Calendar.DAY_OF_MONTH, d); + c.set(Calendar.HOUR_OF_DAY, h); + c.set(Calendar.MINUTE, M[m]); + c.set(Calendar.SECOND, S[s]); + c.set(Calendar.MILLISECOND, 88); + c.add(Calendar.MILLISECOND, 1); + + boolean dltState0 = c.getTimeZone().inDaylightTime(c.getTime()); + + c.setTime(rc.getNextCheckDate(c.getTime())); + c.add(Calendar.MILLISECOND, 0); + boolean dltState1 = c.getTimeZone().inDaylightTime(c.getTime()); + + assertEquals(c.get(Calendar.MILLISECOND), 0); + assertEquals(c.get(Calendar.SECOND), 0); + assertEquals(c.get(Calendar.MINUTE), (M[m]+1)%60); + + if(M[m] == 59) { + if(dltState0 == dltState1) { + assertEquals(c.get(Calendar.HOUR_OF_DAY), (h+1)%24); + } + if(h == 23) { + assertEquals(c.get(Calendar.DAY_OF_MONTH), (d+1)%32); + if(d == 31) { + assertEquals(c.get(Calendar.MONTH), + (Calendar.JANUARY+M31[i]+1)%12); + } else { + assertEquals(c.get(Calendar.MONTH), + Calendar.JANUARY+M31[i]); + } + } else { + assertEquals(c.get(Calendar.DAY_OF_MONTH), d); + } + } else { + // allow discrepancies only if we are switching from std to dls time + if(c.get(Calendar.HOUR_OF_DAY) != h) { + c.add(Calendar.HOUR_OF_DAY, +1); + boolean dltState2 = c.getTimeZone().inDaylightTime(c.getTime()); + if(dltState1 == dltState2) { + fail("No switch"); + } + } + assertEquals(c.get(Calendar.DAY_OF_MONTH), d); + assertEquals(c.get(Calendar.MONTH), Calendar.JANUARY+M31[i]); + } + } + } + } } } } - - public - static - Test suite() { - TestSuite suite = new TestSuite(); - suite.addTest(new DRFATestCase("testComputeCheckPeriod")); - suite.addTest(new DRFATestCase("testRC1")); - suite.addTest(new DRFATestCase("testRC2")); - suite.addTest(new DRFATestCase("testRC3")); - return suite; - } - + /** + * Common test code for 3 parameter constructor. + * + * @throws IOException if IOException during test. + */ + public void test3Param(final String datePattern, + final String filename) throws IOException { + Layout layout = new SimpleLayout(); + DailyRollingFileAppender appender = + new DailyRollingFileAppender(layout, filename, datePattern); + assertEquals(datePattern, appender.getDatePattern()); + Logger root = Logger.getRootLogger(); + root.addAppender(appender); + root.info("Hello, World"); + assertTrue(new File(filename).exists()); + } + + /** + * Creates an appender with an unrecognized top-of-year pattern. + * + * @throws IOException if IOException during test. + */ + public void testTopOfYear() throws IOException { + try { + test3Param("'.'yyyy", "output/drfa_topOfYear.log"); + fail("Expected illegal state exception."); + } catch(IllegalStateException ex) { + assertNotNull(ex); + } + } + + /** + * Creates an appender with a top-of-month pattern. + * + * @throws IOException if IOException during test. + */ + public void testTopOfMonth() throws IOException { + test3Param("'.'yyyy-MM", "output/drfa_topOfMonth.log"); + } + + + /** + * Creates an appender with a top-of-week pattern. + * + * @throws IOException if IOException during test. + */ + public void testTopOfWeek() throws IOException { + test3Param("'.'yyyy-w", "output/drfa_topOfWeek.log"); + } + + /** + * Creates an appender with a top-of-day pattern. + * + * @throws IOException if IOException during test. + */ + public void testTopOfDay() throws IOException { + test3Param("'.'yyyy-MM-dd", "output/drfa_topOfDay.log"); + } + + + /** + * Creates an appender with a half day pattern. + * + * @throws IOException if IOException during test. + */ + public void testHalfDay() throws IOException { + test3Param("'.'yyyy-MM-dd-a", "output/drfa_halfDay.log"); + } + + /** + * Creates an appender with a top-of-hour pattern. + * + * @throws IOException if IOException during test. + */ + public void testTopOfHour() throws IOException { + test3Param("'.'yyyy-MM-dd-HH", "output/drfa_topOfHour.log"); + } + + /** + * Creates an appender with a top-of-day pattern. + * + * @throws IOException if IOException during test. + */ + public void testTopOfMinute() throws IOException { + test3Param("'.'yyyy-MM-dd-HH-mm", "output/drfa_topOfMinute.log"); + } + + /** + * Attempts to rollOver with no date pattern set. + * + * @throws IOException if IOException during test. + */ + public void testRolloverNoPattern() throws IOException { + Layout layout = new SimpleLayout(); + DailyRollingFileAppender appender = + new DailyRollingFileAppender(layout, "output/drfa_nopattern.log", null); + + VectorErrorHandler errorHandler = new VectorErrorHandler(); + appender.setErrorHandler(errorHandler); + appender.rollOver(); + assertEquals(1, errorHandler.size()); + assertEquals("Missing DatePattern option in rollOver().", + errorHandler.getMessage(0)); + } + + /** + * Tests rollOver with a minute periodicity. + * + * @throws IOException + * @throws InterruptedException + */ + public void testMinuteRollover() throws IOException, InterruptedException { + Layout layout = new SimpleLayout(); + String filename = "output/drfa_minuteRollover.log"; + String pattern = "'.'yyyy-MM-dd-HH-mm"; + + DailyRollingFileAppender appender = + new DailyRollingFileAppender(layout, + filename, + pattern); + Logger root = Logger.getRootLogger(); + root.addAppender(appender); + File firstFile = + new File(filename + new SimpleDateFormat(pattern).format(new Date())); + root.info("Hello, World"); + // + // create a file by that name so it has to be deleted + // on rollover + firstFile.createNewFile(); + assertTrue(firstFile.exists()); + assertEquals(0, firstFile.length()); + + Calendar cal = Calendar.getInstance(); + long now = cal.getTime().getTime(); + cal.set(Calendar.SECOND, 3); + cal.set(Calendar.MILLISECOND, 0); + cal.add(Calendar.MINUTE, 1); + long until = cal.getTime().getTime(); + Thread.sleep(until - now); + root.info("Hello, World"); + assertTrue(firstFile.exists()); + assertTrue(firstFile.length() > 0); + + } + } diff --git a/tests/src/java/org/apache/log4j/FileAppenderTest.java b/tests/src/java/org/apache/log4j/FileAppenderTest.java new file mode 100644 index 0000000000..5792986eb2 --- /dev/null +++ b/tests/src/java/org/apache/log4j/FileAppenderTest.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import junit.framework.TestCase; + +import java.io.File; + +import java.lang.reflect.Method; + + +/** + * + * FileAppender tests. + * + * @author Curt Arnold + */ +public class FileAppenderTest extends TestCase { + /** + * Tests that any necessary directories are attempted to + * be created if they don't exist. See bug 9150. + * + */ + public void testDirectoryCreation() { + // + // known to fail on JDK 1.1 + if (!System.getProperty("java.version").startsWith("1.1.")) { + File newFile = new File("output/newdir/temp.log"); + newFile.delete(); + + File newDir = new File("output/newdir"); + newDir.delete(); + + org.apache.log4j.FileAppender wa = new org.apache.log4j.FileAppender(); + wa.setFile("output/newdir/temp.log"); + wa.setLayout(new PatternLayout("%m%n")); + wa.activateOptions(); + + assertTrue(new File("output/newdir/temp.log").exists()); + } + } + + /** + * Tests that the return type of getThreshold is Priority. + * @throws Exception + */ + public void testGetThresholdReturnType() throws Exception { + Method method = FileAppender.class.getMethod("getThreshold", (Class[]) null); + assertTrue(method.getReturnType() == Priority.class); + } + + /** + * Tests getThreshold and setThreshold. + */ + public void testgetSetThreshold() { + FileAppender appender = new FileAppender(); + Priority debug = Level.DEBUG; + Priority all = Level.ALL; + assertNull(appender.getThreshold()); + appender.setThreshold(debug); + assertTrue(appender.getThreshold() == debug); + } + + /** + * Tests isAsSevereAsThreshold. + */ + public void testIsAsSevereAsThreshold() { + FileAppender appender = new FileAppender(); + Priority debug = Level.DEBUG; + assertTrue(appender.isAsSevereAsThreshold(debug)); + } +} diff --git a/tests/src/java/org/apache/log4j/HTMLLayoutTest.java b/tests/src/java/org/apache/log4j/HTMLLayoutTest.java new file mode 100644 index 0000000000..81aab1e28e --- /dev/null +++ b/tests/src/java/org/apache/log4j/HTMLLayoutTest.java @@ -0,0 +1,240 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import org.apache.log4j.spi.LoggingEvent; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.Reader; +import java.io.StringReader; +import java.util.Hashtable; + + +/** + * Test for HTMLLayout. + * + * @author Curt Arnold + */ +public class HTMLLayoutTest extends LayoutTest { + /** + * Construct new instance of XMLLayoutTest. + * + * @param testName test name. + */ + public HTMLLayoutTest(final String testName) { + super(testName, "text/html", false, null, null); + } + + /** + * @{inheritDoc} + */ + protected Layout createLayout() { + return new HTMLLayout(); + } + + /** + * Parses the string as the body of an XML document and returns the document element. + * @param source source string. + * @return document element. + * @throws Exception if parser can not be constructed or source is not a valid XML document. + */ + private Document parse(final String source) throws Exception { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(false); + factory.setCoalescing(true); + + DocumentBuilder builder = factory.newDocumentBuilder(); + Reader reader = new StringReader(source); + + return builder.parse(new InputSource(reader)); + } + + /** + * Tests formatted results. + * @throws Exception if unable to create parser or output is not valid XML. + */ + public void testFormat() throws Exception { + Logger logger = Logger.getLogger("org.apache.log4j.xml.HTMLLayoutTest"); + NDC.push("NDC goes here"); + + LoggingEvent event = + new LoggingEvent( + "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null); + HTMLLayout layout = (HTMLLayout) createLayout(); + layout.setLocationInfo(true); + + String result = layout.format(event); + NDC.pop(); + + String src = + "]>" + result + ""; + Document doc = parse(src); + } + + /** + * Tests getHeader. + */ + public void testGetHeader() { + assertEquals("", createLayout().getFooter().substring(0, 8)); + } + + /** + * Tests getLocationInfo and setLocationInfo. + */ + public void testGetSetLocationInfo() { + HTMLLayout layout = new HTMLLayout(); + assertEquals(false, layout.getLocationInfo()); + layout.setLocationInfo(true); + assertEquals(true, layout.getLocationInfo()); + layout.setLocationInfo(false); + assertEquals(false, layout.getLocationInfo()); + } + + /** + * Tests activateOptions(). + */ + public void testActivateOptions() { + HTMLLayout layout = new HTMLLayout(); + layout.activateOptions(); + } + + /** + * Tests getTitle and setTitle. + */ + public void testGetSetTitle() { + HTMLLayout layout = new HTMLLayout(); + assertEquals("Log4J Log Messages", layout.getTitle()); + layout.setTitle(null); + assertNull(layout.getTitle()); + + String newTitle = "A treatise on messages of log persuasion"; + layout.setTitle(newTitle); + assertEquals(newTitle, layout.getTitle()); + } + + /** + * Tests buffer downsizing and DEBUG and WARN colorization code paths. + */ + public void testFormatResize() { + Logger logger = Logger.getLogger("org.apache.log4j.xml.HTMLLayoutTest"); + NDC.clear(); + + char[] msg = new char[2000]; + + for (int i = 0; i < msg.length; i++) { + msg[i] = 'A'; + } + + LoggingEvent event1 = + new LoggingEvent( + "org.apache.log4j.Logger", logger, Level.DEBUG, new String(msg), null); + HTMLLayout layout = (HTMLLayout) createLayout(); + layout.setLocationInfo(true); + + String result = layout.format(event1); + Exception ex = new IllegalArgumentException("'foo' is not a valid value."); + LoggingEvent event2 = + new LoggingEvent( + "org.apache.log4j.Logger", logger, Level.WARN, "Hello, World", ex); + result = layout.format(event2); + assertEquals( + Layout.LINE_SEP + "", + result.substring(0, Layout.LINE_SEP.length() + 4)); + } + + + /** + * Level with arbitrary toString value. + */ + private static final class ProblemLevel extends Level { + /** + * Construct new instance. + * @param levelName level name, may not be null. + */ + public ProblemLevel(final String levelName) { + super(6000, levelName, 6); + } + } + + /** + * Tests problematic characters in multiple fields. + * @throws Exception if parser can not be constructed + * or source is not a valid XML document. + */ + public void testProblemCharacters() throws Exception { + String problemName = "com.example.bar<>&\"'"; + Logger logger = Logger.getLogger(problemName); + Level level = new ProblemLevel(problemName); + Exception ex = new IllegalArgumentException(problemName); + String threadName = Thread.currentThread().getName(); + Thread.currentThread().setName(problemName); + NDC.push(problemName); + Hashtable mdcMap = MDC.getContext(); + if (mdcMap != null) { + mdcMap.clear(); + } + MDC.put(problemName, problemName); + LoggingEvent event = + new LoggingEvent( + problemName, logger, level, problemName, ex); + HTMLLayout layout = (HTMLLayout) createLayout(); + String result = layout.format(event); + mdcMap = MDC.getContext(); + if (mdcMap != null) { + mdcMap.clear(); + } + + Thread.currentThread().setName(threadName); + + // + // do a little fixup to make output XHTML + // + StringBuffer buf = new StringBuffer( + "]>"); + buf.append(result); + buf.append("
"); + String doc = buf.toString(); + for(int i = doc.lastIndexOf("
"); + i != -1; + i = doc.lastIndexOf("
", i - 1)) { + buf.replace(i, i + 4, "
"); + } + + parse(buf.toString()); + } + +} diff --git a/tests/src/java/org/apache/log4j/HierarchyThresholdTestCase.java b/tests/src/java/org/apache/log4j/HierarchyThresholdTestCase.java index e522506e52..d5307c5d1b 100644 --- a/tests/src/java/org/apache/log4j/HierarchyThresholdTestCase.java +++ b/tests/src/java/org/apache/log4j/HierarchyThresholdTestCase.java @@ -1,8 +1,18 @@ -/* 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.txt file. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j; @@ -88,12 +98,17 @@ public void test8() throws Exception { static void common() { + String oldThreadName = Thread.currentThread().getName(); + Thread.currentThread().setName("main"); + logger.log(XLevel.TRACE, "m0"); logger.debug("m1"); logger.info("m2"); logger.warn("m3"); logger.error("m4"); logger.fatal("m5"); + + Thread.currentThread().setName(oldThreadName); } public static Test suite() { diff --git a/tests/src/java/org/apache/log4j/Last.java b/tests/src/java/org/apache/log4j/Last.java index 635824d4b0..4286ab8ebe 100644 --- a/tests/src/java/org/apache/log4j/Last.java +++ b/tests/src/java/org/apache/log4j/Last.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; diff --git a/tests/src/java/org/apache/log4j/LayoutTest.java b/tests/src/java/org/apache/log4j/LayoutTest.java new file mode 100644 index 0000000000..0d2cac679a --- /dev/null +++ b/tests/src/java/org/apache/log4j/LayoutTest.java @@ -0,0 +1,168 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import junit.framework.TestCase; + +import org.apache.log4j.spi.LoggingEvent; + + +/** + * Tests for Layout. + * + */ +public class LayoutTest extends TestCase { + /** + * Expected content type. + */ + private final String contentType; + + /** + * Expected value for ignoresThrowable. + */ + private final boolean ignoresThrowable; + + /** + * Expected value for header. + */ + private final String header; + + /** + * Expected value for footer. + */ + private final String footer; + + /** + * Construct a new instance of LayoutTest. + * @param testName test name. + */ + public LayoutTest(final String testName) { + super(testName); + contentType = "text/plain"; + ignoresThrowable = true; + header = null; + footer = null; + } + + /** + * Constructor for use by derived tests. + * @param testName name of test. + * @param expectedContentType expected value for getContentType(). + * @param expectedIgnoresThrowable expected value for ignoresThrowable(). + * @param expectedHeader expected value for getHeader(). + * @param expectedFooter expected value for getFooter(). + */ + protected LayoutTest( + final String testName, final String expectedContentType, + final boolean expectedIgnoresThrowable, final String expectedHeader, + final String expectedFooter) { + super(testName); + contentType = expectedContentType; + ignoresThrowable = expectedIgnoresThrowable; + header = expectedHeader; + footer = expectedFooter; + } + + /** + * Tests Layout.LINE_SEP. + */ + public void testLineSep() { + assertEquals(System.getProperty("line.separator"), Layout.LINE_SEP); + } + + /** + * Tests Layout.LINE_SEP. + */ + public void testLineSepLen() { + assertEquals(Layout.LINE_SEP.length(), Layout.LINE_SEP_LEN); + } + + /** + * Creates layout for test. + * @return new instance of Layout. + */ + protected Layout createLayout() { + return new MockLayout(); + } + + /** + * Tests getContentType. + */ + public void testGetContentType() { + assertEquals(contentType, createLayout().getContentType()); + } + + /** + * Tests ignoresThrowable. + */ + public void testIgnoresThrowable() { + assertEquals(ignoresThrowable, createLayout().ignoresThrowable()); + } + + /** + * Tests getHeader. + */ + public void testGetHeader() { + assertEquals(header, createLayout().getHeader()); + } + + /** + * Tests getFooter. + */ + public void testGetFooter() { + assertEquals(footer, createLayout().getFooter()); + } + + /** + * Tests format. + * @throws Exception derived tests, particular XMLLayoutTest, may throw exceptions. + */ + public void testFormat() throws Exception { + Logger logger = Logger.getLogger("org.apache.log4j.LayoutTest"); + LoggingEvent event = + new LoggingEvent( + "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null); + String result = createLayout().format(event); + assertEquals("Mock", result); + } + + /** + * Concrete Layout class for tests. + */ + private static final class MockLayout extends Layout { + /** + * @{inheritDoc} + */ + public String format(final LoggingEvent event) { + return "Mock"; + } + + /** + * @{inheritDoc} + */ + public void activateOptions() { + } + + /** + * @{inheritDoc} + */ + public boolean ignoresThrowable() { + return true; + } + } +} diff --git a/tests/src/java/org/apache/log4j/LevelTest.java b/tests/src/java/org/apache/log4j/LevelTest.java new file mode 100644 index 0000000000..e0bd814306 --- /dev/null +++ b/tests/src/java/org/apache/log4j/LevelTest.java @@ -0,0 +1,266 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import junit.framework.TestCase; + +import org.apache.log4j.util.SerializationTestHelper; +import java.util.Locale; + + +/** + * Tests of Level. + * + * @author Curt Arnold + * @since 1.2.12 + */ +public class LevelTest extends TestCase { + /** + * Constructs new instance of test. + * @param name test name. + */ + public LevelTest(final String name) { + super(name); + } + + /** + * Serialize Level.INFO and check against witness. + * @throws Exception if exception during test. + * + */ + public void testSerializeINFO() throws Exception { + int[] skip = new int[] { }; + SerializationTestHelper.assertSerializationEquals( + "witness/serialization/info.bin", Level.INFO, skip, Integer.MAX_VALUE); + } + + /** + * Deserialize witness and see if resolved to Level.INFO. + * @throws Exception if exception during test. + */ + public void testDeserializeINFO() throws Exception { + Object obj = + SerializationTestHelper.deserializeStream( + "witness/serialization/info.bin"); + assertTrue(obj instanceof Level); + Level info = (Level) obj; + assertEquals("INFO", info.toString()); + // + // JDK 1.1 doesn't support readResolve necessary for the assertion + if (!System.getProperty("java.version").startsWith("1.1.")) { + assertTrue(obj == Level.INFO); + } + } + + /** + * Tests that a custom level can be serialized and deserialized + * and is not resolved to a stock level. + * + * @throws Exception if exception during test. + */ + public void testCustomLevelSerialization() throws Exception { + CustomLevel custom = new CustomLevel(); + Object obj = SerializationTestHelper.serializeClone(custom); + assertTrue(obj instanceof CustomLevel); + + CustomLevel clone = (CustomLevel) obj; + assertEquals(Level.INFO.level, clone.level); + assertEquals(Level.INFO.levelStr, clone.levelStr); + assertEquals(Level.INFO.syslogEquivalent, clone.syslogEquivalent); + } + + /** + * Custom level to check that custom levels are + * serializable, but not resolved to a plain Level. + */ + private static class CustomLevel extends Level { + /** + * Create an instance of CustomLevel. + */ + public CustomLevel() { + super( + Level.INFO.level, Level.INFO.levelStr, Level.INFO.syslogEquivalent); + } + } + + /** + * Tests Level.TRACE_INT. + */ + public void testTraceInt() { + assertEquals(5000, Level.TRACE_INT); + } + + /** + * Tests Level.TRACE. + */ + public void testTrace() { + assertEquals("TRACE", Level.TRACE.toString()); + assertEquals(5000, Level.TRACE.toInt()); + assertEquals(7, Level.TRACE.getSyslogEquivalent()); + } + + /** + * Tests Level.toLevel(Level.TRACE_INT). + */ + public void testIntToTrace() { + Level trace = Level.toLevel(5000); + assertEquals("TRACE", trace.toString()); + } + + /** + * Tests Level.toLevel("TRACE"); + */ + public void testStringToTrace() { + Level trace = Level.toLevel("TRACE"); + assertEquals("TRACE", trace.toString()); + } + + /** + * Tests that Level extends Priority. + */ + public void testLevelExtendsPriority() { + assertTrue(Priority.class.isAssignableFrom(Level.class)); + } + + /** + * Tests Level.OFF. + */ + public void testOFF() { + assertTrue(Level.OFF instanceof Level); + } + + /** + * Tests Level.FATAL. + */ + public void testFATAL() { + assertTrue(Level.FATAL instanceof Level); + } + + /** + * Tests Level.ERROR. + */ + public void testERROR() { + assertTrue(Level.ERROR instanceof Level); + } + + /** + * Tests Level.WARN. + */ + public void testWARN() { + assertTrue(Level.WARN instanceof Level); + } + + /** + * Tests Level.INFO. + */ + public void testINFO() { + assertTrue(Level.INFO instanceof Level); + } + + /** + * Tests Level.DEBUG. + */ + public void testDEBUG() { + assertTrue(Level.DEBUG instanceof Level); + } + + /** + * Tests Level.TRACE. + */ + public void testTRACE() { + assertTrue(Level.TRACE instanceof Level); + } + + /** + * Tests Level.ALL. + */ + public void testALL() { + assertTrue(Level.ALL instanceof Level); + } + + /** + * Tests Level.serialVersionUID. + */ + public void testSerialVersionUID() { + assertEquals(3491141966387921974L, Level.serialVersionUID); + } + + /** + * Tests Level.toLevel(Level.All_INT). + */ + public void testIntToAll() { + Level level = Level.toLevel(Level.ALL_INT); + assertEquals("ALL", level.toString()); + } + + /** + * Tests Level.toLevel(Level.FATAL_INT). + */ + public void testIntToFatal() { + Level level = Level.toLevel(Level.FATAL_INT); + assertEquals("FATAL", level.toString()); + } + + + /** + * Tests Level.toLevel(Level.OFF_INT). + */ + public void testIntToOff() { + Level level = Level.toLevel(Level.OFF_INT); + assertEquals("OFF", level.toString()); + } + + /** + * Tests Level.toLevel(17, Level.FATAL). + */ + public void testToLevelUnrecognizedInt() { + Level level = Level.toLevel(17, Level.FATAL); + assertEquals("FATAL", level.toString()); + } + + /** + * Tests Level.toLevel(null, Level.FATAL). + */ + public void testToLevelNull() { + Level level = Level.toLevel(null, Level.FATAL); + assertEquals("FATAL", level.toString()); + } + + /** + * Test that dotless lower I + "nfo" is recognized as INFO. + */ + public void testDotlessLowerI() { + Level level = Level.toLevel("\u0131nfo"); + assertEquals("INFO", level.toString()); + } + + /** + * Test that dotted lower I + "nfo" is recognized as INFO + * even in Turkish locale. + */ + public void testDottedLowerI() { + Locale defaultLocale = Locale.getDefault(); + Locale turkey = new Locale("tr", "TR"); + Locale.setDefault(turkey); + Level level = Level.toLevel("info"); + Locale.setDefault(defaultLocale); + assertEquals("INFO", level.toString()); + } + + +} diff --git a/tests/src/java/org/apache/log4j/LogManagerTest.java b/tests/src/java/org/apache/log4j/LogManagerTest.java new file mode 100644 index 0000000000..0319fda712 --- /dev/null +++ b/tests/src/java/org/apache/log4j/LogManagerTest.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import junit.framework.TestCase; + + +/** + * Tests for LogManager + * + * @author Curt Arnold + **/ +public class LogManagerTest extends TestCase { + /** + * Create new instance of LogManagerTest. + * @param testName test name + */ + public LogManagerTest(final String testName) { + super(testName); + } + + /** + * Check value of DEFAULT_CONFIGURATION_FILE. + * @deprecated since constant is deprecated + */ + public void testDefaultConfigurationFile() { + assertEquals("log4j.properties", LogManager.DEFAULT_CONFIGURATION_FILE); + } + + /** + * Check value of DEFAULT_XML_CONFIGURATION_FILE. + */ + public void testDefaultXmlConfigurationFile() { + assertEquals("log4j.xml", LogManager.DEFAULT_XML_CONFIGURATION_FILE); + } + + /** + * Check value of DEFAULT_CONFIGURATION_KEY. + * @deprecated since constant is deprecated + */ + public void testDefaultConfigurationKey() { + assertEquals("log4j.configuration", LogManager.DEFAULT_CONFIGURATION_KEY); + } + + /** + * Check value of CONFIGURATOR_CLASS_KEY. + * @deprecated since constant is deprecated + */ + public void testConfiguratorClassKey() { + assertEquals("log4j.configuratorClass", LogManager.CONFIGURATOR_CLASS_KEY); + } + + /** + * Check value of DEFAULT_INIT_OVERRIDE_KEY. + * @deprecated since constant is deprecated + */ + public void testDefaultInitOverrideKey() { + assertEquals("log4j.defaultInitOverride", LogManager.DEFAULT_INIT_OVERRIDE_KEY); + } +} diff --git a/tests/src/java/org/apache/log4j/LoggerTestCase.java b/tests/src/java/org/apache/log4j/LoggerTestCase.java index d5f4274c8a..ccfac8f31b 100644 --- a/tests/src/java/org/apache/log4j/LoggerTestCase.java +++ b/tests/src/java/org/apache/log4j/LoggerTestCase.java @@ -1,21 +1,31 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; -import org.apache.log4j.*; -import org.apache.log4j.spi.*; - import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.framework.Test; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.spi.RootLogger; +import org.apache.log4j.spi.LoggerRepository; + import java.util.Enumeration; -import java.util.ResourceBundle; import java.util.Locale; +import java.util.ResourceBundle; +import java.util.Vector; /** Used for internal unit testing the Logger class. @@ -73,8 +83,8 @@ void testAppender1() { a1.setName("testAppender1"); logger.addAppender(a1); - Enumeration enum = logger.getAllAppenders(); - Appender aHat = (Appender) enum.nextElement(); + Enumeration enumeration = logger.getAllAppenders(); + Appender aHat = (Appender) enumeration.nextElement(); assertEquals(a1, aHat); } @@ -93,10 +103,10 @@ void testAppender2() { logger.addAppender(a1); logger.addAppender(a2); logger.removeAppender("testAppender2.1"); - Enumeration enum = logger.getAllAppenders(); - Appender aHat = (Appender) enum.nextElement(); + Enumeration enumeration = logger.getAllAppenders(); + Appender aHat = (Appender) enumeration.nextElement(); assertEquals(a2, aHat); - assertTrue(!enum.hasMoreElements()); + assertTrue(!enumeration.hasMoreElements()); } /** @@ -204,7 +214,7 @@ void testDisable1() { Logger root = Logger.getRootLogger(); root.addAppender(caRoot); - LoggerRepository h = Category.getDefaultHierarchy(); + LoggerRepository h = LogManager.getLoggerRepository(); //h.disableDebug(); h.setThreshold((Level) Level.INFO); assertEquals(caRoot.counter, 0); @@ -309,7 +319,7 @@ void testExists() { public void testHierarchy1() { - Hierarchy h = new Hierarchy(new RootCategory((Level) Level.ERROR)); + Hierarchy h = new Hierarchy(new RootLogger((Level) Level.ERROR)); Logger a0 = h.getLogger("a"); assertEquals("a", a0.getName()); assertNull(a0.getLevel()); @@ -317,30 +327,76 @@ void testHierarchy1() { Logger a1 = h.getLogger("a"); assertSame(a0, a1); - - - - } - public - static - Test suite() { - TestSuite suite = new TestSuite(); - suite.addTest(new LoggerTestCase("testAppender1")); - suite.addTest(new LoggerTestCase("testAppender2")); - suite.addTest(new LoggerTestCase("testAdditivity1")); - suite.addTest(new LoggerTestCase("testAdditivity2")); - suite.addTest(new LoggerTestCase("testAdditivity3")); - suite.addTest(new LoggerTestCase("testDisable1")); - suite.addTest(new LoggerTestCase("testRB1")); - suite.addTest(new LoggerTestCase("testRB2")); - suite.addTest(new LoggerTestCase("testRB3")); - suite.addTest(new LoggerTestCase("testExists")); - suite.addTest(new LoggerTestCase("testHierarchy1")); - return suite; + /** + * Tests logger.trace(Object). + * @since 1.2.12 + */ + public void testTrace() { + VectorAppender appender = new VectorAppender(); + appender.activateOptions(); + Logger root = Logger.getRootLogger(); + root.addAppender(appender); + root.setLevel(Level.INFO); + + Logger tracer = Logger.getLogger("com.example.Tracer"); + tracer.setLevel(Level.TRACE); + + tracer.trace("Message 1"); + root.trace("Discarded Message"); + root.trace("Discarded Message"); + + Vector msgs = appender.getVector(); + assertEquals(1, msgs.size()); + LoggingEvent event = (LoggingEvent) msgs.elementAt(0); + assertEquals(Level.TRACE, event.getLevel()); + assertEquals("Message 1", event.getMessage()); } + /** + * Tests logger.trace(Object, Exception). + * @since 1.2.12 + */ + public void testTraceWithException() { + VectorAppender appender = new VectorAppender(); + appender.activateOptions(); + Logger root = Logger.getRootLogger(); + root.addAppender(appender); + root.setLevel(Level.INFO); + + Logger tracer = Logger.getLogger("com.example.Tracer"); + tracer.setLevel(Level.TRACE); + NullPointerException ex = new NullPointerException(); + + tracer.trace("Message 1", ex); + root.trace("Discarded Message", ex); + root.trace("Discarded Message", ex); + + Vector msgs = appender.getVector(); + assertEquals(1, msgs.size()); + LoggingEvent event = (LoggingEvent) msgs.elementAt(0); + assertEquals(Level.TRACE, event.getLevel()); + assertEquals("Message 1", event.getMessage()); + } + + /** + * Tests isTraceEnabled. + * @since 1.2.12 + */ + public void testIsTraceEnabled() { + VectorAppender appender = new VectorAppender(); + appender.activateOptions(); + Logger root = Logger.getRootLogger(); + root.addAppender(appender); + root.setLevel(Level.INFO); + + Logger tracer = Logger.getLogger("com.example.Tracer"); + tracer.setLevel(Level.TRACE); + + assertTrue(tracer.isTraceEnabled()); + assertFalse(root.isTraceEnabled()); + } static private class CountingAppender extends AppenderSkeleton { diff --git a/tests/src/java/org/apache/log4j/MinimumTestCase.java b/tests/src/java/org/apache/log4j/MinimumTestCase.java index 1055e588c5..7b3b268805 100644 --- a/tests/src/java/org/apache/log4j/MinimumTestCase.java +++ b/tests/src/java/org/apache/log4j/MinimumTestCase.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; @@ -25,14 +35,16 @@ public class MinimumTestCase extends TestCase { static String EXCEPTION1 = "java.lang.Exception: Just testing"; static String EXCEPTION2 = "\\s*at .*\\(.*:\\d{1,4}\\)"; static String EXCEPTION3 = "\\s*at .*\\(Native Method\\)"; + static String EXCEPTION4 = "\\s*at .*\\(.*Compiled Code\\)"; + static String EXCEPTION5 = "\\s*at .*\\(.*libgcj.*\\)"; //18 fevr. 2002 20:02:41,551 [main] FATAL ERR - Message 0 static String TTCC_PAT = Filter.ABSOLUTE_DATE_AND_TIME_PAT+ - " \\[main]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message \\d{1,2}"; + " \\[main]\\ (TRACE|DEBUG|INFO|WARN|ERROR|FATAL) .* - Message \\d{1,2}"; static String TTCC2_PAT = Filter.ABSOLUTE_DATE_AND_TIME_PAT+ - " \\[main]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Messages should bear numbers 0 through 23\\."; + " \\[main]\\ (TRACE|DEBUG|INFO|WARN|ERROR|FATAL) .* - Messages should bear numbers 0 through 29\\."; //18 fvr. 2002 19:49:53,456 @@ -59,7 +71,11 @@ public void simple() throws Exception { root.addAppender(appender); common(); - Transformer.transform("output/simple", FILTERED, new LineNumberFilter()); + Transformer.transform( + "output/simple", FILTERED, + new Filter[] { new LineNumberFilter(), + new SunReflectFilter(), + new JunitTestRunnerFilter() }); assertTrue(Compare.compare(FILTERED, "witness/simple")); } @@ -68,14 +84,23 @@ public void ttcc() throws Exception { Layout layout = new TTCCLayout(AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT); Appender appender = new FileAppender(layout, "output/ttcc", false); root.addAppender(appender); + + String oldName = Thread.currentThread().getName(); + Thread.currentThread().setName("main"); common(); + Thread.currentThread().setName(oldName); - ControlFilter cf1 = new ControlFilter(new String[]{TTCC_PAT, TTCC2_PAT, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); + ControlFilter cf1 = new ControlFilter(new String[]{TTCC_PAT, + TTCC2_PAT, EXCEPTION1, EXCEPTION2, + EXCEPTION3, EXCEPTION4, EXCEPTION5 }); - Transformer.transform("output/ttcc", FILTERED, new Filter[] {cf1, - new LineNumberFilter(), - new AbsoluteDateAndTimeFilter()}); + Transformer.transform( + "output/ttcc", FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), + new AbsoluteDateAndTimeFilter(), + new SunReflectFilter(), new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/ttcc")); } @@ -97,6 +122,8 @@ void common() { INF_ERR.setLevel(Level.ERROR); Logger DEB = Logger.getLogger("DEB"); DEB.setLevel(Level.DEBUG); + Logger TRC = Logger.getLogger("TRC"); + TRC.setLevel(Level.TRACE); // Note: categories with undefined level Logger INF_UNDEF = Logger.getLogger("INF.UNDEF"); @@ -118,26 +145,33 @@ void common() { INF_UNDEF.warn ( "Message " + i); i++; INF_UNDEF.info ( "Message " + i); i++; - INF_ERR.log(Level.FATAL, "Message " + i); i++; // 10 INF_ERR.error( "Message " + i); i++; - INF_ERR_UNDEF.log(Level.FATAL, "Message " + i); i++; + INF_ERR_UNDEF.log(Level.FATAL, "Message " + i); i++; INF_ERR_UNDEF.error( "Message " + i); i++; DEB.log(Level.FATAL, "Message " + i); i++; //14 DEB.error( "Message " + i); i++; DEB.warn ( "Message " + i); i++; DEB.info ( "Message " + i); i++; - DEB.debug( "Message " + i); i++; - + DEB.debug( "Message " + i); i++; + + TRC.log(Level.FATAL, "Message " + i); i++; //14 + TRC.error( "Message " + i); i++; + TRC.warn ( "Message " + i); i++; + TRC.info ( "Message " + i); i++; + TRC.debug( "Message " + i); i++; + TRC.trace( "Message " + i); i++; // defaultLevel=DEBUG UNDEF.log(Level.FATAL, "Message " + i); i++; // 19 UNDEF.error("Message " + i); i++; UNDEF.warn ("Message " + i); i++; UNDEF.info ("Message " + i); i++; - UNDEF.debug("Message " + i, new Exception("Just testing.")); i++; + UNDEF.debug("Message " + i, new Exception("Just testing.")); + int printCount = i; + i++; // ------------------------------------------------- // The following should not log @@ -155,9 +189,11 @@ void common() { INF_ERR_UNDEF.warn("Message " + i); i++; INF_ERR_UNDEF.info("Message " + i); i++; INF_ERR_UNDEF.debug("Message " + i); i++; + + UNDEF.trace("Message " + i, new Exception("Just testing.")); i++; // ------------------------------------------------- - INF.info("Messages should bear numbers 0 through 23."); + INF.info("Messages should bear numbers 0 through "+printCount+"."); } public static Test suite() { diff --git a/tests/src/java/org/apache/log4j/MyPatternLayout.java b/tests/src/java/org/apache/log4j/MyPatternLayout.java index ae8b90336e..d7cc8ff0ca 100644 --- a/tests/src/java/org/apache/log4j/MyPatternLayout.java +++ b/tests/src/java/org/apache/log4j/MyPatternLayout.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; import org.apache.log4j.helpers.PatternParser; @@ -44,9 +54,9 @@ PatternParser createPatternParser(String pattern) { public static void main(String[] args) { Layout layout = new MyPatternLayout("[counter=%.10#] - %m%n"); - Category cat = Category.getInstance("some.cat"); - cat.addAppender(new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT)); - cat.debug("Hello, log"); - cat.info("Hello again..."); + Logger logger = Logger.getLogger("some.cat"); + logger.addAppender(new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT)); + logger.debug("Hello, log"); + logger.info("Hello again..."); } } diff --git a/tests/src/java/org/apache/log4j/MyPatternParser.java b/tests/src/java/org/apache/log4j/MyPatternParser.java index e8249861c6..25379fca38 100644 --- a/tests/src/java/org/apache/log4j/MyPatternParser.java +++ b/tests/src/java/org/apache/log4j/MyPatternParser.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; diff --git a/tests/src/java/org/apache/log4j/PatternLayoutTest.java b/tests/src/java/org/apache/log4j/PatternLayoutTest.java new file mode 100644 index 0000000000..6d8f03bff4 --- /dev/null +++ b/tests/src/java/org/apache/log4j/PatternLayoutTest.java @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import org.apache.log4j.spi.LoggingEvent; + + +/** + * Test for PatternLayout. + * + * @author Curt Arnold + */ +public class PatternLayoutTest extends LayoutTest { + /** + * Construct new instance of PatternLayoutTest. + * + * @param testName test name. + */ + public PatternLayoutTest(final String testName) { + super(testName, "text/plain", true, null, null); + } + + /** + * @{inheritDoc} + */ + protected Layout createLayout() { + return new PatternLayout("[%t] %p %c - %m%n"); + } + + /** + * Tests format. + */ + public void testFormat() { + Logger logger = Logger.getLogger("org.apache.log4j.LayoutTest"); + LoggingEvent event = + new LoggingEvent( + "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null); + PatternLayout layout = (PatternLayout) createLayout(); + String result = layout.format(event); + StringBuffer buf = new StringBuffer(100); + buf.append('['); + buf.append(event.getThreadName()); + buf.append("] "); + buf.append(event.getLevel().toString()); + buf.append(' '); + buf.append(event.getLoggerName()); + buf.append(" - "); + buf.append(event.getMessage()); + buf.append(System.getProperty("line.separator")); + assertEquals(buf.toString(), result); + } + + /** + * Tests getPatternFormat(). + */ + public void testGetPatternFormat() { + PatternLayout layout = (PatternLayout) createLayout(); + assertEquals("[%t] %p %c - %m%n", layout.getConversionPattern()); + } + + /** + * Tests DEFAULT_CONVERSION_PATTERN constant. + */ + public void testDefaultConversionPattern() { + assertEquals("%m%n", PatternLayout.DEFAULT_CONVERSION_PATTERN); + } + + /** + * Tests DEFAULT_CONVERSION_PATTERN constant. + */ + public void testTTCCConversionPattern() { + assertEquals( + "%r [%t] %p %c %x - %m%n", PatternLayout.TTCC_CONVERSION_PATTERN); + } + + /** + * Tests buffer downsizing code path. + */ + public void testFormatResize() { + Logger logger = Logger.getLogger("org.apache.log4j.xml.PatternLayoutTest"); + NDC.clear(); + + char[] msg = new char[2000]; + + for (int i = 0; i < msg.length; i++) { + msg[i] = 'A'; + } + + LoggingEvent event1 = + new LoggingEvent( + "org.apache.log4j.Logger", logger, Level.DEBUG, new String(msg), null); + PatternLayout layout = (PatternLayout) createLayout(); + String result = layout.format(event1); + LoggingEvent event2 = + new LoggingEvent( + "org.apache.log4j.Logger", logger, Level.WARN, "Hello, World", null); + result = layout.format(event2); + assertEquals("[", result.substring(0, 1)); + } + + /** + * Class to ensure that protected members are still available. + */ + private static final class DerivedPatternLayout extends PatternLayout { + /** + * Constructs a new instance of DerivedPatternLayout. + */ + public DerivedPatternLayout() { + } + + /** + * Get BUF_SIZE. + * @return return initial buffer size in characters. + */ + public int getBufSize() { + return BUF_SIZE; + } + + /** + * Get MAX_CAPACITY. + * @return maximum capacity in characters. + */ + public int getMaxCapacity() { + return MAX_CAPACITY; + } + } +} diff --git a/tests/src/java/org/apache/log4j/PatternLayoutTestCase.java b/tests/src/java/org/apache/log4j/PatternLayoutTestCase.java index 2943d256de..df4c32e25d 100644 --- a/tests/src/java/org/apache/log4j/PatternLayoutTestCase.java +++ b/tests/src/java/org/apache/log4j/PatternLayoutTestCase.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; @@ -25,6 +35,8 @@ import org.apache.log4j.util.AbsoluteTimeFilter; import org.apache.log4j.util.RelativeTimeFilter; import org.apache.log4j.util.AbsoluteDateAndTimeFilter; +import org.apache.log4j.util.SunReflectFilter; +import org.apache.log4j.util.JunitTestRunnerFilter; public class PatternLayoutTestCase extends TestCase { @@ -37,28 +49,30 @@ public class PatternLayoutTestCase extends TestCase { static String EXCEPTION1 = "java.lang.Exception: Just testing"; static String EXCEPTION2 = "\\s*at .*\\(.*:\\d{1,4}\\)"; static String EXCEPTION3 = "\\s*at .*\\(Native Method\\)"; + static String EXCEPTION4 = "\\s*at .*\\(.*Compiled Code\\)"; + static String EXCEPTION5 = "\\s*at .*\\(.*libgcj.*\\)"; - static String PAT0 = "\\[main]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message \\d{1,2}"; + static String PAT0 = "\\[main]\\ (TRACE|DEBUG|INFO |WARN |ERROR|FATAL) .* - Message \\d{1,2}"; static String PAT1 = Filter.ISO8601_PAT + " " + PAT0; static String PAT2 = Filter.ABSOLUTE_DATE_AND_TIME_PAT+ " " + PAT0; static String PAT3 = Filter.ABSOLUTE_TIME_PAT+ " " + PAT0; static String PAT4 = Filter.RELATIVE_TIME_PAT+ " " + PAT0; - static String PAT5 = "\\[main]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* : Message \\d{1,2}"; - static String PAT6 = "\\[main]\\ (DEBUG|INFO |WARN |ERROR|FATAL) org.apache.log4j.PatternLayoutTestCase.common\\(PatternLayoutTestCase.java:\\d{1,4}\\): Message \\d{1,2}"; + static String PAT5 = "\\[main]\\ (TRACE|DEBUG|INFO |WARN |ERROR|FATAL) .* : Message \\d{1,2}"; + static String PAT6 = "\\[main]\\ (TRACE|DEBUG|INFO |WARN |ERROR|FATAL) org.apache.log4j.PatternLayoutTestCase.common\\(PatternLayoutTestCase.java:\\d{1,4}\\): Message \\d{1,2}"; - static String PAT11a = "^(DEBUG|INFO |WARN |ERROR|FATAL) \\[main]\\ log4j.PatternLayoutTestCase: Message \\d{1,2}"; - static String PAT11b = "^(DEBUG|INFO |WARN |ERROR|FATAL) \\[main]\\ root: Message \\d{1,2}"; + static String PAT11a = "^(TRACE|DEBUG|INFO |WARN |ERROR|FATAL) \\[main]\\ log4j.PatternLayoutTestCase: Message \\d{1,2}"; + static String PAT11b = "^(TRACE|DEBUG|INFO |WARN |ERROR|FATAL) \\[main]\\ root: Message \\d{1,2}"; - static String PAT12 = "^\\[main]\\ (DEBUG|INFO |WARN |ERROR|FATAL) "+ + static String PAT12 = "^\\[main]\\ (TRACE|DEBUG|INFO |WARN |ERROR|FATAL) "+ "org.apache.log4j.PatternLayoutTestCase.common\\(PatternLayoutTestCase.java:\\d{3}\\): "+ "Message \\d{1,2}"; - static String PAT13 = "^\\[main]\\ (DEBUG|INFO |WARN |ERROR|FATAL) "+ + static String PAT13 = "^\\[main]\\ (TRACE|DEBUG|INFO |WARN |ERROR|FATAL) "+ "apache.log4j.PatternLayoutTestCase.common\\(PatternLayoutTestCase.java:\\d{3}\\): "+ "Message \\d{1,2}"; - static String PAT14 = "^(DEBUG| INFO| WARN|ERROR|FATAL)\\ \\d{1,2}\\ *- Message \\d{1,2}"; + static String PAT14 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL)\\ \\d{1,2}\\ *- Message \\d{1,2}"; public PatternLayoutTestCase(String name) { super(name); @@ -76,7 +90,12 @@ public void tearDown() { public void test1() throws Exception { PropertyConfigurator.configure("input/patternLayout1.properties"); common(); - Transformer.transform(TEMP, FILTERED, new LineNumberFilter()); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + new LineNumberFilter(), new SunReflectFilter(), + new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.1")); } @@ -84,10 +103,13 @@ public void test2() throws Exception { PropertyConfigurator.configure("input/patternLayout2.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT1, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter(), - new ISO8601Filter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new ISO8601Filter(), + new SunReflectFilter(), new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.2")); } @@ -95,9 +117,13 @@ public void test3() throws Exception { PropertyConfigurator.configure("input/patternLayout3.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT1, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, new LineNumberFilter(), - new ISO8601Filter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new ISO8601Filter(), + new SunReflectFilter(), new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.3")); } @@ -107,10 +133,13 @@ public void test4() throws Exception { PropertyConfigurator.configure("input/patternLayout4.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT2, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter(), - new AbsoluteDateAndTimeFilter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new AbsoluteDateAndTimeFilter(), + new SunReflectFilter(), new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.4")); } @@ -118,10 +147,13 @@ public void test5() throws Exception { PropertyConfigurator.configure("input/patternLayout5.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT2, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter(), - new AbsoluteDateAndTimeFilter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new AbsoluteDateAndTimeFilter(), + new SunReflectFilter(), new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.5")); } @@ -130,10 +162,13 @@ public void test6() throws Exception { PropertyConfigurator.configure("input/patternLayout6.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT3, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter(), - new AbsoluteTimeFilter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new AbsoluteTimeFilter(), + new SunReflectFilter(), new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.6")); } @@ -142,10 +177,13 @@ public void test7() throws Exception { PropertyConfigurator.configure("input/patternLayout7.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT3, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter(), - new AbsoluteTimeFilter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new AbsoluteTimeFilter(), + new SunReflectFilter(), new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.7")); } @@ -153,10 +191,13 @@ public void test8() throws Exception { PropertyConfigurator.configure("input/patternLayout8.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT4, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter(), - new RelativeTimeFilter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new RelativeTimeFilter(), + new SunReflectFilter(), new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.8")); } @@ -164,8 +205,13 @@ public void test9() throws Exception { PropertyConfigurator.configure("input/patternLayout9.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT5, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, new LineNumberFilter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new SunReflectFilter(), + new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.9")); } @@ -173,9 +219,13 @@ public void test10() throws Exception { PropertyConfigurator.configure("input/patternLayout10.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT6, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new SunReflectFilter(), + new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.10")); } @@ -183,9 +233,13 @@ public void test11() throws Exception { PropertyConfigurator.configure("input/patternLayout11.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT11a, PAT11b, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new SunReflectFilter(), + new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.11")); } @@ -193,9 +247,13 @@ public void test12() throws Exception { PropertyConfigurator.configure("input/patternLayout12.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT12, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new SunReflectFilter(), + new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.12")); } @@ -203,9 +261,13 @@ public void test13() throws Exception { PropertyConfigurator.configure("input/patternLayout13.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT13, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter()}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new SunReflectFilter(), + new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.13")); } @@ -213,15 +275,25 @@ public void test14() throws Exception { PropertyConfigurator.configure("input/patternLayout14.properties"); common(); ControlFilter cf1 = new ControlFilter(new String[]{PAT14, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf1, - new LineNumberFilter(), }); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + cf1, new LineNumberFilter(), new SunReflectFilter(), + new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/patternLayout.14")); } void common() { + String oldThreadName = Thread.currentThread().getName(); + Thread.currentThread().setName("main"); + int i = -1; + logger.trace("Message " + ++i); + root.trace("Message " + i); + logger.debug("Message " + ++i); root.debug("Message " + i); @@ -238,11 +310,14 @@ void common() { root.log(Level.FATAL, "Message " + i); Exception e = new Exception("Just testing"); + logger.trace("Message " + ++i, e); logger.debug("Message " + ++i, e); logger.info("Message " + ++i, e); logger.warn("Message " + ++i , e); logger.error("Message " + ++i, e); logger.log(Level.FATAL, "Message " + ++i, e); + + Thread.currentThread().setName(oldThreadName); } diff --git a/tests/src/java/org/apache/log4j/PriorityTest.java b/tests/src/java/org/apache/log4j/PriorityTest.java new file mode 100644 index 0000000000..68c748202a --- /dev/null +++ b/tests/src/java/org/apache/log4j/PriorityTest.java @@ -0,0 +1,212 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import junit.framework.TestCase; + +import java.util.Locale; + + +/** + * Tests of Priority. + * + * @author Curt Arnold + * @since 1.2.14 + */ +public class PriorityTest extends TestCase { + /** + * Constructs new instance of test. + * @param name test name. + */ + public PriorityTest(final String name) { + super(name); + } + + /** + * Tests Priority.OFF_INT. + */ + public void testOffInt() { + assertEquals(Integer.MAX_VALUE, Priority.OFF_INT); + } + + /** + * Tests Priority.FATAL_INT. + */ + public void testFatalInt() { + assertEquals(50000, Priority.FATAL_INT); + } + + /** + * Tests Priority.ERROR_INT. + */ + public void testErrorInt() { + assertEquals(40000, Priority.ERROR_INT); + } + + /** + * Tests Priority.WARN_INT. + */ + public void testWarnInt() { + assertEquals(30000, Priority.WARN_INT); + } + + /** + * Tests Priority.INFO_INT. + */ + public void testInfoInt() { + assertEquals(20000, Priority.INFO_INT); + } + + /** + * Tests Priority.DEBUG_INT. + */ + public void testDebugInt() { + assertEquals(10000, Priority.DEBUG_INT); + } + + /** + * Tests Priority.ALL_INT. + */ + public void testAllInt() { + assertEquals(Integer.MIN_VALUE, Priority.ALL_INT); + } + + /** + * Tests Priority.FATAL. + * @deprecated + */ + public void testFatal() { + assertTrue(Priority.FATAL instanceof Level); + } + + /** + * Tests Priority.ERROR. + * @deprecated + */ + public void testERROR() { + assertTrue(Priority.ERROR instanceof Level); + } + + /** + * Tests Priority.WARN. + * @deprecated + */ + public void testWARN() { + assertTrue(Priority.WARN instanceof Level); + } + + /** + * Tests Priority.INFO. + * @deprecated + */ + public void testINFO() { + assertTrue(Priority.INFO instanceof Level); + } + + /** + * Tests Priority.DEBUG. + * @deprecated + */ + public void testDEBUG() { + assertTrue(Priority.DEBUG instanceof Level); + } + + /** + * Tests Priority.equals(null). + * @deprecated + */ + public void testEqualsNull() { + assertFalse(Priority.DEBUG.equals(null)); + } + + /** + * Tests Priority.equals(Level.DEBUG). + * @deprecated + */ + public void testEqualsLevel() { + // + // this behavior violates the equals contract. + // + assertTrue(Priority.DEBUG.equals(Level.DEBUG)); + } + + /** + * Tests getAllPossiblePriorities(). + * @deprecated + */ + public void testGetAllPossiblePriorities() { + Priority[] priorities = Priority.getAllPossiblePriorities(); + assertEquals(5, priorities.length); + } + + /** + * Tests toPriority(String). + * @deprecated + */ + public void testToPriorityString() { + assertTrue(Priority.toPriority("DEBUG") == Level.DEBUG); + } + + /** + * Tests toPriority(int). + * @deprecated + */ + public void testToPriorityInt() { + assertTrue(Priority.toPriority(Priority.DEBUG_INT) == Level.DEBUG); + } + + /** + * Tests toPriority(String, Priority). + * @deprecated + */ + public void testToPriorityStringPriority() { + assertTrue(Priority.toPriority("foo", Priority.DEBUG) == Priority.DEBUG); + } + + /** + * Tests toPriority(int, Priority). + * @deprecated + */ + public void testToPriorityIntPriority() { + assertTrue(Priority.toPriority(17, Priority.DEBUG) == Priority.DEBUG); + } + + /** + * Test that dotless lower I + "nfo" is recognized as INFO. + * @deprecated + */ + public void testDotlessLowerI() { + Priority level = Priority.toPriority("\u0131nfo"); + assertEquals("INFO", level.toString()); + } + + /** + * Test that dotted lower I + "nfo" is recognized as INFO + * even in Turkish locale. + * @deprecated + */ + public void testDottedLowerI() { + Locale defaultLocale = Locale.getDefault(); + Locale turkey = new Locale("tr", "TR"); + Locale.setDefault(turkey); + Priority level = Priority.toPriority("info"); + Locale.setDefault(defaultLocale); + assertEquals("INFO", level.toString()); + } + +} diff --git a/tests/src/java/org/apache/log4j/PropertyConfiguratorTest.java b/tests/src/java/org/apache/log4j/PropertyConfiguratorTest.java new file mode 100644 index 0000000000..78e032c1ad --- /dev/null +++ b/tests/src/java/org/apache/log4j/PropertyConfiguratorTest.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.log4j; +import java.io.*; +import junit.framework.*; +import org.apache.log4j.PropertyConfigurator; +import java.net.URL; + +/** + * Test property configurator. + * + */ +public class PropertyConfiguratorTest extends TestCase { + public PropertyConfiguratorTest(final String testName) { + super(testName); + } + + /** + * Test for bug 40944. + * Did not catch IllegalArgumentException on Properties.load + * and close input stream. + * @throws IOException if IOException creating properties file. + */ + public void testBadUnicodeEscape() throws IOException { + String fileName = "output/badescape.properties"; + FileWriter writer = new FileWriter(fileName); + writer.write("log4j.rootLogger=\\uXX41"); + writer.close(); + PropertyConfigurator.configure(fileName); + File file = new File(fileName); + assertTrue(file.delete()) ; + assertFalse(file.exists()); + } + + /** + * Test for bug 40944. + * configure(URL) never closed opened stream. + * @throws IOException if IOException creating properties file. + */ + public void testURL() throws IOException { + File file = new File("output/unclosed.properties"); + FileWriter writer = new FileWriter(file); + writer.write("log4j.rootLogger=debug"); + writer.close(); + URL url = file.toURL(); + PropertyConfigurator.configure(url); + assertTrue(file.delete()); + assertFalse(file.exists()); + } + + /** + * Test for bug 40944. + * configure(URL) did not catch IllegalArgumentException and + * did not close stream. + * @throws IOException if IOException creating properties file. + */ + public void testURLBadEscape() throws IOException { + File file = new File("output/urlbadescape.properties"); + FileWriter writer = new FileWriter(file); + writer.write("log4j.rootLogger=\\uXX41"); + writer.close(); + URL url = file.toURL(); + PropertyConfigurator.configure(url); + assertTrue(file.delete()); + assertFalse(file.exists()); + } + +} diff --git a/tests/src/java/org/apache/log4j/RFATestCase.java b/tests/src/java/org/apache/log4j/RFATestCase.java new file mode 100644 index 0000000000..0d11fc200d --- /dev/null +++ b/tests/src/java/org/apache/log4j/RFATestCase.java @@ -0,0 +1,237 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import junit.framework.TestCase; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * Test of RollingFileAppender. + * + * @author Curt Arnold + */ +public class RFATestCase extends TestCase { + + public RFATestCase(String name) { + super(name); + } + + public void tearDown() { + LogManager.resetConfiguration(); + } + + /** + * Test basic rolling functionality using property file configuration. + */ + public void test1() throws Exception { + Logger logger = Logger.getLogger(RFATestCase.class); + PropertyConfigurator.configure("input/RFA1.properties"); + + // Write exactly 10 bytes with each log + for (int i = 0; i < 25; i++) { + if (i < 10) { + logger.debug("Hello---" + i); + } else if (i < 100) { + logger.debug("Hello--" + i); + } + } + + assertTrue(new File("output/RFA-test1.log").exists()); + assertTrue(new File("output/RFA-test1.log.1").exists()); + } + + /** + * Test basic rolling functionality using API configuration. + */ + public void test2() throws Exception { + Logger logger = Logger.getLogger(RFATestCase.class); + Logger root = Logger.getRootLogger(); + PatternLayout layout = new PatternLayout("%m\n"); + org.apache.log4j.RollingFileAppender rfa = + new org.apache.log4j.RollingFileAppender(); + rfa.setName("ROLLING"); + rfa.setLayout(layout); + rfa.setAppend(false); + rfa.setMaxBackupIndex(3); + rfa.setMaximumFileSize(100); + rfa.setFile("output/RFA-test2.log"); + rfa.activateOptions(); + root.addAppender(rfa); + + // Write exactly 10 bytes with each log + for (int i = 0; i < 55; i++) { + if (i < 10) { + logger.debug("Hello---" + i); + } else if (i < 100) { + logger.debug("Hello--" + i); + } + } + + assertTrue(new File("output/RFA-test2.log").exists()); + assertTrue(new File("output/RFA-test2.log.1").exists()); + assertTrue(new File("output/RFA-test2.log.2").exists()); + assertTrue(new File("output/RFA-test2.log.3").exists()); + assertFalse(new File("output/RFA-test2.log.4").exists()); + } + + /** + * Tests 2 parameter constructor. + * @throws IOException if IOException during test. + */ + public void test2ParamConstructor() throws IOException { + SimpleLayout layout = new SimpleLayout(); + RollingFileAppender appender = + new RollingFileAppender(layout,"output/rfa_2param.log"); + assertEquals(1, appender.getMaxBackupIndex()); + assertEquals(10*1024*1024, appender.getMaximumFileSize()); + } + /** + * Tests 3 parameter constructor. + * @throws IOException if IOException during test. + */ + public void test3ParamConstructor() throws IOException { + SimpleLayout layout = new SimpleLayout(); + RollingFileAppender appender = + new RollingFileAppender(layout,"output/rfa_3param.log", false); + assertEquals(1, appender.getMaxBackupIndex()); + } + + /** + * Test locking of .1 file. + */ + public void testLockDotOne() throws Exception { + Logger logger = Logger.getLogger(RFATestCase.class); + Logger root = Logger.getRootLogger(); + PatternLayout layout = new PatternLayout("%m\n"); + org.apache.log4j.RollingFileAppender rfa = + new org.apache.log4j.RollingFileAppender(); + rfa.setName("ROLLING"); + rfa.setLayout(layout); + rfa.setAppend(false); + rfa.setMaxBackupIndex(10); + rfa.setMaximumFileSize(100); + rfa.setFile("output/RFA-dot1.log"); + rfa.activateOptions(); + root.addAppender(rfa); + + new File("output/RFA-dot1.log.2").delete(); + + FileWriter dot1 = new FileWriter("output/RFA-dot1.log.1"); + dot1.write("Locked file"); + FileWriter dot5 = new FileWriter("output/RFA-dot1.log.5"); + dot5.write("Unlocked file"); + dot5.close(); + + // Write exactly 10 bytes with each log + for (int i = 0; i < 15; i++) { + if (i < 10) { + logger.debug("Hello---" + i); + } else if (i < 100) { + logger.debug("Hello--" + i); + } + } + dot1.close(); + + for (int i = 15; i < 25; i++) { + logger.debug("Hello--" + i); + } + rfa.close(); + + + assertTrue(new File("output/RFA-dot1.log.7").exists()); + // + // if .2 is the locked file then + // renaming wasn't successful until the file was closed + if (new File("output/RFA-dot1.log.2").length() < 15) { + assertEquals(50, new File("output/RFA-dot1.log").length()); + assertEquals(200, new File("output/RFA-dot1.log.1").length()); + } else { + assertTrue(new File("output/RFA-dot1.log").exists()); + assertTrue(new File("output/RFA-dot1.log.1").exists()); + assertTrue(new File("output/RFA-dot1.log.2").exists()); + assertTrue(new File("output/RFA-dot1.log.3").exists()); + assertFalse(new File("output/RFA-dot1.log.4").exists()); + } + } + + + /** + * Test locking of .3 file. + */ + public void testLockDotThree() throws Exception { + Logger logger = Logger.getLogger(RFATestCase.class); + Logger root = Logger.getRootLogger(); + PatternLayout layout = new PatternLayout("%m\n"); + org.apache.log4j.RollingFileAppender rfa = + new org.apache.log4j.RollingFileAppender(); + rfa.setName("ROLLING"); + rfa.setLayout(layout); + rfa.setAppend(false); + rfa.setMaxBackupIndex(10); + rfa.setMaximumFileSize(100); + rfa.setFile("output/RFA-dot3.log"); + rfa.activateOptions(); + root.addAppender(rfa); + + new File("output/RFA-dot3.log.1").delete(); + new File("output/RFA-dot3.log.2").delete(); + new File("output/RFA-dot3.log.4").delete(); + + FileWriter dot3 = new FileWriter("output/RFA-dot3.log.3"); + dot3.write("Locked file"); + FileWriter dot5 = new FileWriter("output/RFA-dot3.log.5"); + dot5.write("Unlocked file"); + dot5.close(); + + // Write exactly 10 bytes with each log + for (int i = 0; i < 15; i++) { + if (i < 10) { + logger.debug("Hello---" + i); + } else if (i < 100) { + logger.debug("Hello--" + i); + } + } + dot3.close(); + + for (int i = 15; i < 35; i++) { + logger.debug("Hello--" + i); + } + rfa.close(); + + assertTrue(new File("output/RFA-dot3.log.8").exists()); + // + // if .3 is the locked file then + // renaming wasn't successful until file was closed + if (new File("output/RFA-dot3.log.5").exists()) { + assertEquals(50, new File("output/RFA-dot3.log").length()); + assertEquals(100, new File("output/RFA-dot3.log.1").length()); + assertEquals(200, new File("output/RFA-dot3.log.2").length()); + } else { + assertTrue(new File("output/RFA-dot3.log").exists()); + assertTrue(new File("output/RFA-dot3.log.1").exists()); + assertTrue(new File("output/RFA-dot3.log.2").exists()); + assertTrue(new File("output/RFA-dot3.log.3").exists()); + assertFalse(new File("output/RFA-dot3.log.4").exists()); + } + } + + +} diff --git a/tests/src/java/org/apache/log4j/StressCategory.java b/tests/src/java/org/apache/log4j/StressCategory.java index dbce0a06bb..551a922885 100644 --- a/tests/src/java/org/apache/log4j/StressCategory.java +++ b/tests/src/java/org/apache/log4j/StressCategory.java @@ -1,19 +1,29 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; import org.apache.log4j.Level; -import org.apache.log4j.Category; +import org.apache.log4j.Logger; import java.util.Random; /* - Stress test the Category class. + Stress test the Logger class. */ @@ -25,11 +35,11 @@ class StressCategory { Level.ERROR, Level.FATAL}; - static Level defaultLevel = Category.getRoot().getLevel(); + static Level defaultLevel = Logger.getRootLogger().getLevel(); static int LENGTH; static String[] names; - static Category[] cat; + static Logger[] cat; static CT[] ct; static Random random = new Random(10); @@ -53,7 +63,7 @@ public static void main(String[] args) { for(int i=0; i < LENGTH; i++) { names[i] = args[i]; } - cat = new Category[LENGTH]; + cat = new Logger[LENGTH]; ct = new CT[LENGTH]; @@ -105,7 +115,7 @@ void createLoop(int n) { if(ct[i] == null) cat[i] = null; else { - cat[i] = Category.getInstance(ct[i].catstr); + cat[i] = Logger.getLogger(ct[i].catstr); cat[i].setLevel(ct[i].level); } } @@ -183,7 +193,7 @@ void catDump() { boolean checkCorrectness(int i) { CT localCT = ct[i]; - // Can't perform test if category is not instantiated + // Can't perform test if logger is not instantiated if(localCT == null) return true; diff --git a/tests/src/java/org/apache/log4j/TTCCLayoutTest.java b/tests/src/java/org/apache/log4j/TTCCLayoutTest.java new file mode 100644 index 0000000000..35f6d1ec06 --- /dev/null +++ b/tests/src/java/org/apache/log4j/TTCCLayoutTest.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import org.apache.log4j.helpers.DateLayoutTest; +import org.apache.log4j.spi.LoggingEvent; + + +/** + * Test for TTCCLayout. + * + * @author Curt Arnold + */ +public class TTCCLayoutTest extends DateLayoutTest { + /** + * Construct new instance of TTCCLayoutTest. + * + * @param testName test name. + */ + public TTCCLayoutTest(final String testName) { + super(testName, "text/plain", true, null, null); + } + + /** + * @{inheritDoc} + */ + protected Layout createLayout() { + return new TTCCLayout(); + } + + /** + * Tests format. + */ + public void testFormat() { + NDC.clear(); + NDC.push("NDC goes here"); + + Logger logger = Logger.getLogger("org.apache.log4j.LayoutTest"); + LoggingEvent event = + new LoggingEvent( + "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null); + TTCCLayout layout = (TTCCLayout) createLayout(); + String result = layout.format(event); + NDC.pop(); + + StringBuffer buf = new StringBuffer(100); + layout.dateFormat(buf, event); + buf.append('['); + buf.append(event.getThreadName()); + buf.append("] "); + buf.append(event.getLevel().toString()); + buf.append(' '); + buf.append(event.getLoggerName()); + buf.append(' '); + buf.append("NDC goes here"); + buf.append(" - "); + buf.append(event.getMessage()); + buf.append(System.getProperty("line.separator")); + assertEquals(buf.toString(), result); + } + + /** + * Tests getThreadPrinting and setThreadPrinting. + */ + public void testGetSetThreadPrinting() { + TTCCLayout layout = new TTCCLayout(); + assertEquals(true, layout.getThreadPrinting()); + layout.setThreadPrinting(false); + assertEquals(false, layout.getThreadPrinting()); + layout.setThreadPrinting(true); + assertEquals(true, layout.getThreadPrinting()); + } + + /** + * Tests getCategoryPrefixing and setCategoryPrefixing. + */ + public void testGetSetCategoryPrefixing() { + TTCCLayout layout = new TTCCLayout(); + assertEquals(true, layout.getCategoryPrefixing()); + layout.setCategoryPrefixing(false); + assertEquals(false, layout.getCategoryPrefixing()); + layout.setCategoryPrefixing(true); + assertEquals(true, layout.getCategoryPrefixing()); + } + + /** + * Tests getContextPrinting and setContextPrinting. + */ + public void testGetSetContextPrinting() { + TTCCLayout layout = new TTCCLayout(); + assertEquals(true, layout.getContextPrinting()); + layout.setContextPrinting(false); + assertEquals(false, layout.getContextPrinting()); + layout.setContextPrinting(true); + assertEquals(true, layout.getContextPrinting()); + } +} diff --git a/tests/src/java/org/apache/log4j/VectorAppender.java b/tests/src/java/org/apache/log4j/VectorAppender.java index 6621bc7430..a87ab521fc 100644 --- a/tests/src/java/org/apache/log4j/VectorAppender.java +++ b/tests/src/java/org/apache/log4j/VectorAppender.java @@ -1,18 +1,26 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j; import java.util.Vector; import org.apache.log4j.Layout; import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.spi.LocationInfo; import org.apache.log4j.helpers.OptionConverter; -import org.apache.log4j.helpers.DateLayout; import org.apache.log4j.helpers.Transform; import org.apache.log4j.helpers.LogLog; @@ -24,16 +32,14 @@ public class VectorAppender extends AppenderSkeleton { public Vector vector; - public - VectorAppender() { + public VectorAppender() { vector = new Vector(); } /** Does nothing. */ - public - void activateOptions() { + public void activateOptions() { } @@ -42,28 +48,32 @@ void activateOptions() { method. */ - public - void append(LoggingEvent event) { - System.out.println("---Vector appender called with message ["+event.getRenderedMessage()+"]."); + public void append(LoggingEvent event) { + //System.out.println("---Vector appender called with message ["+event.getRenderedMessage()+"]."); + //System.out.flush(); + try { + Thread.currentThread().sleep(100); + } catch(Exception e) { + } vector.addElement(event); } - public - Vector getVector() { + public Vector getVector() { return vector; } - public - synchronized - void close() { + public synchronized void close() { if(this.closed) return; this.closed = true; } - public - boolean requiresLayout() { + public boolean isClosed() { + return closed; + } + + public boolean requiresLayout() { return false; } } diff --git a/tests/src/java/org/apache/log4j/VectorErrorHandler.java b/tests/src/java/org/apache/log4j/VectorErrorHandler.java new file mode 100644 index 0000000000..a08726c2f0 --- /dev/null +++ b/tests/src/java/org/apache/log4j/VectorErrorHandler.java @@ -0,0 +1,182 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j; + +import org.apache.log4j.spi.ErrorHandler; +import org.apache.log4j.spi.LoggingEvent; + +import java.util.Vector; + + +/** + * Utility class used in testing to capture errors dispatched + * by appenders. + * + * @author Curt Arnold + */ +public final class VectorErrorHandler implements ErrorHandler { + /** + * Logger. + */ + private Logger logger; + + /** + * Appender. + */ + private Appender appender; + + /** + * Backup appender. + */ + private Appender backupAppender; + + /** + * Array of processed errors. + */ + private final Vector errors = new Vector(); + + /** + * Default constructor. + */ + public VectorErrorHandler() { + } + + /** + * {@inheritDoc} + */ + public void setLogger(final Logger logger) { + this.logger = logger; + } + + /** + * Gets last logger specified by setLogger. + * @return logger. + */ + public Logger getLogger() { + return logger; + } + + /** + * {@inheritDoc} + */ + public void activateOptions() { + } + + /** + * {@inheritDoc} + */ + public void error( + final String message, final Exception e, final int errorCode) { + error(message, e, errorCode, null); + } + + /** + * {@inheritDoc} + */ + public void error(final String message) { + error(message, null, -1, null); + } + + /** + * {@inheritDoc} + */ + public void error( + final String message, final Exception e, final int errorCode, + final LoggingEvent event) { + errors.addElement( + new Object[] { message, e, new Integer(errorCode), event }); + } + + /** + * Gets message from specified error. + * + * @param index index. + * @return message, may be null. + */ + public String getMessage(final int index) { + return (String) ((Object[]) errors.elementAt(index))[0]; + } + + /** + * Gets exception from specified error. + * + * @param index index. + * @return exception. + */ + public Exception getException(final int index) { + return (Exception) ((Object[]) errors.elementAt(index))[1]; + } + + /** + * Gets error code from specified error. + * + * @param index index. + * @return error code, -1 if not specified. + */ + public int getErrorCode(final int index) { + return ((Integer) ((Object[]) errors.elementAt(index))[2]).intValue(); + } + + /** + * Gets logging event from specified error. + * + * @param index index. + * @return exception. + */ + public LoggingEvent getEvent(final int index) { + return (LoggingEvent) ((Object[]) errors.elementAt(index))[3]; + } + + /** + * Gets number of errors captured. + * @return number of errors captured. + */ + public int size() { + return errors.size(); + } + + /** + * {@inheritDoc} + */ + public void setAppender(final Appender appender) { + this.appender = appender; + } + + /** + * Get appender. + * @return appender, may be null. + */ + public Appender getAppender() { + return appender; + } + + /** + * {@inheritDoc} + */ + public void setBackupAppender(final Appender appender) { + this.backupAppender = appender; + } + + /** + * Get backup appender. + * @return backup appender, may be null. + */ + public Appender getBackupAppender() { + return backupAppender; + } +} diff --git a/tests/src/java/org/apache/log4j/customLogger/XLogger.java b/tests/src/java/org/apache/log4j/customLogger/XLogger.java index ed3acd6568..c24828dd2b 100644 --- a/tests/src/java/org/apache/log4j/customLogger/XLogger.java +++ b/tests/src/java/org/apache/log4j/customLogger/XLogger.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.customLogger; diff --git a/tests/src/java/org/apache/log4j/customLogger/XLoggerTestCase.java b/tests/src/java/org/apache/log4j/customLogger/XLoggerTestCase.java index 12be126474..f80103c854 100644 --- a/tests/src/java/org/apache/log4j/customLogger/XLoggerTestCase.java +++ b/tests/src/java/org/apache/log4j/customLogger/XLoggerTestCase.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.customLogger; @@ -52,7 +62,12 @@ void common(int number) throws Exception { Exception e = new Exception("Just testing"); logger.debug("Message " + ++i, e); - Transformer.transform("output/temp", FILTERED, new LineNumberFilter()); + Transformer.transform( + "output/temp", FILTERED, + new Filter[] { + new LineNumberFilter(), new SunReflectFilter(), + new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/customLogger."+number)); } diff --git a/tests/src/java/org/apache/log4j/defaultInit/TestCase1.java b/tests/src/java/org/apache/log4j/defaultInit/TestCase1.java new file mode 100644 index 0000000000..24669b691b --- /dev/null +++ b/tests/src/java/org/apache/log4j/defaultInit/TestCase1.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.defaultInit; + +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.framework.Test; + +import java.util.Vector; + +import org.apache.log4j.*; + +public class TestCase1 extends TestCase { + + public TestCase1(String name) { + super(name); + } + + public void setUp() { + } + + public void tearDown() { + LogManager.shutdown(); + } + + public void noneTest() { + Logger root = Logger.getRootLogger(); + boolean rootIsConfigured = root.getAllAppenders().hasMoreElements(); + assertTrue(!rootIsConfigured); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTest(new TestCase1("noneTest")); + return suite; + } + +} + diff --git a/tests/src/java/org/apache/log4j/defaultInit/TestCase2.java b/tests/src/java/org/apache/log4j/defaultInit/TestCase2.java new file mode 100644 index 0000000000..d5da315359 --- /dev/null +++ b/tests/src/java/org/apache/log4j/defaultInit/TestCase2.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.defaultInit; + +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.framework.Test; + +import java.util.Vector; +import java.util.Enumeration; + +import org.apache.log4j.*; + +public class TestCase2 extends TestCase { + + public TestCase2(String name) { + super(name); + } + + public void setUp() { + } + + public void tearDown() { + LogManager.shutdown(); + } + + public void xmlTest() { + Logger root = Logger.getRootLogger(); + boolean rootIsConfigured = root.getAllAppenders().hasMoreElements(); + assertTrue(rootIsConfigured); + Enumeration e = root.getAllAppenders(); + Appender appender = (Appender) e.nextElement(); + assertEquals(appender.getName(), "D1"); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTest(new TestCase2("xmlTest")); + return suite; + } + +} + diff --git a/tests/src/java/org/apache/log4j/defaultInit/TestCase3.java b/tests/src/java/org/apache/log4j/defaultInit/TestCase3.java new file mode 100644 index 0000000000..2c9abc478c --- /dev/null +++ b/tests/src/java/org/apache/log4j/defaultInit/TestCase3.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.defaultInit; + +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.framework.Test; + +import java.util.Vector; +import java.util.Enumeration; + +import org.apache.log4j.*; + +public class TestCase3 extends TestCase { + + public TestCase3(String name) { + super(name); + } + + public void setUp() { + } + + public void tearDown() { + LogManager.shutdown(); + } + + public void propertiesTest() { + Logger root = Logger.getRootLogger(); + boolean rootIsConfigured = root.getAllAppenders().hasMoreElements(); + assertTrue(rootIsConfigured); + Enumeration e = root.getAllAppenders(); + Appender appender = (Appender) e.nextElement(); + assertEquals(appender.getName(), "D3"); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTest(new TestCase3("propertiesTest")); + return suite; + } + +} + diff --git a/tests/src/java/org/apache/log4j/defaultInit/TestCase4.java b/tests/src/java/org/apache/log4j/defaultInit/TestCase4.java new file mode 100644 index 0000000000..dff7813ec5 --- /dev/null +++ b/tests/src/java/org/apache/log4j/defaultInit/TestCase4.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.defaultInit; + +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.framework.Test; + +import java.util.Vector; +import java.util.Enumeration; + +import org.apache.log4j.*; + +public class TestCase4 extends TestCase { + + public TestCase4(String name) { + super(name); + } + + public void setUp() { + } + + public void tearDown() { + LogManager.shutdown(); + } + + public void combinedTest() { + Logger root = Logger.getRootLogger(); + boolean rootIsConfigured = root.getAllAppenders().hasMoreElements(); + assertTrue(rootIsConfigured); + Enumeration e = root.getAllAppenders(); + Appender appender = (Appender) e.nextElement(); + assertEquals(appender.getName(), "D1"); + assertEquals(e.hasMoreElements(), false); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTest(new TestCase4("combinedTest")); + return suite; + } + +} + diff --git a/tests/src/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java b/tests/src/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java index 2baa672ec0..1412fab62f 100644 --- a/tests/src/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java +++ b/tests/src/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // Log4j uses the JUnit framework for internal unit testing. JUnit @@ -15,8 +25,8 @@ package org.apache.log4j.helpers; import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.Category; -import org.apache.log4j.Priority; +import org.apache.log4j.Logger; +import org.apache.log4j.Level; import org.apache.log4j.helpers.BoundedFIFO; @@ -33,7 +43,7 @@ @author Ceki Gülcü @since 0.9.1 */ public class BoundedFIFOTestCase extends TestCase { - static Category cat = Category.getInstance("x"); + static Logger cat = Logger.getLogger("x"); static int MAX = 1000; @@ -41,7 +51,7 @@ public class BoundedFIFOTestCase extends TestCase { { for (int i = 0; i < MAX; i++) { - e[i] = new LoggingEvent("", cat, Priority.DEBUG, "e"+i, null); + e[i] = new LoggingEvent("", cat, Level.DEBUG, "e"+i, null); } } diff --git a/tests/src/java/org/apache/log4j/helpers/CyclicBufferTestCase.java b/tests/src/java/org/apache/log4j/helpers/CyclicBufferTestCase.java index 221e86f201..d46adb16bb 100644 --- a/tests/src/java/org/apache/log4j/helpers/CyclicBufferTestCase.java +++ b/tests/src/java/org/apache/log4j/helpers/CyclicBufferTestCase.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // Log4j uses the JUnit framework for internal unit testing. JUnit @@ -15,8 +25,8 @@ package org.apache.log4j.helpers; import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.Category; -import org.apache.log4j.Priority; +import org.apache.log4j.Logger; +import org.apache.log4j.Level; import org.apache.log4j.helpers.CyclicBuffer; import junit.framework.TestCase; @@ -32,7 +42,7 @@ */ public class CyclicBufferTestCase extends TestCase { - static Category cat = Category.getInstance("x"); + static Logger cat = Logger.getLogger("x"); static int MAX = 1000; @@ -40,7 +50,7 @@ public class CyclicBufferTestCase extends TestCase { { for (int i = 0; i < MAX; i++) { - e[i] = new LoggingEvent("", cat, Priority.DEBUG, "e"+i, null); + e[i] = new LoggingEvent("", cat, Level.DEBUG, "e"+i, null); } } diff --git a/tests/src/java/org/apache/log4j/helpers/DateLayoutTest.java b/tests/src/java/org/apache/log4j/helpers/DateLayoutTest.java new file mode 100644 index 0000000000..9a3b62f9fd --- /dev/null +++ b/tests/src/java/org/apache/log4j/helpers/DateLayoutTest.java @@ -0,0 +1,286 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.helpers; + +import org.apache.log4j.Layout; +import org.apache.log4j.LayoutTest; +import org.apache.log4j.spi.LoggingEvent; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; + +import java.util.TimeZone; +import java.util.Date; +import java.util.Calendar; + + +/** + * Tests for DateLayout. + * + */ +public class DateLayoutTest extends LayoutTest { + /** + * Construct a new instance of LayoutTest. + * @param testName test name. + */ + public DateLayoutTest(final String testName) { + super(testName); + } + + /** + * Constructor for use by derived tests. + * @param testName name of test. + * @param expectedContentType expected value for getContentType(). + * @param expectedIgnoresThrowable expected value for ignoresThrowable(). + * @param expectedHeader expected value for getHeader(). + * @param expectedFooter expected value for getFooter(). + */ + protected DateLayoutTest( + final String testName, final String expectedContentType, + final boolean expectedIgnoresThrowable, final String expectedHeader, + final String expectedFooter) { + super( + testName, expectedContentType, expectedIgnoresThrowable, expectedHeader, + expectedFooter); + } + + /** + * @{inheritDoc} + */ + protected Layout createLayout() { + return new MockLayout(); + } + + /** + * Tests DateLayout.NULL_DATE_FORMAT constant. + */ + public void testNullDateFormat() { + assertEquals("NULL", DateLayout.NULL_DATE_FORMAT); + } + + /** + * Tests DateLayout.RELATIVE constant. + */ + public void testRelativeTimeDateFormat() { + assertEquals("RELATIVE", DateLayout.RELATIVE_TIME_DATE_FORMAT); + } + + /** + * Tests DateLayout.DATE_FORMAT_OPTION constant. + * @deprecated since constant is deprecated + */ + public void testDateFormatOption() { + assertEquals("DateFormat", DateLayout.DATE_FORMAT_OPTION); + } + + /** + * Tests DateLayout.TIMEZONE_OPTION constant. + * @deprecated since constant is deprecated + */ + public void testTimeZoneOption() { + assertEquals("TimeZone", DateLayout.TIMEZONE_OPTION); + } + + /** + * Tests getOptionStrings(). + * @deprecated since getOptionStrings is deprecated. + * + */ + public void testGetOptionStrings() { + String[] options = ((DateLayout) createLayout()).getOptionStrings(); + assertEquals(2, options.length); + } + + /** + * Tests setting DateFormat through setOption method. + * @deprecated since setOption is deprecated. + */ + public void testSetOptionDateFormat() { + DateLayout layout = (DateLayout) createLayout(); + layout.setOption("dAtefOrmat", "foobar"); + assertEquals("FOOBAR", layout.getDateFormat()); + } + + /** + * Tests setting TimeZone through setOption method. + * @deprecated since setOption is deprecated. + */ + public void testSetOptionTimeZone() { + DateLayout layout = (DateLayout) createLayout(); + layout.setOption("tImezOne", "+05:00"); + assertEquals("+05:00", layout.getTimeZone()); + } + + /** + * Tests setDateFormat. + */ + public void testSetDateFormat() { + DateLayout layout = (DateLayout) createLayout(); + layout.setDateFormat("ABSOLUTE"); + assertEquals("ABSOLUTE", layout.getDateFormat()); + } + + /** + * Tests setTimeZone. + */ + public void testSetTimeZone() { + DateLayout layout = (DateLayout) createLayout(); + layout.setTimeZone("+05:00"); + assertEquals("+05:00", layout.getTimeZone()); + } + + /** + * Tests 2 parameter setDateFormat with null. + */ + public void testSetDateFormatNull() { + DateLayout layout = (DateLayout) createLayout(); + layout.setDateFormat((String) null, null); + } + + /** + * Tests 2 parameter setDateFormat with "NULL". + */ + public void testSetDateFormatNullString() { + DateLayout layout = (DateLayout) createLayout(); + layout.setDateFormat("NuLL", null); + } + + /** + * Tests 2 parameter setDateFormat with "RELATIVE". + */ + public void testSetDateFormatRelative() { + DateLayout layout = (DateLayout) createLayout(); + layout.setDateFormat("rElatIve", TimeZone.getDefault()); + } + + /** + * Tests 2 parameter setDateFormat with "ABSOLUTE". + */ + public void testSetDateFormatAbsolute() { + DateLayout layout = (DateLayout) createLayout(); + layout.setDateFormat("aBsolUte", TimeZone.getDefault()); + } + + /** + * Tests 2 parameter setDateFormat with "DATETIME". + */ + public void testSetDateFormatDateTime() { + DateLayout layout = (DateLayout) createLayout(); + layout.setDateFormat("dAte", TimeZone.getDefault()); + } + + /** + * Tests 2 parameter setDateFormat with "ISO8601". + */ + public void testSetDateFormatISO8601() { + DateLayout layout = (DateLayout) createLayout(); + layout.setDateFormat("iSo8601", TimeZone.getDefault()); + } + + /** + * Tests 2 parameter setDateFormat with "HH:mm:ss". + */ + public void testSetDateFormatSimple() { + DateLayout layout = (DateLayout) createLayout(); + layout.setDateFormat("HH:mm:ss", TimeZone.getDefault()); + } + + /** + * Tests activateOptions. + */ + public void testActivateOptions() { + DateLayout layout = (DateLayout) createLayout(); + layout.setDateFormat("HH:mm:ss"); + layout.setTimeZone("+05:00"); + layout.activateOptions(); + } + + /** + * Tests setDateFormat(DateFormat, TimeZone). + */ + public void testSetDateFormatWithFormat() { + DateFormat format = new SimpleDateFormat("HH:mm"); + DateLayout layout = (DateLayout) createLayout(); + layout.setDateFormat(format, TimeZone.getDefault()); + } + + + /** + * Tests IS08601DateFormat class. + * @deprecated since ISO8601DateFormat is deprecated + */ + public void testISO8601Format() { + DateFormat format = new ISO8601DateFormat(); + Calendar calendar = Calendar.getInstance(); + calendar.clear(); + calendar.set(1970, 0, 1, 0, 0, 0); + String actual = format.format(calendar.getTime()); + assertEquals("1970-01-01 00:00:00,000", actual); + } + + /** + * Tests DateTimeDateFormat class. + * @deprecated since DateTimeDateFormat is deprecated + */ + public void testDateTimeFormat() { + DateFormat format = new DateTimeDateFormat(); + Calendar calendar = Calendar.getInstance(); + calendar.clear(); + calendar.set(1970, 0, 1, 0, 0, 0); + String actual = format.format(calendar.getTime()); + SimpleDateFormat df = new SimpleDateFormat("dd MMM yyyy HH:mm:ss,SSS"); + String expected = df.format(calendar.getTime()); + assertEquals(expected, actual); + } + + /** + * Concrete Layout class for tests. + */ + private static final class MockLayout extends DateLayout { + /** + * Create new instance of MockLayout. + */ + public MockLayout() { + // + // checks that protected fields are properly initialized + assertNotNull(pos); + assertNotNull(date); + assertNull(dateFormat); + } + + /** + * @{inheritDoc} + */ + public String format(final LoggingEvent event) { + return "Mock"; + } + + /** + * @{inheritDoc} + */ + public void activateOptions() { + } + + /** + * @{inheritDoc} + */ + public boolean ignoresThrowable() { + return true; + } + } +} diff --git a/tests/src/java/org/apache/log4j/helpers/LogLogTest.java b/tests/src/java/org/apache/log4j/helpers/LogLogTest.java new file mode 100644 index 0000000000..3eab58fc3b --- /dev/null +++ b/tests/src/java/org/apache/log4j/helpers/LogLogTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.helpers; + +import junit.framework.TestCase; + + +/** + * Tests for LogLog. + * + * @author Curt Arnold + **/ +public class LogLogTest extends TestCase { + /** + * Create new instance of LogLogTest. + * @param testName test name + */ + public LogLogTest(final String testName) { + super(testName); + } + + /** + * Check value of DEBUG_KEY. + */ + public void testDebugKey() { + assertEquals("log4j.debug", LogLog.DEBUG_KEY); + } + + /** + * Check value of CONFIG_DEBUG_KEY. + * @deprecated since constant is deprecated + */ + public void testConfigDebugKey() { + assertEquals("log4j.configDebug", LogLog.CONFIG_DEBUG_KEY); + } +} diff --git a/tests/src/java/org/apache/log4j/helpers/OptionConverterTestCase.java b/tests/src/java/org/apache/log4j/helpers/OptionConverterTestCase.java index 2110875855..739a76b87a 100644 --- a/tests/src/java/org/apache/log4j/helpers/OptionConverterTestCase.java +++ b/tests/src/java/org/apache/log4j/helpers/OptionConverterTestCase.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // Log4j uses the JUnit framework for internal unit testing. JUnit // is available from "http://www.junit.org". diff --git a/tests/src/java/org/apache/log4j/helpers/PatternParserTestCase.java b/tests/src/java/org/apache/log4j/helpers/PatternParserTestCase.java new file mode 100644 index 0000000000..872e15faa0 --- /dev/null +++ b/tests/src/java/org/apache/log4j/helpers/PatternParserTestCase.java @@ -0,0 +1,136 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.helpers; + +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.framework.Test; + +import org.apache.log4j.Logger; +import org.apache.log4j.Level; +import org.apache.log4j.Appender; +import org.apache.log4j.FileAppender; +import org.apache.log4j.PatternLayout; +import org.apache.log4j.MDC; + +import org.apache.log4j.util.Compare; + +/** + Test case for helpers/PatternParser.java. Tests the various + conversion patterns supported by PatternParser. This test + class tests PatternParser via the PatternLayout class which + uses it. + */ +public class PatternParserTestCase extends TestCase { + + static String OUTPUT_FILE = "output/PatternParser"; + static String WITNESS_FILE = "witness/PatternParser"; + + static String msgPattern = "%m%n"; + + Logger root; + Logger logger; + + public PatternParserTestCase(String name) { + super(name); + } + + public void setUp() { + root = Logger.getRootLogger(); + root.removeAllAppenders(); + } + + public void tearDown() { + root.getLoggerRepository().resetConfiguration(); + } + + /** + Test case for MDC conversion pattern. */ + public void mdcPattern() throws Exception { + + String mdcMsgPattern1 = "%m : %X%n"; + String mdcMsgPattern2 = "%m : %X{key1}%n"; + String mdcMsgPattern3 = "%m : %X{key2}%n"; + String mdcMsgPattern4 = "%m : %X{key3}%n"; + String mdcMsgPattern5 = "%m : %X{key1},%X{key2},%X{key3}%n"; + + // set up appender + PatternLayout layout = new PatternLayout(msgPattern); + Appender appender = new FileAppender(layout, OUTPUT_FILE+"_mdc", false); + + // set appender on root and set level to debug + root.addAppender(appender); + root.setLevel(Level.DEBUG); + + // output starting message + root.debug("starting mdc pattern test"); + + layout.setConversionPattern(mdcMsgPattern1); + root.debug("empty mdc, no key specified in pattern"); + + layout.setConversionPattern(mdcMsgPattern2); + root.debug("empty mdc, key1 in pattern"); + + layout.setConversionPattern(mdcMsgPattern3); + root.debug("empty mdc, key2 in pattern"); + + layout.setConversionPattern(mdcMsgPattern4); + root.debug("empty mdc, key3 in pattern"); + + layout.setConversionPattern(mdcMsgPattern5); + root.debug("empty mdc, key1, key2, and key3 in pattern"); + + MDC.put("key1", "value1"); + MDC.put("key2", "value2"); + + layout.setConversionPattern(mdcMsgPattern1); + root.debug("filled mdc, no key specified in pattern"); + + layout.setConversionPattern(mdcMsgPattern2); + root.debug("filled mdc, key1 in pattern"); + + layout.setConversionPattern(mdcMsgPattern3); + root.debug("filled mdc, key2 in pattern"); + + layout.setConversionPattern(mdcMsgPattern4); + root.debug("filled mdc, key3 in pattern"); + + layout.setConversionPattern(mdcMsgPattern5); + root.debug("filled mdc, key1, key2, and key3 in pattern"); + + MDC.remove("key1"); + MDC.remove("key2"); + + layout.setConversionPattern(msgPattern); + root.debug("finished mdc pattern test"); + + assertTrue(Compare.compare(OUTPUT_FILE+"_mdc", WITNESS_FILE+"_mdc")); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + // + // MDC requires JDK 1.2+ + // + if (!System.getProperty("java.version").startsWith("1.1.")) { + suite.addTest(new PatternParserTestCase("mdcPattern")); + } + return suite; + } + +} diff --git a/tests/src/java/org/apache/log4j/net/ShortSocketServer.java b/tests/src/java/org/apache/log4j/net/ShortSocketServer.java index 99b8d5c520..4b590cdc9a 100644 --- a/tests/src/java/org/apache/log4j/net/ShortSocketServer.java +++ b/tests/src/java/org/apache/log4j/net/ShortSocketServer.java @@ -1,8 +1,18 @@ -/* 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.txt file. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ @@ -15,15 +25,21 @@ import org.apache.log4j.Logger; import org.apache.log4j.LogManager; import org.apache.log4j.PropertyConfigurator; +import org.apache.log4j.MDC; import org.apache.log4j.helpers.LogLog; import org.apache.log4j.net.SocketNode; import org.apache.log4j.net.SocketServer; /** - This SocketServer exits after just one connection from a client. - - @author Ceki Gulcu -*/ + * This SocketServer exits after certain number of connections from a + * client. This number is determined the totalsTest parameter, that is + * the first argument on the commmand line. The second argument, + * prefix, determines the prefix of the configuration file to + * use. Each run of the server will use a different properties + * file. For the i-th run, the path to the file is + * (prefix+i+".properties"). + * + * @author Ceki Gulcu */ public class ShortSocketServer { @@ -46,6 +62,8 @@ void main(String args[]) throws Exception { LogLog.debug("Listening on port " + SocketServerTestCase.PORT); ServerSocket serverSocket = new ServerSocket(SocketServerTestCase.PORT); + MDC.put("hostID", "shortSocketServer"); + for(int i = 1; i <= totalTests; i++) { PropertyConfigurator.configure(prefix+i+".properties"); LogLog.debug("Waiting to accept a new client."); @@ -61,7 +79,7 @@ void main(String args[]) throws Exception { static - void usage(String msg) { + void usage(String msg) { System.err.println(msg); System.err.println( "Usage: java " +ShortSocketServer.class.getName() + " totalTests configFilePrefix"); diff --git a/tests/src/java/org/apache/log4j/net/SocketAppenderTest.java b/tests/src/java/org/apache/log4j/net/SocketAppenderTest.java new file mode 100644 index 0000000000..e85f140c46 --- /dev/null +++ b/tests/src/java/org/apache/log4j/net/SocketAppenderTest.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.log4j.net; + +import junit.framework.TestCase; + +import org.apache.log4j.Appender; +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.Logger; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.xml.DOMConfigurator; + +public class SocketAppenderTest extends TestCase { + + /** + * Create new instance. + */ + public SocketAppenderTest(final String testName) { + super(testName); + } + + /* JUnit's setUp and tearDown */ + + protected void setUp() { + DOMConfigurator.configure("input/xml/SocketAppenderTestConfig.xml"); + + logger = Logger.getLogger(SocketAppenderTest.class); + primary = logger.getAppender("remote"); + secondary = (LastOnlyAppender) Logger.getLogger( + "org.apache.log4j.net.SocketAppenderTestDummy").getAppender("lastOnly"); + } + + protected void tearDown() { + } + + /* Tests */ + + public void testFallbackErrorHandlerWhenStarting() { + String msg = "testFallbackErrorHandlerWhenStarting"; + logger.debug(msg); + + // above debug log will fail and shoul be redirected to secondary appender + assertEquals("SocketAppender with FallbackErrorHandler", msg, secondary.getLastMessage()); + } + + /* Fields */ + + private static Logger logger; + private static Appender primary; + private static LastOnlyAppender secondary; + + /* Inner classes */ + + /** + * Inner-class For debugging purposes only Saves last LoggerEvent + */ + static public class LastOnlyAppender extends AppenderSkeleton { + protected void append(LoggingEvent event) { + this.lastEvent = event; + } + + public boolean requiresLayout() { + return false; + } + + public void close() { + this.closed = true; + } + + /** + * @return last appended LoggingEvent's message + */ + public String getLastMessage() { + if (this.lastEvent != null) + return this.lastEvent.getMessage().toString(); + else + return ""; + } + + private LoggingEvent lastEvent; + }; + +} \ No newline at end of file diff --git a/tests/src/java/org/apache/log4j/net/SocketServerTestCase.java b/tests/src/java/org/apache/log4j/net/SocketServerTestCase.java index 3810ac2bff..9352396322 100644 --- a/tests/src/java/org/apache/log4j/net/SocketServerTestCase.java +++ b/tests/src/java/org/apache/log4j/net/SocketServerTestCase.java @@ -1,8 +1,18 @@ -/* 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.txt file. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.apache.log4j.net; @@ -36,29 +46,45 @@ public class SocketServerTestCase extends TestCase { // %5p %x [%t] %c %m%n // DEBUG T1 [main] org.apache.log4j.net.SocketAppenderTestCase Message 1 - static String PAT1 = "^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T1 \\[main]\\ " + static String PAT1 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T1 \\[main]\\ " + ".* Message \\d{1,2}"; // DEBUG T2 [main] ? (?:?) Message 1 - static String PAT2 = "^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T2 \\[main]\\ " + static String PAT2 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T2 \\[main]\\ " + "\\? \\(\\?:\\?\\) Message \\d{1,2}"; // DEBUG T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:121) Message 1 - static String PAT3 = "^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T3 \\[main]\\ " + static String PAT3 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) T3 \\[main]\\ " + "org.apache.log4j.net.SocketServerTestCase " + "\\(SocketServerTestCase.java:\\d{3}\\) Message \\d{1,2}"; // DEBUG some T4 MDC-TEST4 [main] SocketAppenderTestCase - Message 1 // DEBUG some T4 MDC-TEST4 [main] SocketAppenderTestCase - Message 1 - static String PAT4 = "^(DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some T4 MDC-TEST4 \\[main]\\" + static String PAT4 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some T4 MDC-TEST4 \\[main]\\" + " (root|SocketServerTestCase) - Message \\d{1,2}"; + static String PAT5 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some5 T5 MDC-TEST5 \\[main]\\" + + " (root|SocketServerTestCase) - Message \\d{1,2}"; + + static String PAT6 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some6 T6 client-test6 MDC-TEST6" + + " \\[main]\\ (root|SocketServerTestCase) - Message \\d{1,2}"; + + static String PAT7 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some7 T7 client-test7 MDC-TEST7" + + " \\[main]\\ (root|SocketServerTestCase) - Message \\d{1,2}"; + + // DEBUG some8 T8 shortSocketServer MDC-TEST7 [main] SocketServerTestCase - Message 1 + static String PAT8 = "^(TRACE|DEBUG| INFO| WARN|ERROR|FATAL|LETHAL) some8 T8 shortSocketServer" + + " MDC-TEST8 \\[main]\\ (root|SocketServerTestCase) - Message \\d{1,2}"; + + static String EXCEPTION1 = "java.lang.Exception: Just testing"; static String EXCEPTION2 = "\\s*at .*\\(.*:\\d{1,4}\\)"; static String EXCEPTION3 = "\\s*at .*\\(Native Method\\)"; + static String EXCEPTION4 = "\\s*at .*\\(.*Compiled Code\\)"; + static String EXCEPTION5 = "\\s*at .*\\(.*libgcj.*\\)"; static Logger logger = Logger.getLogger(SocketServerTestCase.class); @@ -72,8 +98,6 @@ public SocketServerTestCase(String name) { public void setUp() { System.out.println("Setting up test case."); - socketAppender = new SocketAppender("localhost", PORT); - rootLogger.addAppender(socketAppender); } public void tearDown() { @@ -81,62 +105,269 @@ public void tearDown() { socketAppender = null; rootLogger.removeAllAppenders(); } - + + /** + * The pattern on the server side: %5p %x [%t] %c %m%n + * + * We are testing NDC functionality across the wire. + */ public void test1() throws Exception { + socketAppender = new SocketAppender("localhost", PORT); + rootLogger.addAppender(socketAppender); common("T1", "key1", "MDC-TEST1"); delay(1); ControlFilter cf = new ControlFilter(new String[]{PAT1, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { cf, new LineNumberFilter(), + new JunitTestRunnerFilter(), + new SunReflectFilter() }); assertTrue(Compare.compare(FILTERED, "witness/socketServer.1")); } + /** + * The pattern on the server side: %5p %x [%t] %C (%F:%L) %m%n + * + * We are testing NDC across the wire. Localization is turned off by + * default so it is not tested here even if the conversion pattern + * uses localization. */ public void test2() throws Exception { + socketAppender = new SocketAppender("localhost", PORT); + rootLogger.addAppender(socketAppender); + common("T2", "key2", "MDC-TEST2"); delay(1); ControlFilter cf = new ControlFilter(new String[]{PAT2, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { cf, new LineNumberFilter(), + new JunitTestRunnerFilter(), + new SunReflectFilter() }); assertTrue(Compare.compare(FILTERED, "witness/socketServer.2")); } + /** + * The pattern on the server side: %5p %x [%t] %C (%F:%L) %m%n + * meaning that we are testing NDC and locatization functionality + * across the wire. */ public void test3() throws Exception { + socketAppender = new SocketAppender("localhost", PORT); socketAppender.setLocationInfo(true); + rootLogger.addAppender(socketAppender); + common("T3", "key3", "MDC-TEST3"); delay(1); ControlFilter cf = new ControlFilter(new String[]{PAT3, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { cf, new LineNumberFilter(), + new JunitTestRunnerFilter(), + new SunReflectFilter() }); assertTrue(Compare.compare(FILTERED, "witness/socketServer.3")); } + /** + * The pattern on the server side: %5p %x %X{key1}%X{key4} [%t] %c{1} - %m%n + * meaning that we are testing NDC, MDC and localization functionality across + * the wire. + */ public void test4() throws Exception { + socketAppender = new SocketAppender("localhost", PORT); socketAppender.setLocationInfo(true); + rootLogger.addAppender(socketAppender); + NDC.push("some"); common("T4", "key4", "MDC-TEST4"); + NDC.pop(); delay(1); - ControlFilter cf = new ControlFilter(new String[]{PAT4, EXCEPTION1, - EXCEPTION2, EXCEPTION3}); + // + // These tests check MDC operation which + // requires JDK 1.2 or later + if(!System.getProperty("java.version").startsWith("1.1.")) { - Transformer.transform(TEMP, FILTERED, new Filter[] {cf, new LineNumberFilter()}); + ControlFilter cf = new ControlFilter(new String[]{PAT4, EXCEPTION1, + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { cf, new LineNumberFilter(), + new JunitTestRunnerFilter(), + new SunReflectFilter() }); - assertTrue(Compare.compare(FILTERED, "witness/socketServer.4")); + assertTrue(Compare.compare(FILTERED, "witness/socketServer.4")); + } + } + + /** + * The pattern on the server side: %5p %x %X{key1}%X{key5} [%t] %c{1} - %m%n + * + * The test case uses wraps an AsyncAppender around the + * SocketAppender. This tests was written specifically for bug + * report #9155. + + * Prior to the bug fix the output on the server did not contain the + * MDC-TEST5 string because the MDC clone operation (in getMDCCopy + * method) operation is performed twice, once from the main thread + * which is correct, and a second time from the AsyncAppender's + * dispatch thread which is incrorrect. + + */ + public void test5() throws Exception { + socketAppender = new SocketAppender("localhost", PORT); + socketAppender.setLocationInfo(true); + AsyncAppender asyncAppender = new AsyncAppender(); + asyncAppender.setLocationInfo(true); + asyncAppender.addAppender(socketAppender); + rootLogger.addAppender(asyncAppender); + + NDC.push("some5"); + common("T5", "key5", "MDC-TEST5"); + NDC.pop(); + delay(2); + // + // These tests check MDC operation which + // requires JDK 1.2 or later + if(!System.getProperty("java.version").startsWith("1.1.")) { + ControlFilter cf = new ControlFilter(new String[]{PAT5, EXCEPTION1, + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + + Transformer.transform( + TEMP, FILTERED, + new Filter[] { cf, new LineNumberFilter(), + new JunitTestRunnerFilter(), + new SunReflectFilter() }); + + assertTrue(Compare.compare(FILTERED, "witness/socketServer.5")); + } + } + + /** + * The pattern on the server side: %5p %x %X{hostID}${key6} [%t] %c{1} - %m%n + * + * This test checks whether client-side MDC overrides the server side. + * It uses an AsyncAppender encapsulating a SocketAppender + */ + public void test6() throws Exception { + socketAppender = new SocketAppender("localhost", PORT); + socketAppender.setLocationInfo(true); + AsyncAppender asyncAppender = new AsyncAppender(); + asyncAppender.setLocationInfo(true); + asyncAppender.addAppender(socketAppender); + rootLogger.addAppender(asyncAppender); + + NDC.push("some6"); + MDC.put("hostID", "client-test6"); + common("T6", "key6", "MDC-TEST6"); + NDC.pop(); + MDC.remove("hostID"); + delay(2); + // + // These tests check MDC operation which + // requires JDK 1.2 or later + if(!System.getProperty("java.version").startsWith("1.1.")) { + ControlFilter cf = new ControlFilter(new String[]{PAT6, EXCEPTION1, + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + + Transformer.transform( + TEMP, FILTERED, + new Filter[] { cf, new LineNumberFilter(), + new JunitTestRunnerFilter(), + new SunReflectFilter() }); + + assertTrue(Compare.compare(FILTERED, "witness/socketServer.6")); + } + } + + /** + * The pattern on the server side: %5p %x %X{hostID}${key7} [%t] %c{1} - %m%n + * + * This test checks whether client-side MDC overrides the server side. + */ + public void test7() throws Exception { + socketAppender = new SocketAppender("localhost", PORT); + socketAppender.setLocationInfo(true); + rootLogger.addAppender(socketAppender); + + NDC.push("some7"); + MDC.put("hostID", "client-test7"); + common("T7", "key7", "MDC-TEST7"); + NDC.pop(); + MDC.remove("hostID"); + delay(2); + // + // These tests check MDC operation which + // requires JDK 1.2 or later + if(!System.getProperty("java.version").startsWith("1.1.")) { + ControlFilter cf = new ControlFilter(new String[]{PAT7, EXCEPTION1, + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + + Transformer.transform( + TEMP, FILTERED, + new Filter[] { cf, new LineNumberFilter(), + new JunitTestRunnerFilter(), + new SunReflectFilter() }); + assertTrue(Compare.compare(FILTERED, "witness/socketServer.7")); + } + } + + /** + * The pattern on the server side: %5p %x %X{hostID}${key7} [%t] %c{1} - %m%n + * + * This test checks whether server side MDC works. + */ + public void test8() throws Exception { + socketAppender = new SocketAppender("localhost", PORT); + socketAppender.setLocationInfo(true); + rootLogger.addAppender(socketAppender); + + NDC.push("some8"); + common("T8", "key8", "MDC-TEST8"); + NDC.pop(); + delay(2); + // + // These tests check MDC operation which + // requires JDK 1.2 or later + if(!System.getProperty("java.version").startsWith("1.1.")) { + ControlFilter cf = new ControlFilter(new String[]{PAT8, EXCEPTION1, + EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + + Transformer.transform( + TEMP, FILTERED, + new Filter[] { cf, new LineNumberFilter(), + new JunitTestRunnerFilter(), + new SunReflectFilter() }); + assertTrue(Compare.compare(FILTERED, "witness/socketServer.8")); + } } static void common(String dc, String key, Object o) { + String oldThreadName = Thread.currentThread().getName(); + Thread.currentThread().setName("main"); + int i = -1; NDC.push(dc); MDC.put(key, o); Logger root = Logger.getRootLogger(); + logger.setLevel(Level.DEBUG); + rootLogger.setLevel(Level.DEBUG); + logger.log(XLevel.TRACE, "Message " + ++i); + + logger.setLevel(Level.TRACE); + rootLogger.setLevel(Level.TRACE); + + logger.trace("Message " + ++i); + root.trace("Message " + ++i); logger.debug("Message " + ++i); root.debug("Message " + ++i); logger.info("Message " + ++i); @@ -148,6 +379,8 @@ void common(String dc, String key, Object o) { root.error("Message " + ++i, e); NDC.pop(); MDC.remove(key); + + Thread.currentThread().setName(oldThreadName); } public void delay(int secs) { @@ -161,6 +394,10 @@ public static Test suite() { suite.addTest(new SocketServerTestCase("test2")); suite.addTest(new SocketServerTestCase("test3")); suite.addTest(new SocketServerTestCase("test4")); + suite.addTest(new SocketServerTestCase("test5")); + suite.addTest(new SocketServerTestCase("test6")); + suite.addTest(new SocketServerTestCase("test7")); + suite.addTest(new SocketServerTestCase("test8")); return suite; } } diff --git a/tests/src/java/org/apache/log4j/net/SyslogAppenderTest.java b/tests/src/java/org/apache/log4j/net/SyslogAppenderTest.java new file mode 100644 index 0000000000..8fbf024241 --- /dev/null +++ b/tests/src/java/org/apache/log4j/net/SyslogAppenderTest.java @@ -0,0 +1,593 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.net; + +import junit.framework.TestCase; + +import org.apache.log4j.AsyncAppender; +import org.apache.log4j.Layout; +import org.apache.log4j.Level; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.log4j.PatternLayout; +import org.apache.log4j.VectorErrorHandler; +import org.apache.log4j.HTMLLayout; + +import java.util.StringTokenizer; +import java.net.DatagramSocket; +import java.net.DatagramPacket; +import java.text.SimpleDateFormat; +import java.util.Locale; +import java.util.Date; +import java.util.Calendar; + + +/** + * Tests for SyslogAppender + * + * + * */ +public class SyslogAppenderTest extends TestCase { + /** + * Create new instance of SyslogAppenderTest. + * @param testName test name + */ + public SyslogAppenderTest(final String testName) { + super(testName); + } + + /** + * Resets configuration after every test. + */ + public void tearDown() { + LogManager.resetConfiguration(); + } + + /** + * Test default constructor. + */ + public void testDefaultConstructor() { + SyslogAppender appender = new SyslogAppender(); + assertEquals("user", appender.getFacility()); + assertEquals(false, appender.getFacilityPrinting()); + assertNull(appender.getLayout()); + assertNull(appender.getSyslogHost()); + assertTrue(appender.requiresLayout()); + } + + /** + * Test two parameter constructor. + */ + public void testTwoParamConstructor() { + Layout layout = new PatternLayout(); + SyslogAppender appender = new SyslogAppender(layout, 24); + assertEquals("daemon", appender.getFacility()); + assertEquals(false, appender.getFacilityPrinting()); + assertEquals(layout, appender.getLayout()); + assertNull(appender.getSyslogHost()); + assertTrue(appender.requiresLayout()); + } + + /** + * Test two parameter constructor with unexpected facility. + */ + public void testTwoParamConstructorBadFacility() { + Layout layout = new PatternLayout(); + SyslogAppender appender = new SyslogAppender(layout, 25); + assertEquals("user", appender.getFacility()); + assertEquals(false, appender.getFacilityPrinting()); + assertEquals(layout, appender.getLayout()); + assertNull(appender.getSyslogHost()); + assertTrue(appender.requiresLayout()); + } + + /** + * Test three parameter constructor. + */ + public void testThreeParamConstructor() { + Layout layout = new PatternLayout(); + SyslogAppender appender = + new SyslogAppender(layout, "syslog.example.org", 24); + assertEquals("daemon", appender.getFacility()); + assertEquals(false, appender.getFacilityPrinting()); + assertEquals(layout, appender.getLayout()); + assertEquals("syslog.example.org", appender.getSyslogHost()); + assertTrue(appender.requiresLayout()); + } + + /** + * Test getFacilityString for expected facility codes. + */ + public void testGetFacilityString() { + String expected = + "kern user mail daemon auth syslog lpr news " + + "uucp cron authpriv ftp local0 local1 local2 local3 " + + "local4 local5 local6 local7 "; + StringBuffer actual = new StringBuffer(); + + for (int i = 0; i <= 11; i++) { + actual.append(SyslogAppender.getFacilityString(i << 3)); + actual.append(' '); + } + + for (int i = 16; i <= 23; i++) { + actual.append(SyslogAppender.getFacilityString(i << 3)); + actual.append(' '); + } + + assertEquals(expected, actual.toString()); + } + + /** + * Test getFacilityString for some unexpected facility codes. + */ + public void testGetFacilityStringUnexpected() { + assertNull(SyslogAppender.getFacilityString(1)); + assertNull(SyslogAppender.getFacilityString(12 << 3)); + } + + /** + * Test getFacility with a bogus facility name. + */ + public void testGetFacilityBogus() { + assertEquals(-1, SyslogAppender.getFacility("bogus")); + } + + /** + * Test getFacility with a null facility name. + */ + public void testGetFacilityNull() { + assertEquals(-1, SyslogAppender.getFacility(null)); + } + + /** + * Test getFacility for expected system facility names. + */ + public void testGetFacilitySystemNames() { + String[] names = + new String[] { + "kErn", "usEr", "MaIL", "daemOn", "auTh", "syslOg", "lPr", "newS", + "Uucp", "croN", "authprIv", "ftP" + }; + + for (int i = 0; i <= 11; i++) { + assertEquals(i << 3, SyslogAppender.getFacility(names[i])); + } + } + + /** + * Test getFacility for expected system facility names. + */ + public void testGetFacilityLocalNames() { + String[] names = + new String[] { + "lOcal0", "LOCAL1", "loCal2", "locAl3", "locaL4", "local5", "LOCal6", + "loCAL7" + }; + + for (int i = 0; i <= 7; i++) { + assertEquals((16 + i) << 3, SyslogAppender.getFacility(names[i])); + } + } + + /** + * Test setFacilityPrinting. + */ + public void testSetFacilityPrinting() { + SyslogAppender appender = new SyslogAppender(); + assertFalse(appender.getFacilityPrinting()); + appender.setFacilityPrinting(true); + assertTrue(appender.getFacilityPrinting()); + appender.setFacilityPrinting(false); + assertFalse(appender.getFacilityPrinting()); + } + + /** + * Test of SyslogAppender constants. + */ + public void testConstants() { + assertEquals(0 << 3, SyslogAppender.LOG_KERN); + assertEquals(1 << 3, SyslogAppender.LOG_USER); + assertEquals(2 << 3, SyslogAppender.LOG_MAIL); + assertEquals(3 << 3, SyslogAppender.LOG_DAEMON); + assertEquals(4 << 3, SyslogAppender.LOG_AUTH); + assertEquals(5 << 3, SyslogAppender.LOG_SYSLOG); + assertEquals(6 << 3, SyslogAppender.LOG_LPR); + assertEquals(7 << 3, SyslogAppender.LOG_NEWS); + assertEquals(8 << 3, SyslogAppender.LOG_UUCP); + assertEquals(9 << 3, SyslogAppender.LOG_CRON); + assertEquals(10 << 3, SyslogAppender.LOG_AUTHPRIV); + assertEquals(11 << 3, SyslogAppender.LOG_FTP); + assertEquals(16 << 3, SyslogAppender.LOG_LOCAL0); + assertEquals(17 << 3, SyslogAppender.LOG_LOCAL1); + assertEquals(18 << 3, SyslogAppender.LOG_LOCAL2); + assertEquals(19 << 3, SyslogAppender.LOG_LOCAL3); + assertEquals(20 << 3, SyslogAppender.LOG_LOCAL4); + assertEquals(21 << 3, SyslogAppender.LOG_LOCAL5); + assertEquals(22 << 3, SyslogAppender.LOG_LOCAL6); + assertEquals(23 << 3, SyslogAppender.LOG_LOCAL7); + } + + /** + * Test setFacility with null. + * Should have no effect. + */ + public void testSetFacilityKern() { + SyslogAppender appender = new SyslogAppender(); + appender.setFacility("kern"); + appender.setFacility(null); + assertEquals("kern", appender.getFacility()); + } + + /** + * Test setFacility with null. + * Should have no effect. + */ + public void testSetFacilityNull() { + SyslogAppender appender = new SyslogAppender(); + appender.setFacility("kern"); + appender.setFacility(null); + assertEquals("kern", appender.getFacility()); + } + + /** + * Test setFacility with bogus value. + * Should reset to user. + */ + public void testSetFacilityBogus() { + SyslogAppender appender = new SyslogAppender(); + appender.setFacility("kern"); + appender.setFacility("bogus"); + assertEquals("user", appender.getFacility()); + } + + /** + * Tests calling setFacility after appender has been activated. + */ + public void testSetFacilityAfterActivation() { + SyslogAppender appender = new SyslogAppender(); + appender.setName("foo"); + appender.setThreshold(Level.INFO); + appender.setSyslogHost("localhost"); + appender.setFacility("user"); + appender.setLayout(new PatternLayout("%m%n")); + + VectorErrorHandler errorHandler = new VectorErrorHandler(); + appender.setErrorHandler(errorHandler); + appender.activateOptions(); + appender.setFacility("kern"); + assertEquals("kern", appender.getFacility()); + } + + /** + * Tests that append method drops messages below threshold. + * Can't reach isSevereAsThreshold call in SyslogAppender.append + * since it is checked in AppenderSkeleton.doAppend. + */ + public void testAppendBelowThreshold() { + SyslogAppender appender = new SyslogAppender(); + appender.setThreshold(Level.ERROR); + appender.activateOptions(); + + Logger logger = Logger.getRootLogger(); + logger.addAppender(appender); + logger.info( + "Should not be logged by SyslogAppenderTest.testAppendBelowThreshold."); + } + + /** + * Tests that append method drops messages below threshold. + */ + public void testAppendNoHost() { + SyslogAppender appender = new SyslogAppender(); + appender.setName("foo"); + appender.setThreshold(Level.INFO); + + VectorErrorHandler errorHandler = new VectorErrorHandler(); + appender.setErrorHandler(errorHandler); + appender.setLayout(new PatternLayout("%m%n")); + appender.activateOptions(); + + Logger logger = Logger.getRootLogger(); + logger.addAppender(appender); + logger.info( + "Should not be logged by SyslogAppenderTest.testAppendNoHost."); + assertEquals(1, errorHandler.size()); + + // + // Appender is misspelled in implementation + // + assertEquals( + "No syslog host is set for SyslogAppedender named \"foo\".", + errorHandler.getMessage(0)); + } + + /** + * Tests append method under normal conditions. + */ + public void testAppend() { + SyslogAppender appender = new SyslogAppender(); + appender.setName("foo"); + appender.setThreshold(Level.INFO); + appender.setSyslogHost("localhost"); + appender.setFacility("user"); + appender.setLayout(new PatternLayout("%m%n")); + + VectorErrorHandler errorHandler = new VectorErrorHandler(); + appender.setErrorHandler(errorHandler); + appender.activateOptions(); + + // + // wrap SyslogAppender with an Async since appender may + // hang if syslogd is not accepting network messages + // + AsyncAppender asyncAppender = new AsyncAppender(); + asyncAppender.addAppender(appender); + asyncAppender.activateOptions(); + + Logger logger = Logger.getRootLogger(); + logger.addAppender(asyncAppender); + + Exception e = + new Exception("Expected exception from SyslogAppenderTest.testAppend"); + logger.info( + "Expected message from log4j unit test SyslogAppenderTest.testAppend.", e); + assertEquals(0, errorHandler.size()); + } + + /** + * Tests SyslogAppender with IPv6 address. + */ + public void testIPv6() { + SyslogAppender appender = new SyslogAppender(); + appender.setSyslogHost("::1"); + } + + /** + * Tests SyslogAppender with IPv6 address enclosed in square brackets. + */ + public void testIPv6InBrackets() { + SyslogAppender appender = new SyslogAppender(); + appender.setSyslogHost("[::1]"); + } + + /** + * Tests SyslogAppender with IPv6 address enclosed in square brackets + * followed by port specification. + */ + public void testIPv6AndPort() { + SyslogAppender appender = new SyslogAppender(); + appender.setSyslogHost("[::1]:1514"); + } + + /** + * Tests SyslogAppender with host name enclosed in square brackets + * followed by port specification. + */ + public void testHostNameAndPort() { + SyslogAppender appender = new SyslogAppender(); + appender.setSyslogHost("localhost:1514"); + } + + + /** + * Tests SyslogAppender with IPv4 address followed by port specification. + */ + public void testIPv4AndPort() { + SyslogAppender appender = new SyslogAppender(); + appender.setSyslogHost("127.0.0.1:1514"); + } + + private static String[] log(final boolean header, + final String msg, + final Exception ex, + final int packets) throws Exception { + DatagramSocket ds = new DatagramSocket(); + ds.setSoTimeout(2000); + + SyslogAppender appender = new SyslogAppender(); + appender.setSyslogHost("localhost:" + ds.getLocalPort()); + appender.setName("name"); + appender.setHeader(header); + PatternLayout pl = new PatternLayout("%m"); + appender.setLayout(pl); + appender.activateOptions(); + + Logger l = Logger.getRootLogger(); + l.addAppender(appender); + if (ex == null) { + l.info(msg); + } else { + l.error(msg, ex); + } + appender.close(); + String[] retval = new String[packets]; + byte[] buf = new byte[1000]; + for(int i = 0; i < packets; i++) { + DatagramPacket p = new DatagramPacket(buf, 0, buf.length); + ds.receive(p); + retval[i] = new String(p.getData(), 0, p.getLength()); + } + ds.close(); + return retval; + } + + public void testActualLogging() throws Exception { + String s = log(false, "greetings", null, 1)[0]; + StringTokenizer st = new StringTokenizer(s, "<>() "); + assertEquals("14", st.nextToken()); + assertEquals("greetings", st.nextToken()); + } + + /** + * Exception with printStackTrace that breaks earlier SyslogAppender. + */ + private static class MishandledException extends Exception { + /* + * Create new instance. + */ + public MishandledException() { + } + + /** + * Print stack trace. + * @param w print writer, may not be null. + */ + public void printStackTrace(final java.io.PrintWriter w) { + w.println("Mishandled stack trace follows:"); + w.println(""); + w.println("No tab here"); + w.println("\ttab here"); + w.println("\t"); + } + } + + /** + * Tests fix for bug 40502. + * @throws Exception on IOException. + */ + public void testBadTabbing() throws Exception { + String[] s = log(false, "greetings", new MishandledException(), 6); + StringTokenizer st = new StringTokenizer(s[0], "<>() "); + assertEquals("11", st.nextToken()); + assertEquals("greetings", st.nextToken()); + assertEquals("<11>Mishandled stack trace follows:", s[1]); + assertEquals("<11>", s[2]); + assertEquals("<11>No tab here", s[3]); + assertEquals("<11>" + SyslogAppender.TAB + "tab here", s[4]); + assertEquals("<11>" + SyslogAppender.TAB, s[5]); + } + + /** + * Tests presence of timestamp if header = true. + * + * @throws Exception if IOException. + */ + public void testHeaderLogging() throws Exception { + Date preDate = new Date(); + String s = log(true, "greetings", null, 1)[0]; + Date postDate = new Date(); + assertEquals("<14>", s.substring(0, 4)); + + String syslogDateStr = s.substring(4, 20); + SimpleDateFormat fmt = new SimpleDateFormat("MMM dd HH:mm:ss ", Locale.ENGLISH); + Date syslogDate = fmt.parse(syslogDateStr); + Calendar cal = Calendar.getInstance(Locale.ENGLISH); + cal.setTime(syslogDate); + int syslogMonth = cal.get(Calendar.MONTH); + int syslogDay = cal.get(Calendar.DATE); + if (syslogDay < 10) { + assertEquals(' ', syslogDateStr.charAt(4)); + } + cal.setTime(preDate); + int preMonth = cal.get(Calendar.MONTH); + cal.set(Calendar.MILLISECOND, 0); + preDate = cal.getTime(); + int syslogYear; + if (preMonth == syslogMonth) { + syslogYear = cal.get(Calendar.YEAR); + } else { + cal.setTime(postDate); + syslogYear = cal.get(Calendar.YEAR); + } + cal.setTime(syslogDate); + cal.set(Calendar.YEAR, syslogYear); + syslogDate = cal.getTime(); + assertTrue(syslogDate.compareTo(preDate) >= 0); + assertTrue(syslogDate.compareTo(postDate) <= 0); + } + + + /** + * Tests that any header or footer in layout is sent. + * @throws Exception if exception during test. + */ + public void testLayoutHeader() throws Exception { + DatagramSocket ds = new DatagramSocket(); + ds.setSoTimeout(2000); + + SyslogAppender appender = new SyslogAppender(); + appender.setSyslogHost("localhost:" + ds.getLocalPort()); + appender.setName("name"); + appender.setHeader(false); + HTMLLayout pl = new HTMLLayout(); + appender.setLayout(pl); + appender.activateOptions(); + + Logger l = Logger.getRootLogger(); + l.addAppender(appender); + l.info("Hello, World"); + appender.close(); + String[] s = new String[3]; + byte[] buf = new byte[1000]; + for(int i = 0; i < 3; i++) { + DatagramPacket p = new DatagramPacket(buf, 0, buf.length); + ds.receive(p); + s[i] = new String(p.getData(), 0, p.getLength()); + } + ds.close(); + assertEquals("<14>", s[2].substring(0,12)); + } + + /** + * Tests that syslog packets do not exceed 1024 bytes. + * See bug 42087. + * @throws Exception if exception during test. + */ + public void testBigPackets() throws Exception { + DatagramSocket ds = new DatagramSocket(); + ds.setSoTimeout(2000); + + SyslogAppender appender = new SyslogAppender(); + appender.setSyslogHost("localhost:" + ds.getLocalPort()); + appender.setName("name"); + appender.setHeader(false); + PatternLayout pl = new PatternLayout("%m"); + appender.setLayout(pl); + appender.activateOptions(); + + Logger l = Logger.getRootLogger(); + l.addAppender(appender); + StringBuffer msgbuf = new StringBuffer(); + while(msgbuf.length() < 8000) { + msgbuf.append("0123456789"); + } + String msg = msgbuf.toString(); + l.info(msg); + appender.close(); + String[] s = new String[8]; + byte[] buf = new byte[1200]; + for(int i = 0; i < 8; i++) { + DatagramPacket p = new DatagramPacket(buf, 0, buf.length); + ds.receive(p); + assertTrue(p.getLength() <= 1024); + s[i] = new String(p.getData(), 0, p.getLength()); + } + ds.close(); + StringBuffer rcvbuf = new StringBuffer(s[0]); + rcvbuf.delete(0, 4); + for(int i = 1; i < 8; i++) { + rcvbuf.setLength(rcvbuf.length() - 3); + rcvbuf.append(s[i].substring(s[i].indexOf("...") + 3)); + } + assertEquals(msg.length(), rcvbuf.length()); + assertEquals(msg, rcvbuf.toString()); + } + +} diff --git a/tests/src/java/org/apache/log4j/nt/NTEventLogAppenderTest.java b/tests/src/java/org/apache/log4j/nt/NTEventLogAppenderTest.java new file mode 100755 index 0000000000..1fa2e096ed --- /dev/null +++ b/tests/src/java/org/apache/log4j/nt/NTEventLogAppenderTest.java @@ -0,0 +1,54 @@ +/* + * Copyright 1999,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.nt; +import junit.framework.TestCase; +import org.apache.log4j.Logger; +import org.apache.log4j.LogManager; +import org.apache.log4j.Level; +import org.apache.log4j.BasicConfigurator; + + +/** + * + * NTEventLogAppender tests. + * + * @author Curt Arnold + */ +public class NTEventLogAppenderTest extends TestCase { + + /** + * Clean up configuration after each test. + */ + public void tearDown() { + LogManager.shutdown(); + } + + /** + * Simple test of NTEventLogAppender. + */ + public void testSimple() { + BasicConfigurator.configure(new NTEventLogAppender()); + Logger logger = Logger.getLogger("org.apache.log4j.nt.NTEventLogAppenderTest"); + int i = 0; + logger.debug( "Message " + i++); + logger.info( "Message " + i++); + logger.warn( "Message " + i++); + logger.error( "Message " + i++); + logger.log(Level.FATAL, "Message " + i++); + logger.debug("Message " + i++, new Exception("Just testing.")); + } +} diff --git a/tests/src/java/org/apache/log4j/or/ORTestCase.java b/tests/src/java/org/apache/log4j/or/ORTestCase.java index f7b36454ae..4b40f6c892 100644 --- a/tests/src/java/org/apache/log4j/or/ORTestCase.java +++ b/tests/src/java/org/apache/log4j/or/ORTestCase.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // Log4j uses the JUnit framework for internal unit testing. JUnit @@ -138,9 +148,16 @@ void test6() { // Add: Comparable // Expect: Comparable public - void test7() { + void test7() throws Exception { RendererMap map = new RendererMap(); - map.put(Comparable.class, cor); + Class comparable = null; + try { + comparable = getClass().forName("java.lang.Comparable"); + } catch(Exception ex) { + // likely JDK 1.1 + return; + } + map.put(comparable, cor); ObjectRenderer r = map.get(Integer.class); assertEquals(r, cor); } diff --git a/tests/src/java/org/apache/log4j/spi/LocationInfoTest.java b/tests/src/java/org/apache/log4j/spi/LocationInfoTest.java new file mode 100644 index 0000000000..9bee5ff39a --- /dev/null +++ b/tests/src/java/org/apache/log4j/spi/LocationInfoTest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.log4j.spi; + +import junit.framework.TestCase; + +/** + * Tests for LocationInfo. + */ +public class LocationInfoTest extends TestCase { + + /** + * Tests four parameter constructor. + */ + public void testFourParamConstructor() { + final String className = LocationInfoTest.class.getName(); + final String methodName = "testFourParamConstructor"; + final String fileName = "LocationInfoTest.java"; + final String lineNumber = "41"; + LocationInfo li = new LocationInfo(fileName, + className, methodName, lineNumber); + assertEquals(className, li.getClassName()); + assertEquals(methodName, li.getMethodName()); + assertEquals(fileName, li.getFileName()); + assertEquals(lineNumber, li.getLineNumber()); + assertEquals(className + "." + methodName + + "(" + fileName + ":" + lineNumber + ")", + li.fullInfo); + } + +} diff --git a/tests/src/java/org/apache/log4j/spi/LoggingEventTest.java b/tests/src/java/org/apache/log4j/spi/LoggingEventTest.java new file mode 100644 index 0000000000..74281768bc --- /dev/null +++ b/tests/src/java/org/apache/log4j/spi/LoggingEventTest.java @@ -0,0 +1,242 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.spi; + +import junit.framework.TestCase; + +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.MDC; +import org.apache.log4j.NDC; +import org.apache.log4j.spi.LocationInfo; +import org.apache.log4j.util.SerializationTestHelper; +import org.apache.log4j.Priority; +import org.apache.log4j.Category; + + +/** + * Tests LoggingEvent. + * + * @author Curt Arnold + */ +public class LoggingEventTest extends TestCase { + /** + * Create LoggingEventTest. + * + * @param name test name. + */ + public LoggingEventTest(final String name) { + super(name); + } + + /** + * Serialize a simple logging event and check it against + * a witness. + * @throws Exception if exception during test. + */ + public void testSerializationSimple() throws Exception { + Logger root = Logger.getRootLogger(); + LoggingEvent event = + new LoggingEvent( + root.getClass().getName(), root, Level.INFO, "Hello, world.", null); +// event.prepareForDeferredProcessing(); + + int[] skip = new int[] { 352, 353, 354, 355, 356 }; + SerializationTestHelper.assertSerializationEquals( + "witness/serialization/simple.bin", event, skip, 237); + } + + /** + * Serialize a logging event with an exception and check it against + * a witness. + * @throws Exception if exception during test. + * + */ + public void testSerializationWithException() throws Exception { + Logger root = Logger.getRootLogger(); + Exception ex = new Exception("Don't panic"); + LoggingEvent event = + new LoggingEvent( + root.getClass().getName(), root, Level.INFO, "Hello, world.", ex); +// event.prepareForDeferredProcessing(); + + int[] skip = new int[] { 352, 353, 354, 355, 356 }; + SerializationTestHelper.assertSerializationEquals( + "witness/serialization/exception.bin", event, skip, 237); + } + + /** + * Serialize a logging event with an exception and check it against + * a witness. + * @throws Exception if exception during test. + * + */ + public void testSerializationWithLocation() throws Exception { + Logger root = Logger.getRootLogger(); + LoggingEvent event = + new LoggingEvent( + root.getClass().getName(), root, Level.INFO, "Hello, world.", null); + LocationInfo info = event.getLocationInformation(); +// event.prepareForDeferredProcessing(); + + int[] skip = new int[] { 352, 353, 354, 355, 356 }; + SerializationTestHelper.assertSerializationEquals( + "witness/serialization/location.bin", event, skip, 237); + } + + /** + * Serialize a logging event with ndc. + * @throws Exception if exception during test. + * + */ + public void testSerializationNDC() throws Exception { + Logger root = Logger.getRootLogger(); + NDC.push("ndc test"); + + LoggingEvent event = + new LoggingEvent( + root.getClass().getName(), root, Level.INFO, "Hello, world.", null); +// event.prepareForDeferredProcessing(); + + int[] skip = new int[] { 352, 353, 354, 355, 356 }; + SerializationTestHelper.assertSerializationEquals( + "witness/serialization/ndc.bin", event, skip, 237); + } + + /** + * Serialize a logging event with mdc. + * @throws Exception if exception during test. + * + */ + public void testSerializationMDC() throws Exception { + Logger root = Logger.getRootLogger(); + MDC.put("mdckey", "mdcvalue"); + + LoggingEvent event = + new LoggingEvent( + root.getClass().getName(), root, Level.INFO, "Hello, world.", null); +// event.prepareForDeferredProcessing(); + + int[] skip = new int[] { 352, 353, 354, 355, 356 }; + SerializationTestHelper.assertSerializationEquals( + "witness/serialization/mdc.bin", event, skip, 237); + } + + /** + * Deserialize a simple logging event. + * @throws Exception if exception during test. + * + */ + public void testDeserializationSimple() throws Exception { + Object obj = + SerializationTestHelper.deserializeStream( + "witness/serialization/simple.bin"); + assertTrue(obj instanceof LoggingEvent); + + LoggingEvent event = (LoggingEvent) obj; + assertEquals("Hello, world.", event.getMessage()); + assertEquals(Level.INFO, event.getLevel()); + } + + /** + * Deserialize a logging event with an exception. + * @throws Exception if exception during test. + * + */ + public void testDeserializationWithException() throws Exception { + Object obj = + SerializationTestHelper.deserializeStream( + "witness/serialization/exception.bin"); + assertTrue(obj instanceof LoggingEvent); + + LoggingEvent event = (LoggingEvent) obj; + assertEquals("Hello, world.", event.getMessage()); + assertEquals(Level.INFO, event.getLevel()); + } + + /** + * Deserialize a logging event with an exception. + * @throws Exception if exception during test. + * + */ + public void testDeserializationWithLocation() throws Exception { + Object obj = + SerializationTestHelper.deserializeStream( + "witness/serialization/location.bin"); + assertTrue(obj instanceof LoggingEvent); + + LoggingEvent event = (LoggingEvent) obj; + assertEquals("Hello, world.", event.getMessage()); + assertEquals(Level.INFO, event.getLevel()); + } + + /** + * Tests LoggingEvent.fqnOfCategoryClass. + */ + public void testFQNOfCategoryClass() { + Category root = Logger.getRootLogger(); + Priority info = Level.INFO; + String catName = Logger.class.toString(); + LoggingEvent event = + new LoggingEvent( + catName, root, info, "Hello, world.", null); + assertEquals(catName, event.fqnOfCategoryClass); + } + + /** + * Tests LoggingEvent.level. + * @deprecated + */ + public void testLevel() { + Category root = Logger.getRootLogger(); + Priority info = Level.INFO; + String catName = Logger.class.toString(); + LoggingEvent event = + new LoggingEvent( + catName, root, 0L, info, "Hello, world.", null); + Priority error = Level.ERROR; + event.level = error; + assertEquals(Level.ERROR, event.level); + } + + /** + * Tests LoggingEvent.getLocationInfo() when no FQCN is specified. + * See bug 41186. + */ + public void testLocationInfoNoFQCN() { + Category root = Logger.getRootLogger(); + Priority level = Level.INFO; + LoggingEvent event = + new LoggingEvent( + null, root, 0L, level, "Hello, world.", null); + LocationInfo info = event.getLocationInformation(); + // + // log4j 1.2 returns an object, its layout doesn't check for nulls. + // log4j 1.3 returns a null. + // + assertNotNull(info); + if (info != null) { + assertEquals("?", info.getLineNumber()); + assertEquals("?", info.getClassName()); + assertEquals("?", info.getFileName()); + assertEquals("?", info.getMethodName()); + } + } + + +} diff --git a/tests/src/java/org/apache/log4j/spi/ThrowableInformationTest.java b/tests/src/java/org/apache/log4j/spi/ThrowableInformationTest.java new file mode 100644 index 0000000000..a0881b0840 --- /dev/null +++ b/tests/src/java/org/apache/log4j/spi/ThrowableInformationTest.java @@ -0,0 +1,286 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.log4j.spi; + +import junit.framework.TestCase; + +import java.io.PrintWriter; + + +/** + * Unit tests for ThrowableInformation. + */ +public class ThrowableInformationTest extends TestCase { + /** + * Create ThrowableInformationTest. + * + * @param name test name. + */ + public ThrowableInformationTest(final String name) { + super(name); + } + + /** + * Custom throwable that only calls methods + * overridden by VectorWriter in log4j 1.2.14 and earlier. + */ + private static final class OverriddenThrowable extends Throwable { + /** + * Create new instance. + */ + public OverriddenThrowable() { + } + + /** + * Print stack trace. + * + * @param s print writer. + */ + public void printStackTrace(final PrintWriter s) { + s.print((Object) "print(Object)"); + s.print("print(char[])".toCharArray()); + s.print("print(String)"); + s.println((Object) "println(Object)"); + s.println("println(char[])".toCharArray()); + s.println("println(String)"); + s.write("write(char[])".toCharArray()); + s.write("write(char[], int, int)".toCharArray(), 2, 8); + s.write("write(String, int, int)", 2, 8); + } + } + + /** + * Test capturing stack trace from a throwable that only uses the + * PrintWriter methods overridden in log4j 1.2.14 and earlier. + */ + public void testOverriddenBehavior() { + ThrowableInformation ti = new ThrowableInformation(new OverriddenThrowable()); + String[] rep = ti.getThrowableStrRep(); + assertEquals(4, rep.length); + assertEquals("print(Object)print(char[])print(String)println(Object)", rep[0]); + assertEquals("println(char[])", rep[1]); + assertEquals("println(String)", rep[2]); + assertEquals("write(char[])ite(charite(Stri", rep[3]); + } + + /** + * Custom throwable that calls methods + * not overridden by VectorWriter in log4j 1.2.14 and earlier. + */ + private static final class NotOverriddenThrowable extends Throwable { + /** + * Create new instance. + */ + public NotOverriddenThrowable() { + } + + /** + * Print stack trace. + * + * @param s print writer. + */ + public void printStackTrace(final PrintWriter s) { + s.print(true); + s.print('a'); + s.print(1); + s.print(2L); + s.print(Float.MAX_VALUE); + s.print(Double.MIN_VALUE); + s.println(true); + s.println('a'); + s.println(1); + s.println(2L); + s.println(Float.MAX_VALUE); + s.println(Double.MIN_VALUE); + s.write('C'); + } + } + + /** + * Test capturing stack trace from a throwable that uses the + * PrintWriter methods not overridden in log4j 1.2.14 and earlier. + */ + public void testNotOverriddenBehavior() { + ThrowableInformation ti = new ThrowableInformation(new NotOverriddenThrowable()); + String[] rep = ti.getThrowableStrRep(); + assertEquals(7, rep.length); + StringBuffer buf = new StringBuffer(String.valueOf(true)); + buf.append('a'); + buf.append(String.valueOf(1)); + buf.append(String.valueOf(2L)); + buf.append(String.valueOf(Float.MAX_VALUE)); + buf.append(String.valueOf(Double.MIN_VALUE)); + buf.append(String.valueOf(true)); + assertEquals(buf.toString(), rep[0]); + assertEquals("a", rep[1]); + assertEquals(String.valueOf(1), rep[2]); + assertEquals(String.valueOf(2L), rep[3]); + assertEquals(String.valueOf(Float.MAX_VALUE), rep[4]); + assertEquals(String.valueOf(Double.MIN_VALUE), rep[5]); + assertEquals("C", rep[6]); + } + + /** + * Custom throwable that calls methods of VectorWriter + * with null. + */ + private static final class NullThrowable extends Throwable { + /** + * Create new instance. + */ + public NullThrowable() { + } + + /** + * Print stack trace. + * + * @param s print writer. + */ + public void printStackTrace(final PrintWriter s) { + s.print((Object) null); + s.print((String) null); + s.println((Object) null); + s.println((String) null); + } + } + + /** + * Test capturing stack trace from a throwable that passes + * null to PrintWriter methods. + */ + + public void testNull() { + ThrowableInformation ti = new ThrowableInformation(new NullThrowable()); + String[] rep = ti.getThrowableStrRep(); + assertEquals(2, rep.length); + String nullStr = String.valueOf((Object) null); + assertEquals(nullStr + nullStr + nullStr, rep[0]); + assertEquals(nullStr, rep[1]); + } + + /** + * Custom throwable that does nothing in printStackTrace. + */ + private static final class EmptyThrowable extends Throwable { + /** + * Create new instance. + */ + public EmptyThrowable() { + } + + /** + * Print stack trace. + * + * @param s print writer. + */ + public void printStackTrace(final PrintWriter s) { + } + } + + /** + * Test capturing stack trace from a throwable that + * does nothing on a call to printStackTrace. + */ + + public void testEmpty() { + ThrowableInformation ti = new ThrowableInformation(new EmptyThrowable()); + String[] rep = ti.getThrowableStrRep(); + assertEquals(0, rep.length); + } + + /** + * Custom throwable that emits a specified string in printStackTrace. + */ + private static final class StringThrowable extends Throwable { + /** + * Stack trace. + */ + private final String stackTrace; + /** + * Create new instance. + * @param trace stack trace. + */ + public StringThrowable(final String trace) { + stackTrace = trace; + } + + /** + * Print stack trace. + * + * @param s print writer. + */ + public void printStackTrace(final PrintWriter s) { + s.print(stackTrace); + } + } + + /** + * Test capturing stack trace from throwable that just has a line feed. + */ + public void testLineFeed() { + ThrowableInformation ti = new ThrowableInformation(new StringThrowable("\n")); + String[] rep = ti.getThrowableStrRep(); + assertEquals(1, rep.length); + assertEquals("", rep[0]); + } + + /** + * Test capturing stack trace from throwable that just has a carriage return. + */ + public void testCarriageReturn() { + ThrowableInformation ti = new ThrowableInformation(new StringThrowable("\r")); + String[] rep = ti.getThrowableStrRep(); + assertEquals(1, rep.length); + assertEquals("", rep[0]); + } + + /** + * Test parsing of line breaks. + */ + public void testParsing() { + ThrowableInformation ti = new ThrowableInformation( + new StringThrowable("Line1\rLine2\nLine3\r\nLine4\n\rLine6")); + String[] rep = ti.getThrowableStrRep(); + assertEquals(6, rep.length); + assertEquals("Line1", rep[0]); + assertEquals("Line2", rep[1]); + assertEquals("Line3", rep[2]); + assertEquals("Line4", rep[3]); + assertEquals("", rep[4]); + assertEquals("Line6", rep[5]); + } + + /** + * Test capturing stack trace from throwable that a line feed followed by blank. + */ + public void testLineFeedBlank() { + ThrowableInformation ti = new ThrowableInformation(new StringThrowable("\n ")); + String[] rep = ti.getThrowableStrRep(); + assertEquals(2, rep.length); + assertEquals("", rep[0]); + assertEquals(" ", rep[1]); + } + + /** + * Test that getThrowable returns the throwable provided to the constructor. + */ + public void testGetThrowable() { + Throwable t = new StringThrowable("Hello, World"); + ThrowableInformation ti = new ThrowableInformation(t); + assertSame(t, ti.getThrowable()); + } +} diff --git a/tests/src/java/org/apache/log4j/util/AbsoluteDateAndTimeFilter.java b/tests/src/java/org/apache/log4j/util/AbsoluteDateAndTimeFilter.java index f611a5009d..55cc500493 100644 --- a/tests/src/java/org/apache/log4j/util/AbsoluteDateAndTimeFilter.java +++ b/tests/src/java/org/apache/log4j/util/AbsoluteDateAndTimeFilter.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; diff --git a/tests/src/java/org/apache/log4j/util/AbsoluteTimeFilter.java b/tests/src/java/org/apache/log4j/util/AbsoluteTimeFilter.java index 82b5c02a05..73e203a2cf 100644 --- a/tests/src/java/org/apache/log4j/util/AbsoluteTimeFilter.java +++ b/tests/src/java/org/apache/log4j/util/AbsoluteTimeFilter.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; diff --git a/tests/src/java/org/apache/log4j/util/Compare.java b/tests/src/java/org/apache/log4j/util/Compare.java index 7cbd0dbed4..9b4146660b 100644 --- a/tests/src/java/org/apache/log4j/util/Compare.java +++ b/tests/src/java/org/apache/log4j/util/Compare.java @@ -1,17 +1,25 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; -import java.io.InputStream; -import java.io.FileInputStream; -import java.io.FileReader; import java.io.BufferedReader; import java.io.FileNotFoundException; +import java.io.FileReader; import java.io.IOException; public class Compare { diff --git a/tests/src/java/org/apache/log4j/util/ControlFilter.java b/tests/src/java/org/apache/log4j/util/ControlFilter.java index 0809d167eb..821d104378 100644 --- a/tests/src/java/org/apache/log4j/util/ControlFilter.java +++ b/tests/src/java/org/apache/log4j/util/ControlFilter.java @@ -1,14 +1,22 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; -import java.io.*; - import org.apache.oro.text.perl.Perl5Util; public class ControlFilter implements Filter { diff --git a/tests/src/java/org/apache/log4j/util/Filter.java b/tests/src/java/org/apache/log4j/util/Filter.java index 650c38161d..3534b2039c 100644 --- a/tests/src/java/org/apache/log4j/util/Filter.java +++ b/tests/src/java/org/apache/log4j/util/Filter.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; diff --git a/tests/src/java/org/apache/log4j/util/ISO8601Filter.java b/tests/src/java/org/apache/log4j/util/ISO8601Filter.java index 59eb5d5529..50479f65fa 100644 --- a/tests/src/java/org/apache/log4j/util/ISO8601Filter.java +++ b/tests/src/java/org/apache/log4j/util/ISO8601Filter.java @@ -1,14 +1,22 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; -import java.io.*; - import org.apache.oro.text.perl.Perl5Util; public class ISO8601Filter implements Filter { diff --git a/tests/src/java/org/apache/log4j/util/JunitTestRunnerFilter.java b/tests/src/java/org/apache/log4j/util/JunitTestRunnerFilter.java new file mode 100644 index 0000000000..dbdd3dcdf2 --- /dev/null +++ b/tests/src/java/org/apache/log4j/util/JunitTestRunnerFilter.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.util; + +import org.apache.oro.text.perl.Perl5Util; + + +public class JunitTestRunnerFilter implements Filter { + Perl5Util util = new Perl5Util(); + + /** + * Filter out stack trace lines coming from the various JUnit TestRunners. + */ + public String filter(String in) { + if (in == null) { + return null; + } + + if ( + util.match( + "/at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner/", in)) { + return null; + } else if ( + util.match( + "/at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner/", + in)) { + return null; + } else if ( + util.match( + "/at com.intellij/", + in)) { + return null; + } else if (in.indexOf("at junit.") >= 0 && in.indexOf("ui.TestRunner") >= 0) { + return null; + } else if (in.indexOf("org.apache.maven") >= 0) { + return null; + } else if (util.match("/\\sat /", in)) { + return "\t" + in.trim(); + } else { + return in; + } + } +} diff --git a/tests/src/java/org/apache/log4j/util/LineNumberFilter.java b/tests/src/java/org/apache/log4j/util/LineNumberFilter.java index 2b826b9c1e..c47b9b7a3a 100644 --- a/tests/src/java/org/apache/log4j/util/LineNumberFilter.java +++ b/tests/src/java/org/apache/log4j/util/LineNumberFilter.java @@ -1,14 +1,22 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; -import java.io.*; - import org.apache.oro.text.perl.Perl5Util; public class LineNumberFilter implements Filter { @@ -20,6 +28,9 @@ String filter(String in) { if(util.match("/\\(.*:\\d{1,4}\\)/", in)) { return util.substitute("s/:\\d{1,4}\\)/:XXX)/", in); } else { + if(in.indexOf(", Compiled Code") >= 0) { + return util.substitute("s/, Compiled Code/:XXX/", in); + } return in; } } diff --git a/tests/src/java/org/apache/log4j/util/RelativeTimeFilter.java b/tests/src/java/org/apache/log4j/util/RelativeTimeFilter.java index 652b06d753..94d6d0eb09 100644 --- a/tests/src/java/org/apache/log4j/util/RelativeTimeFilter.java +++ b/tests/src/java/org/apache/log4j/util/RelativeTimeFilter.java @@ -1,14 +1,22 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; -import java.io.*; - import org.apache.oro.text.perl.Perl5Util; public class RelativeTimeFilter implements Filter { diff --git a/tests/src/java/org/apache/log4j/util/SerializationTestHelper.java b/tests/src/java/org/apache/log4j/util/SerializationTestHelper.java new file mode 100644 index 0000000000..f592a83421 --- /dev/null +++ b/tests/src/java/org/apache/log4j/util/SerializationTestHelper.java @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.util; + +import junit.framework.TestCase; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + + +/** + * Utiities for serialization tests. + * + * @author Curt Arnold + */ +public class SerializationTestHelper { + /** + * Private constructor. + */ + private SerializationTestHelper() { + } + + /** + * Creates a clone by serializing object and + * deserializing byte stream. + * @param obj object to serialize and deserialize. + * @return clone + * @throws IOException on IO error. + * @throws ClassNotFoundException if class not found. + */ + public static Object serializeClone(final Object obj) + throws IOException, ClassNotFoundException { + ByteArrayOutputStream memOut = new ByteArrayOutputStream(); + ObjectOutputStream objOut = new ObjectOutputStream(memOut); + objOut.writeObject(obj); + objOut.close(); + + ByteArrayInputStream src = new ByteArrayInputStream(memOut.toByteArray()); + ObjectInputStream objIs = new ObjectInputStream(src); + + return objIs.readObject(); + } + + /** + * Deserializes a specified file. + * @param witness serialization file, may not be null. + * @return deserialized object. + * @throws Exception thrown on IO or deserialization exception. + */ + public static Object deserializeStream(final String witness) + throws Exception { + FileInputStream fileIs = new FileInputStream(witness); + ObjectInputStream objIs = new ObjectInputStream(fileIs); + + return objIs.readObject(); + } + + /** + * Checks the serialization of an object against an file + * containing the expected serialization. + * + * @param witness name of file containing expected serialization. + * @param obj object to be serialized. + * @param skip positions in serialized stream that should not be compared. + * @param endCompare position to stop comparison. + * @throws Exception thrown on IO or serialization exception. + */ + public static void assertSerializationEquals( + final String witness, final Object obj, final int[] skip, + final int endCompare) throws Exception { + ByteArrayOutputStream memOut = new ByteArrayOutputStream(); + ObjectOutputStream objOut = new ObjectOutputStream(memOut); + objOut.writeObject(obj); + objOut.close(); + + assertStreamEquals(witness, memOut.toByteArray(), skip, endCompare); + } + + /** + * Asserts the serialized form of an object. + * @param witness file name of expected serialization. + * @param actual byte array of actual serialization. + * @param skip positions to skip comparison. + * @param endCompare position to stop comparison. + * @throws IOException thrown on IO or serialization exception. + */ + public static void assertStreamEquals( + final String witness, final byte[] actual, final int[] skip, + final int endCompare) throws IOException { + File witnessFile = new File(witness); + + if (witnessFile.exists()) { + int skipIndex = 0; + byte[] expected = new byte[actual.length]; + FileInputStream is = new FileInputStream(witnessFile); + int bytesRead = is.read(expected); + is.close(); + + if(bytesRead < endCompare) { + TestCase.assertEquals(bytesRead, actual.length); + } + + int endScan = actual.length; + + if (endScan > endCompare) { + endScan = endCompare; + } + + for (int i = 0; i < endScan; i++) { + if ((skipIndex < skip.length) && (skip[skipIndex] == i)) { + skipIndex++; + } else { + if (expected[i] != actual[i]) { + TestCase.assertEquals( + "Difference at offset " + i, expected[i], actual[i]); + } + } + } + } else { + // + // if the file doesn't exist then + // assume that we are setting up and need to write it + FileOutputStream os = new FileOutputStream(witnessFile); + os.write(actual); + os.close(); + TestCase.fail("Writing witness file " + witness); + } + } +} diff --git a/tests/src/java/org/apache/log4j/util/SunReflectFilter.java b/tests/src/java/org/apache/log4j/util/SunReflectFilter.java new file mode 100644 index 0000000000..75cd75ab79 --- /dev/null +++ b/tests/src/java/org/apache/log4j/util/SunReflectFilter.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.util; + +import org.apache.oro.text.perl.Perl5Util; + +/** + * The sun.reflect.* and java.lang.reflect.* lines are not present in all JDKs. + * + * @author Ceki Gulcu + */ +public class SunReflectFilter implements Filter { + Perl5Util util = new Perl5Util(); + + public String filter(String in) { + if(in == null) { + return null; + } + if (util.match("/at sun.reflect/", in)) { + return null; + } + if (in.indexOf("at java.lang.reflect.Method") >= 0) { + return null; + } + if (in.indexOf("Compiled Code") >= 0) { + if(in.indexOf("junit.framework.TestSuite") >= 0) { + return util.substitute("s/Compiled Code/TestSuite.java:XXX/", in); + } + } + if (util.match("/\\(Method.java:.*\\)/", in)) { + return util.substitute("s/\\(Method.java:.*\\)/(Native Method)/", in); + } + return in; + } +} diff --git a/tests/src/java/org/apache/log4j/util/Transformer.java b/tests/src/java/org/apache/log4j/util/Transformer.java index d5a38dc576..fd8e81d3b1 100644 --- a/tests/src/java/org/apache/log4j/util/Transformer.java +++ b/tests/src/java/org/apache/log4j/util/Transformer.java @@ -1,25 +1,36 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; -import java.io.*; - -import org.apache.oro.text.perl.Perl5Util; +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.PrintStream; public class Transformer { public static - void transform(String in, String out, Filter[] filters) throws FileNotFoundException, - IOException, + void transform(String in, String out, Filter[] filters) throws IOException, UnexpectedFormatException { - Perl5Util util = new Perl5Util(); String line; BufferedReader input = new BufferedReader(new FileReader(in)); PrintStream output = new PrintStream(new FileOutputStream(out, false)); @@ -30,7 +41,9 @@ void transform(String in, String out, Filter[] filters) throws FileNotFoundExcep for(int i = 0; i < filters.length; i++) { line = filters[i].filter(line); } - output.println(line); + if(line != null) { + output.println(line); + } } } @@ -38,11 +51,9 @@ void transform(String in, String out, Filter[] filters) throws FileNotFoundExcep public static - void transform(String in, String out, Filter filter) throws FileNotFoundException, - IOException, + void transform(String in, String out, Filter filter) throws IOException, UnexpectedFormatException { - Perl5Util util = new Perl5Util(); String line; BufferedReader input = new BufferedReader(new FileReader(in)); PrintStream output = new PrintStream(new FileOutputStream(out)); diff --git a/tests/src/java/org/apache/log4j/util/UnexpectedFormatException.java b/tests/src/java/org/apache/log4j/util/UnexpectedFormatException.java index 03779958fe..8ab79ff8b1 100644 --- a/tests/src/java/org/apache/log4j/util/UnexpectedFormatException.java +++ b/tests/src/java/org/apache/log4j/util/UnexpectedFormatException.java @@ -1,13 +1,24 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; public class UnexpectedFormatException extends Exception { + private static final long serialVersionUID = 1787725660780924147L; public UnexpectedFormatException(String msg) { super(msg); diff --git a/tests/src/java/org/apache/log4j/util/XMLLineAttributeFilter.java b/tests/src/java/org/apache/log4j/util/XMLLineAttributeFilter.java index 8edd2251e1..877b432717 100644 --- a/tests/src/java/org/apache/log4j/util/XMLLineAttributeFilter.java +++ b/tests/src/java/org/apache/log4j/util/XMLLineAttributeFilter.java @@ -1,14 +1,22 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; -import java.io.*; - import org.apache.oro.text.perl.Perl5Util; public class XMLLineAttributeFilter implements Filter { diff --git a/tests/src/java/org/apache/log4j/util/XMLTimestampFilter.java b/tests/src/java/org/apache/log4j/util/XMLTimestampFilter.java index 6bd07da52b..dfac8c798c 100644 --- a/tests/src/java/org/apache/log4j/util/XMLTimestampFilter.java +++ b/tests/src/java/org/apache/log4j/util/XMLTimestampFilter.java @@ -1,14 +1,22 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.util; -import java.io.*; - import org.apache.oro.text.perl.Perl5Util; public class XMLTimestampFilter implements Filter { diff --git a/tests/src/java/org/apache/log4j/varia/ERFATestCase.java b/tests/src/java/org/apache/log4j/varia/ERFATestCase.java new file mode 100644 index 0000000000..8995fd3c27 --- /dev/null +++ b/tests/src/java/org/apache/log4j/varia/ERFATestCase.java @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.varia; +import junit.framework.TestCase; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.log4j.PatternLayout; +import org.apache.log4j.RFATestCase; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.IOException; +import java.net.Socket; +import java.net.InetAddress; + +/** + * Test of ExternallyRolledFileAppender. + * + * @author Curt Arnold + */ +public class ERFATestCase extends TestCase { + + /** + * Create new instance of test. + * @param name test name. + */ + public ERFATestCase(final String name) { + super(name); + } + + /** + * Reset configuration after test. + */ + public void tearDown() { + LogManager.resetConfiguration(); + } + + /** + * Test ExternallyRolledFileAppender constructor. + */ + public void testConstructor() { + ExternallyRolledFileAppender appender = + new ExternallyRolledFileAppender(); + assertEquals(0, appender.getPort()); + } + + /** + * Send a message to the ERFA. + * @param port port number. + * @param msg message, may not be null. + * @param expectedResponse expected response, may not be null. + * @throws IOException thrown on IO error. + */ + void sendMessage(int port, final String msg, final String expectedResponse) throws IOException { + Socket socket = new Socket((String) null, port); + DataInputStream reader = new DataInputStream(socket.getInputStream()); + DataOutputStream writer = new DataOutputStream(socket.getOutputStream()); + writer.writeUTF(msg); + String response = reader.readUTF(); + assertEquals(expectedResponse, response); + reader.close(); + writer.close(); + socket.close(); + } + + /** + * Test externally triggered rollover. + * @throws IOException thrown on IO error. + */ + public void testRollover() throws IOException { + ExternallyRolledFileAppender erfa = + new ExternallyRolledFileAppender(); + + int port = 5500; + + Logger logger = Logger.getLogger(RFATestCase.class); + Logger root = Logger.getRootLogger(); + PatternLayout layout = new PatternLayout("%m\n"); + erfa.setLayout(layout); + erfa.setAppend(false); + erfa.setMaxBackupIndex(2); + erfa.setPort(port); + erfa.setFile("output/ERFA-test2.log"); + try { + erfa.activateOptions(); + } catch(SecurityException ex) { + return; + } + try { + Thread.sleep(100); + } catch(InterruptedException ex) { + } + root.addAppender(erfa); + + + // Write exactly 10 bytes with each log + for (int i = 0; i < 55; i++) { + if (i < 10) { + logger.debug("Hello---" + i); + } else if (i < 100) { + logger.debug("Hello--" + i); + } + if ((i % 10) == 9) { + try { + sendMessage(port, "RollOver", "OK"); + } catch(SecurityException ex) { + return; + } + } + } + + try { + sendMessage(port, + "That's all folks.", + "Expecting [RollOver] string."); + } catch(SecurityException ex) { + return; + } + + + assertTrue(new File("output/ERFA-test2.log").exists()); + assertTrue(new File("output/ERFA-test2.log.1").exists()); + assertTrue(new File("output/ERFA-test2.log.2").exists()); + assertFalse(new File("output/ERFA-test2.log.3").exists()); + } +} diff --git a/tests/src/java/org/apache/log4j/varia/ErrorHandlerTestCase.java b/tests/src/java/org/apache/log4j/varia/ErrorHandlerTestCase.java new file mode 100644 index 0000000000..7eea034008 --- /dev/null +++ b/tests/src/java/org/apache/log4j/varia/ErrorHandlerTestCase.java @@ -0,0 +1,125 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.varia; + +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.framework.Test; + +import org.apache.log4j.Logger; +import org.apache.log4j.Level; +import org.apache.log4j.xml.DOMConfigurator; +import org.apache.log4j.util.Filter; +import org.apache.log4j.util.LineNumberFilter; +import org.apache.log4j.util.ControlFilter; +import org.apache.log4j.util.ISO8601Filter; +import org.apache.log4j.util.Transformer; +import org.apache.log4j.util.Compare; + +public class ErrorHandlerTestCase extends TestCase { + + static String TEMP_A1 = "output/temp.A1"; + static String TEMP_A2 = "output/temp.A2"; + static String FILTERED_A1 = "output/filtered.A1"; + static String FILTERED_A2 = "output/filtered.A2"; + + + static String EXCEPTION1 = "java.lang.Exception: Just testing"; + static String EXCEPTION2 = "\\s*at .*\\(.*:\\d{1,4}\\)"; + static String EXCEPTION3 = "\\s*at .*\\(Native Method\\)"; + + static String TEST1_1A_PAT = + "(DEBUG|INFO |WARN |ERROR|FATAL) \\w*\\.\\w* - Message \\d"; + + static String TEST1_1B_PAT = "(DEBUG|INFO |WARN |ERROR|FATAL) root - Message \\d"; + + static String TEST1_2_PAT = "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3} "+ + "\\[main]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message \\d"; + + + + Logger root; + Logger logger; + + public ErrorHandlerTestCase(String name) { + super(name); + } + + public void setUp() { + root = Logger.getRootLogger(); + logger = Logger.getLogger("test"); + } + + public void tearDown() { + root.getLoggerRepository().resetConfiguration(); + } + + public void test1() throws Exception { + DOMConfigurator.configure("input/xml/fallback1.xml"); + common(); + + ControlFilter cf1 = new ControlFilter(new String[]{TEST1_1A_PAT, TEST1_1B_PAT, + EXCEPTION1, EXCEPTION2, EXCEPTION3}); + + ControlFilter cf2 = new ControlFilter(new String[]{TEST1_2_PAT, + EXCEPTION1, EXCEPTION2, EXCEPTION3}); + + Transformer.transform(TEMP_A1, FILTERED_A1, new Filter[] {cf1, + new LineNumberFilter()}); + + Transformer.transform(TEMP_A2, FILTERED_A2, new Filter[] {cf2, + new LineNumberFilter(), new ISO8601Filter()}); + + assertTrue(Compare.compare(FILTERED_A1, "witness/dom.A1.1")); + assertTrue(Compare.compare(FILTERED_A2, "witness/dom.A2.1")); + } + + void common() { + int i = -1; + + logger.debug("Message " + ++i); + root.debug("Message " + i); + + logger.info ("Message " + ++i); + root.info("Message " + i); + + logger.warn ("Message " + ++i); + root.warn("Message " + i); + + logger.error("Message " + ++i); + root.error("Message " + i); + + logger.log(Level.FATAL, "Message " + ++i); + root.log(Level.FATAL, "Message " + i); + + Exception e = new Exception("Just testing"); + logger.debug("Message " + ++i, e); + root.debug("Message " + i, e); + + logger.error("Message " + ++i, e); + root.error("Message " + i, e); + + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTest(new ErrorHandlerTestCase("test1")); + return suite; + } + +} diff --git a/tests/src/java/org/apache/log4j/varia/LevelMatchFilterTestCase.java b/tests/src/java/org/apache/log4j/varia/LevelMatchFilterTestCase.java index dbe9cc53db..1afc0d502c 100644 --- a/tests/src/java/org/apache/log4j/varia/LevelMatchFilterTestCase.java +++ b/tests/src/java/org/apache/log4j/varia/LevelMatchFilterTestCase.java @@ -1,9 +1,19 @@ /* - * 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.txt file. */ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.varia; @@ -71,9 +81,9 @@ public void accept() throws Exception { // set appender on root and set level to debug root.addAppender(appender); - root.setLevel(Level.DEBUG); + root.setLevel(Level.TRACE); - Level[] levelArray = new Level[] {Level.DEBUG, Level.INFO, Level.WARN, + Level[] levelArray = new Level[] {Level.TRACE, Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL}; for (int x = 0; x < levelArray.length; x++) { // set the level to match @@ -101,9 +111,9 @@ public void deny() throws Exception { // set appender on root and set level to debug root.addAppender(appender); - root.setLevel(Level.DEBUG); + root.setLevel(Level.TRACE); - Level[] levelArray = new Level[] {Level.DEBUG, Level.INFO, Level.WARN, + Level[] levelArray = new Level[] {Level.TRACE, Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL}; for (int x = 0; x < levelArray.length; x++) { // set the level to match @@ -119,6 +129,7 @@ public void deny() throws Exception { void common(String msg) { Logger logger = Logger.getLogger("test"); + logger.trace(msg); logger.debug(msg); logger.info(msg); logger.warn(msg); diff --git a/tests/src/java/org/apache/log4j/xml/CustomLevelTestCase.java b/tests/src/java/org/apache/log4j/xml/CustomLevelTestCase.java index 45fb9087f5..52c366ae94 100644 --- a/tests/src/java/org/apache/log4j/xml/CustomLevelTestCase.java +++ b/tests/src/java/org/apache/log4j/xml/CustomLevelTestCase.java @@ -1,17 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.xml; +import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import junit.framework.Test; - import org.apache.log4j.Logger; -import org.apache.log4j.Level; -import org.apache.log4j.util.Filter; -import org.apache.log4j.util.LineNumberFilter; -import org.apache.log4j.util.ControlFilter; -import org.apache.log4j.util.ISO8601Filter; -import org.apache.log4j.util.Transformer; import org.apache.log4j.util.Compare; public class CustomLevelTestCase extends TestCase { diff --git a/tests/src/java/org/apache/log4j/xml/DOMTestCase.java b/tests/src/java/org/apache/log4j/xml/DOMTestCase.java index b3991c6053..e6b02ebf1b 100644 --- a/tests/src/java/org/apache/log4j/xml/DOMTestCase.java +++ b/tests/src/java/org/apache/log4j/xml/DOMTestCase.java @@ -1,18 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.xml; import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.framework.Test; - -import org.apache.log4j.Logger; +import org.apache.log4j.Appender; import org.apache.log4j.Level; -import org.apache.log4j.util.Filter; -import org.apache.log4j.util.LineNumberFilter; +import org.apache.log4j.Logger; +import org.apache.log4j.spi.ErrorHandler; +import org.apache.log4j.spi.LoggerFactory; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.util.Compare; import org.apache.log4j.util.ControlFilter; +import org.apache.log4j.util.Filter; import org.apache.log4j.util.ISO8601Filter; +import org.apache.log4j.util.JunitTestRunnerFilter; +import org.apache.log4j.util.LineNumberFilter; +import org.apache.log4j.util.SunReflectFilter; import org.apache.log4j.util.Transformer; -import org.apache.log4j.util.Compare; public class DOMTestCase extends TestCase { @@ -25,14 +44,17 @@ public class DOMTestCase extends TestCase { static String EXCEPTION1 = "java.lang.Exception: Just testing"; static String EXCEPTION2 = "\\s*at .*\\(.*:\\d{1,4}\\)"; static String EXCEPTION3 = "\\s*at .*\\(Native Method\\)"; + static String EXCEPTION4 = "\\s*at .*\\(.*Compiled Code\\)"; + static String EXCEPTION5 = "\\s*at .*\\(.*libgcj.*\\)"; + static String TEST1_1A_PAT = - "(DEBUG|INFO |WARN |ERROR|FATAL) \\w*\\.\\w* - Message \\d"; + "(TRACE|DEBUG|INFO |WARN |ERROR|FATAL) \\w*\\.\\w* - Message \\d"; - static String TEST1_1B_PAT = "(DEBUG|INFO |WARN |ERROR|FATAL) root - Message \\d"; + static String TEST1_1B_PAT = "(TRACE|DEBUG|INFO |WARN |ERROR|FATAL) root - Message \\d"; static String TEST1_2_PAT = "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3} "+ - "\\[main]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message \\d"; + "\\[main]\\ (TRACE|DEBUG|INFO|WARN|ERROR|FATAL) .* - Message \\d"; @@ -57,24 +79,69 @@ public void test1() throws Exception { common(); ControlFilter cf1 = new ControlFilter(new String[]{TEST1_1A_PAT, TEST1_1B_PAT, - EXCEPTION1, EXCEPTION2, EXCEPTION3}); + EXCEPTION1, EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); ControlFilter cf2 = new ControlFilter(new String[]{TEST1_2_PAT, - EXCEPTION1, EXCEPTION2, EXCEPTION3}); + EXCEPTION1, EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); - Transformer.transform(TEMP_A1, FILTERED_A1, new Filter[] {cf1, - new LineNumberFilter()}); + Transformer.transform( + TEMP_A1, FILTERED_A1, + new Filter[] { + cf1, new LineNumberFilter(), new SunReflectFilter(), + new JunitTestRunnerFilter() + }); - Transformer.transform(TEMP_A2, FILTERED_A2, new Filter[] {cf2, - new LineNumberFilter(), new ISO8601Filter()}); + Transformer.transform( + TEMP_A2, FILTERED_A2, + new Filter[] { + cf2, new LineNumberFilter(), new ISO8601Filter(), + new SunReflectFilter(), new JunitTestRunnerFilter() + }); assertTrue(Compare.compare(FILTERED_A1, "witness/dom.A1.1")); assertTrue(Compare.compare(FILTERED_A2, "witness/dom.A2.1")); } + + /** + * Tests processing of external entities in XML file. + */ + public void test4() throws Exception { + DOMConfigurator.configure("input/xml/DOMTest4.xml"); + common(); + + ControlFilter cf1 = new ControlFilter(new String[]{TEST1_1A_PAT, TEST1_1B_PAT, + EXCEPTION1, EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + + ControlFilter cf2 = new ControlFilter(new String[]{TEST1_2_PAT, + EXCEPTION1, EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5}); + + Transformer.transform( + TEMP_A1 + ".4", FILTERED_A1 + ".4", + new Filter[] { + cf1, new LineNumberFilter(), new SunReflectFilter(), + new JunitTestRunnerFilter() + }); + + Transformer.transform( + TEMP_A2 + ".4", FILTERED_A2 + ".4", + new Filter[] { + cf2, new LineNumberFilter(), new ISO8601Filter(), + new SunReflectFilter(), new JunitTestRunnerFilter() + }); + + assertTrue(Compare.compare(FILTERED_A1 + ".4", "witness/dom.A1.4")); + assertTrue(Compare.compare(FILTERED_A2 + ".4", "witness/dom.A2.4")); + } void common() { + String oldThreadName = Thread.currentThread().getName(); + Thread.currentThread().setName("main"); + int i = -1; + logger.trace("Message " + ++i); + root.trace("Message " + i); + logger.debug("Message " + ++i); root.debug("Message " + i); @@ -97,12 +164,125 @@ void common() { logger.error("Message " + ++i, e); root.error("Message " + i, e); + Thread.currentThread().setName(oldThreadName); } - public static Test suite() { - TestSuite suite = new TestSuite(); - suite.addTest(new DOMTestCase("test1")); - return suite; + + /** + * CustomLogger implementation for testCategoryFactory1 and 2. + */ + private static class CustomLogger extends Logger { + /** + * Creates new instance. + * @param name logger name. + */ + public CustomLogger(final String name) { + super(name); + } + } + + /** + * Creates new instances of CustomLogger. + */ + public static class CustomLoggerFactory implements LoggerFactory { + /** + * Addivity, expected to be set false in configuration file. + */ + private boolean additivity; + + /** + * Create new instance of factory. + */ + public CustomLoggerFactory() { + additivity = true; + } + + /** + * Create new logger. + * @param name logger name. + * @return new logger. + */ + public Logger makeNewLoggerInstance(final String name) { + Logger logger = new CustomLogger(name); + assertFalse(additivity); + return logger; + } + + /** + * Set additivity. + * @param newVal new value of additivity. + */ + public void setAdditivity(final boolean newVal) { + additivity = newVal; + } + } + + /** + * CustomErrorHandler for testCategoryFactory2. + */ + public static class CustomErrorHandler implements ErrorHandler { + public CustomErrorHandler() {} + public void activateOptions() {} + public void setLogger(final Logger logger) {} + public void error(String message, Exception e, int errorCode) {} + public void error(String message) {} + public void error(String message, Exception e, int errorCode, LoggingEvent event) {} + public void setAppender(Appender appender) {} + public void setBackupAppender(Appender appender) {} + } + + /** + * Tests that loggers mentioned in logger elements + * use the specified categoryFactory. See bug 33708. + */ + public void testCategoryFactory1() { + DOMConfigurator.configure("input/xml/categoryfactory1.xml"); + // + // logger explicitly mentioned in configuration, + // should be a CustomLogger + Logger logger1 = Logger.getLogger("org.apache.log4j.xml.DOMTestCase.testCategoryFactory1.1"); + assertTrue(logger1 instanceof CustomLogger); + // + // logger not explicitly mentioned in configuration, + // should use default factory + Logger logger2 = Logger.getLogger("org.apache.log4j.xml.DOMTestCase.testCategoryFactory1.2"); + assertFalse(logger2 instanceof CustomLogger); + } + + /** + * Tests that loggers mentioned in logger-ref elements + * use the specified categoryFactory. See bug 33708. + */ + public void testCategoryFactory2() { + DOMConfigurator.configure("input/xml/categoryfactory2.xml"); + // + // logger explicitly mentioned in configuration, + // should be a CustomLogger + Logger logger1 = Logger.getLogger("org.apache.log4j.xml.DOMTestCase.testCategoryFactory2.1"); + assertTrue(logger1 instanceof CustomLogger); + // + // logger not explicitly mentioned in configuration, + // should use default factory + Logger logger2 = Logger.getLogger("org.apache.log4j.xml.DOMTestCase.testCategoryFactory2.2"); + assertFalse(logger2 instanceof CustomLogger); + } + + /** + * Tests that loggers mentioned in logger elements + * use the specified loggerFactory. See bug 33708. + */ + public void testLoggerFactory1() { + DOMConfigurator.configure("input/xml/loggerfactory1.xml"); + // + // logger explicitly mentioned in configuration, + // should be a CustomLogger + Logger logger1 = Logger.getLogger("org.apache.log4j.xml.DOMTestCase.testLoggerFactory1.1"); + assertTrue(logger1 instanceof CustomLogger); + // + // logger not explicitly mentioned in configuration, + // should use default factory + Logger logger2 = Logger.getLogger("org.apache.log4j.xml.DOMTestCase.testLoggerFactory1.2"); + assertFalse(logger2 instanceof CustomLogger); } } diff --git a/tests/src/java/org/apache/log4j/xml/XLevel.java b/tests/src/java/org/apache/log4j/xml/XLevel.java index af424256d4..36ff30dc22 100644 --- a/tests/src/java/org/apache/log4j/xml/XLevel.java +++ b/tests/src/java/org/apache/log4j/xml/XLevel.java @@ -1,8 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.xml; import org.apache.log4j.Level; -import org.apache.log4j.Priority; /** @@ -11,6 +26,7 @@ */ public class XLevel extends Level { + private static final long serialVersionUID = 7288304330257085144L; static public final int TRACE_INT = Level.DEBUG_INT - 1; static public final int LETHAL_INT = Level.FATAL_INT + 1; diff --git a/tests/src/java/org/apache/log4j/xml/XMLLayoutTest.java b/tests/src/java/org/apache/log4j/xml/XMLLayoutTest.java new file mode 100644 index 0000000000..8642b393f1 --- /dev/null +++ b/tests/src/java/org/apache/log4j/xml/XMLLayoutTest.java @@ -0,0 +1,432 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.log4j.xml; + +import org.apache.log4j.Layout; +import org.apache.log4j.LayoutTest; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.NDC; +import org.apache.log4j.MDC; +import org.apache.log4j.spi.LoggingEvent; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import org.xml.sax.InputSource; + +import java.io.Reader; +import java.io.StringReader; +import java.util.Hashtable; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + + +/** + * Test for XMLLayout. + * + * @author Curt Arnold + */ +public class XMLLayoutTest extends LayoutTest { + /** + * Construct new instance of XMLLayoutTest. + * + * @param testName test name. + */ + public XMLLayoutTest(final String testName) { + super(testName, "text/plain", false, null, null); + } + + /** + * @{inheritDoc} + */ + protected Layout createLayout() { + return new XMLLayout(); + } + + /** + * Parses the string as the body of an XML document and returns the document element. + * @param source source string. + * @return document element. + * @throws Exception if parser can not be constructed or source is not a valid XML document. + */ + private Element parse(final String source) throws Exception { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(false); + factory.setCoalescing(true); + + DocumentBuilder builder = factory.newDocumentBuilder(); + Reader reader = new StringReader(source); + Document doc = builder.parse(new InputSource(reader)); + + return doc.getDocumentElement(); + } + + /** + * Checks a log4j:event element against expectations. + * @param element element, may not be null. + * @param event event, may not be null. + */ + private void checkEventElement( + final Element element, final LoggingEvent event) { + assertEquals("log4j:event", element.getTagName()); + assertEquals( + event.getLoggerName(), element.getAttribute("logger")); + assertEquals( + Long.toString(event.timeStamp), element.getAttribute("timestamp")); + assertEquals(event.getLevel().toString(), element.getAttribute("level")); + assertEquals(event.getThreadName(), element.getAttribute("thread")); + } + + /** + * Checks a log4j:message element against expectations. + * @param element element, may not be null. + * @param message expected message. + */ + private void checkMessageElement( + final Element element, final String message) { + assertEquals("log4j:message", element.getTagName()); + + Node messageNode = element.getFirstChild(); + assertNotNull(messageNode); + assertEquals(Node.TEXT_NODE, messageNode.getNodeType()); + assertEquals(message, messageNode.getNodeValue()); + assertNull(messageNode.getNextSibling()); + } + + /** + * Checks a log4j:message element against expectations. + * @param element element, may not be null. + * @param message expected message. + */ + private void checkNDCElement(final Element element, final String message) { + assertEquals("log4j:NDC", element.getTagName()); + + Node messageNode = element.getFirstChild(); + assertNotNull(messageNode); + assertEquals(Node.TEXT_NODE, messageNode.getNodeType()); + assertEquals(message, messageNode.getNodeValue()); + assertNull(messageNode.getNextSibling()); + } + + /** + * Checks a log4j:throwable element against expectations. + * @param element element, may not be null. + * @param ex exception, may not be null. + */ + private void checkThrowableElement( + final Element element, final Exception ex) { + assertEquals("log4j:throwable", element.getTagName()); + + Node messageNode = element.getFirstChild(); + assertNotNull(messageNode); + assertEquals(Node.TEXT_NODE, messageNode.getNodeType()); + + String msg = ex.toString(); + assertEquals(msg, messageNode.getNodeValue().substring(0, msg.length())); + assertNull(messageNode.getNextSibling()); + } + + /** + * Checks a log4j:properties element against expectations. + * @param element element, may not be null. + * @param key key. + * @param value value. + */ + private void checkPropertiesElement( + final Element element, final String key, final String value) { + assertEquals("log4j:properties", element.getTagName()); + + int childNodeCount = 0; + for(Node child = element.getFirstChild(); + child != null; + child = child.getNextSibling()) { + if (child.getNodeType() == Node.ELEMENT_NODE) { + assertEquals("log4j:data", child.getNodeName()); + Element childElement = (Element) child; + assertEquals(key, childElement.getAttribute("name")); + assertEquals(value, childElement.getAttribute("value")); + childNodeCount++; + } + } + assertEquals(1, childNodeCount); + } + + /** + * Tests formatted results. + * @throws Exception if parser can not be constructed or source is not a valid XML document. + */ + public void testFormat() throws Exception { + Logger logger = Logger.getLogger("org.apache.log4j.xml.XMLLayoutTest"); + LoggingEvent event = + new LoggingEvent( + "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null); + XMLLayout layout = (XMLLayout) createLayout(); + String result = layout.format(event); + Element parsedResult = parse(result); + checkEventElement(parsedResult, event); + + int childElementCount = 0; + + for ( + Node node = parsedResult.getFirstChild(); node != null; + node = node.getNextSibling()) { + switch (node.getNodeType()) { + case Node.ELEMENT_NODE: + childElementCount++; + checkMessageElement((Element) node, "Hello, World"); + + break; + + case Node.COMMENT_NODE: + break; + + case Node.TEXT_NODE: + + // should only be whitespace + break; + + default: + fail("Unexpected node type"); + + break; + } + } + + assertEquals(1, childElementCount); + } + + /** + * Tests formatted results with an exception. + * @throws Exception if parser can not be constructed or source is not a valid XML document. + */ + public void testFormatWithException() throws Exception { + Logger logger = Logger.getLogger("org.apache.log4j.xml.XMLLayoutTest"); + Exception ex = new IllegalArgumentException("'foo' is not a valid name"); + LoggingEvent event = + new LoggingEvent( + "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", ex); + XMLLayout layout = (XMLLayout) createLayout(); + String result = layout.format(event); + Element parsedResult = parse(result); + checkEventElement(parsedResult, event); + + int childElementCount = 0; + + for ( + Node node = parsedResult.getFirstChild(); node != null; + node = node.getNextSibling()) { + switch (node.getNodeType()) { + case Node.ELEMENT_NODE: + childElementCount++; + + if (childElementCount == 1) { + checkMessageElement((Element) node, "Hello, World"); + } else { + checkThrowableElement((Element) node, ex); + } + + break; + + case Node.COMMENT_NODE: + break; + + case Node.TEXT_NODE: + + // should only be whitespace + break; + + default: + fail("Unexpected node type"); + + break; + } + } + + assertEquals(2, childElementCount); + } + + /** + * Tests formatted results with an exception. + * @throws Exception if parser can not be constructed or source is not a valid XML document. + */ + public void testFormatWithNDC() throws Exception { + Logger logger = Logger.getLogger("org.apache.log4j.xml.XMLLayoutTest"); + NDC.push("NDC goes here"); + + LoggingEvent event = + new LoggingEvent( + "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null); + XMLLayout layout = (XMLLayout) createLayout(); + String result = layout.format(event); + NDC.pop(); + + Element parsedResult = parse(result); + checkEventElement(parsedResult, event); + + int childElementCount = 0; + + for ( + Node node = parsedResult.getFirstChild(); node != null; + node = node.getNextSibling()) { + switch (node.getNodeType()) { + case Node.ELEMENT_NODE: + childElementCount++; + + if (childElementCount == 1) { + checkMessageElement((Element) node, "Hello, World"); + } else { + checkNDCElement((Element) node, "NDC goes here"); + } + + break; + + case Node.COMMENT_NODE: + break; + + case Node.TEXT_NODE: + + // should only be whitespace + break; + + default: + fail("Unexpected node type"); + + break; + } + } + + assertEquals(2, childElementCount); + } + + /** + * Tests getLocationInfo and setLocationInfo. + */ + public void testGetSetLocationInfo() { + XMLLayout layout = new XMLLayout(); + assertEquals(false, layout.getLocationInfo()); + layout.setLocationInfo(true); + assertEquals(true, layout.getLocationInfo()); + layout.setLocationInfo(false); + assertEquals(false, layout.getLocationInfo()); + } + + /** + * Tests activateOptions(). + */ + public void testActivateOptions() { + XMLLayout layout = new XMLLayout(); + layout.activateOptions(); + } + + /** + * Level with arbitrary toString value. + */ + private static final class ProblemLevel extends Level { + /** + * Construct new instance. + * @param levelName level name, may not be null. + */ + public ProblemLevel(final String levelName) { + super(6000, levelName, 6); + } + } + + /** + * Tests problematic characters in multiple fields. + * @throws Exception if parser can not be constructed or source is not a valid XML document. + */ + public void testProblemCharacters() throws Exception { + String problemName = "com.example.bar<>&\"'"; + Logger logger = Logger.getLogger(problemName); + Level level = new ProblemLevel(problemName); + Exception ex = new IllegalArgumentException(problemName); + String threadName = Thread.currentThread().getName(); + Thread.currentThread().setName(problemName); + NDC.push(problemName); + Hashtable mdcMap = MDC.getContext(); + if (mdcMap != null) { + mdcMap.clear(); + } + MDC.put(problemName, problemName); + LoggingEvent event = + new LoggingEvent( + problemName, logger, level, problemName, ex); + XMLLayout layout = (XMLLayout) createLayout(); + layout.setProperties(true); + String result = layout.format(event); + mdcMap = MDC.getContext(); + if (mdcMap != null) { + mdcMap.clear(); + } + Thread.currentThread().setName(threadName); + + Element parsedResult = parse(result); + checkEventElement(parsedResult, event); + + int childElementCount = 0; + + for ( + Node node = parsedResult.getFirstChild(); node != null; + node = node.getNextSibling()) { + switch (node.getNodeType()) { + case Node.ELEMENT_NODE: + childElementCount++; + switch(childElementCount) { + case 1: + checkMessageElement((Element) node, problemName); + break; + + case 2: + checkNDCElement((Element) node, problemName); + break; + + case 3: + checkThrowableElement((Element) node, ex); + break; + + case 4: + checkPropertiesElement((Element) node, problemName, problemName); + break; + + default: + fail("Unexpected element"); + break; + } + + break; + + case Node.COMMENT_NODE: + break; + + case Node.TEXT_NODE: + + // should only be whitespace + break; + + default: + fail("Unexpected node type"); + + break; + } + } + } + +} diff --git a/tests/src/java/org/apache/log4j/xml/XMLLayoutTestCase.java b/tests/src/java/org/apache/log4j/xml/XMLLayoutTestCase.java index 49c214d8a3..e76acd6b19 100644 --- a/tests/src/java/org/apache/log4j/xml/XMLLayoutTestCase.java +++ b/tests/src/java/org/apache/log4j/xml/XMLLayoutTestCase.java @@ -1,21 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.log4j.xml; +import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import junit.framework.Test; - -import org.apache.log4j.Logger; -import org.apache.log4j.Level; import org.apache.log4j.FileAppender; -import org.apache.log4j.xml.XMLLayout; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.MDC; +import org.apache.log4j.util.Compare; import org.apache.log4j.util.Filter; -import org.apache.log4j.util.ControlFilter; -import org.apache.log4j.util.XMLTimestampFilter; -import org.apache.log4j.util.XMLLineAttributeFilter; +import org.apache.log4j.util.JunitTestRunnerFilter; import org.apache.log4j.util.LineNumberFilter; +import org.apache.log4j.util.SunReflectFilter; import org.apache.log4j.util.Transformer; -import org.apache.log4j.util.Compare; +import org.apache.log4j.util.XMLLineAttributeFilter; +import org.apache.log4j.util.XMLTimestampFilter; + +import java.util.Hashtable; public class XMLLayoutTestCase extends TestCase { @@ -31,7 +49,9 @@ public XMLLayoutTestCase(String name) { public void setUp() { root = Logger.getRootLogger(); + root.setLevel(Level.TRACE); logger = Logger.getLogger(XMLLayoutTestCase.class); + logger.setLevel(Level.TRACE); } public void tearDown() { @@ -42,8 +62,14 @@ public void basic() throws Exception { XMLLayout xmlLayout = new XMLLayout(); root.addAppender(new FileAppender(xmlLayout, TEMP, false)); common(); - Transformer.transform(TEMP, FILTERED, new Filter[] {new LineNumberFilter(), - new XMLTimestampFilter()}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + new LineNumberFilter(), + new XMLTimestampFilter(), + new JunitTestRunnerFilter(), + new SunReflectFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/xmlLayout.1")); } @@ -52,26 +78,138 @@ public void locationInfo() throws Exception { xmlLayout.setLocationInfo(true); root.addAppender(new FileAppender(xmlLayout, TEMP, false)); common(); - Transformer.transform(TEMP, FILTERED, new Filter[] {new LineNumberFilter(), - new XMLTimestampFilter(), - new XMLLineAttributeFilter()}); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + new LineNumberFilter(), + new XMLTimestampFilter(), + new XMLLineAttributeFilter(), + new JunitTestRunnerFilter(), + new SunReflectFilter() + }); assertTrue(Compare.compare(FILTERED, "witness/xmlLayout.2")); } + public void testCDATA() throws Exception { + XMLLayout xmlLayout = new XMLLayout(); + xmlLayout.setLocationInfo(true); + root.addAppender(new FileAppender(xmlLayout, TEMP, false)); + + String oldThreadName = Thread.currentThread().getName(); + Thread.currentThread().setName("main"); + + logger.trace("Message with embedded hi]]>."); + logger.debug("Message with embedded hi]]>."); + + Thread.currentThread().setName(oldThreadName); + + Transformer.transform( + TEMP, FILTERED, + new Filter[] { + new LineNumberFilter(), + new XMLTimestampFilter(), + new XMLLineAttributeFilter(), + new SunReflectFilter(), + new JunitTestRunnerFilter() + + }); + Transformer.transform(TEMP, FILTERED, new Filter[] {new LineNumberFilter(), + new XMLTimestampFilter(), + new XMLLineAttributeFilter()}); + assertTrue(Compare.compare(FILTERED, "witness/xmlLayout.3")); + } + + public void testNull() throws Exception { + XMLLayout xmlLayout = new XMLLayout(); + root.addAppender(new FileAppender(xmlLayout, TEMP, false)); + + String oldThreadName = Thread.currentThread().getName(); + Thread.currentThread().setName("main"); + + logger.debug("hi"); + logger.debug(null); + Exception e = new Exception((String) null); + logger.debug("hi", e); + + Thread.currentThread().setName(oldThreadName); + + Transformer.transform( + TEMP, FILTERED, + new Filter[] { new LineNumberFilter(), + new XMLTimestampFilter(), + new JunitTestRunnerFilter(), + new SunReflectFilter()}); + assertTrue(Compare.compare(FILTERED, "witness/xmlLayout.null")); + } + + /** + * Tests the format of the MDC portion of the layout to ensure + * the key-value pairs we put in turn up in the output file. + * @throws Exception + */ + public void testMDC() throws Exception { + XMLLayout xmlLayout = new XMLLayout(); + xmlLayout.setProperties(true); + root.addAppender(new FileAppender(xmlLayout, TEMP, false)); + + Hashtable context = MDC.getContext(); + if (context != null) { + context.clear(); + } + MDC.put("key1", "val1"); + MDC.put("key2", "val2"); + + logger.debug("Hello"); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { new LineNumberFilter(), + new JunitTestRunnerFilter(), + new XMLTimestampFilter()}); + assertTrue(Compare.compare(FILTERED, "witness/xmlLayout.mdc.1")); + } + + public void testMDCEscaped() throws Exception { + XMLLayout xmlLayout = new XMLLayout(); + xmlLayout.setProperties(true); + root.addAppender(new FileAppender(xmlLayout, TEMP, false)); + + Hashtable context = MDC.getContext(); + if (context != null) { + context.clear(); + } + MDC.put("blahAttribute", ""); + MDC.put("", "blahValue"); + + logger.debug("Hello"); + Transformer.transform( + TEMP, FILTERED, + new Filter[] { new LineNumberFilter(), + new JunitTestRunnerFilter(), + new XMLTimestampFilter() }); + assertTrue(Compare.compare(FILTERED, "witness/xmlLayout.mdc.2")); + } + + void common() { + String oldThreadName = Thread.currentThread().getName(); + Thread.currentThread().setName("main"); + int i = -1; - X x = new X(); + new X(); + + logger.trace("Message " + ++i); + root.trace("Message " + i); logger.debug("Message " + ++i); root.debug("Message " + i); - logger.info ("Message " + ++i); + logger.info("Message " + ++i); root.info("Message " + i); logger.warn ("Message " + ++i); root.warn("Message " + i); - + logger.error("Message " + ++i); root.error("Message " + i); @@ -85,12 +223,18 @@ void common() { logger.error("Message " + ++i, e); root.error("Message " + i, e); + + Thread.currentThread().setName(oldThreadName); } public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(new XMLLayoutTestCase("basic")); suite.addTest(new XMLLayoutTestCase("locationInfo")); + suite.addTest(new XMLLayoutTestCase("testCDATA")); + suite.addTest(new XMLLayoutTestCase("testNull")); + suite.addTest(new XMLLayoutTestCase("testMDC")); + suite.addTest(new XMLLayoutTestCase("testMDCEscaped")); return suite; } diff --git a/tests/sun_checks.xml b/tests/sun_checks.xml new file mode 100644 index 0000000000..2385ae1c3f --- /dev/null +++ b/tests/sun_checks.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/witness/LevelMatchFilter_accept b/tests/witness/LevelMatchFilter_accept index a6a4d484a5..14c0b245bc 100644 --- a/tests/witness/LevelMatchFilter_accept +++ b/tests/witness/LevelMatchFilter_accept @@ -1,5 +1,6 @@ -DEBUG - pass 0; filter set to accept only DEBUG msgs -INFO - pass 1; filter set to accept only INFO msgs -WARN - pass 2; filter set to accept only WARN msgs -ERROR - pass 3; filter set to accept only ERROR msgs -FATAL - pass 4; filter set to accept only FATAL msgs +TRACE - pass 0; filter set to accept only TRACE msgs +DEBUG - pass 1; filter set to accept only DEBUG msgs +INFO - pass 2; filter set to accept only INFO msgs +WARN - pass 3; filter set to accept only WARN msgs +ERROR - pass 4; filter set to accept only ERROR msgs +FATAL - pass 5; filter set to accept only FATAL msgs diff --git a/tests/witness/LevelMatchFilter_deny b/tests/witness/LevelMatchFilter_deny index 5273424d4c..3755855736 100644 --- a/tests/witness/LevelMatchFilter_deny +++ b/tests/witness/LevelMatchFilter_deny @@ -1,20 +1,30 @@ -INFO - pass 0; filter set to deny only DEBUG msgs -WARN - pass 0; filter set to deny only DEBUG msgs -ERROR - pass 0; filter set to deny only DEBUG msgs -FATAL - pass 0; filter set to deny only DEBUG msgs -DEBUG - pass 1; filter set to deny only INFO msgs -WARN - pass 1; filter set to deny only INFO msgs -ERROR - pass 1; filter set to deny only INFO msgs -FATAL - pass 1; filter set to deny only INFO msgs -DEBUG - pass 2; filter set to deny only WARN msgs -INFO - pass 2; filter set to deny only WARN msgs -ERROR - pass 2; filter set to deny only WARN msgs -FATAL - pass 2; filter set to deny only WARN msgs -DEBUG - pass 3; filter set to deny only ERROR msgs -INFO - pass 3; filter set to deny only ERROR msgs -WARN - pass 3; filter set to deny only ERROR msgs -FATAL - pass 3; filter set to deny only ERROR msgs -DEBUG - pass 4; filter set to deny only FATAL msgs -INFO - pass 4; filter set to deny only FATAL msgs -WARN - pass 4; filter set to deny only FATAL msgs -ERROR - pass 4; filter set to deny only FATAL msgs +DEBUG - pass 0; filter set to deny only TRACE msgs +INFO - pass 0; filter set to deny only TRACE msgs +WARN - pass 0; filter set to deny only TRACE msgs +ERROR - pass 0; filter set to deny only TRACE msgs +FATAL - pass 0; filter set to deny only TRACE msgs +TRACE - pass 1; filter set to deny only DEBUG msgs +INFO - pass 1; filter set to deny only DEBUG msgs +WARN - pass 1; filter set to deny only DEBUG msgs +ERROR - pass 1; filter set to deny only DEBUG msgs +FATAL - pass 1; filter set to deny only DEBUG msgs +TRACE - pass 2; filter set to deny only INFO msgs +DEBUG - pass 2; filter set to deny only INFO msgs +WARN - pass 2; filter set to deny only INFO msgs +ERROR - pass 2; filter set to deny only INFO msgs +FATAL - pass 2; filter set to deny only INFO msgs +TRACE - pass 3; filter set to deny only WARN msgs +DEBUG - pass 3; filter set to deny only WARN msgs +INFO - pass 3; filter set to deny only WARN msgs +ERROR - pass 3; filter set to deny only WARN msgs +FATAL - pass 3; filter set to deny only WARN msgs +TRACE - pass 4; filter set to deny only ERROR msgs +DEBUG - pass 4; filter set to deny only ERROR msgs +INFO - pass 4; filter set to deny only ERROR msgs +WARN - pass 4; filter set to deny only ERROR msgs +FATAL - pass 4; filter set to deny only ERROR msgs +TRACE - pass 5; filter set to deny only FATAL msgs +DEBUG - pass 5; filter set to deny only FATAL msgs +INFO - pass 5; filter set to deny only FATAL msgs +WARN - pass 5; filter set to deny only FATAL msgs +ERROR - pass 5; filter set to deny only FATAL msgs diff --git a/tests/witness/PatternParser_mdc b/tests/witness/PatternParser_mdc new file mode 100644 index 0000000000..6960248522 --- /dev/null +++ b/tests/witness/PatternParser_mdc @@ -0,0 +1,12 @@ +starting mdc pattern test +empty mdc, no key specified in pattern : +empty mdc, key1 in pattern : +empty mdc, key2 in pattern : +empty mdc, key3 in pattern : +empty mdc, key1, key2, and key3 in pattern : ,, +filled mdc, no key specified in pattern : +filled mdc, key1 in pattern : value1 +filled mdc, key2 in pattern : value2 +filled mdc, key3 in pattern : +filled mdc, key1, key2, and key3 in pattern : value1,value2, +finished mdc pattern test diff --git a/tests/witness/customLogger.1 b/tests/witness/customLogger.1 index 57095c1e46..5697b70dea 100644 --- a/tests/witness/customLogger.1 +++ b/tests/witness/customLogger.1 @@ -7,7 +7,6 @@ DEBUG customLogger.XLoggerTestCase - Message 5 java.lang.Exception: Just testing at org.apache.log4j.customLogger.XLoggerTestCase.common(XLoggerTestCase.java:XXX) at org.apache.log4j.customLogger.XLoggerTestCase.test1(XLoggerTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -16,5 +15,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/dom.A1.1 b/tests/witness/dom.A1.1 index d8b3acceba..0c619b6a1a 100644 --- a/tests/witness/dom.A1.1 +++ b/tests/witness/dom.A1.1 @@ -1,23 +1,25 @@ -DEBUG xml.DOMTestCase - Message 0 -DEBUG xml.DOMTestCase - Message 0 -DEBUG root - Message 0 -INFO xml.DOMTestCase - Message 1 -INFO xml.DOMTestCase - Message 1 -INFO root - Message 1 -WARN xml.DOMTestCase - Message 2 -WARN xml.DOMTestCase - Message 2 -WARN root - Message 2 -ERROR xml.DOMTestCase - Message 3 -ERROR xml.DOMTestCase - Message 3 -ERROR root - Message 3 -FATAL xml.DOMTestCase - Message 4 -FATAL xml.DOMTestCase - Message 4 -FATAL root - Message 4 -DEBUG xml.DOMTestCase - Message 5 +TRACE xml.DOMTestCase - Message 0 +TRACE xml.DOMTestCase - Message 0 +TRACE root - Message 0 +DEBUG xml.DOMTestCase - Message 1 +DEBUG xml.DOMTestCase - Message 1 +DEBUG root - Message 1 +INFO xml.DOMTestCase - Message 2 +INFO xml.DOMTestCase - Message 2 +INFO root - Message 2 +WARN xml.DOMTestCase - Message 3 +WARN xml.DOMTestCase - Message 3 +WARN root - Message 3 +ERROR xml.DOMTestCase - Message 4 +ERROR xml.DOMTestCase - Message 4 +ERROR root - Message 4 +FATAL xml.DOMTestCase - Message 5 +FATAL xml.DOMTestCase - Message 5 +FATAL root - Message 5 +DEBUG xml.DOMTestCase - Message 6 java.lang.Exception: Just testing at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) at org.apache.log4j.xml.DOMTestCase.test1(DOMTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -26,13 +28,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -DEBUG xml.DOMTestCase - Message 5 +DEBUG xml.DOMTestCase - Message 6 java.lang.Exception: Just testing at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) at org.apache.log4j.xml.DOMTestCase.test1(DOMTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -41,13 +40,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -DEBUG root - Message 5 +DEBUG root - Message 6 java.lang.Exception: Just testing at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) at org.apache.log4j.xml.DOMTestCase.test1(DOMTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -56,13 +52,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -ERROR xml.DOMTestCase - Message 6 +ERROR xml.DOMTestCase - Message 7 java.lang.Exception: Just testing at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) at org.apache.log4j.xml.DOMTestCase.test1(DOMTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -71,13 +64,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -ERROR xml.DOMTestCase - Message 6 +ERROR xml.DOMTestCase - Message 7 java.lang.Exception: Just testing at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) at org.apache.log4j.xml.DOMTestCase.test1(DOMTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -86,13 +76,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -ERROR root - Message 6 +ERROR root - Message 7 java.lang.Exception: Just testing at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) at org.apache.log4j.xml.DOMTestCase.test1(DOMTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -101,5 +88,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/dom.A1.4 b/tests/witness/dom.A1.4 new file mode 100644 index 0000000000..5e961105d4 --- /dev/null +++ b/tests/witness/dom.A1.4 @@ -0,0 +1,90 @@ +TRACE xml.DOMTestCase - Message 0 +TRACE xml.DOMTestCase - Message 0 +TRACE root - Message 0 +DEBUG xml.DOMTestCase - Message 1 +DEBUG xml.DOMTestCase - Message 1 +DEBUG root - Message 1 +INFO xml.DOMTestCase - Message 2 +INFO xml.DOMTestCase - Message 2 +INFO root - Message 2 +WARN xml.DOMTestCase - Message 3 +WARN xml.DOMTestCase - Message 3 +WARN root - Message 3 +ERROR xml.DOMTestCase - Message 4 +ERROR xml.DOMTestCase - Message 4 +ERROR root - Message 4 +FATAL xml.DOMTestCase - Message 5 +FATAL xml.DOMTestCase - Message 5 +FATAL root - Message 5 +DEBUG xml.DOMTestCase - Message 6 +java.lang.Exception: Just testing + at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) + at org.apache.log4j.xml.DOMTestCase.test4(DOMTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +DEBUG xml.DOMTestCase - Message 6 +java.lang.Exception: Just testing + at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) + at org.apache.log4j.xml.DOMTestCase.test4(DOMTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +DEBUG root - Message 6 +java.lang.Exception: Just testing + at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) + at org.apache.log4j.xml.DOMTestCase.test4(DOMTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +ERROR xml.DOMTestCase - Message 7 +java.lang.Exception: Just testing + at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) + at org.apache.log4j.xml.DOMTestCase.test4(DOMTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +ERROR xml.DOMTestCase - Message 7 +java.lang.Exception: Just testing + at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) + at org.apache.log4j.xml.DOMTestCase.test4(DOMTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +ERROR root - Message 7 +java.lang.Exception: Just testing + at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) + at org.apache.log4j.xml.DOMTestCase.test4(DOMTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) diff --git a/tests/witness/dom.A2.1 b/tests/witness/dom.A2.1 index 6c84658d1c..e04b617d85 100644 --- a/tests/witness/dom.A2.1 +++ b/tests/witness/dom.A2.1 @@ -1,18 +1,19 @@ - [main] DEBUG org.apache.log4j.xml.DOMTestCase - Message 0 - [main] DEBUG root - Message 0 - [main] INFO org.apache.log4j.xml.DOMTestCase - Message 1 - [main] INFO root - Message 1 - [main] WARN org.apache.log4j.xml.DOMTestCase - Message 2 - [main] WARN root - Message 2 - [main] ERROR org.apache.log4j.xml.DOMTestCase - Message 3 - [main] ERROR root - Message 3 - [main] FATAL org.apache.log4j.xml.DOMTestCase - Message 4 - [main] FATAL root - Message 4 - [main] DEBUG org.apache.log4j.xml.DOMTestCase - Message 5 + [main] TRACE org.apache.log4j.xml.DOMTestCase - Message 0 + [main] TRACE root - Message 0 + [main] DEBUG org.apache.log4j.xml.DOMTestCase - Message 1 + [main] DEBUG root - Message 1 + [main] INFO org.apache.log4j.xml.DOMTestCase - Message 2 + [main] INFO root - Message 2 + [main] WARN org.apache.log4j.xml.DOMTestCase - Message 3 + [main] WARN root - Message 3 + [main] ERROR org.apache.log4j.xml.DOMTestCase - Message 4 + [main] ERROR root - Message 4 + [main] FATAL org.apache.log4j.xml.DOMTestCase - Message 5 + [main] FATAL root - Message 5 + [main] DEBUG org.apache.log4j.xml.DOMTestCase - Message 6 java.lang.Exception: Just testing at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) at org.apache.log4j.xml.DOMTestCase.test1(DOMTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] DEBUG root - Message 5 + [main] DEBUG root - Message 6 java.lang.Exception: Just testing at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) at org.apache.log4j.xml.DOMTestCase.test1(DOMTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] ERROR org.apache.log4j.xml.DOMTestCase - Message 6 + [main] ERROR org.apache.log4j.xml.DOMTestCase - Message 7 java.lang.Exception: Just testing at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) at org.apache.log4j.xml.DOMTestCase.test1(DOMTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] ERROR root - Message 6 + [main] ERROR root - Message 7 java.lang.Exception: Just testing at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) at org.apache.log4j.xml.DOMTestCase.test1(DOMTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,5 +58,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/dom.A2.4 b/tests/witness/dom.A2.4 new file mode 100644 index 0000000000..6444feeeb7 --- /dev/null +++ b/tests/witness/dom.A2.4 @@ -0,0 +1,60 @@ + [main] TRACE org.apache.log4j.xml.DOMTestCase - Message 0 + [main] TRACE root - Message 0 + [main] DEBUG org.apache.log4j.xml.DOMTestCase - Message 1 + [main] DEBUG root - Message 1 + [main] INFO org.apache.log4j.xml.DOMTestCase - Message 2 + [main] INFO root - Message 2 + [main] WARN org.apache.log4j.xml.DOMTestCase - Message 3 + [main] WARN root - Message 3 + [main] ERROR org.apache.log4j.xml.DOMTestCase - Message 4 + [main] ERROR root - Message 4 + [main] FATAL org.apache.log4j.xml.DOMTestCase - Message 5 + [main] FATAL root - Message 5 + [main] DEBUG org.apache.log4j.xml.DOMTestCase - Message 6 +java.lang.Exception: Just testing + at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) + at org.apache.log4j.xml.DOMTestCase.test4(DOMTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) + [main] DEBUG root - Message 6 +java.lang.Exception: Just testing + at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) + at org.apache.log4j.xml.DOMTestCase.test4(DOMTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) + [main] ERROR org.apache.log4j.xml.DOMTestCase - Message 7 +java.lang.Exception: Just testing + at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) + at org.apache.log4j.xml.DOMTestCase.test4(DOMTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) + [main] ERROR root - Message 7 +java.lang.Exception: Just testing + at org.apache.log4j.xml.DOMTestCase.common(DOMTestCase.java:XXX) + at org.apache.log4j.xml.DOMTestCase.test4(DOMTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) diff --git a/tests/witness/patternLayout.1 b/tests/witness/patternLayout.1 index 52457f3e5c..263f242977 100644 --- a/tests/witness/patternLayout.1 +++ b/tests/witness/patternLayout.1 @@ -1,18 +1,19 @@ -DEBUG - Message 0 -DEBUG - Message 0 -INFO - Message 1 -INFO - Message 1 -WARN - Message 2 -WARN - Message 2 -ERROR - Message 3 -ERROR - Message 3 -FATAL - Message 4 -FATAL - Message 4 -DEBUG - Message 5 +TRACE - Message 0 +TRACE - Message 0 +DEBUG - Message 1 +DEBUG - Message 1 +INFO - Message 2 +INFO - Message 2 +WARN - Message 3 +WARN - Message 3 +ERROR - Message 4 +ERROR - Message 4 +FATAL - Message 5 +FATAL - Message 5 +TRACE - Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test1(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -INFO - Message 6 +DEBUG - Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test1(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -WARN - Message 7 +INFO - Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test1(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -ERROR - Message 8 +WARN - Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test1(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -FATAL - Message 9 +ERROR - Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test1(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +FATAL - Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test1(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.10 b/tests/witness/patternLayout.10 index d10fb04360..46fce63db2 100644 --- a/tests/witness/patternLayout.10 +++ b/tests/witness/patternLayout.10 @@ -1,18 +1,19 @@ -[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 -[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 -[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 -[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 -[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 -[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 -[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 -[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 -[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 -[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 -[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 5 +[main] TRACE org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 +[main] TRACE org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 +[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 +[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 +[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 +[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 +[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 +[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 +[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 +[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 +[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 5 +[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 5 +[main] TRACE org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test10(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 6 +[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test10(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 7 +[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test10(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 8 +[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test10(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 9 +[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test10(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test10(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.11 b/tests/witness/patternLayout.11 index c16da56f95..6a91cc54d7 100644 --- a/tests/witness/patternLayout.11 +++ b/tests/witness/patternLayout.11 @@ -1,18 +1,19 @@ -DEBUG [main] log4j.PatternLayoutTestCase: Message 0 -DEBUG [main] root: Message 0 -INFO [main] log4j.PatternLayoutTestCase: Message 1 -INFO [main] root: Message 1 -WARN [main] log4j.PatternLayoutTestCase: Message 2 -WARN [main] root: Message 2 -ERROR [main] log4j.PatternLayoutTestCase: Message 3 -ERROR [main] root: Message 3 -FATAL [main] log4j.PatternLayoutTestCase: Message 4 -FATAL [main] root: Message 4 -DEBUG [main] log4j.PatternLayoutTestCase: Message 5 +TRACE [main] log4j.PatternLayoutTestCase: Message 0 +TRACE [main] root: Message 0 +DEBUG [main] log4j.PatternLayoutTestCase: Message 1 +DEBUG [main] root: Message 1 +INFO [main] log4j.PatternLayoutTestCase: Message 2 +INFO [main] root: Message 2 +WARN [main] log4j.PatternLayoutTestCase: Message 3 +WARN [main] root: Message 3 +ERROR [main] log4j.PatternLayoutTestCase: Message 4 +ERROR [main] root: Message 4 +FATAL [main] log4j.PatternLayoutTestCase: Message 5 +FATAL [main] root: Message 5 +TRACE [main] log4j.PatternLayoutTestCase: Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test11(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -INFO [main] log4j.PatternLayoutTestCase: Message 6 +DEBUG [main] log4j.PatternLayoutTestCase: Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test11(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -WARN [main] log4j.PatternLayoutTestCase: Message 7 +INFO [main] log4j.PatternLayoutTestCase: Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test11(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -ERROR [main] log4j.PatternLayoutTestCase: Message 8 +WARN [main] log4j.PatternLayoutTestCase: Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test11(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -FATAL [main] log4j.PatternLayoutTestCase: Message 9 +ERROR [main] log4j.PatternLayoutTestCase: Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test11(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +FATAL [main] log4j.PatternLayoutTestCase: Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test11(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.12 b/tests/witness/patternLayout.12 index 5e84eb5338..374f54a6bf 100644 --- a/tests/witness/patternLayout.12 +++ b/tests/witness/patternLayout.12 @@ -1,18 +1,19 @@ -[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 -[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 -[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 -[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 -[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 -[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 -[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 -[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 -[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 -[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 -[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 5 +[main] TRACE org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 +[main] TRACE org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 +[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 +[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 +[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 +[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 +[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 +[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 +[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 +[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 +[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 5 +[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 5 +[main] TRACE org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test12(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 6 +[main] DEBUG org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test12(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 7 +[main] INFO org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test12(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 8 +[main] WARN org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test12(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 9 +[main] ERROR org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test12(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +[main] FATAL org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test12(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.13 b/tests/witness/patternLayout.13 index db6d8917b4..a359f35761 100644 --- a/tests/witness/patternLayout.13 +++ b/tests/witness/patternLayout.13 @@ -1,18 +1,19 @@ -[main] DEBUG apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 -[main] DEBUG apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 -[main] INFO apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 -[main] INFO apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 -[main] WARN apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 -[main] WARN apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 -[main] ERROR apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 -[main] ERROR apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 -[main] FATAL apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 -[main] FATAL apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 -[main] DEBUG apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 5 +[main] TRACE apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 +[main] TRACE apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 0 +[main] DEBUG apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 +[main] DEBUG apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 1 +[main] INFO apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 +[main] INFO apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 2 +[main] WARN apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 +[main] WARN apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 3 +[main] ERROR apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 +[main] ERROR apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 4 +[main] FATAL apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 5 +[main] FATAL apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 5 +[main] TRACE apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test13(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] INFO apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 6 +[main] DEBUG apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test13(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] WARN apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 7 +[main] INFO apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test13(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] ERROR apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 8 +[main] WARN apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test13(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] FATAL apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 9 +[main] ERROR apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test13(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +[main] FATAL apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX): Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test13(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.14 b/tests/witness/patternLayout.14 index 5fb542d290..df0ebbdfa5 100644 --- a/tests/witness/patternLayout.14 +++ b/tests/witness/patternLayout.14 @@ -1,18 +1,19 @@ -DEBUG 1 - Message 0 -DEBUG 2 - Message 0 - INFO 3 - Message 1 - INFO 4 - Message 1 - WARN 5 - Message 2 - WARN 6 - Message 2 -ERROR 7 - Message 3 -ERROR 8 - Message 3 -FATAL 9 - Message 4 -FATAL 10 - Message 4 -DEBUG 11 - Message 5 +TRACE 1 - Message 0 +TRACE 2 - Message 0 +DEBUG 3 - Message 1 +DEBUG 4 - Message 1 + INFO 5 - Message 2 + INFO 6 - Message 2 + WARN 7 - Message 3 + WARN 8 - Message 3 +ERROR 9 - Message 4 +ERROR 10 - Message 4 +FATAL 11 - Message 5 +FATAL 12 - Message 5 +TRACE 13 - Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test14(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - INFO 12 - Message 6 +DEBUG 14 - Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test14(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - WARN 13 - Message 7 + INFO 15 - Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test14(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -ERROR 14 - Message 8 + WARN 16 - Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test14(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -FATAL 15 - Message 9 +ERROR 17 - Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test14(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +FATAL 18 - Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test14(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.2 b/tests/witness/patternLayout.2 index b79c74fcb5..82e6336909 100644 --- a/tests/witness/patternLayout.2 +++ b/tests/witness/patternLayout.2 @@ -1,18 +1,19 @@ - [main] DEBUG rnLayoutTestCase - Message 0 - [main] DEBUG root - Message 0 - [main] INFO rnLayoutTestCase - Message 1 - [main] INFO root - Message 1 - [main] WARN rnLayoutTestCase - Message 2 - [main] WARN root - Message 2 - [main] ERROR rnLayoutTestCase - Message 3 - [main] ERROR root - Message 3 - [main] FATAL rnLayoutTestCase - Message 4 - [main] FATAL root - Message 4 - [main] DEBUG rnLayoutTestCase - Message 5 + [main] TRACE rnLayoutTestCase - Message 0 + [main] TRACE root - Message 0 + [main] DEBUG rnLayoutTestCase - Message 1 + [main] DEBUG root - Message 1 + [main] INFO rnLayoutTestCase - Message 2 + [main] INFO root - Message 2 + [main] WARN rnLayoutTestCase - Message 3 + [main] WARN root - Message 3 + [main] ERROR rnLayoutTestCase - Message 4 + [main] ERROR root - Message 4 + [main] FATAL rnLayoutTestCase - Message 5 + [main] FATAL root - Message 5 + [main] TRACE rnLayoutTestCase - Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test2(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] INFO rnLayoutTestCase - Message 6 + [main] DEBUG rnLayoutTestCase - Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test2(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] WARN rnLayoutTestCase - Message 7 + [main] INFO rnLayoutTestCase - Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test2(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] ERROR rnLayoutTestCase - Message 8 + [main] WARN rnLayoutTestCase - Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test2(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] FATAL rnLayoutTestCase - Message 9 + [main] ERROR rnLayoutTestCase - Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test2(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) + [main] FATAL rnLayoutTestCase - Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test2(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.3 b/tests/witness/patternLayout.3 index c48f7ab4ac..b30661136a 100644 --- a/tests/witness/patternLayout.3 +++ b/tests/witness/patternLayout.3 @@ -1,18 +1,19 @@ - [main] DEBUG rnLayoutTestCase - Message 0 - [main] DEBUG root - Message 0 - [main] INFO rnLayoutTestCase - Message 1 - [main] INFO root - Message 1 - [main] WARN rnLayoutTestCase - Message 2 - [main] WARN root - Message 2 - [main] ERROR rnLayoutTestCase - Message 3 - [main] ERROR root - Message 3 - [main] FATAL rnLayoutTestCase - Message 4 - [main] FATAL root - Message 4 - [main] DEBUG rnLayoutTestCase - Message 5 + [main] TRACE rnLayoutTestCase - Message 0 + [main] TRACE root - Message 0 + [main] DEBUG rnLayoutTestCase - Message 1 + [main] DEBUG root - Message 1 + [main] INFO rnLayoutTestCase - Message 2 + [main] INFO root - Message 2 + [main] WARN rnLayoutTestCase - Message 3 + [main] WARN root - Message 3 + [main] ERROR rnLayoutTestCase - Message 4 + [main] ERROR root - Message 4 + [main] FATAL rnLayoutTestCase - Message 5 + [main] FATAL root - Message 5 + [main] TRACE rnLayoutTestCase - Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test3(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] INFO rnLayoutTestCase - Message 6 + [main] DEBUG rnLayoutTestCase - Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test3(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] WARN rnLayoutTestCase - Message 7 + [main] INFO rnLayoutTestCase - Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test3(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] ERROR rnLayoutTestCase - Message 8 + [main] WARN rnLayoutTestCase - Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test3(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] FATAL rnLayoutTestCase - Message 9 + [main] ERROR rnLayoutTestCase - Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test3(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) + [main] FATAL rnLayoutTestCase - Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test3(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.4 b/tests/witness/patternLayout.4 index 732f208ebd..b807e55b95 100644 --- a/tests/witness/patternLayout.4 +++ b/tests/witness/patternLayout.4 @@ -1,18 +1,19 @@ - [main] DEBUG rnLayoutTestCase - Message 0 - [main] DEBUG root - Message 0 - [main] INFO rnLayoutTestCase - Message 1 - [main] INFO root - Message 1 - [main] WARN rnLayoutTestCase - Message 2 - [main] WARN root - Message 2 - [main] ERROR rnLayoutTestCase - Message 3 - [main] ERROR root - Message 3 - [main] FATAL rnLayoutTestCase - Message 4 - [main] FATAL root - Message 4 - [main] DEBUG rnLayoutTestCase - Message 5 + [main] TRACE rnLayoutTestCase - Message 0 + [main] TRACE root - Message 0 + [main] DEBUG rnLayoutTestCase - Message 1 + [main] DEBUG root - Message 1 + [main] INFO rnLayoutTestCase - Message 2 + [main] INFO root - Message 2 + [main] WARN rnLayoutTestCase - Message 3 + [main] WARN root - Message 3 + [main] ERROR rnLayoutTestCase - Message 4 + [main] ERROR root - Message 4 + [main] FATAL rnLayoutTestCase - Message 5 + [main] FATAL root - Message 5 + [main] TRACE rnLayoutTestCase - Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test4(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] INFO rnLayoutTestCase - Message 6 + [main] DEBUG rnLayoutTestCase - Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test4(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] WARN rnLayoutTestCase - Message 7 + [main] INFO rnLayoutTestCase - Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test4(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] ERROR rnLayoutTestCase - Message 8 + [main] WARN rnLayoutTestCase - Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test4(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] FATAL rnLayoutTestCase - Message 9 + [main] ERROR rnLayoutTestCase - Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test4(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) + [main] FATAL rnLayoutTestCase - Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test4(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.5 b/tests/witness/patternLayout.5 index 20f52e9ee3..e45c5cbc03 100644 --- a/tests/witness/patternLayout.5 +++ b/tests/witness/patternLayout.5 @@ -1,18 +1,19 @@ - [main] DEBUG rnLayoutTestCase - Message 0 - [main] DEBUG root - Message 0 - [main] INFO rnLayoutTestCase - Message 1 - [main] INFO root - Message 1 - [main] WARN rnLayoutTestCase - Message 2 - [main] WARN root - Message 2 - [main] ERROR rnLayoutTestCase - Message 3 - [main] ERROR root - Message 3 - [main] FATAL rnLayoutTestCase - Message 4 - [main] FATAL root - Message 4 - [main] DEBUG rnLayoutTestCase - Message 5 + [main] TRACE rnLayoutTestCase - Message 0 + [main] TRACE root - Message 0 + [main] DEBUG rnLayoutTestCase - Message 1 + [main] DEBUG root - Message 1 + [main] INFO rnLayoutTestCase - Message 2 + [main] INFO root - Message 2 + [main] WARN rnLayoutTestCase - Message 3 + [main] WARN root - Message 3 + [main] ERROR rnLayoutTestCase - Message 4 + [main] ERROR root - Message 4 + [main] FATAL rnLayoutTestCase - Message 5 + [main] FATAL root - Message 5 + [main] TRACE rnLayoutTestCase - Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test5(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] INFO rnLayoutTestCase - Message 6 + [main] DEBUG rnLayoutTestCase - Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test5(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] WARN rnLayoutTestCase - Message 7 + [main] INFO rnLayoutTestCase - Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test5(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] ERROR rnLayoutTestCase - Message 8 + [main] WARN rnLayoutTestCase - Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test5(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] FATAL rnLayoutTestCase - Message 9 + [main] ERROR rnLayoutTestCase - Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test5(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) + [main] FATAL rnLayoutTestCase - Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test5(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.6 b/tests/witness/patternLayout.6 index acaf3a25e5..6140e468ea 100644 --- a/tests/witness/patternLayout.6 +++ b/tests/witness/patternLayout.6 @@ -1,18 +1,19 @@ - [main] DEBUG rnLayoutTestCase - Message 0 - [main] DEBUG root - Message 0 - [main] INFO rnLayoutTestCase - Message 1 - [main] INFO root - Message 1 - [main] WARN rnLayoutTestCase - Message 2 - [main] WARN root - Message 2 - [main] ERROR rnLayoutTestCase - Message 3 - [main] ERROR root - Message 3 - [main] FATAL rnLayoutTestCase - Message 4 - [main] FATAL root - Message 4 - [main] DEBUG rnLayoutTestCase - Message 5 + [main] TRACE rnLayoutTestCase - Message 0 + [main] TRACE root - Message 0 + [main] DEBUG rnLayoutTestCase - Message 1 + [main] DEBUG root - Message 1 + [main] INFO rnLayoutTestCase - Message 2 + [main] INFO root - Message 2 + [main] WARN rnLayoutTestCase - Message 3 + [main] WARN root - Message 3 + [main] ERROR rnLayoutTestCase - Message 4 + [main] ERROR root - Message 4 + [main] FATAL rnLayoutTestCase - Message 5 + [main] FATAL root - Message 5 + [main] TRACE rnLayoutTestCase - Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test6(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] INFO rnLayoutTestCase - Message 6 + [main] DEBUG rnLayoutTestCase - Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test6(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] WARN rnLayoutTestCase - Message 7 + [main] INFO rnLayoutTestCase - Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test6(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] ERROR rnLayoutTestCase - Message 8 + [main] WARN rnLayoutTestCase - Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test6(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] FATAL rnLayoutTestCase - Message 9 + [main] ERROR rnLayoutTestCase - Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test6(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) + [main] FATAL rnLayoutTestCase - Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test6(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.7 b/tests/witness/patternLayout.7 index 2f600070fc..7a802bc49d 100644 --- a/tests/witness/patternLayout.7 +++ b/tests/witness/patternLayout.7 @@ -1,18 +1,19 @@ - [main] DEBUG rnLayoutTestCase - Message 0 - [main] DEBUG root - Message 0 - [main] INFO rnLayoutTestCase - Message 1 - [main] INFO root - Message 1 - [main] WARN rnLayoutTestCase - Message 2 - [main] WARN root - Message 2 - [main] ERROR rnLayoutTestCase - Message 3 - [main] ERROR root - Message 3 - [main] FATAL rnLayoutTestCase - Message 4 - [main] FATAL root - Message 4 - [main] DEBUG rnLayoutTestCase - Message 5 + [main] TRACE rnLayoutTestCase - Message 0 + [main] TRACE root - Message 0 + [main] DEBUG rnLayoutTestCase - Message 1 + [main] DEBUG root - Message 1 + [main] INFO rnLayoutTestCase - Message 2 + [main] INFO root - Message 2 + [main] WARN rnLayoutTestCase - Message 3 + [main] WARN root - Message 3 + [main] ERROR rnLayoutTestCase - Message 4 + [main] ERROR root - Message 4 + [main] FATAL rnLayoutTestCase - Message 5 + [main] FATAL root - Message 5 + [main] TRACE rnLayoutTestCase - Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test7(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] INFO rnLayoutTestCase - Message 6 + [main] DEBUG rnLayoutTestCase - Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test7(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] WARN rnLayoutTestCase - Message 7 + [main] INFO rnLayoutTestCase - Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test7(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] ERROR rnLayoutTestCase - Message 8 + [main] WARN rnLayoutTestCase - Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test7(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] FATAL rnLayoutTestCase - Message 9 + [main] ERROR rnLayoutTestCase - Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test7(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) + [main] FATAL rnLayoutTestCase - Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test7(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.8 b/tests/witness/patternLayout.8 index eaf7c79cba..30cb5cb584 100644 --- a/tests/witness/patternLayout.8 +++ b/tests/witness/patternLayout.8 @@ -1,18 +1,19 @@ - [main] DEBUG rnLayoutTestCase - Message 0 - [main] DEBUG root - Message 0 - [main] INFO rnLayoutTestCase - Message 1 - [main] INFO root - Message 1 - [main] WARN rnLayoutTestCase - Message 2 - [main] WARN root - Message 2 - [main] ERROR rnLayoutTestCase - Message 3 - [main] ERROR root - Message 3 - [main] FATAL rnLayoutTestCase - Message 4 - [main] FATAL root - Message 4 - [main] DEBUG rnLayoutTestCase - Message 5 + [main] TRACE rnLayoutTestCase - Message 0 + [main] TRACE root - Message 0 + [main] DEBUG rnLayoutTestCase - Message 1 + [main] DEBUG root - Message 1 + [main] INFO rnLayoutTestCase - Message 2 + [main] INFO root - Message 2 + [main] WARN rnLayoutTestCase - Message 3 + [main] WARN root - Message 3 + [main] ERROR rnLayoutTestCase - Message 4 + [main] ERROR root - Message 4 + [main] FATAL rnLayoutTestCase - Message 5 + [main] FATAL root - Message 5 + [main] TRACE rnLayoutTestCase - Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test8(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] INFO rnLayoutTestCase - Message 6 + [main] DEBUG rnLayoutTestCase - Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test8(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] WARN rnLayoutTestCase - Message 7 + [main] INFO rnLayoutTestCase - Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test8(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] ERROR rnLayoutTestCase - Message 8 + [main] WARN rnLayoutTestCase - Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test8(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] FATAL rnLayoutTestCase - Message 9 + [main] ERROR rnLayoutTestCase - Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test8(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) + [main] FATAL rnLayoutTestCase - Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test8(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/patternLayout.9 b/tests/witness/patternLayout.9 index cbf6c1ec94..7b54f6da0f 100644 --- a/tests/witness/patternLayout.9 +++ b/tests/witness/patternLayout.9 @@ -1,18 +1,19 @@ -[main] DEBUG rnLayoutTestCase : Message 0 -[main] DEBUG root : Message 0 -[main] INFO rnLayoutTestCase : Message 1 -[main] INFO root : Message 1 -[main] WARN rnLayoutTestCase : Message 2 -[main] WARN root : Message 2 -[main] ERROR rnLayoutTestCase : Message 3 -[main] ERROR root : Message 3 -[main] FATAL rnLayoutTestCase : Message 4 -[main] FATAL root : Message 4 -[main] DEBUG rnLayoutTestCase : Message 5 +[main] TRACE rnLayoutTestCase : Message 0 +[main] TRACE root : Message 0 +[main] DEBUG rnLayoutTestCase : Message 1 +[main] DEBUG root : Message 1 +[main] INFO rnLayoutTestCase : Message 2 +[main] INFO root : Message 2 +[main] WARN rnLayoutTestCase : Message 3 +[main] WARN root : Message 3 +[main] ERROR rnLayoutTestCase : Message 4 +[main] ERROR root : Message 4 +[main] FATAL rnLayoutTestCase : Message 5 +[main] FATAL root : Message 5 +[main] TRACE rnLayoutTestCase : Message 6 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test9(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -21,13 +22,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] INFO rnLayoutTestCase : Message 6 +[main] DEBUG rnLayoutTestCase : Message 7 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test9(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -36,13 +34,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] WARN rnLayoutTestCase : Message 7 +[main] INFO rnLayoutTestCase : Message 8 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test9(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -51,13 +46,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] ERROR rnLayoutTestCase : Message 8 +[main] WARN rnLayoutTestCase : Message 9 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test9(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -66,13 +58,22 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -[main] FATAL rnLayoutTestCase : Message 9 +[main] ERROR rnLayoutTestCase : Message 10 +java.lang.Exception: Just testing + at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) + at org.apache.log4j.PatternLayoutTestCase.test9(PatternLayoutTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +[main] FATAL rnLayoutTestCase : Message 11 java.lang.Exception: Just testing at org.apache.log4j.PatternLayoutTestCase.common(PatternLayoutTestCase.java:XXX) at org.apache.log4j.PatternLayoutTestCase.test9(PatternLayoutTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -81,5 +82,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/serialization/exception.bin b/tests/witness/serialization/exception.bin new file mode 100644 index 0000000000..87b0c1db0c Binary files /dev/null and b/tests/witness/serialization/exception.bin differ diff --git a/tests/witness/serialization/info.bin b/tests/witness/serialization/info.bin new file mode 100644 index 0000000000..f887f39e9b Binary files /dev/null and b/tests/witness/serialization/info.bin differ diff --git a/tests/witness/serialization/location.bin b/tests/witness/serialization/location.bin new file mode 100644 index 0000000000..c7988504f2 Binary files /dev/null and b/tests/witness/serialization/location.bin differ diff --git a/tests/witness/serialization/mdc.bin b/tests/witness/serialization/mdc.bin new file mode 100644 index 0000000000..42e994e757 Binary files /dev/null and b/tests/witness/serialization/mdc.bin differ diff --git a/tests/witness/serialization/ndc.bin b/tests/witness/serialization/ndc.bin new file mode 100644 index 0000000000..7f434550e9 Binary files /dev/null and b/tests/witness/serialization/ndc.bin differ diff --git a/tests/witness/serialization/simple.bin b/tests/witness/serialization/simple.bin new file mode 100644 index 0000000000..c31f3cffb7 Binary files /dev/null and b/tests/witness/serialization/simple.bin differ diff --git a/tests/witness/simple b/tests/witness/simple index a1fb1243d4..77cef876ab 100644 --- a/tests/witness/simple +++ b/tests/witness/simple @@ -22,10 +22,15 @@ ERROR - Message 20 WARN - Message 21 INFO - Message 22 DEBUG - Message 23 +TRACE - Message 24 +FATAL - Message 25 +ERROR - Message 26 +WARN - Message 27 +INFO - Message 28 +DEBUG - Message 29 java.lang.Exception: Just testing. at org.apache.log4j.MinimumTestCase.common(MinimumTestCase.java:XXX) at org.apache.log4j.MinimumTestCase.simple(MinimumTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -34,6 +39,4 @@ java.lang.Exception: Just testing. at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -INFO - Messages should bear numbers 0 through 23. +INFO - Messages should bear numbers 0 through 29. diff --git a/tests/witness/socketServer.1 b/tests/witness/socketServer.1 index 38a52de140..113f262eec 100644 --- a/tests/witness/socketServer.1 +++ b/tests/witness/socketServer.1 @@ -1,13 +1,14 @@ -DEBUG T1 [main] org.apache.log4j.net.SocketServerTestCase Message 1 -DEBUG T1 [main] root Message 2 - INFO T1 [main] org.apache.log4j.net.SocketServerTestCase Message 3 - WARN T1 [main] org.apache.log4j.net.SocketServerTestCase Message 4 -LETHAL T1 [main] org.apache.log4j.net.SocketServerTestCase Message 5 -DEBUG T1 [main] org.apache.log4j.net.SocketServerTestCase Message 6 +TRACE T1 [main] org.apache.log4j.net.SocketServerTestCase Message 1 +TRACE T1 [main] root Message 2 +DEBUG T1 [main] org.apache.log4j.net.SocketServerTestCase Message 3 +DEBUG T1 [main] root Message 4 + INFO T1 [main] org.apache.log4j.net.SocketServerTestCase Message 5 + WARN T1 [main] org.apache.log4j.net.SocketServerTestCase Message 6 +LETHAL T1 [main] org.apache.log4j.net.SocketServerTestCase Message 7 +DEBUG T1 [main] org.apache.log4j.net.SocketServerTestCase Message 8 java.lang.Exception: Just testing at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) at org.apache.log4j.net.SocketServerTestCase.test1(SocketServerTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -16,13 +17,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -ERROR T1 [main] root Message 7 +ERROR T1 [main] root Message 9 java.lang.Exception: Just testing at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) at org.apache.log4j.net.SocketServerTestCase.test1(SocketServerTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -31,5 +29,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/socketServer.2 b/tests/witness/socketServer.2 index 3965164a58..3ee37c1a51 100644 --- a/tests/witness/socketServer.2 +++ b/tests/witness/socketServer.2 @@ -1,13 +1,14 @@ -DEBUG T2 [main] ? (?:?) Message 1 -DEBUG T2 [main] ? (?:?) Message 2 - INFO T2 [main] ? (?:?) Message 3 - WARN T2 [main] ? (?:?) Message 4 -LETHAL T2 [main] ? (?:?) Message 5 -DEBUG T2 [main] ? (?:?) Message 6 +TRACE T2 [main] ? (?:?) Message 1 +TRACE T2 [main] ? (?:?) Message 2 +DEBUG T2 [main] ? (?:?) Message 3 +DEBUG T2 [main] ? (?:?) Message 4 + INFO T2 [main] ? (?:?) Message 5 + WARN T2 [main] ? (?:?) Message 6 +LETHAL T2 [main] ? (?:?) Message 7 +DEBUG T2 [main] ? (?:?) Message 8 java.lang.Exception: Just testing at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) at org.apache.log4j.net.SocketServerTestCase.test2(SocketServerTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -16,13 +17,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -ERROR T2 [main] ? (?:?) Message 7 +ERROR T2 [main] ? (?:?) Message 9 java.lang.Exception: Just testing at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) at org.apache.log4j.net.SocketServerTestCase.test2(SocketServerTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -31,5 +29,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/socketServer.3 b/tests/witness/socketServer.3 index 5a12cfccdc..de184bbd8c 100644 --- a/tests/witness/socketServer.3 +++ b/tests/witness/socketServer.3 @@ -1,13 +1,14 @@ -DEBUG T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 1 -DEBUG T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 2 - INFO T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 3 - WARN T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 4 -LETHAL T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 5 -DEBUG T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 6 +TRACE T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 1 +TRACE T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 2 +DEBUG T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 3 +DEBUG T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 4 + INFO T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 5 + WARN T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 6 +LETHAL T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 7 +DEBUG T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 8 java.lang.Exception: Just testing at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) at org.apache.log4j.net.SocketServerTestCase.test3(SocketServerTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -16,13 +17,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -ERROR T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 7 +ERROR T3 [main] org.apache.log4j.net.SocketServerTestCase (SocketServerTestCase.java:XXX) Message 9 java.lang.Exception: Just testing at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) at org.apache.log4j.net.SocketServerTestCase.test3(SocketServerTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -31,5 +29,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/socketServer.4 b/tests/witness/socketServer.4 index c645732ea7..69236688b4 100644 --- a/tests/witness/socketServer.4 +++ b/tests/witness/socketServer.4 @@ -1,13 +1,14 @@ -DEBUG some T4 MDC-TEST4 [main] SocketServerTestCase - Message 1 -DEBUG some T4 MDC-TEST4 [main] root - Message 2 - INFO some T4 MDC-TEST4 [main] SocketServerTestCase - Message 3 - WARN some T4 MDC-TEST4 [main] SocketServerTestCase - Message 4 -LETHAL some T4 MDC-TEST4 [main] SocketServerTestCase - Message 5 -DEBUG some T4 MDC-TEST4 [main] SocketServerTestCase - Message 6 +TRACE some T4 MDC-TEST4 [main] SocketServerTestCase - Message 1 +TRACE some T4 MDC-TEST4 [main] root - Message 2 +DEBUG some T4 MDC-TEST4 [main] SocketServerTestCase - Message 3 +DEBUG some T4 MDC-TEST4 [main] root - Message 4 + INFO some T4 MDC-TEST4 [main] SocketServerTestCase - Message 5 + WARN some T4 MDC-TEST4 [main] SocketServerTestCase - Message 6 +LETHAL some T4 MDC-TEST4 [main] SocketServerTestCase - Message 7 +DEBUG some T4 MDC-TEST4 [main] SocketServerTestCase - Message 8 java.lang.Exception: Just testing at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) at org.apache.log4j.net.SocketServerTestCase.test4(SocketServerTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -16,13 +17,10 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) -ERROR some T4 MDC-TEST4 [main] root - Message 7 +ERROR some T4 MDC-TEST4 [main] root - Message 9 java.lang.Exception: Just testing at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) at org.apache.log4j.net.SocketServerTestCase.test4(SocketServerTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -31,5 +29,3 @@ java.lang.Exception: Just testing at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) diff --git a/tests/witness/socketServer.5 b/tests/witness/socketServer.5 new file mode 100644 index 0000000000..cde6de7152 --- /dev/null +++ b/tests/witness/socketServer.5 @@ -0,0 +1,31 @@ +TRACE some5 T5 MDC-TEST5 [main] SocketServerTestCase - Message 1 +TRACE some5 T5 MDC-TEST5 [main] root - Message 2 +DEBUG some5 T5 MDC-TEST5 [main] SocketServerTestCase - Message 3 +DEBUG some5 T5 MDC-TEST5 [main] root - Message 4 + INFO some5 T5 MDC-TEST5 [main] SocketServerTestCase - Message 5 + WARN some5 T5 MDC-TEST5 [main] SocketServerTestCase - Message 6 +LETHAL some5 T5 MDC-TEST5 [main] SocketServerTestCase - Message 7 +DEBUG some5 T5 MDC-TEST5 [main] SocketServerTestCase - Message 8 +java.lang.Exception: Just testing + at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) + at org.apache.log4j.net.SocketServerTestCase.test5(SocketServerTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +ERROR some5 T5 MDC-TEST5 [main] root - Message 9 +java.lang.Exception: Just testing + at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) + at org.apache.log4j.net.SocketServerTestCase.test5(SocketServerTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) diff --git a/tests/witness/socketServer.6 b/tests/witness/socketServer.6 new file mode 100644 index 0000000000..ae9a686040 --- /dev/null +++ b/tests/witness/socketServer.6 @@ -0,0 +1,31 @@ +TRACE some6 T6 client-test6 MDC-TEST6 [main] SocketServerTestCase - Message 1 +TRACE some6 T6 client-test6 MDC-TEST6 [main] root - Message 2 +DEBUG some6 T6 client-test6 MDC-TEST6 [main] SocketServerTestCase - Message 3 +DEBUG some6 T6 client-test6 MDC-TEST6 [main] root - Message 4 + INFO some6 T6 client-test6 MDC-TEST6 [main] SocketServerTestCase - Message 5 + WARN some6 T6 client-test6 MDC-TEST6 [main] SocketServerTestCase - Message 6 +LETHAL some6 T6 client-test6 MDC-TEST6 [main] SocketServerTestCase - Message 7 +DEBUG some6 T6 client-test6 MDC-TEST6 [main] SocketServerTestCase - Message 8 +java.lang.Exception: Just testing + at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) + at org.apache.log4j.net.SocketServerTestCase.test6(SocketServerTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +ERROR some6 T6 client-test6 MDC-TEST6 [main] root - Message 9 +java.lang.Exception: Just testing + at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) + at org.apache.log4j.net.SocketServerTestCase.test6(SocketServerTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) diff --git a/tests/witness/socketServer.7 b/tests/witness/socketServer.7 new file mode 100644 index 0000000000..3ea7428cbd --- /dev/null +++ b/tests/witness/socketServer.7 @@ -0,0 +1,31 @@ +TRACE some7 T7 client-test7 MDC-TEST7 [main] SocketServerTestCase - Message 1 +TRACE some7 T7 client-test7 MDC-TEST7 [main] root - Message 2 +DEBUG some7 T7 client-test7 MDC-TEST7 [main] SocketServerTestCase - Message 3 +DEBUG some7 T7 client-test7 MDC-TEST7 [main] root - Message 4 + INFO some7 T7 client-test7 MDC-TEST7 [main] SocketServerTestCase - Message 5 + WARN some7 T7 client-test7 MDC-TEST7 [main] SocketServerTestCase - Message 6 +LETHAL some7 T7 client-test7 MDC-TEST7 [main] SocketServerTestCase - Message 7 +DEBUG some7 T7 client-test7 MDC-TEST7 [main] SocketServerTestCase - Message 8 +java.lang.Exception: Just testing + at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) + at org.apache.log4j.net.SocketServerTestCase.test7(SocketServerTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +ERROR some7 T7 client-test7 MDC-TEST7 [main] root - Message 9 +java.lang.Exception: Just testing + at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) + at org.apache.log4j.net.SocketServerTestCase.test7(SocketServerTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) diff --git a/tests/witness/socketServer.8 b/tests/witness/socketServer.8 new file mode 100644 index 0000000000..c317ac7aca --- /dev/null +++ b/tests/witness/socketServer.8 @@ -0,0 +1,31 @@ +TRACE some8 T8 shortSocketServer MDC-TEST8 [main] SocketServerTestCase - Message 1 +TRACE some8 T8 shortSocketServer MDC-TEST8 [main] root - Message 2 +DEBUG some8 T8 shortSocketServer MDC-TEST8 [main] SocketServerTestCase - Message 3 +DEBUG some8 T8 shortSocketServer MDC-TEST8 [main] root - Message 4 + INFO some8 T8 shortSocketServer MDC-TEST8 [main] SocketServerTestCase - Message 5 + WARN some8 T8 shortSocketServer MDC-TEST8 [main] SocketServerTestCase - Message 6 +LETHAL some8 T8 shortSocketServer MDC-TEST8 [main] SocketServerTestCase - Message 7 +DEBUG some8 T8 shortSocketServer MDC-TEST8 [main] SocketServerTestCase - Message 8 +java.lang.Exception: Just testing + at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) + at org.apache.log4j.net.SocketServerTestCase.test8(SocketServerTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) +ERROR some8 T8 shortSocketServer MDC-TEST8 [main] root - Message 9 +java.lang.Exception: Just testing + at org.apache.log4j.net.SocketServerTestCase.common(SocketServerTestCase.java:XXX) + at org.apache.log4j.net.SocketServerTestCase.test8(SocketServerTestCase.java:XXX) + at junit.framework.TestCase.runTest(TestCase.java:XXX) + at junit.framework.TestCase.runBare(TestCase.java:XXX) + at junit.framework.TestResult$1.protect(TestResult.java:XXX) + at junit.framework.TestResult.runProtected(TestResult.java:XXX) + at junit.framework.TestResult.run(TestResult.java:XXX) + at junit.framework.TestCase.run(TestCase.java:XXX) + at junit.framework.TestSuite.runTest(TestSuite.java:XXX) + at junit.framework.TestSuite.run(TestSuite.java:XXX) diff --git a/tests/witness/ttcc b/tests/witness/ttcc index 976984de12..43b7394cd3 100644 --- a/tests/witness/ttcc +++ b/tests/witness/ttcc @@ -17,15 +17,20 @@ [main] WARN DEB - Message 16 [main] INFO DEB - Message 17 [main] DEBUG DEB - Message 18 - [main] FATAL UNDEF - Message 19 - [main] ERROR UNDEF - Message 20 - [main] WARN UNDEF - Message 21 - [main] INFO UNDEF - Message 22 - [main] DEBUG UNDEF - Message 23 + [main] FATAL TRC - Message 19 + [main] ERROR TRC - Message 20 + [main] WARN TRC - Message 21 + [main] INFO TRC - Message 22 + [main] DEBUG TRC - Message 23 + [main] TRACE TRC - Message 24 + [main] FATAL UNDEF - Message 25 + [main] ERROR UNDEF - Message 26 + [main] WARN UNDEF - Message 27 + [main] INFO UNDEF - Message 28 + [main] DEBUG UNDEF - Message 29 java.lang.Exception: Just testing. at org.apache.log4j.MinimumTestCase.common(MinimumTestCase.java:XXX) at org.apache.log4j.MinimumTestCase.ttcc(MinimumTestCase.java:XXX) - at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:XXX) at junit.framework.TestCase.runBare(TestCase.java:XXX) at junit.framework.TestResult$1.protect(TestResult.java:XXX) @@ -34,6 +39,4 @@ java.lang.Exception: Just testing. at junit.framework.TestCase.run(TestCase.java:XXX) at junit.framework.TestSuite.runTest(TestSuite.java:XXX) at junit.framework.TestSuite.run(TestSuite.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:XXX) - at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:XXX) - [main] INFO INF - Messages should bear numbers 0 through 23. + [main] INFO INF - Messages should bear numbers 0 through 29. diff --git a/tests/witness/xmlLayout.1 b/tests/witness/xmlLayout.1 index dd160c2063..80e596846b 100644 --- a/tests/witness/xmlLayout.1 +++ b/tests/witness/xmlLayout.1 @@ -1,53 +1,60 @@ - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + - - + + - - + + - - + + diff --git a/tests/witness/xmlLayout.2 b/tests/witness/xmlLayout.2 index be20b340b5..a3e094b1ca 100644 --- a/tests/witness/xmlLayout.2 +++ b/tests/witness/xmlLayout.2 @@ -1,64 +1,73 @@ - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + - - + + - - + + - - + + diff --git a/tests/witness/xmlLayout.3 b/tests/witness/xmlLayout.3 new file mode 100644 index 0000000000..2fa705f773 --- /dev/null +++ b/tests/witness/xmlLayout.3 @@ -0,0 +1,10 @@ + +hi]]>]]> + + + + +hi]]>]]> + + + diff --git a/tests/witness/xmlLayout.mdc.1 b/tests/witness/xmlLayout.mdc.1 new file mode 100644 index 0000000000..2dfe4ef8f7 --- /dev/null +++ b/tests/witness/xmlLayout.mdc.1 @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/witness/xmlLayout.mdc.2 b/tests/witness/xmlLayout.mdc.2 new file mode 100644 index 0000000000..d382c4c43f --- /dev/null +++ b/tests/witness/xmlLayout.mdc.2 @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/witness/xmlLayout.null b/tests/witness/xmlLayout.null new file mode 100644 index 0000000000..0ebcb33cd0 --- /dev/null +++ b/tests/witness/xmlLayout.null @@ -0,0 +1,23 @@ + + + + + + + + + + + + +