Move Log4j2 from experimental to its own trunk
git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL@1241271 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/rgoers/checkstyle-header.txt b/rgoers/checkstyle-header.txt
deleted file mode 100644
index 4f33236..0000000
--- a/rgoers/checkstyle-header.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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/rgoers/checkstyle.xml b/rgoers/checkstyle.xml
deleted file mode 100644
index 623b3e9..0000000
--- a/rgoers/checkstyle.xml
+++ /dev/null
@@ -1,217 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE module PUBLIC
- "-//Puppy Crawl//DTD Check Configuration 1.1//EN"
- "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
-
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- Checkstyle configuration that checks the commons-configuration coding conventions -->
-
-<module name="Checker">
- <property name="localeLanguage" value="en"/>
-
- <!-- Checks that a package.html file exists for each package. -->
- <!-- See http://checkstyle.sourceforge.net/config_javadoc.html -->
- <module name="JavadocPackage"/>
-
- <!-- Checks whether files end with a new line. -->
- <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
- <module name="NewlineAtEndOfFile"/>
-
- <!-- Checks that property files contain the same keys. -->
- <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
- <module name="Translation"/>
-
- <!-- Checks for Headers -->
- <!-- See http://checkstyle.sourceforge.net/config_header.html#Header -->
- <module name="Header">
- <property name="headerFile" value="${licensedir}"/>
- <property name="fileExtensions" value="java"/>
- <!--<property name="ignoreLines" value="2"/> -->
- </module>
-
- <!-- Checks for Tab characters -->
- <!-- See http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter -->
- <module name="FileTabCharacter">
- <property name="fileExtensions" value="java"/>
- </module>
-
- <!-- Checks for white space at the end of the line -->
- <!-- See http://checkstyle.sourceforge.net/config_regexp.html -->
- <module name="RegexpSingleline">
- <property name="format" value="\s+$"/>
- <property name="message" value="Line has trailing spaces."/>
- <property name="fileExtensions" value="java"/>
- </module>
-
- <!-- Exceptions -->
- <!--<module name="SuppressionFilter">
- <property name="file" value="conf/checkstyle-suppressions.xml"/>
- </module> -->
-
- <module name="TreeWalker">
-
- <property name="cacheFile" value="${checkstyle.cache.file}"/>
-
- <!-- Checks for Javadoc comments. -->
- <!-- See http://checkstyle.sf.net/config_javadoc.html -->
- <module name="JavadocMethod">
- <property name="scope" value="public"/>
- <property name="allowUndeclaredRTE" value="true"/>
- <property name="allowMissingJavadoc" value="true"/>
- </module>
- <module name="JavadocType">
- <!-- <property name="authorFormat" value="null"/> -->
- <!-- It is unfortunate to have to do this but checkstyle doesn't allow custom tags -->
- <property name="allowUnknownTags" value="true"/>
- </module>
- <module name="JavadocVariable">
- <property name="scope" value="protected"/>
- </module>
- <module name="JavadocStyle">
- <property name="scope" value="public"/>
- <!-- the checkHtml check is disabled as it generates incorrect errors -->
- <property name="checkHtml" value="false"/>
- </module>
-
-
- <!-- Checks for Naming Conventions. -->
- <!-- See http://checkstyle.sf.net/config_naming.html -->
- <module name="ConstantName">
- <property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$|^capabilities$|^log$"/>
- </module>
- <module name="LocalFinalVariableName"/>
- <module name="LocalVariableName"/>
- <module name="MemberName"/>
- <module name="MethodName"/>
- <module name="PackageName"/>
- <module name="ParameterName"/>
- <module name="StaticVariableName"/>
- <module name="TypeName"/>
-
- <!-- Following interprets the header file as regular expressions. -->
- <!-- <module name="RegexpHeader"/> -->
-
-
- <!-- Checks for imports -->
- <!-- See http://checkstyle.sf.net/config_import.html -->
- <module name="AvoidStarImport"/>
- <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
- <module name="RedundantImport"/>
- <module name="UnusedImports"/>
-
-
- <!-- Checks for Size Violations. -->
- <!-- See http://checkstyle.sf.net/config_sizes.html -->
- <!--<module name="FileLength"/>-->
- <module name="LineLength">
- <property name="max" value="120"/>
- </module>
- <module name="MethodLength"/>
- <module name="ParameterNumber">
- <property name="max" value="15"/>
- </module>
-
-
- <!-- Checks for whitespace -->
- <!-- See http://checkstyle.sf.net/config_whitespace.html -->
- <module name="EmptyForIteratorPad"/>
- <module name="NoWhitespaceAfter"/>
- <module name="NoWhitespaceBefore"/>
- <module name="OperatorWrap">
- <property name="tokens" value="ASSIGN"/>
- <property name="option" value="eol"/>
- </module>
- <module name="ParenPad"/>
- <module name="WhitespaceAfter"/>
- <module name="WhitespaceAround"/>
- <module name="GenericWhitespace"/>
-
-
- <!-- Modifier Checks -->
- <!-- See http://checkstyle.sf.net/config_modifiers.html -->
- <module name="ModifierOrder"/>
- <module name="RedundantModifier"/>
-
-
- <!-- Checks for blocks. You know, those {}'s -->
- <!-- See http://checkstyle.sf.net/config_blocks.html -->
- <module name="AvoidNestedBlocks">
- <property name="allowInSwitchCase" value="true"/>
- </module>
- <!-- Require empty catch blocks to have at least a comment -->
- <module name="EmptyBlock">
- <property name="option" value="text"/>
- <property name="tokens" value="LITERAL_CATCH"/>
- </module>
- <module name="LeftCurly">
- <property name="option" value="eol"/>
- </module>
- <module name="NeedBraces"/>
- <module name="RightCurly">
- <property name="option" value="same"/>
- </module>
-
-
- <!-- Checks for common coding problems -->
- <!-- See http://checkstyle.sf.net/config_coding.html -->
- <module name="CovariantEquals"/>
- <module name="DoubleCheckedLocking"/>
- <module name="EqualsHashCode"/>
- <module name="IllegalInstantiation"/>
- <!-- <module name="InnerAssignment"/> -->
- <module name="MagicNumber">
- <property name="ignoreNumbers" value="-1,0,1,2,3,4,5,6,7"/>
- </module>
- <module name="RedundantThrows">
- <property name="allowUnchecked" value="true"/>
- </module>
- <module name="SimplifyBooleanExpression"/>
- <module name="SimplifyBooleanReturn"/>
- <module name="StringLiteralEquality"/>
- <module name="SuperClone"/>
- <module name="SuperFinalize"/>
- <module name="DeclarationOrder"/>
- <!-- <module name="ExplicitInitialization"/> -->
- <module name="DefaultComesLast"/>
- <module name="FallThrough"/>
- <module name="MultipleVariableDeclarations"/>
- <!-- <module name="UnnecessaryParentheses"/> -->
-
- <!-- Checks for class design -->
- <!-- See http://checkstyle.sf.net/config_design.html -->
- <module name="FinalClass"/>
- <module name="HideUtilityClassConstructor"/>
- <module name="InterfaceIsType"/>
- <module name="VisibilityModifier">
- <property name="protectedAllowed" value="true"/>
- </module>
-
-
-
- <!-- Miscellaneous other checks. -->
- <!-- See http://checkstyle.sf.net/config_misc.html -->
- <module name="ArrayTypeStyle"/>
- <module name="TodoComment">
- <property name="severity" value="info"/>
- </module>
- <module name="UpperEll"/>
-
- </module>
-
-</module>
diff --git a/rgoers/findbugs-exclude-filter.xml b/rgoers/findbugs-exclude-filter.xml
deleted file mode 100644
index 327be31..0000000
--- a/rgoers/findbugs-exclude-filter.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- ===================================================================== -->
-<!-- $Id: findbugs-exclude-filter.xml 773234 2009-05-09 15:27:59Z rgoers $ -->
-<!-- ===================================================================== -->
-<FindBugsFilter>
- <!-- Enable only high priority warnings -->
- <Match>
- <Priority value="2"/>
- </Match>
-
- <Match>
- <Priority value="3"/>
- </Match>
-</FindBugsFilter>
diff --git a/rgoers/log4j12-api/LICENSE b/rgoers/log4j12-api/LICENSE
deleted file mode 100644
index 6279e52..0000000
--- a/rgoers/log4j12-api/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- 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/rgoers/log4j12-api/NOTICE b/rgoers/log4j12-api/NOTICE
deleted file mode 100644
index 6233b56..0000000
--- a/rgoers/log4j12-api/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache log4j Enhanced PatternLayout for log4j 1.2.x
-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/rgoers/log4j12-api/pom.xml b/rgoers/log4j12-api/pom.xml
deleted file mode 100644
index 80c79b6..0000000
--- a/rgoers/log4j12-api/pom.xml
+++ /dev/null
@@ -1,172 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2</artifactId>
- <version>1.99.0-SNAPSHOT</version>
- </parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j12-api</artifactId>
- <packaging>jar</packaging>
- <name>Log4J Compatibility API</name>
- <description>The Log4J Compatibility API</description>
- <properties>
- <log4j.parent.dir>${basedir}/..</log4j.parent.dir>
- </properties>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.3.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-core</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <version>2.6</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>changes-report</report>
- </reports>
- </reportSet>
- </reportSets>
- <configuration>
- <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.7</version>
- <configuration>
- <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
- <configLocation>${log4j.parent.dir}/checkstyle.xml</configLocation>
- <suppressionsLocation>${log4j.parent.dir}/checkstyle-suppressions.xml</suppressionsLocation>
- <enableRulesSummary>false</enableRulesSummary>
- <propertyExpansion>basedir=${basedir}</propertyExpansion>
- <propertyExpansion>licensedir=${log4j.parent.dir}/checkstyle-header.txt</propertyExpansion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8</version>
- <configuration>
- <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
- project -->
- <detectOfflineLinks>false</detectOfflineLinks>
- <linksource>true</linksource>
- <tags>
- <tag>
- <name>issue</name>
- <placement>a</placement>
- <head>JIRA issue:</head>
- </tag>
- <tag>
- <name>doubt</name>
- <placement>a</placement>
- <head>Troublesome:</head>
- </tag>
- <tag>
- <name>compare</name>
- <placement>a</placement>
- <head>Compare with:</head>
- </tag>
- </tags>
- </configuration>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <threshold>Normal</threshold>
- <effort>Default</effort>
- <excludeFilterFile>findbugs-exclude-filter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.3</version>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>jxr</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <targetJdk>1.5</targetJdk>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.2</version>
- <reportSets>
- <reportSet>
- <!-- Disabled at it kills the site generation via a NoClassDefFoundError -->
- <reports/>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
-</project>
-
diff --git a/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java b/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java
deleted file mode 100644
index 1922820..0000000
--- a/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.helpers.NameUtil;
-import org.apache.logging.log4j.message.LocalizedMessage;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.ObjectMessage;
-
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.WeakHashMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-
-/**
- * Implementation of the Category class for compatibility, despite it having been deprecated a long, long time ago.
- */
-public class Category {
-
- private static org.apache.log4j.LoggerFactory loggerFactory = new PrivateFactory();
-
- private static final Map<LoggerContext, ConcurrentMap<String, Logger>> CONTEXT_MAP =
- new WeakHashMap<LoggerContext, ConcurrentMap<String, Logger>>();
-
- private static final String FQCN = Category.class.getName();
-
- /**
- * Resource bundle for localized messages.
- */
- protected ResourceBundle bundle = null;
-
- private final org.apache.logging.log4j.core.Logger logger;
-
- /**
- * Constructor used by Logger to specify a LoggerContext.
- * @param context The LoggerContext.
- * @param name The name of the Logger.
- */
- protected Category(LoggerContext context, String name) {
- this.logger = context.getLogger(name);
- }
-
- /**
- * Constructor exposed by Log4j 1.2.
- * @param name The name of the Logger.
- */
- protected Category(String name) {
- this((LoggerContext) PrivateManager.getContext(), name);
- }
-
- private Category(org.apache.logging.log4j.core.Logger logger) {
- this.logger = logger;
- }
-
- public static Category getInstance(String name) {
- return getInstance((LoggerContext) PrivateManager.getContext(), name, loggerFactory);
- }
-
- static Category getInstance(LoggerContext context, String name) {
- return getInstance(context, name, loggerFactory);
- }
-
- static Category getInstance(LoggerContext context, String name, org.apache.log4j.LoggerFactory factory) {
- ConcurrentMap<String, Logger> loggers = getLoggersMap(context);
- Logger logger = loggers.get(name);
- if (logger != null) {
- return logger;
- }
- logger = factory.makeNewLoggerInstance(context, name);
- Logger prev = loggers.putIfAbsent(name, logger);
- return prev == null ? logger : prev;
- }
-
- public static Category getInstance(Class clazz) {
- return getInstance(clazz.getName());
- }
-
- static Category getInstance(LoggerContext context, Class clazz) {
- return getInstance(context, clazz.getName());
- }
-
- public final String getName() {
- return logger.getName();
- }
-
- org.apache.logging.log4j.core.Logger getLogger() {
- return logger;
- }
-
- public final Category getParent() {
- org.apache.logging.log4j.core.Logger parent = logger.getParent();
- if (parent == null) {
- return null;
- }
- ConcurrentMap<String, Logger> loggers = getLoggersMap(logger.getContext());
- Logger l = loggers.get(parent.getName());
- return l == null ? new Category(parent) : l;
- }
-
- public static Category getRoot() {
- return getInstance("");
- }
-
-
- static Category getRoot(LoggerContext context) {
- return getInstance(context, "");
- }
-
- private static ConcurrentMap<String, Logger> getLoggersMap(LoggerContext context) {
- synchronized (CONTEXT_MAP) {
- ConcurrentMap<String, Logger> map = CONTEXT_MAP.get(context);
- if (map == null) {
- map = new ConcurrentHashMap<String, Logger>();
- CONTEXT_MAP.put(context, map);
- }
- return map;
- }
- }
-
- public final Level getEffectiveLevel() {
- org.apache.logging.log4j.Level level = logger.getLevel();
-
- switch (level) {
- case TRACE:
- return Level.TRACE;
- case DEBUG:
- return Level.DEBUG;
- case INFO:
- return Level.INFO;
- case WARN:
- return Level.WARN;
- default:
- return Level.ERROR;
- }
- }
-
- public final Priority getChainedPriority() {
- return getEffectiveLevel();
- }
-
- public final Level getLevel() {
- return getEffectiveLevel();
- }
-
- public void setLevel(Level level) {
- logger.setLevel(org.apache.logging.log4j.Level.toLevel(level.levelStr));
- }
-
- public final Level getPriority() {
- return getEffectiveLevel();
- }
-
- public void setPriority(Priority priority) {
- logger.setLevel(org.apache.logging.log4j.Level.toLevel(priority.levelStr));
- }
-
- public void debug(Object message) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.DEBUG, message, null);
- }
-
- public void debug(Object message, Throwable t) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.DEBUG, message, t);
- }
-
- public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
- }
-
- public void error(Object message) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.ERROR, message, null);
- }
-
- public void error(Object message, Throwable t) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.ERROR, message, t);
- }
-
- public boolean isErrorEnabled() {
- return logger.isErrorEnabled();
- }
-
- public void warn(Object message) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.WARN, message, null);
- }
-
- public void warn(Object message, Throwable t) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.WARN, message, t);
- }
-
- public boolean isWarnEnabled() {
- return logger.isWarnEnabled();
- }
-
- public void fatal(Object message) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.FATAL, message, null);
- }
-
- public void fatal(Object message, Throwable t) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.FATAL, message, t);
- }
-
- public boolean isFatalEnabled() {
- return logger.isFatalEnabled();
- }
-
- public void info(Object message) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.INFO, message, null);
- }
-
- public void info(Object message, Throwable t) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.INFO, message, t);
- }
-
- public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
- }
-
- public void trace(Object message) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.TRACE, message, null);
- }
-
- public void trace(Object message, Throwable t) {
- maybeLog(FQCN, org.apache.logging.log4j.Level.TRACE, message, t);
- }
-
- public boolean isTraceEnabled() {
- return logger.isTraceEnabled();
- }
-
- public boolean isEnabledFor(Priority level) {
- org.apache.logging.log4j.Level lvl = org.apache.logging.log4j.Level.toLevel(level.toString());
- return isEnabledFor(lvl);
- }
-
- public void forcedLog(String fqcn, Priority level, Object message, Throwable t) {
- org.apache.logging.log4j.Level lvl = org.apache.logging.log4j.Level.toLevel(level.toString());
- logger.log(null, fqcn, lvl, new ObjectMessage(message), t);
- }
-
- public boolean exists(String name) {
- return PrivateManager.getContext().hasLogger(name);
- }
-
- public boolean getAdditivity() {
- return logger.isAdditive();
- }
-
- public void setAdditivity(boolean additivity) {
- logger.setAdditive(additivity);
- }
-
- public void setResourceBundle(ResourceBundle bundle) {
- this.bundle = bundle;
- }
-
- public ResourceBundle getResourceBundle() {
- if (bundle != null) {
- return bundle;
- }
- int i = 0;
- String name = logger.getName();
- ConcurrentMap<String, Logger> loggers = getLoggersMap(logger.getContext());
- while ((name = NameUtil.getSubName(name)) != null) {
- if (loggers.containsKey(name)) {
- ResourceBundle rb = loggers.get(name).bundle;
- if (rb != null) {
- return rb;
- }
- }
- }
- return null;
- }
-
- public void l7dlog(Priority priority, String key, Throwable t) {
- if (isEnabledFor(priority)) {
- Message msg = new LocalizedMessage(bundle, key, null);
- forcedLog(FQCN, priority, msg, t);
- }
- }
-
- public void l7dlog(Priority priority, String key, Object[] params, Throwable t) {
- if (isEnabledFor(priority)) {
- Message msg = new LocalizedMessage(bundle, key, params);
- forcedLog(FQCN, priority, msg, t);
- }
- }
-
- private void maybeLog(String fqcn, org.apache.logging.log4j.Level level,
- Object message, Throwable throwable) {
- if(logger.isEnabled(level, null, message, throwable)) {
- logger.log(null, FQCN, level, new ObjectMessage(message), throwable);
- }
- }
-
- /**
- * Private logger factory.
- */
- private static class PrivateFactory implements org.apache.log4j.LoggerFactory {
-
- public Logger makeNewLoggerInstance(LoggerContext context, String name) {
- return new Logger(context, name);
- }
- }
-
- /**
- * Private LogManager.
- */
- private static class PrivateManager extends org.apache.logging.log4j.LogManager {
- private static final String FQCN = Category.class.getName();
-
- public static org.apache.logging.log4j.spi.LoggerContext getContext() {
- return getContext(FQCN, false);
- }
-
- public static org.apache.logging.log4j.Logger getLogger(String name) {
- return getLogger(FQCN, name);
- }
- }
-
- private boolean isEnabledFor(org.apache.logging.log4j.Level level) {
- return logger.isEnabled(level, null, null);
- }
-
-}
diff --git a/rgoers/log4j12-api/src/main/java/org/apache/log4j/Level.java b/rgoers/log4j12-api/src/main/java/org/apache/log4j/Level.java
deleted file mode 100644
index b0a0940..0000000
--- a/rgoers/log4j12-api/src/main/java/org/apache/log4j/Level.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.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
- * <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
- * <code>WARN</code>, <code>INFO</code, <code>DEBUG</code>
- * and
- * <code>ALL</code>.
- * <p/>
- * <p>The <code>Level</code> class may be subclassed to define a larger
- * level set.
- */
-public class Level extends Priority implements Serializable {
-
- /**
- * TRACE level integer value.
- *
- * @since 1.2.12
- */
- public static final int TRACE_INT = 5000;
-
- /**
- * The <code>OFF</code> has the highest possible rank and is
- * intended to turn off logging.
- */
- public static final Level OFF = new Level(OFF_INT, "OFF", 0);
-
- /**
- * The <code>FATAL</code> level designates very severe error
- * events that will presumably lead the application to abort.
- */
- public static final Level FATAL = new Level(FATAL_INT, "FATAL", 0);
-
- /**
- * The <code>ERROR</code> level designates error events that
- * might still allow the application to continue running.
- */
- public static final Level ERROR = new Level(ERROR_INT, "ERROR", 3);
-
- /**
- * The <code>WARN</code> level designates potentially harmful situations.
- */
- public static final Level WARN = new Level(WARN_INT, "WARN", 4);
-
- /**
- * The <code>INFO</code> level designates informational messages
- * that highlight the progress of the application at coarse-grained
- * level.
- */
- public static final Level INFO = new Level(INFO_INT, "INFO", 6);
-
- /**
- * The <code>DEBUG</code> Level designates fine-grained
- * informational events that are most useful to debug an
- * application.
- */
- public static final Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
-
- /**
- * The <code>TRACE</code> Level designates finer-grained
- * informational events than the <code>DEBUG</code> level.
- */
- public static final Level TRACE = new Level(TRACE_INT, "TRACE", 7);
-
- /**
- * The <code>ALL</code> has the lowest possible rank and is intended to
- * turn on all logging.
- */
- public static final Level ALL = new Level(ALL_INT, "ALL", 7);
-
- /**
- * Serialization version id.
- */
- private static final long serialVersionUID = 3491141966387921974L;
-
- /**
- * Instantiate a Level object.
- *
- * @param level The logging level.
- * @param levelStr The level name.
- * @param syslogEquivalent The matching syslog level.
- */
- protected Level(int level, String levelStr, int syslogEquivalent) {
- super(level, levelStr, syslogEquivalent);
- }
-
-
- /**
- * Convert the string passed as argument to a level. If the
- * conversion fails, then this method returns {@link #DEBUG}.
- *
- * @param sArg The level name.
- * @return The Level.
- */
- public static Level toLevel(String sArg) {
- return toLevel(sArg, Level.DEBUG);
- }
-
- /**
- * Convert an integer passed as argument to a level. If the
- * conversion fails, then this method returns {@link #DEBUG}.
- *
- * @param val The integer value of the Level.
- * @return The Level.
- */
- public static Level toLevel(int val) {
- return toLevel(val, Level.DEBUG);
- }
-
- /**
- * Convert an integer passed as argument to a level. If the
- * conversion fails, then this method returns the specified default.
- *
- * @param val The integer value of the Level.
- * @param defaultLevel the default level if the integer doesn't match.
- * @return The matching Level.
- */
- public static Level toLevel(int val, Level defaultLevel) {
- switch (val) {
- case ALL_INT:
- return ALL;
- case DEBUG_INT:
- return Level.DEBUG;
- case INFO_INT:
- return Level.INFO;
- case WARN_INT:
- return Level.WARN;
- 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;
- }
- }
-
- /**
- * Convert the string passed as argument to a level. If the
- * conversion fails, then this method returns the value of
- * <code>defaultLevel</code>.
- * @param sArg The name of the Level.
- * @param defaultLevel The default Level to use.
- * @return the matching Level.
- */
- public static Level toLevel(String sArg, Level defaultLevel) {
- if (sArg == null) {
- return defaultLevel;
- }
-
- String s = sArg.toUpperCase();
-
- if (s.equals("ALL")) {
- return Level.ALL;
- }
- if (s.equals("DEBUG")) {
- return Level.DEBUG;
- }
- 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.
- */
- protected 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/rgoers/log4j12-api/src/main/java/org/apache/log4j/LogManager.java b/rgoers/log4j12-api/src/main/java/org/apache/log4j/LogManager.java
deleted file mode 100644
index 8bfc699..0000000
--- a/rgoers/log4j12-api/src/main/java/org/apache/log4j/LogManager.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.LoggerContext;
-
-/**
- *
- */
-public final class LogManager {
-
- private LogManager() {
- }
-
- public static Logger getRootLogger() {
- return (Logger) Category.getInstance((LoggerContext) PrivateManager.getContext(), "");
- }
-
- public static Logger getLogger(final String name) {
- return (Logger) Category.getInstance((LoggerContext) PrivateManager.getContext(), name);
- }
-
- public static Logger getLogger(final Class clazz) {
- return (Logger) Category.getInstance((LoggerContext) PrivateManager.getContext(), clazz.getName());
- }
-
- public static Logger exists(String name) {
- LoggerContext ctx = (LoggerContext) PrivateManager.getContext();
- if (!ctx.hasLogger(name)) {
- return null;
- }
- return Logger.getLogger(name);
- }
-
- /**
- * Internal LogManager.
- */
- private static class PrivateManager extends org.apache.logging.log4j.LogManager {
- private static final String FQCN = LogManager.class.getName();
-
-
- public static org.apache.logging.log4j.spi.LoggerContext getContext() {
- return getContext(FQCN, false);
- }
-
- public static org.apache.logging.log4j.Logger getLogger(String name) {
- return getLogger(FQCN, name);
- }
- }
-}
diff --git a/rgoers/log4j12-api/src/main/java/org/apache/log4j/Logger.java b/rgoers/log4j12-api/src/main/java/org/apache/log4j/Logger.java
deleted file mode 100644
index e5e7d9c..0000000
--- a/rgoers/log4j12-api/src/main/java/org/apache/log4j/Logger.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.LoggerContext;
-
-/**
- *
- */
-public class Logger extends Category {
-
- private static final String FQCN = Logger.class.getName();
-
- protected Logger(String name) {
- super((LoggerContext) PrivateManager.getContext(), name);
- }
-
- Logger(LoggerContext context, String name) {
- super(context, name);
- }
-
- public static Logger getLogger(String name) {
- return (Logger) Category.getInstance((LoggerContext) PrivateManager.getContext(), name);
- }
-
- public static Logger getLogger(Class clazz) {
- return (Logger) Category.getInstance((LoggerContext) PrivateManager.getContext(), clazz);
- }
-
- public static Logger getRootLogger() {
- return (Logger) Category.getRoot((LoggerContext) PrivateManager.getContext());
- }
-
- public static Logger getLogger(String name, LoggerFactory factory) {
- return (Logger) Category.getInstance((LoggerContext) PrivateManager.getContext(), name, factory);
- }
-
- /**
- * Internal Log Manager.
- */
- private static class PrivateManager extends org.apache.logging.log4j.LogManager {
- private static final String FQCN = Logger.class.getName();
-
- public static org.apache.logging.log4j.spi.LoggerContext getContext() {
- return getContext(FQCN, false);
- }
-
- public static org.apache.logging.log4j.Logger getLogger(String name) {
- return getLogger(FQCN, name);
- }
- }
-}
diff --git a/rgoers/log4j12-api/src/main/java/org/apache/log4j/LoggerFactory.java b/rgoers/log4j12-api/src/main/java/org/apache/log4j/LoggerFactory.java
deleted file mode 100644
index 9974243..0000000
--- a/rgoers/log4j12-api/src/main/java/org/apache/log4j/LoggerFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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;
-/**
- *
- * Implement this interface to create new instances of Logger or
- * a sub-class of Logger.
- *
- * <p>See <code>examples/subclass/MyLogger.java</code> for an example.
- */
-public interface LoggerFactory {
-
- Logger makeNewLoggerInstance(org.apache.logging.log4j.core.LoggerContext context, String name);
-
-}
diff --git a/rgoers/log4j12-api/src/main/java/org/apache/log4j/MDC.java b/rgoers/log4j12-api/src/main/java/org/apache/log4j/MDC.java
deleted file mode 100644
index 704e364..0000000
--- a/rgoers/log4j12-api/src/main/java/org/apache/log4j/MDC.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.ThreadContext;
-
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-
-/**
- * This class behaves just like Log4j's MDC would - and so can cause issues with the redeployment of web
- * applications if the Objects stored in the threads Map cannot be garbage collected.
- */
-public final class MDC {
-
-
- private static ThreadLocal<Map<String, Object>> localMap =
- new InheritableThreadLocal<Map<String, Object>>() {
- protected Map<String, Object> initialValue() {
- return new HashMap<String, Object>();
- }
-
- protected Map<String, Object> childValue(Map<String, Object> parentValue) {
- return parentValue == null ? new HashMap<String, Object>() : new HashMap<String, Object>(parentValue);
- }
- };
-
- private MDC() {
- }
-
-
- public static void put(String key, String value) {
- localMap.get().put(key, value);
- ThreadContext.put(key, value);
- }
-
-
- public static void put(String key, Object value) {
- localMap.get().put(key, value);
- ThreadContext.put(key, value.toString());
- }
-
- public static Object get(String key) {
- return localMap.get().get(key);
- }
-
- public static void remove(String key) {
- localMap.get().remove(key);
- ThreadContext.remove(key);
- }
-
- public static void clear() {
- localMap.get().clear();
- ThreadContext.clear();
- }
-
- public static Hashtable getContext() {
- return new Hashtable(localMap.get());
- }
-}
diff --git a/rgoers/log4j12-api/src/main/java/org/apache/log4j/NDC.java b/rgoers/log4j12-api/src/main/java/org/apache/log4j/NDC.java
deleted file mode 100644
index 91b645f..0000000
--- a/rgoers/log4j12-api/src/main/java/org/apache/log4j/NDC.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.Stack;
-
-/**
- *
- */
-public final class NDC {
-
- private NDC() {
- }
-
- /**
- * Clear any nested diagnostic information if any. This method is
- * useful in cases where the same thread can be potentially used
- * over and over in different unrelated contexts.
- * <p/>
- * <p>This method is equivalent to calling the {@link #setMaxDepth}
- * method with a zero <code>maxDepth</code> argument.
- */
- public static void clear() {
- org.apache.logging.log4j.ThreadContext.clearStack();
- }
-
-
- /**
- * Clone the diagnostic context for the current thread.
- * <p/>
- * <p>Internally a diagnostic context is represented as a stack. A
- * given thread can supply the stack (i.e. diagnostic context) to a
- * child thread so that the child can inherit the parent thread's
- * diagnostic context.
- * <p/>
- * <p>The child thread uses the {@link #inherit inherit} method to
- * inherit the parent's diagnostic context.
- *
- * @return Stack A clone of the current thread's diagnostic context.
- */
- public static Stack cloneStack() {
- return org.apache.logging.log4j.ThreadContext.cloneStack();
- }
-
-
- /**
- * Inherit the diagnostic context of another thread.
- * <p/>
- * <p>The parent thread can obtain a reference to its diagnostic
- * context using the {@link #cloneStack} method. It should
- * communicate this information to its child so that it may inherit
- * the parent's diagnostic context.
- * <p/>
- * <p>The parent's diagnostic context is cloned before being
- * inherited. In other words, once inherited, the two diagnostic
- * contexts can be managed independently.
- * <p/>
- * <p>In java, a child thread cannot obtain a reference to its
- * parent, unless it is directly handed the reference. Consequently,
- * there is no client-transparent way of inheriting diagnostic
- * contexts. Do you know any solution to this problem?
- *
- * @param stack The diagnostic context of the parent thread.
- */
- public static void inherit(Stack stack) {
- org.apache.logging.log4j.ThreadContext.setStack(stack);
- }
-
-
- /**
- * <font color="#FF4040"><b>Never use this method directly.</b>
- * @return The string value of the specified key.
- */
- public static String get() {
- return org.apache.logging.log4j.ThreadContext.peek();
- }
-
- /**
- * Get the current nesting depth of this diagnostic context.
- * @return int The number of elements in the call stack.
- * @see #setMaxDepth
- */
- public static int getDepth() {
- return org.apache.logging.log4j.ThreadContext.getDepth();
- }
-
- /**
- * Clients should call this method before leaving a diagnostic
- * context.
- * <p/>
- * <p>The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.
- *
- * @return String The innermost diagnostic context.
- */
- public static String pop() {
- return org.apache.logging.log4j.ThreadContext.pop();
- }
-
- /**
- * Looks at the last diagnostic context at the top of this NDC
- * without removing it.
- * <p/>
- * <p>The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.
- *
- * @return String The innermost diagnostic context.
- */
- public static String peek() {
- return org.apache.logging.log4j.ThreadContext.peek();
- }
-
- /**
- * Push new diagnostic context information for the current thread.
- * <p/>
- * <p>The contents of the <code>message</code> parameter is
- * determined solely by the client.
- *
- * @param message The new diagnostic context information.
- */
- public static void push(String message) {
- org.apache.logging.log4j.ThreadContext.push(message);
- }
-
- /**
- * Remove the diagnostic context for this thread.
- * <p/>
- * <p>Each thread that created a diagnostic context by calling
- * {@link #push} should call this method before exiting. Otherwise,
- * the memory used by the <b>thread</b> cannot be reclaimed by the
- * VM.
- * <p/>
- * <p>As this is such an important problem in heavy duty systems and
- * because it is difficult to always guarantee that the remove
- * method is called before exiting a thread, this method has been
- * augmented to lazily remove references to dead threads. In
- * practice, this means that you can be a little sloppy and
- * occasionally forget to call {@link #remove} before exiting a
- * thread. However, you must call <code>remove</code> sometime. If
- * you never call it, then your application is sure to run out of
- * memory.
- */
- public static void remove() {
- org.apache.logging.log4j.ThreadContext.removeStack();
- }
-
- /**
- * Set maximum depth of this diagnostic context. If the current
- * depth is smaller or equal to <code>maxDepth</code>, then no
- * action is taken.
- * <p/>
- * <p>This method is a convenient alternative to multiple {@link
- * #pop} calls. Moreover, it is often the case that at the end of
- * complex call sequences, the depth of the NDC is
- * unpredictable. The <code>setMaxDepth</code> method circumvents
- * this problem.
- * <p/>
- * <p>For example, the combination
- * <pre>
- * void foo() {
- * int depth = NDC.getDepth();
- * <p/>
- * ... complex sequence of calls
- * <p/>
- * NDC.setMaxDepth(depth);
- * }
- * </pre>
- * <p/>
- * ensures that between the entry and exit of foo the depth of the
- * diagnostic stack is conserved.
- *
- * @see #getDepth
- * @param maxDepth The maximum depth of the stack.
- */
- public static void setMaxDepth(int maxDepth) {
- org.apache.logging.log4j.ThreadContext.setMaxDepth(maxDepth);
- }
-}
diff --git a/rgoers/log4j12-api/src/main/java/org/apache/log4j/Priority.java b/rgoers/log4j12-api/src/main/java/org/apache/log4j/Priority.java
deleted file mode 100644
index c17123e..0000000
--- a/rgoers/log4j12-api/src/main/java/org/apache/log4j/Priority.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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;
-
-/**
- * <font color="#AA4444">Refrain from using this class directly, use
- * the {@link Level} class instead</font>.
- */
-public class Priority {
-
- /**
- * The <code>OFF</code> has the highest possible rank and is
- * intended to turn off logging.
- */
- public static final int OFF_INT = Integer.MAX_VALUE;
- /**
- * The <code>FATAL</code> level designates very severe error
- * events that will presumably lead the application to abort.
- */
- public static final int FATAL_INT = 50000;
- /**
- * The <code>ERROR</code> level designates error events that
- * might still allow the application to continue running.
- */
- public static final int ERROR_INT = 40000;
- /**
- * The <code>WARN</code> level designates potentially harmful situations.
- */
- public static final int WARN_INT = 30000;
- /**
- * The <code>INFO</code> level designates informational messages
- * that highlight the progress of the application at coarse-grained
- * level.
- */
- public static final int INFO_INT = 20000;
- /**
- * The <code>DEBUG</code> Level designates fine-grained
- * informational events that are most useful to debug an
- * application.
- */
- public static final int DEBUG_INT = 10000;
- //public final static int FINE_INT = DEBUG_INT;
- /**
- * The <code>ALL</code> has the lowest possible rank and is intended to
- * turn on all logging.
- */
- public static final int ALL_INT = Integer.MIN_VALUE;
-
- /**
- * @deprecated Use {@link Level#FATAL} instead.
- */
- public static final Priority FATAL = new Level(FATAL_INT, "FATAL", 0);
-
- /**
- * @deprecated Use {@link Level#ERROR} instead.
- */
- public static final Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
-
- /**
- * @deprecated Use {@link Level#WARN} instead.
- */
- public static final Priority WARN = new Level(WARN_INT, "WARN", 4);
-
- /**
- * @deprecated Use {@link Level#INFO} instead.
- */
- public static final Priority INFO = new Level(INFO_INT, "INFO", 6);
-
- /**
- * @deprecated Use {@link Level#DEBUG} instead.
- */
- public static final Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
-
- /*
- * These variables should be private but were not in Log4j 1.2 so are left the same way here.
- */
- transient int level;
- transient String levelStr;
- transient int syslogEquivalent;
-
- /**
- * Default constructor for deserialization.
- */
- protected Priority() {
- level = DEBUG_INT;
- levelStr = "DEBUG";
- syslogEquivalent = 7;
- }
-
- /**
- * Instantiate a level object.
- * @param level The level value.
- * @param levelStr The level name.
- * @param syslogEquivalent The equivalent syslog value.
- */
- protected Priority(int level, String levelStr, int syslogEquivalent) {
- this.level = level;
- this.levelStr = levelStr;
- this.syslogEquivalent = syslogEquivalent;
- }
-
- /**
- * Two priorities are equal if their level fields are equal.
- * @param o The Object to check.
- * @return true if the objects are equal, false otherwise.
- *
- * @since 1.2
- */
- public boolean equals(Object o) {
- if (o instanceof Priority) {
- Priority r = (Priority) o;
- return (this.level == r.level);
- } else {
- return false;
- }
- }
-
- /**
- * Return the syslog equivalent of this priority as an integer.
- * @return The equivalent syslog value.
- */
- public
- final int getSyslogEquivalent() {
- return syslogEquivalent;
- }
-
-
- /**
- * Returns <code>true</code> if this level has a higher or equal
- * level than the level passed as argument, <code>false</code>
- * otherwise.
- * <p/>
- * <p>You should think twice before overriding the default
- * implementation of <code>isGreaterOrEqual</code> method.
- * @param r The Priority to check.
- * @return true if the current level is greater or equal to the specified Priority.
- */
- public boolean isGreaterOrEqual(Priority r) {
- return level >= r.level;
- }
-
- /**
- * Return all possible priorities as an array of Level objects in
- * descending order.
- * @return An array of all possible Priorities.
- *
- * @deprecated This method will be removed with no replacement.
- */
- public static Priority[] getAllPossiblePriorities() {
- return new Priority[]{Priority.FATAL, Priority.ERROR, Level.WARN,
- Priority.INFO, Priority.DEBUG};
- }
-
-
- /**
- * Returns the string representation of this priority.
- * @return The name of the Priority.
- */
- public final String toString() {
- return levelStr;
- }
-
- /**
- * Returns the integer representation of this level.
- * @return The integer value of this level.
- */
- public final int toInt() {
- return level;
- }
-
- /**
- * @param sArg The name of the Priority.
- * @return The Priority matching the name.
- * @deprecated Please use the {@link Level#toLevel(String)} method instead.
- */
- public static Priority toPriority(String sArg) {
- return Level.toLevel(sArg);
- }
-
- /**
- * @param val The value of the Priority.
- * @return The Priority matching the value.
- * @deprecated Please use the {@link Level#toLevel(int)} method instead.
- */
- public static Priority toPriority(int val) {
- return toPriority(val, Priority.DEBUG);
- }
-
- /**
- * @param val The value of the Priority.
- * @param defaultPriority The default Priority to use if the value is invalid.
- * @return The Priority matching the value or the default Priority if no match is found.
- * @deprecated Please use the {@link Level#toLevel(int, Level)} method instead.
- */
- public static Priority toPriority(int val, Priority defaultPriority) {
- return Level.toLevel(val, (Level) defaultPriority);
- }
-
- /**
- * @param sArg The name of the Priority.
- * @param defaultPriority The default Priority to use if the name is not found.
- * @return The Priority matching the name or the default Priority if no match is found.
- * @deprecated Please use the {@link Level#toLevel(String, Level)} method instead.
- */
- public static Priority toPriority(String sArg, Priority defaultPriority) {
- return Level.toLevel(sArg, (Level) defaultPriority);
- }
-}
diff --git a/rgoers/log4j12-api/src/main/java/org/apache/log4j/package-info.java b/rgoers/log4j12-api/src/main/java/org/apache/log4j/package-info.java
deleted file mode 100644
index 714c200..0000000
--- a/rgoers/log4j12-api/src/main/java/org/apache/log4j/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.x compatibility layer.
- */
-package org.apache.log4j;
diff --git a/rgoers/log4j12-api/src/site/site.xml b/rgoers/log4j12-api/src/site/site.xml
deleted file mode 100644
index 832d7b8..0000000
--- a/rgoers/log4j12-api/src/site/site.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project name="Component">
- <bannerLeft>
- <name>Logging Services</name>
- <src>../images/ls-logo.jpg</src>
- <href>../index.html</href>
- </bannerLeft>
- <bannerRight>
- <src>../images/logo.jpg</src>
- </bannerRight>
- <body>
- <links>
- <item name="Apache" href="http://www.apache.org/" />
- <item name="Logging Services" href="http://logging.apache.org/"/>
- <item name="Log4j" href="../index.html"/>
- </links>
- <menu ref="reports"/>
- </body>
-</project>
diff --git a/rgoers/log4j12-api/src/site/xdoc/api.xml b/rgoers/log4j12-api/src/site/xdoc/api.xml
deleted file mode 100644
index d0a60fb..0000000
--- a/rgoers/log4j12-api/src/site/xdoc/api.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4J 1.2 Bridge</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Log4J 1.2 Bridge">
-
- <p>
- The Log4Jj 2.0 API provides the interface that applications should code to and provides the
- adapter components required for implementers to create a logging implementation.
- </p>
-
- </section>
-
- <section name="Requirements">
- <p>
- The Log4j 2.0 API requires at least Java 5.
- </p>
- </section>
-
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/log4j12-api/src/site/xdoc/index.xml b/rgoers/log4j12-api/src/site/xdoc/index.xml
deleted file mode 100644
index a35b531..0000000
--- a/rgoers/log4j12-api/src/site/xdoc/index.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4J 1.2 Bridge</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Log4J 1.2 Bridge">
-
- <p>
- The Log4j 1.2 Bridge allows applications coded to use Log4j 1.2 API to use
- Log4j 2.0 instead.
- </p>
-
- </section>
-
- <section name="Requirements">
- <p>
- The Log4j 1.2 bridge requires at least Java 5.
- </p>
- </section>
-
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/log4j12-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java b/rgoers/log4j12-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
deleted file mode 100644
index 65b94d7..0000000
--- a/rgoers/log4j12-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.Level;
-import org.apache.logging.log4j.core.config.BaseConfiguration;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.xml.sax.InputSource;
-
-import java.net.URI;
-
-/**
- *
- */
-public class BasicConfigurationFactory extends ConfigurationFactory {
-
- @Override
- public String[] getSupportedTypes() {
- return new String[] {"*"};
- }
-
- @Override
- public Configuration getConfiguration(InputSource source) {
- return new BasicConfiguration();
- }
-
- @Override
- public Configuration getConfiguration(String name, URI configLocation) {
- return new BasicConfiguration();
- }
-
- public class BasicConfiguration extends BaseConfiguration {
-
- private static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";
-
- public BasicConfiguration() {
-
- LoggerConfig root = getRootLogger();
- String l = System.getProperty(DEFAULT_LEVEL);
- Level level = (l != null && Level.valueOf(l) != null) ? Level.valueOf(l) : Level.DEBUG;
- root.setLevel(level);
- }
- }
-}
diff --git a/rgoers/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java b/rgoers/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java
deleted file mode 100644
index 8c081e8..0000000
--- a/rgoers/log4j12-api/src/test/java/org/apache/log4j/CategoryTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.status.StatusConsoleListener;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-
-/**
- * Tests of Category.
- */
-public class CategoryTest {
-
- static ConfigurationFactory cf = new BasicConfigurationFactory();
-
- private ListAppender appender = new ListAppender("List");
-
- @BeforeClass
- public static void setupClass() {
- ConfigurationFactory.setConfigurationFactory(cf);
- LoggerContext ctx = (LoggerContext) org.apache.logging.log4j.LogManager.getContext();
- ctx.reconfigure();
- }
-
- @AfterClass
- public static void cleanupClass() {
- ConfigurationFactory.removeConfigurationFactory(cf);
- }
-
- /**
- * Tests Category.forcedLog.
- */
- @Test
- public void testForcedLog() {
- MockCategory category = new MockCategory("org.example.foo");
- category.setAdditivity(false);
- category.getLogger().addAppender(appender);
- category.info("Hello, World");
- int events = appender.getEvents().size();
- assertTrue("Number of events should be 1, was " + events, events == 1);
- appender.clear();
- }
-
- /**
- * Tests that the return type of getChainedPriority is Priority.
- *
- * @throws Exception thrown if Category.getChainedPriority can not be found.
- */
- @Test
- public void testGetChainedPriorityReturnType() throws Exception {
- Method method = Category.class.getMethod("getChainedPriority", (Class[]) null);
- assertTrue(method.getReturnType() == Priority.class);
- }
-
- /**
- * Tests l7dlog(Priority, String, Throwable).
- */
- @Test
- public void testL7dlog() {
- Logger logger = Logger.getLogger("org.example.foo");
- logger.setLevel(Level.ERROR);
- Priority debug = Level.DEBUG;
- logger.l7dlog(debug, "Hello, World", null);
- assertTrue(appender.getEvents().size() == 0);
- }
-
- /**
- * Tests l7dlog(Priority, String, Object[], Throwable).
- */
- @Test
- 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);
- assertTrue(appender.getEvents().size() == 0);
- }
-
- /**
- * Test using a pre-existing log4j2 logger
- */
- @Test
- public void testExistingLog4j2Logger() {
- // create the logger using LogManager
- org.apache.logging.log4j.LogManager.getLogger("existingLogger");
- // Logger will be the one created above
- Logger logger = Logger.getLogger("existingLogger");
- Logger l2 = LogManager.getLogger("existingLogger");
- assertEquals(logger, l2);
- logger.setLevel(Level.ERROR);
- Priority debug = Level.DEBUG;
- // the next line will throw an exception if the LogManager loggers
- // aren't supported by 1.2 Logger/Category
- logger.l7dlog(debug, "Hello, World", new Object[0], null);
- assertTrue(appender.getEvents().size() == 0);
- }
-
- /**
- * Tests setPriority(Priority).
- *
- * @deprecated
- */
- @Test
- public void testSetPriority() {
- Logger logger = Logger.getLogger("org.example.foo");
- Priority debug = Level.DEBUG;
- logger.setPriority(debug);
- }
-
- @Test
- public void testClassName() {
- Category category = Category.getInstance("TestCategory");
- Layout layout = PatternLayout.createLayout("%d %p %C{1.} [%t] %m%n", null, null, null);
- ListAppender appender = new ListAppender("List2", null, layout, false, false);
- appender.start();
- category.setAdditivity(false);
- category.getLogger().addAppender(appender);
- category.error("Test Message");
- List<String> msgs = appender.getMessages();
- assertTrue("Incorrect number of messages. Expected 1 got " + msgs.size(), msgs.size() == 1);
- String msg = msgs.get(0);
- appender.clear();
- String expected = "ERROR o.a.l.CategoryTest [main] Test Message\n";
- assertTrue("Incorrect message \"" + msg + "\"" + " expected \"" + expected +"\"", msg.endsWith(expected));
- }
-
- /**
- * 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);
- }
-
- /**
- * 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/rgoers/log4j12-api/src/test/java/org/apache/log4j/LevelTest.java b/rgoers/log4j12-api/src/test/java/org/apache/log4j/LevelTest.java
deleted file mode 100644
index 12e9212..0000000
--- a/rgoers/log4j12-api/src/test/java/org/apache/log4j/LevelTest.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.util.SerializationTestHelper;
-
-import java.util.Locale;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.junit.Assert;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
-/**
- * Tests of Level.
- *
- * @author Curt Arnold
- * @since 1.2.12
- */
-public class LevelTest {
-
- /**
- * Serialize Level.INFO and check against witness.
- *
- * @throws Exception if exception during test.
- */
- @Test
- public void testSerializeINFO() throws Exception {
- int[] skip = new int[]{};
- SerializationTestHelper.assertSerializationEquals(
- "target/test-classes/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.
- */
- @Test
- public void testDeserializeINFO() throws Exception {
- Object obj =
- SerializationTestHelper.deserializeStream(
- "target/test-classes/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.
- */
- @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.
- */
- @Test
- public void testTraceInt() {
- assertEquals(5000, Level.TRACE_INT);
- }
-
- /**
- * Tests Level.TRACE.
- */
- @Test
- public void testTrace() {
- assertEquals("TRACE", Level.TRACE.toString());
- assertEquals(5000, Level.TRACE.toInt());
- assertEquals(7, Level.TRACE.getSyslogEquivalent());
- }
-
- /**
- * Tests Level.toLevel(Level.TRACE_INT).
- */
- @Test
- public void testIntToTrace() {
- Level trace = Level.toLevel(5000);
- assertEquals("TRACE", trace.toString());
- }
-
- /**
- * Tests Level.toLevel("TRACE");
- */
- @Test
- public void testStringToTrace() {
- Level trace = Level.toLevel("TRACE");
- assertEquals("TRACE", trace.toString());
- }
-
- /**
- * Tests that Level extends Priority.
- */
- @Test
- public void testLevelExtendsPriority() {
- assertTrue(Priority.class.isAssignableFrom(Level.class));
- }
-
- /**
- * Tests Level.OFF.
- */
- @Test
- public void testOFF() {
- assertTrue(Level.OFF instanceof Level);
- }
-
- /**
- * Tests Level.FATAL.
- */
- @Test
- public void testFATAL() {
- assertTrue(Level.FATAL instanceof Level);
- }
-
- /**
- * Tests Level.ERROR.
- */
- @Test
- public void testERROR() {
- assertTrue(Level.ERROR instanceof Level);
- }
-
- /**
- * Tests Level.WARN.
- */
- @Test
- public void testWARN() {
- assertTrue(Level.WARN instanceof Level);
- }
-
- /**
- * Tests Level.INFO.
- */
- @Test
- public void testINFO() {
- assertTrue(Level.INFO instanceof Level);
- }
-
- /**
- * Tests Level.DEBUG.
- */
- @Test
- public void testDEBUG() {
- assertTrue(Level.DEBUG instanceof Level);
- }
-
- /**
- * Tests Level.TRACE.
- */
- @Test
- public void testTRACE() {
- assertTrue(Level.TRACE instanceof Level);
- }
-
- /**
- * Tests Level.ALL.
- */
- @Test
- public void testALL() {
- assertTrue(Level.ALL instanceof Level);
- }
-
- /**
- * Tests Level.toLevel(Level.All_INT).
- */
- @Test
- public void testIntToAll() {
- Level level = Level.toLevel(Level.ALL_INT);
- assertEquals("ALL", level.toString());
- }
-
- /**
- * Tests Level.toLevel(Level.FATAL_INT).
- */
- @Test
- public void testIntToFatal() {
- Level level = Level.toLevel(Level.FATAL_INT);
- assertEquals("FATAL", level.toString());
- }
-
-
- /**
- * Tests Level.toLevel(Level.OFF_INT).
- */
- @Test
- public void testIntToOff() {
- Level level = Level.toLevel(Level.OFF_INT);
- assertEquals("OFF", level.toString());
- }
-
- /**
- * Tests Level.toLevel(17, Level.FATAL).
- */
- @Test
- public void testToLevelUnrecognizedInt() {
- Level level = Level.toLevel(17, Level.FATAL);
- assertEquals("FATAL", level.toString());
- }
-
- /**
- * Tests Level.toLevel(null, Level.FATAL).
- */
- @Test
- public void testToLevelNull() {
- Level level = Level.toLevel(null, Level.FATAL);
- assertEquals("FATAL", level.toString());
- }
-
- /**
- * Test that dotless lower I + "nfo" is recognized as INFO.
- */
- @Test
- 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.
- */
- @Test
- 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/rgoers/log4j12-api/src/test/java/org/apache/log4j/LoggerTest.java b/rgoers/log4j12-api/src/test/java/org/apache/log4j/LoggerTest.java
deleted file mode 100644
index 8202e9d..0000000
--- a/rgoers/log4j12-api/src/test/java/org/apache/log4j/LoggerTest.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.Appender;
-
-import java.util.List;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.AppenderBase;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertSame;
-
-/**
- * Used for internal unit testing the Logger class.
- */
-public class LoggerTest {
-
- Logger logger;
- Appender a1;
- Appender a2;
-
- static ResourceBundle rbUS;
- static ResourceBundle rbFR;
- static ResourceBundle rbCH;
-
- // A short message.
- static String MSG = "M";
-
- static ConfigurationFactory cf = new BasicConfigurationFactory();
-
- @BeforeClass
- public static void setUpClass() {
- rbUS = ResourceBundle.getBundle("L7D", new Locale("en", "US"));
- assertNotNull(rbUS);
-
- rbFR = ResourceBundle.getBundle("L7D", new Locale("fr", "FR"));
- assertNotNull("Got a null resource bundle.", rbFR);
-
- rbCH = ResourceBundle.getBundle("L7D", new Locale("fr", "CH"));
- assertNotNull("Got a null resource bundle.", rbCH);
-
- ConfigurationFactory.setConfigurationFactory(cf);
- }
-
- @AfterClass
- public static void tearDownClass() {
- }
-
- @After
- public void tearDown() {
- LoggerContext ctx = (LoggerContext) org.apache.logging.log4j.LogManager.getContext();
- ctx.reconfigure();
- a1 = null;
- a2 = null;
- }
-
- /**
- * Add an appender and see if it can be retrieved.
- * Skipping this test as the Appender interface isn't compatible with legacy Log4j.
- public void testAppender1() {
- logger = Logger.getLogger("test");
- a1 = new ListAppender("testAppender1");
- logger.addAppender(a1);
-
- Enumeration enumeration = logger.getAllAppenders();
- Appender aHat = (Appender) enumeration.nextElement();
- assertEquals(a1, aHat);
- } */
-
- /**
- * Add an appender X, Y, remove X and check if Y is the only
- * remaining appender.
- * Skipping this test as the Appender interface isn't compatible with legacy Log4j.
- public void testAppender2() {
- a1 = new FileAppender();
- a1.setName("testAppender2.1");
- a2 = new FileAppender();
- a2.setName("testAppender2.2");
-
- logger = Logger.getLogger("test");
- logger.addAppender(a1);
- logger.addAppender(a2);
- logger.removeAppender("testAppender2.1");
- Enumeration enumeration = logger.getAllAppenders();
- Appender aHat = (Appender) enumeration.nextElement();
- assertEquals(a2, aHat);
- assertTrue(!enumeration.hasMoreElements());
- } */
-
- /**
- * Test if logger a.b inherits its appender from a.
- */
- @Test
- public void testAdditivity1() {
- Logger a = Logger.getLogger("a");
- Logger ab = Logger.getLogger("a.b");
- CountingAppender ca = new CountingAppender();
- a.getLogger().addAppender(ca);
-
- assertEquals(ca.counter, 0);
- ab.debug(MSG);
- assertEquals(ca.counter, 1);
- ab.info(MSG);
- assertEquals(ca.counter, 2);
- ab.warn(MSG);
- assertEquals(ca.counter, 3);
- ab.error(MSG);
- assertEquals(ca.counter, 4);
- }
-
- /**
- * Test multiple additivity.
- */
- @Test
- public void testAdditivity2() {
-
- Logger a = Logger.getLogger("a");
- Logger ab = Logger.getLogger("a.b");
- Logger abc = Logger.getLogger("a.b.c");
- Logger x = Logger.getLogger("x");
-
- CountingAppender ca1 = new CountingAppender();
- CountingAppender ca2 = new CountingAppender();
-
- a.getLogger().addAppender(ca1);
- abc.getLogger().addAppender(ca2);
-
- assertEquals(ca1.counter, 0);
- assertEquals(ca2.counter, 0);
-
- ab.debug(MSG);
- assertEquals(ca1.counter, 1);
- assertEquals(ca2.counter, 0);
-
- abc.debug(MSG);
- assertEquals(ca1.counter, 2);
- assertEquals(ca2.counter, 1);
-
- x.debug(MSG);
- assertEquals(ca1.counter, 2);
- assertEquals(ca2.counter, 1);
- }
-
- /**
- * Test additivity flag.
- */
- @Test
- public void testAdditivity3() {
-
- Logger root = Logger.getRootLogger();
- Logger a = Logger.getLogger("a");
- Logger ab = Logger.getLogger("a.b");
- Logger abc = Logger.getLogger("a.b.c");
- Logger x = Logger.getLogger("x");
-
- CountingAppender caRoot = new CountingAppender();
- CountingAppender caA = new CountingAppender();
- CountingAppender caABC = new CountingAppender();
-
- root.getLogger().addAppender(caRoot);
- a.getLogger().addAppender(caA);
- abc.getLogger().addAppender(caABC);
-
- assertEquals(caRoot.counter, 0);
- assertEquals(caA.counter, 0);
- assertEquals(caABC.counter, 0);
-
- ab.setAdditivity(false);
-
-
- a.debug(MSG);
- assertEquals(caRoot.counter, 1);
- assertEquals(caA.counter, 1);
- assertEquals(caABC.counter, 0);
-
- ab.debug(MSG);
- assertEquals(caRoot.counter, 1);
- assertEquals(caA.counter, 1);
- assertEquals(caABC.counter, 0);
-
- abc.debug(MSG);
- assertEquals(caRoot.counter, 1);
- assertEquals(caA.counter, 1);
- assertEquals(caABC.counter, 1);
- }
-
- /* Don't support getLoggerRepository
- public void testDisable1() {
- CountingAppender caRoot = new CountingAppender();
- Logger root = Logger.getRootLogger();
- root.getLogger().addAppender(caRoot);
-
- LoggerRepository h = LogManager.getLoggerRepository();
- //h.disableDebug();
- h.setThreshold((Level) Level.INFO);
- assertEquals(caRoot.counter, 0);
-
- root.debug(MSG);
- assertEquals(caRoot.counter, 0);
- root.info(MSG);
- assertEquals(caRoot.counter, 1);
- root.log(Level.WARN, MSG);
- assertEquals(caRoot.counter, 2);
- root.warn(MSG);
- assertEquals(caRoot.counter, 3);
-
- //h.disableInfo();
- h.setThreshold((Level) Level.WARN);
- root.debug(MSG);
- assertEquals(caRoot.counter, 3);
- root.info(MSG);
- assertEquals(caRoot.counter, 3);
- root.log(Level.WARN, MSG);
- assertEquals(caRoot.counter, 4);
- root.error(MSG);
- assertEquals(caRoot.counter, 5);
- root.log(Level.ERROR, MSG);
- assertEquals(caRoot.counter, 6);
-
- //h.disableAll();
- h.setThreshold(Level.OFF);
- root.debug(MSG);
- assertEquals(caRoot.counter, 6);
- root.info(MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.WARN, MSG);
- assertEquals(caRoot.counter, 6);
- root.error(MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.FATAL, MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.FATAL, MSG);
- assertEquals(caRoot.counter, 6);
-
- //h.disable(Level.FATAL);
- h.setThreshold(Level.OFF);
- root.debug(MSG);
- assertEquals(caRoot.counter, 6);
- root.info(MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.WARN, MSG);
- assertEquals(caRoot.counter, 6);
- root.error(MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.ERROR, MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.FATAL, MSG);
- assertEquals(caRoot.counter, 6);
- } */
-
- @Test
- public void testRB1() {
- Logger root = Logger.getRootLogger();
- root.setResourceBundle(rbUS);
- ResourceBundle t = root.getResourceBundle();
- assertSame(t, rbUS);
-
- Logger x = Logger.getLogger("x");
- Logger x_y = Logger.getLogger("x.y");
- Logger x_y_z = Logger.getLogger("x.y.z");
-
- t = x.getResourceBundle();
- assertSame(t, rbUS);
- t = x_y.getResourceBundle();
- assertSame(t, rbUS);
- t = x_y_z.getResourceBundle();
- assertSame(t, rbUS);
- }
-
- @Test
- public void testRB2() {
- Logger root = Logger.getRootLogger();
- root.setResourceBundle(rbUS);
- ResourceBundle t = root.getResourceBundle();
- assertTrue(t == rbUS);
-
- Logger x = Logger.getLogger("x");
- Logger x_y = Logger.getLogger("x.y");
- Logger x_y_z = Logger.getLogger("x.y.z");
-
- x_y.setResourceBundle(rbFR);
- t = x.getResourceBundle();
- assertSame(t, rbUS);
- t = x_y.getResourceBundle();
- assertSame(t, rbFR);
- t = x_y_z.getResourceBundle();
- assertSame(t, rbFR);
- }
-
- @Test
- public void testRB3() {
- Logger root = Logger.getRootLogger();
- root.setResourceBundle(rbUS);
- ResourceBundle t = root.getResourceBundle();
- assertTrue(t == rbUS);
-
- Logger x = Logger.getLogger("x");
- Logger x_y = Logger.getLogger("x.y");
- Logger x_y_z = Logger.getLogger("x.y.z");
-
- x_y.setResourceBundle(rbFR);
- x_y_z.setResourceBundle(rbCH);
- t = x.getResourceBundle();
- assertSame(t, rbUS);
- t = x_y.getResourceBundle();
- assertSame(t, rbFR);
- t = x_y_z.getResourceBundle();
- assertSame(t, rbCH);
- }
-
- @Test
- public void testExists() {
- Logger a = Logger.getLogger("a");
- Logger a_b = Logger.getLogger("a.b");
- Logger a_b_c = Logger.getLogger("a.b.c");
-
- Logger t;
- t = LogManager.exists("xx");
- assertNull(t);
- t = LogManager.exists("a");
- assertSame(a, t);
- t = LogManager.exists("a.b");
- assertSame(a_b, t);
- t = LogManager.exists("a.b.c");
- assertSame(a_b_c, t);
- }
- /* Don't support hierarchy
- public void testHierarchy1() {
- Hierarchy h = new Hierarchy(new RootLogger((Level) Level.ERROR));
- Logger a0 = h.getLogger("a");
- assertEquals("a", a0.getName());
- assertNull(a0.getLevel());
- assertSame(Level.ERROR, a0.getEffectiveLevel());
-
- Logger a1 = h.getLogger("a");
- assertSame(a0, a1);
- } */
-
- /**
- * Tests logger.trace(Object).
- */
- @Test
- public void testTrace() {
- ListAppender appender = new ListAppender("List");
- appender.start();
- Logger root = Logger.getRootLogger();
- root.getLogger().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");
-
- List<LogEvent> msgs = appender.getEvents();
- assertEquals(1, msgs.size());
- LogEvent event = (LogEvent) msgs.get(0);
- assertEquals(org.apache.logging.log4j.Level.TRACE, event.getLevel());
- assertEquals("Message 1", event.getMessage().getMessageFormat());
- }
-
- /**
- * Tests logger.trace(Object, Exception).
- */
- @Test
- public void testTraceWithException() {
- ListAppender appender = new ListAppender("List");
- Logger root = Logger.getRootLogger();
- root.getLogger().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);
-
- List<LogEvent> msgs = appender.getEvents();
- assertEquals(1, msgs.size());
- LogEvent event = msgs.get(0);
- assertEquals(org.apache.logging.log4j.Level.TRACE, event.getLevel());
- assertEquals("Message 1", event.getMessage().getFormattedMessage());
- }
-
- /**
- * Tests isTraceEnabled.
- */
- @Test
- public void testIsTraceEnabled() {
- ListAppender appender = new ListAppender("List");
- Logger root = Logger.getRootLogger();
- root.getLogger().addAppender(appender);
- root.setLevel(Level.INFO);
-
- Logger tracer = Logger.getLogger("com.example.Tracer");
- tracer.setLevel(Level.TRACE);
-
- assertTrue(tracer.isTraceEnabled());
- assertFalse(root.isTraceEnabled());
- }
-
- private static class CountingAppender extends AppenderBase {
-
- int counter;
-
- CountingAppender() {
- super("Counter", null, null);
- counter = 0;
- }
-
- public void close() {
- }
-
- public void append(LogEvent event) {
- counter++;
- }
-
- public boolean requiresLayout() {
- return true;
- }
- }
-}
-
diff --git a/rgoers/log4j12-api/src/test/java/org/apache/log4j/PriorityTest.java b/rgoers/log4j12-api/src/test/java/org/apache/log4j/PriorityTest.java
deleted file mode 100644
index 97dd687..0000000
--- a/rgoers/log4j12-api/src/test/java/org/apache/log4j/PriorityTest.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.Locale;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.junit.Assert;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Tests of Priority.
- *
- */
-public class PriorityTest {
-
- /**
- * Tests Priority.OFF_INT.
- */
- @Test
- public void testOffInt() {
- assertEquals(Integer.MAX_VALUE, Priority.OFF_INT);
- }
-
- /**
- * Tests Priority.FATAL_INT.
- */
- @Test
- public void testFatalInt() {
- assertEquals(50000, Priority.FATAL_INT);
- }
-
- /**
- * Tests Priority.ERROR_INT.
- */
- @Test
- public void testErrorInt() {
- assertEquals(40000, Priority.ERROR_INT);
- }
-
- /**
- * Tests Priority.WARN_INT.
- */
- @Test
- public void testWarnInt() {
- assertEquals(30000, Priority.WARN_INT);
- }
-
- /**
- * Tests Priority.INFO_INT.
- */
- @Test
- public void testInfoInt() {
- assertEquals(20000, Priority.INFO_INT);
- }
-
- /**
- * Tests Priority.DEBUG_INT.
- */
- @Test
- public void testDebugInt() {
- assertEquals(10000, Priority.DEBUG_INT);
- }
-
- /**
- * Tests Priority.ALL_INT.
- */
- @Test
- public void testAllInt() {
- assertEquals(Integer.MIN_VALUE, Priority.ALL_INT);
- }
-
- /**
- * Tests Priority.FATAL.
- *
- * @deprecated
- */
- @Test
- public void testFatal() {
- assertTrue(Priority.FATAL instanceof Level);
- }
-
- /**
- * Tests Priority.ERROR.
- *
- * @deprecated
- */
- @Test
- public void testERROR() {
- assertTrue(Priority.ERROR instanceof Level);
- }
-
- /**
- * Tests Priority.WARN.
- *
- * @deprecated
- */
- @Test
- public void testWARN() {
- assertTrue(Priority.WARN instanceof Level);
- }
-
- /**
- * Tests Priority.INFO.
- *
- * @deprecated
- */
- @Test
- public void testINFO() {
- assertTrue(Priority.INFO instanceof Level);
- }
-
- /**
- * Tests Priority.DEBUG.
- *
- * @deprecated
- */
- @Test
- public void testDEBUG() {
- assertTrue(Priority.DEBUG instanceof Level);
- }
-
- /**
- * Tests Priority.equals(null).
- *
- * @deprecated
- */
- @Test
- public void testEqualsNull() {
- assertFalse(Priority.DEBUG.equals(null));
- }
-
- /**
- * Tests Priority.equals(Level.DEBUG).
- *
- * @deprecated
- */
- @Test
- public void testEqualsLevel() {
- //
- // this behavior violates the equals contract.
- //
- assertTrue(Priority.DEBUG.equals(Level.DEBUG));
- }
-
- /**
- * Tests getAllPossiblePriorities().
- *
- * @deprecated
- */
- @Test
- public void testGetAllPossiblePriorities() {
- Priority[] priorities = Priority.getAllPossiblePriorities();
- assertEquals(5, priorities.length);
- }
-
- /**
- * Tests toPriority(String).
- *
- * @deprecated
- */
- @Test
- public void testToPriorityString() {
- assertTrue(Priority.toPriority("DEBUG") == Level.DEBUG);
- }
-
- /**
- * Tests toPriority(int).
- *
- * @deprecated
- */
- @Test
- public void testToPriorityInt() {
- assertTrue(Priority.toPriority(Priority.DEBUG_INT) == Level.DEBUG);
- }
-
- /**
- * Tests toPriority(String, Priority).
- *
- * @deprecated
- */
- @Test
- public void testToPriorityStringPriority() {
- assertTrue(Priority.toPriority("foo", Priority.DEBUG) == Priority.DEBUG);
- }
-
- /**
- * Tests toPriority(int, Priority).
- *
- * @deprecated
- */
- @Test
- public void testToPriorityIntPriority() {
- assertTrue(Priority.toPriority(17, Priority.DEBUG) == Priority.DEBUG);
- }
-
- /**
- * Test that dotless lower I + "nfo" is recognized as INFO.
- *
- * @deprecated
- */
- @Test
- 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
- */
- @Test
- 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/rgoers/log4j12-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java b/rgoers/log4j12-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java
deleted file mode 100644
index 89feb33..0000000
--- a/rgoers/log4j12-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.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;
-
-import org.junit.Assert;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
-/**
- * Utiities for serialization tests.
- */
-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) {
- 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]) {
- 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();
- fail("Writing witness file " + witness);
- }
- }
-}
-
diff --git a/rgoers/log4j12-api/src/test/resources/L7D_en_US.properties b/rgoers/log4j12-api/src/test/resources/L7D_en_US.properties
deleted file mode 100644
index c3c2802..0000000
--- a/rgoers/log4j12-api/src/test/resources/L7D_en_US.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-test=This is the English, US test.
-hello_world=Hello world.
-msg1=This is test number {0} with string argument {1}.
diff --git a/rgoers/log4j12-api/src/test/resources/L7D_fr.properties b/rgoers/log4j12-api/src/test/resources/L7D_fr.properties
deleted file mode 100644
index 25b878a..0000000
--- a/rgoers/log4j12-api/src/test/resources/L7D_fr.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-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/rgoers/log4j12-api/src/test/resources/L7D_fr_CH.properties b/rgoers/log4j12-api/src/test/resources/L7D_fr_CH.properties
deleted file mode 100644
index ba9b1ff..0000000
--- a/rgoers/log4j12-api/src/test/resources/L7D_fr_CH.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-test=Ceci est le test en francais pour la p'tite Suisse.
-hello world=Salut le monde.
diff --git a/rgoers/log4j12-api/src/test/resources/witness/serialization/info.bin b/rgoers/log4j12-api/src/test/resources/witness/serialization/info.bin
deleted file mode 100644
index f887f39..0000000
--- a/rgoers/log4j12-api/src/test/resources/witness/serialization/info.bin
+++ /dev/null
Binary files differ
diff --git a/rgoers/log4j2-api/pom.xml b/rgoers/log4j2-api/pom.xml
deleted file mode 100644
index c5ab564..0000000
--- a/rgoers/log4j2-api/pom.xml
+++ /dev/null
@@ -1,164 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2</artifactId>
- <version>1.99.0-SNAPSHOT</version>
- </parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-api</artifactId>
- <packaging>jar</packaging>
- <name>Log4J API</name>
- <description>The Log4J API</description>
- <properties>
- <log4j.parent.dir>${basedir}/..</log4j.parent.dir>
- </properties>
- <dependencies>
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.3.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <version>2.6</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>changes-report</report>
- </reports>
- </reportSet>
- </reportSets>
- <configuration>
- <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.7</version>
- <configuration>
- <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
- <configLocation>${log4j.parent.dir}/checkstyle.xml</configLocation>
- <suppressionsLocation>${log4j.parent.dir}/checkstyle-suppressions.xml</suppressionsLocation>
- <enableRulesSummary>false</enableRulesSummary>
- <propertyExpansion>basedir=${basedir}</propertyExpansion>
- <propertyExpansion>licensedir=${log4j.parent.dir}/checkstyle-header.txt</propertyExpansion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8</version>
- <configuration>
- <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
- project -->
- <detectOfflineLinks>false</detectOfflineLinks>
- <linksource>true</linksource>
- <tags>
- <tag>
- <name>issue</name>
- <placement>a</placement>
- <head>JIRA issue:</head>
- </tag>
- <tag>
- <name>doubt</name>
- <placement>a</placement>
- <head>Troublesome:</head>
- </tag>
- <tag>
- <name>compare</name>
- <placement>a</placement>
- <head>Compare with:</head>
- </tag>
- </tags>
- </configuration>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <threshold>Normal</threshold>
- <effort>Default</effort>
- <excludeFilterFile>${log4j.parent.dir}/findbugs-exclude-filter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.3</version>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>jxr</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <targetJdk>1.5</targetJdk>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.2</version>
- <reportSets>
- <reportSet>
- <!-- Disabled at it kills the site generation via a NoClassDefFoundError -->
- <reports/>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
-</project>
-
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/EventLogger.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/EventLogger.java
deleted file mode 100644
index 3a047e3..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/EventLogger.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.spi.AbstractLoggerWrapper;
-
-/**
- * Logs "Events" that are represented as StructuredDataMessages.
- */
-public final class EventLogger {
-
- /**
- * Define the Event Marker.
- */
- public static final Marker EVENT_MARKER = MarkerManager.getMarker("EVENT");
-
- private static final String FQCN = EventLogger.class.getName();
-
- private static AbstractLoggerWrapper logger;
-
- static {
- Logger l = LogManager.getLogger("EventLogger");
- if (!(l instanceof AbstractLogger)) {
- throw new LoggingException("Logger returned must be based on AbstractLogger");
- }
- logger = new AbstractLoggerWrapper((AbstractLogger) l, "EventLogger");
- }
-
-
- private EventLogger() {
- }
-
- /**
- * Log events with a level of ALL.
- * @param msg The event StructuredDataMessage.
- */
- public static void logEvent(StructuredDataMessage msg) {
- logger.log(EVENT_MARKER, FQCN, Level.OFF, msg, null);
- }
-
- /**
- * Log events and specify the logging level.
- * @param msg The event StructuredDataMessage.
- * @param level The logging Level.
- */
- public static void logEvent(StructuredDataMessage msg, Level level) {
- logger.log(EVENT_MARKER, FQCN, level, msg, null);
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Level.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Level.java
deleted file mode 100644
index 4fd3115..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Level.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-/**
- * Levels used for identifying the severity of an event. Levels are organized from most specific to least:<br>
- * OFF (most specific)<br>
- * FATAL<br>
- * ERROR<br>
- * WARN<br>
- * INFO<br>
- * DEBUG<br>
- * TRACE<br>
- * AL (least specific)<br>
- *
- * Typically, configuring a level in a filter or on a logger will cause logging events of that level and those
- * that are more specific to pass through the filter.
- * A special level, ALL, is guaranteed to capture all levels when used in logging configurations.
- * @doubt see LOG4J-41
- */
-public enum Level {
- /**
- * No events will be logged.
- */
- OFF(0),
- /**
- * A severe error that will prevent the application from continuing.
- */
- FATAL(1),
- /**
- * An error in the application, possibly recoverable.
- */
- ERROR(2),
- /**
- * An event that might possible lead to an error.
- */
- WARN(3),
- /**
- * An event for informational purposes.
- */
- INFO(4),
- /**
- * A general debugging event.
- */
- DEBUG(5),
- /**
- * A fine-grained debug message, typically capturing the flow through the application.
- */
- TRACE(6),
- /**
- * All events should be logged.
- */
- ALL(Integer.MAX_VALUE);
-
- private final int intLevel;
-
- private Level(int val) {
- intLevel = val;
- }
-
- /**
- * Convert the string passed as argument to a level. If the
- * conversion fails, then this method returns {@link #DEBUG}.
- *
- * @param sArg The name of the desired Level.
- * @return The Level associated with the String.
- */
- public static Level toLevel(String sArg) {
- return toLevel(sArg, DEBUG);
- }
-
- /**
- * Convert the string passed as argument to a level. If the
- * conversion fails, then this method returns the value of
- * <code>defaultLevel</code>.
- *
- * @param sArg The name of the desired Level.
- * @param defaultLevel The Level to use if the String is invalid.
- * @return The LEvel associated with the String.
- */
- public static Level toLevel(String sArg, Level defaultLevel) {
- if (sArg == null) {
- return defaultLevel;
- }
- for (Level level : values()) {
- if (level.name().equals(sArg)) {
- return level;
- }
- }
- return defaultLevel;
- }
-
- /**
- * Compares this level against the level passed as an argument and returns true if this
- * level is the same or more specific.
- *
- * @param level The level to check.
- * @return True if the passed Level is more specific or the same as this Level.
- */
- public boolean isAtLeastAsSpecificAs(Level level) {
- return (intLevel <= level.intLevel);
- }
-
- /**
- * Compares this level against the level passed as an argument and returns true if this
- * level is the same or more specific.
- *
- * @param level The level to check.
- * @return True if the passed Level is more specific or the same as this Level.
- */
- public boolean isAtLeastAsSpecificAs(int level) {
- return (intLevel <= level);
- }
-
- /**
- * Compares the specified Level against this one.
- * @param level The level to check.
- * @return True if the passed Level is more specific or the same as this Level.
- */
- public boolean lessOrEqual(Level level) {
- return (intLevel <= level.intLevel);
- }
-
- /**
- * Compares the specified Level against this one.
- * @param level The level to check.
- * @return True if the passed Level is more specific or the same as this Level.
- */
- public boolean lessOrEqual(int level) {
- return (intLevel <= level);
- }
-
- /**
- * Returns the integer value of the Level.
- * @return the integer value of the Level.
- */
- public int intLevel() {
- return intLevel;
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java
deleted file mode 100644
index 2c9f149..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.apache.logging.log4j.spi.LoggerContextFactory;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * The anchor point for the logging system.
- */
-public class LogManager {
- /**
- * The name of the root Logger.
- */
- public static final String ROOT_LOGGER_NAME = "";
-
- private static final String LOGGER_RESOURCE = "META-INF/log4j-provider.xml";
- private static final String LOGGER_CONTEXT_FACTORY = "LoggerContextFactory";
- private static final String API_VERSION = "Log4jAPIVersion";
- private static final String[] COMPATIBLE_API_VERSIONS = {
- "1.99.0"
- };
-
- private static LoggerContextFactory factory;
-
- private static Logger logger = StatusLogger.getLogger();
-
- /**
- * Prevent instantiation
- */
- protected LogManager() {
- }
-
-
- /**
- * Scans the classpath to find all logging implementation. Currently, only one will
- * be used but this could be extended to allow multiple implementations to be used.
- */
- static {
- ClassLoader cl = findClassLoader();
- List<LoggerContextFactory> factories = new ArrayList<LoggerContextFactory>();
-
- Enumeration enumResources = null;
- try {
- enumResources = cl.getResources(LOGGER_RESOURCE);
- } catch (IOException e) {
- logger.fatal("Unable to locate " + LOGGER_RESOURCE, e);
- }
-
- if (enumResources != null) {
- while (enumResources.hasMoreElements()) {
- Properties props = new Properties();
- URL url = (URL) enumResources.nextElement();
- try {
- props.loadFromXML(url.openStream());
- } catch (IOException ioe) {
- logger.error("Unable to read " + url.toString(), ioe);
- }
- if (!validVersion(props.getProperty(API_VERSION))) {
- continue;
- }
- String className = props.getProperty(LOGGER_CONTEXT_FACTORY);
- if (className != null) {
- try {
- Class clazz = cl.loadClass(className);
- if (LoggerContextFactory.class.isAssignableFrom(clazz)) {
- factories.add((LoggerContextFactory) clazz.newInstance());
- } else {
- logger.error(className + " does not implement " + LoggerContextFactory.class.getName());
- }
- } catch (ClassNotFoundException cnfe) {
- logger.error("Unable to locate class " + className + " specified in " + url.toString(), cnfe);
- } catch (IllegalAccessException iae) {
- logger.error("Unable to create class " + className + " specified in " + url.toString(), iae);
- } catch (Exception e) {
- logger.error("Unable to create class " + className + " specified in " + url.toString(), e);
- e.printStackTrace();
- }
- }
- }
- if (factories.size() != 1) {
- logger.fatal("Unable to locate a logging implementation");
- } else {
- factory = factories.get(0);
- }
- } else {
- logger.fatal("Unable to locate a logging implementation");
- }
- }
-
- /**
- * Return the LoggerContextFactory.
- * @return The LoggerContextFactory.
- */
- public static LoggerContextFactory getFactory() {
- return factory;
- }
-
- /**
- * Return a Logger with the specified name.
- *
- * @param name The logger name.
- * @return The Logger.
- */
- public static Logger getLogger(String name) {
-
- return factory.getContext(LogManager.class.getName(), false).getLogger(name);
- }
-
- /**
- * Return a Logger with the specified name.
- *
- * @param fqcn The fully qualified class name of the class that this method is a member of.
- * @param name The logger name.
- * @return The Logger.
- */
- protected static Logger getLogger(String fqcn, String name) {
-
- return factory.getContext(fqcn, false).getLogger(name);
- }
-
- /**
- * Returns the current LoggerContext.
- * <p>
- * WARNING - The LoggerContext returned by this method may not be the LoggerContext used to create a Logger
- * for the calling class.
- * @return The current LoggerContext.
- */
- public static LoggerContext getContext() {
- return factory.getContext(LogManager.class.getName(), true);
- }
-
- /**
- * Returns a LoggerContext.
- *
- * @param currentContext if false the LoggerContext appropriate for the caller of this method is returned. For
- * example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be
- * returned and if the caller is a class in the container's classpath then a different LoggerContext may be
- * returned. If true then only a single LoggerContext will be returned.
- * @return a LoggerContext.
- */
- public static LoggerContext getContext(boolean currentContext) {
- return factory.getContext(LogManager.class.getName(), currentContext);
- }
-
- /**
- * Returns a LoggerContext
- * @param fqcn The fully qualified class name of the Class that this method is a member of.
- * @param currentContext if false the LoggerContext appropriate for the caller of this method is returned. For
- * example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be
- * returned and if the caller is a class in the container's classpath then a different LoggerContext may be
- * returned. If true then only a single LoggerContext will be returned.
- * @return a LoggerContext.
- */
- protected static LoggerContext getContext(String fqcn, boolean currentContext) {
- return factory.getContext(fqcn, currentContext);
- }
-
- private static ClassLoader findClassLoader() {
- ClassLoader cl;
- if (System.getSecurityManager() == null) {
- cl = Thread.currentThread().getContextClassLoader();
- } else {
- cl = (ClassLoader) java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
- return Thread.currentThread().getContextClassLoader();
- }
- }
- );
- }
- if (cl == null) {
- cl = LogManager.class.getClassLoader();
- }
-
- return cl;
- }
-
- private static boolean validVersion(String version) {
- for (String v : COMPATIBLE_API_VERSIONS) {
- if (version.startsWith(v)) {
- return true;
- }
- }
- return false;
- }
-
-
-
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Logger.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Logger.java
deleted file mode 100644
index c7ae395..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Logger.java
+++ /dev/null
@@ -1,944 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.message.Message;
-
-/**
- * This is the central interface in the log4j package. Most logging
- * operations, except configuration, are done through this interface.
- * @doubt See LOG4J2-39.
- * @doubt See LOG4J2-16.
- */
-public interface Logger {
-
- /**
- * Log entry to a method.
- */
- void entry();
-
- /**
- * Log entry to a method.
- * @param params The parameters to the method.
- * @doubt Use of varargs results in array creation which can be a substantial portion of no-op case.
- * LogMF/LogSF provides several overrides to avoid vararg except in edge cases. (RG) LogMF
- * and LogSF implement these in LogXF which calls logger.callAppenders. callAppenders is
- * part of the implementation and cannot be used by the API. Adding more methods here
- * and in AbstractLogger is sufficient.
- */
- void entry(Object... params);
-
- /**
- * Log exit from a method.
- */
- void exit();
-
- /**
- * Log exiting from a method with the result. This may be coded as <br />
- * return logger.exit(myResult);
- * @param result The result being returned from the method call.
- * @return the result.
- */
- <R> R exit(R result);
-
- /**
- * Log an exception or error to be thrown. This may be coded as <br />
- * throw logger.throwing(myException);
- *
- * @param t The Throwable.
- * @return the Throwable.
- */
- <T extends Throwable> T throwing(T t);
-
- /**
- * Log an exception or error to be thrown. This may be coded as <br />
- * throw logger.throwing(debug, myException);
- * @param level The logging Level.
- * @param t The Throwable.
- * @return the Throwable.
- */
- <T extends Throwable> T throwing(Level level, T t);
-
- /**
- * Log an exception or error that has been caught.
- * @param t The Throwable.
- */
- void catching(Throwable t);
-
- /**
- * Log an exception or error that has been caught.
- * @param level The logging Level.
- * @param t The Throwable.
- */
- void catching(Level level, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
- *
- * @param message the message object to log.
- */
- void trace(String message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- */
- void trace(Marker marker, String message);
-
- /**
- * Log a message at the <code>TRACE</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- * <p/>
- * <p>
- * See {@link #debug(String)} form for more detailed information.
- * </p>
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void trace(String message, Throwable t);
-
- /**
- * Log a message at the <code>TRACE</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- * <p/>
- * <p>
- * See {@link #debug(String)} form for more detailed information.
- * </p>
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void trace(Marker marker, String message, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
- *
- * @param message the message object to log.
- */
- void trace(Object message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- */
- void trace(Marker marker, Object message);
-
- /**
- * Log a message at the <code>TRACE</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- * <p/>
- * <p>
- * See {@link #debug(String)} form for more detailed information.
- * </p>
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void trace(Object message, Throwable t);
-
- /**
- * Log a message at the <code>TRACE</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- * <p/>
- * <p>
- * See {@link #debug(String)} form for more detailed information.
- * </p>
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void trace(Marker marker, Object message, Throwable t);
-
- /**
- * Log a message with parameters at the <code>TRACE</code> level.
- * @param message the message to log.
- * @param params parameters to the message.
- */
- void trace(String message, Object... params);
-
- /**
- * Log a message with parameters at the <code>TRACE</code> level.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message to log.
- * @param params parameters to the message.
- */
- void trace(Marker marker, String message, Object... params);
-
- /**
- * Check whether this Logger is enabled for the TRACE Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * TRACE, <code>false</code> otherwise.
- */
- boolean isTraceEnabled();
-
- /**
- * Check whether this Logger is enabled for the TRACE Level.
- *
- * @param marker The marker data specific to this log statement.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * TRACE, <code>false</code> otherwise.
- */
- boolean isTraceEnabled(Marker marker);
-
- /**
- * Log a message with the specific Marker at the TRACE level.
- *
- * @param msg the message string to be logged
- */
- void trace(Message msg);
-
- /**
- * Log a message with the specific Marker at the TRACE level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void trace(Message msg, Throwable t);
-
- /**
- * Log a message with the specific Marker at the TRACE level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- */
- void trace(Marker marker, Message msg);
-
- /**
- * Log a message with the specific Marker at the TRACE level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void trace(Marker marker, Message msg, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
- *
- * @param message the message object to log.
- */
- void debug(String message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- */
- void debug(Marker marker, String message);
-
- /**
- * Log a message at the <code>DEBUG</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message to log.
- * @param t the exception to log, including its stack trace.
- */
- void debug(String message, Throwable t);
-
- /**
- * Log a message at the <code>DEBUG</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message to log.
- * @param t the exception to log, including its stack trace.
- */
- void debug(Marker marker, String message, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
- *
- * @param message the message object to log.
- */
- void debug(Object message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- */
- void debug(Marker marker, Object message);
-
- /**
- * Log a message at the <code>DEBUG</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message to log.
- * @param t the exception to log, including its stack trace.
- */
- void debug(Object message, Throwable t);
-
- /**
- * Log a message at the <code>DEBUG</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message to log.
- * @param t the exception to log, including its stack trace.
- */
- void debug(Marker marker, Object message, Throwable t);
-
- /**
- * Log a message with parameters at the <code>DEBUG</code> level.
- * @param message the message to log.
- * @param params parameters to the message.
- */
- void debug(String message, Object... params);
-
- /**
- * Log a message with parameters at the <code>DEBUG</code> level.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message to log.
- * @param params parameters to the message.
- */
- void debug(Marker marker, String message, Object... params);
-
- /**
- * Check whether this Logger is enabled for the DEBUG Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * DEBUG, <code>false</code> otherwise.
- */
- boolean isDebugEnabled();
-
- /**
- * Check whether this Logger is enabled for the DEBUG Level.
- *
- * @param marker The marker data specific to this log statement.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * DEBUG, <code>false</code> otherwise.
- */
- boolean isDebugEnabled(Marker marker);
-
- /**
- * Log a message with the specific Marker at the DEBUG level.
- *
- * @param msg the message string to be logged
- */
- void debug(Message msg);
-
- /**
- * Log a message with the specific Marker at the DEBUG level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void debug(Message msg, Throwable t);
-
- /**
- * Log a message with the specific Marker at the DEBUG level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- */
- void debug(Marker marker, Message msg);
-
- /**
- * Log a message with the specific Marker at the DEBUG level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void debug(Marker marker, Message msg, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
- *
- * @param message the message object to log.
- */
- void info(String message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- */
- void info(Marker marker, String message);
-
- /**
- * Log a message at the <code>INFO</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void info(String message, Throwable t);
-
- /**
- * Log a message at the <code>INFO</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void info(Marker marker, String message, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
- *
- * @param message the message object to log.
- */
- void info(Object message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- */
- void info(Marker marker, Object message);
-
- /**
- * Log a message at the <code>INFO</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void info(Object message, Throwable t);
-
- /**
- * Log a message at the <code>INFO</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void info(Marker marker, Object message, Throwable t);
-
- /**
- * Log a message with parameters at the <code>INFO</code> level.
- *
- * @param message the message to log.
- * @param params parameters to the message.
- *
- * @doubt Likely to misinterpret existing log4j client code that intended to call
- * info(Object,Throwable). Incurs array creation expense on every call. (RG) It isn't
- * possible to be misinterpreted as the previous method is for that signature. Methods
- * should be added to avoid varargs for 1, 2 or 3 parameters.
- */
- void info(String message, Object... params);
-
- /**
- * Log a message with parameters at the <code>INFO</code> level.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message to log.
- * @param params parameters to the message.
- *
- * @doubt Likely to misinterpret existing log4j client code that intended to call
- * info(Object,Throwable). Incurs array creation expense on every call. (RG) It isn't
- * possible to be misinterpreted as the previous method is for that signature. Methods
- * should be added to avoid varargs for 1, 2 or 3 parameters.
- */
- void info(Marker marker, String message, Object... params);
- /**
- * Check whether this Logger is enabled for the INFO Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * INFO, <code>false</code> otherwise.
- */
- boolean isInfoEnabled();
-
- /**
- * Check whether this Logger is enabled for the INFO Level.
- *
- * @param marker The marker data specific to this log statement.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * INFO, <code>false</code> otherwise.
- */
- boolean isInfoEnabled(Marker marker);
-
- /**
- * Log a message with the specific Marker at the TRACE level.
- *
- * @param msg the message string to be logged
- */
- void info(Message msg);
-
- /**
- * Log a message with the specific Marker at the INFO level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void info(Message msg, Throwable t);
-
- /**
- * Log a message with the specific Marker at the INFO level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- */
- void info(Marker marker, Message msg);
-
- /**
- * Log a message with the specific Marker at the INFO level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void info(Marker marker, Message msg, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
- *
- * @param message the message object to log.
- */
- void warn(String message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- */
- void warn(Marker marker, String message);
-
- /**
- * Log a message at the <code>WARN</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void warn(String message, Throwable t);
-
- /**
- * Log a message at the <code>WARN</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void warn(Marker marker, String message, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
- *
- * @param message the message object to log.
- */
- void warn(Object message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- */
- void warn(Marker marker, Object message);
-
- /**
- * Log a message at the <code>WARN</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void warn(Object message, Throwable t);
-
- /**
- * Log a message at the <code>WARN</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void warn(Marker marker, Object message, Throwable t);
-
- /**
- * Log a message with parameters at the <code>WARN</code> level.
- * @param message the message to log.
- * @param params parameters to the message.
- * @doubt Likely to misinterpret existing log4j client code that intended to call
- * info(Object,Throwable). Incurs array creation expense on every call. (RG) I assume you
- * meant warn, not info. It isn't possible to be misinterpreted as the previous method
- * is for that signature.Methods should be added to avoid varargs for 1, 2 or 3 parameters.
- */
- void warn(String message, Object... params);
-
- /**
- * Log a message with parameters at the <code>WARN</code> level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message to log.
- * @param params parameters to the message.
- *
- * @doubt Likely to misinterpret existing log4j client code that intended to call
- * info(Object,Throwable). Incurs array creation expense on every call. (RG) I assume you
- * meant warn, not info. It isn't possible to be misinterpreted as the previous method
- * is for that signature.Methods should be added to avoid varargs for 1, 2 or 3 parameters.
- */
- void warn(Marker marker, String message, Object... params);
-
- /**
- * Check whether this Logger is enabled for the WARN Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * WARN, <code>false</code> otherwise.
- */
- boolean isWarnEnabled();
-
- /**
- * Check whether this Logger is enabled for the WARN Level.
- *
- * @param marker The marker data specific to this log statement.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * WARN, <code>false</code> otherwise.
- */
- boolean isWarnEnabled(Marker marker);
-
- /**
- * Log a message with the specific Marker at the WARN level.
- *
- * @param msg the message string to be logged
- */
- void warn(Message msg);
-
- /**
- * Log a message with the specific Marker at the WARN level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void warn(Message msg, Throwable t);
-
- /**
- * Log a message with the specific Marker at the WARN level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- */
- void warn(Marker marker, Message msg);
-
- /**
- * Log a message with the specific Marker at the WARN level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void warn(Marker marker, Message msg, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
- *
- * @param message the message object to log.
- */
- void error(String message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- void error(Marker marker, String message);
-
- /**
- * Log a message at the <code>ERROR</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void error(String message, Throwable t);
-
- /**
- * Log a message at the <code>ERROR</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void error(Marker marker, String message, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
- *
- * @param message the message object to log.
- */
- void error(Object message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- void error(Marker marker, Object message);
-
- /**
- * Log a message at the <code>ERROR</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void error(Object message, Throwable t);
-
- /**
- * Log a message at the <code>ERROR</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void error(Marker marker, Object message, Throwable t);
-
- /**
- * Log a message with parameters at the <code>ERROR</code> level.
- *
- * @param message the message to log.
- * @param params parameters to the message.
- *
- * @doubt Likely to misinterpret existing log4j client code that intended to call
- * info(Object,Throwable). Incurs array creation expense on every call. (RG) I assume you
- * meant error, not info. It isn't possible to be misinterpreted as the previous method
- * is for that signature. Methods should be added to avoid varargs for 1, 2 or 3 parameters.
- */
- void error(String message, Object... params);
-
- /**
- * Log a message with parameters at the <code>ERROR</code> level.
- * @param marker the marker data specific to this log statement.
- * @param message the message to log.
- * @param params parameters to the message.
- *
- * @doubt Likely to misinterpret existing log4j client code that intended to call
- * info(Object,Throwable). Incurs array creation expense on every call. (RG) I assume you
- * meant error, not info. It isn't possible to be misinterpreted as the previous method
- * is for that signature. Methods should be added to avoid varargs for 1, 2 or 3 parameters.
- */
- void error(Marker marker, String message, Object... params);
-
- /**
- * Check whether this Logger is enabled for the ERROR Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * ERROR, <code>false</code> otherwise.
- */
- boolean isErrorEnabled();
-
- /**
- * Check whether this Logger is enabled for the ERROR Level.
- *
- * @param marker The marker data specific to this log statement.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * ERROR, <code>false</code> otherwise.
- */
- boolean isErrorEnabled(Marker marker);
-
- /**
- * Log a message with the specific Marker at the ERROR level.
- *
- * @param msg the message string to be logged
- */
- void error(Message msg);
-
- /**
- * Log a message with the specific Marker at the ERROR level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void error(Message msg, Throwable t);
-
- /**
- * Log a message with the specific Marker at the ERROR level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- */
- void error(Marker marker, Message msg);
-
- /**
- * Log a message with the specific Marker at the ERROR level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void error(Marker marker, Message msg, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
- *
- * @param message the message object to log.
- */
- void fatal(String message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
- *
- * @param marker The marker data specific to this log statement.
- * @param message the message object to log.
- */
- void fatal(Marker marker, String message);
-
- /**
- * Log a message at the <code>FATAL</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void fatal(String message, Throwable t);
-
-
- /**
- * Log a message at the <code>FATAL</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker The marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void fatal(Marker marker, String message, Throwable t);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
- *
- * @param message the message object to log.
- */
- void fatal(Object message);
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
- *
- * @param marker The marker data specific to this log statement.
- * @param message the message object to log.
- */
- void fatal(Marker marker, Object message);
-
- /**
- * Log a message at the <code>FATAL</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void fatal(Object message, Throwable t);
-
- /**
- * Log a message at the <code>FATAL</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker The marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void fatal(Marker marker, Object message, Throwable t);
-
- /**
- * Log a message with parameters at the <code>FATAL</code> level.
- *
- *
- * @param message the message to log.
- * @param params parameters to the message.
- *
- * @doubt Likely to misinterpret existing log4j client code that intended to call
- * info(Object,Throwable). Incurs array creation expense on every call.(RG) I assume you
- * meant fatal, not info. It isn't possible to be misinterpreted as the previous method
- * is for that signature. Methods should be added to avoid varargs for 1, 2 or 3 parameters.
- */
- void fatal(String message, Object... params);
-
- /**
- * Log a message with parameters at the <code>FATAL</code> level.
- *
- * @param marker The marker data specific to this log statement.
- * @param message the message to log.
- * @param params parameters to the message.
- *
- * @doubt Likely to misinterpret existing log4j client code that intended to call
- * info(Object,Throwable). Incurs array creation expense on every call.(RG) I assume you
- * meant fatal, not info. It isn't possible to be misinterpreted as the previous method
- * is for that signature. Methods should be added to avoid varargs for 1, 2 or 3 parameters.
- */
- void fatal(Marker marker, String message, Object... params);
-
- /**
- * Check whether this Logger is enabled for the FATAL Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * FATAL, <code>false</code> otherwise.
- */
- boolean isFatalEnabled();
-
- /**
- * Check whether this Logger is enabled for the FATAL Level.
- *
- * @param marker The marker data specific to this log statement.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * FATAL, <code>false</code> otherwise.
- */
- boolean isFatalEnabled(Marker marker);
-
- /**
- * Log a message with the specific Marker at the FATAL level.
- *
- * @param msg the message string to be logged
- */
- void fatal(Message msg);
-
- /**
- * Log a message with the specific Marker at the FATAL level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void fatal(Message msg, Throwable t);
-
- /**
- * Log a message with the specific Marker at the FATAL level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- */
- void fatal(Marker marker, Message msg);
-
- /**
- * Log a message with the specific Marker at the FATAL level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- void fatal(Marker marker, Message msg, Throwable t);
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LoggingException.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LoggingException.java
deleted file mode 100644
index 49969c2..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LoggingException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-/**
- * Exception thrown when a exception occurs while logging. In most cases exceptions will be handled
- * within Log4j but certain Appenders may be configured to allow exceptions to propagate to the
- * application. This is a RuntimeException so that the exception may be thrown in those cases without
- * requiring all Logger methods be contained with try/catch blocks.
- *
- */
-public class LoggingException extends RuntimeException {
-
- private static final long serialVersionUID = 6366395965071580537L;
-
- /**
- * Constructs a LoggingException with a message.
- * @param msg The message.
- */
- public LoggingException(String msg) {
- super(msg);
- }
-
- /**
- * Constructs a LoggingException with a message and a chained Exception.
- * @param msg The message.
- * @param ex The chained Exception.
- */
- public LoggingException(String msg, Exception ex) {
- super(msg, ex);
- }
-
- /**
- * Constructs a Logging Exception with a chained Exception and no message.
- * @param ex The chained Exception.
- */
- public LoggingException(Exception ex) {
- super(ex);
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Marker.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Marker.java
deleted file mode 100644
index 37cb3ed..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Marker.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import java.io.Serializable;
-
-/**
- * Markers are objects that are used to add easily filterable information to log messages.
- *
- * Markers can be hierarchical - each Marker may have a parent. This allows for broad categories
- * being subdivided into more specific categories. An example might be a Marker named "Error" with
- * children named "SystemError" and "ApplicationError".
- */
-public interface Marker extends Serializable {
-
- /**
- * Returns the name of this Marker.
- * @return The name of the Marker.
- */
- String getName();
-
- /**
- * Returns the parent of this Marker.
- * @return The parent Marker or null if this Marker has no parent.
- */
- Marker getParent();
-
- /**
- * Checks whether this Marker is an instance of the specified Marker.
- * @param m The Marker to check.
- * @return true of this Marker or one of its ancestors is the specified Marker, false otherwise.
- */
- boolean isInstanceOf(Marker m);
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/MarkerManager.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/MarkerManager.java
deleted file mode 100644
index 4bbd660..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/MarkerManager.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-
-/**
- * Applications create Markers by using the Marker Manager. All Markers created by this Manager are
- * immutable.
- */
-public final class MarkerManager {
-
- private static ConcurrentMap<String, Marker> markerMap = new ConcurrentHashMap<String, Marker>();
-
- private MarkerManager() {
- }
-
- /**
- * Retrieve a Marker or create a Marker that has no parent.
- * @param name The name of the Marker.
- * @return The Marker with the specified name.
- */
- public static Marker getMarker(String name) {
- markerMap.putIfAbsent(name, new Log4JMarker(name));
- return markerMap.get(name);
- }
-
- /**
- * Retrieves or creates a Marker with the specified parent. The parent must have been previously created.
- * @param name The name of the Marker.
- * @param parent The name of the parent Marker.
- * @return The Marker with the specified name.
- * @throws IllegalArgumentException if the parent Marker does not exist.
- */
- public static Marker getMarker(String name, String parent) {
- Marker parentMarker = markerMap.get(parent);
- if (parentMarker == null) {
- throw new IllegalArgumentException("Parent Marker " + parent + " has not been defined");
- }
- return getMarker(name, parentMarker);
- }
-
- /**
- * Retrieves or creates a Marker with the specified parent.
- * @param name The name of the Marker.
- * @param parent The parent Marker.
- * @return The Marker with the specified name.
- */
- public static Marker getMarker(String name, Marker parent) {
- markerMap.putIfAbsent(name, new Log4JMarker(name, parent));
- return markerMap.get(name);
- }
-
- /**
- * The actual Marker implementation.
- */
- private static class Log4JMarker implements Marker {
-
- private static final long serialVersionUID = 100L;
-
- private final String name;
- private final Marker parent;
-
- public Log4JMarker(String name) {
- this.name = name;
- this.parent = null;
- }
-
- public Log4JMarker(String name, Marker parent) {
- this.name = name;
- this.parent = parent;
- }
-
- public String getName() {
- return this.name;
- }
-
- public Marker getParent() {
- return this.parent;
- }
-
- public boolean isInstanceOf(Marker m) {
- if (m == null) {
- throw new IllegalArgumentException("A marker parameter is required");
- }
- Marker test = this;
- do {
- if (test == m) {
- return true;
- }
- test = test.getParent();
- } while (test != null);
- return false;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Marker marker = (Marker) o;
-
- if (name != null ? !name.equals(marker.getName()) : marker.getName() != null) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return name != null ? name.hashCode() : 0;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder(name);
- if (parent != null) {
- Marker m = parent;
- sb.append("[ ");
- boolean first = true;
- while (m != null) {
- if (!first) {
- sb.append(", ");
- }
- sb.append(m.getName());
- first = false;
- m = m.getParent();
- }
- sb.append(" ]");
- }
- return sb.toString();
- }
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/ThreadContext.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/ThreadContext.java
deleted file mode 100644
index add7efe..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/ThreadContext.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
-
-
-/**
- * The ThreadContext allows applications to store information either in a Map
- * <p/>
- * <p><b><em>The MDC is managed on a per thread basis</em></b>. A
- * child thread automatically inherits a <em>copy</em> of the mapped
- * diagnostic context of its parent.
- */
-public final class ThreadContext {
-
- private static ThreadLocal<Map<String, String>> localMap =
- new InheritableThreadLocal<Map<String, String>>() {
- protected Map<String, String> childValue(Map<String, String> parentValue) {
- return parentValue == null ? null : new HashMap<String, String>(parentValue);
- }
- };
-
- private static ThreadLocal<Stack<String>> localStack =
- new InheritableThreadLocal<Stack<String>>() {
- protected Stack<String> childValue(Stack<String> parentValue) {
- return parentValue == null ? null : (Stack<String>) parentValue.clone();
- }
- };
-
-
-
- private ThreadContext() {
-
- }
-
- /**
- * Put a context value (the <code>o</code> parameter) as identified
- * with the <code>key</code> parameter into the current thread's
- * context map.
- * <p/>
- * <p>If the current thread does not have a context map it is
- * created as a side effect.
- * @param key The key name.
- * @param value The key value.
- */
- public static void put(String key, String value) {
- Map<String, String> map = localMap.get();
- if (map == null) {
- map = new HashMap<String, String>();
- localMap.set(map);
- }
- map.put(key, value);
- }
-
- /**
- * Get the context identified by the <code>key</code> parameter.
- * <p/>
- * <p>This method has no side effects.
- * @param key The key to locate.
- * @return The value associated with the key or null.
- */
- public static String get(String key) {
- Map<String, String> map = localMap.get();
- return map == null ? null : map.get(key);
- }
-
- /**
- * Remove the the context identified by the <code>key</code>
- * parameter.
- * @param key The key to remove.
- */
- public static void remove(String key) {
- Map<String, String> map = localMap.get();
- if (map != null) {
- map.remove(key);
- }
- }
-
- /**
- * Clear the context.
- */
- public static void clear() {
- localMap.remove();
- }
-
- /**
- * Determine if the key is in the context.
- * @param key The key to locate.
- * @return True if the key is in the context, false otherwise.
- */
- public static boolean containsKey(String key) {
- Map<String, String> map = localMap.get();
- return map == null ? false : map.containsKey(key);
- }
-
- /**
- * Get the current thread's MDC as a hashtable. This method is
- * intended to be used internally.
- * @return a copy of the context.
- */
- public static Map<String, String> getContext() {
- Map<String, String> map = localMap.get();
- return map == null ? new HashMap<String, String>() : new HashMap<String, String>(localMap.get());
- }
-
- /**
- * Clear the stack for this thread.
- */
- public static void clearStack() {
- localStack.remove();
- }
-
- /**
- * Return a copy of this thread's stack.
- * @return A copy of this thread's stack.
- */
- public static Stack<String> cloneStack() {
- Stack<String> stack = localStack.get();
- return stack == null ? new Stack<String>() : (Stack<String>) stack.clone();
- }
-
- /**
- * Set this thread's stack.
- * @param stack The stack to use.
- */
- public static void setStack(Stack<String> stack) {
- localStack.set(stack);
- }
-
- /**
- * Get the current nesting depth of this thread's stack.
- * @return the number of items in the stack.
- *
- * @see #setMaxDepth
- */
- public static int getDepth() {
- Stack<String> stack = localStack.get();
- return stack == null ? 0 : stack.size();
- }
-
- /**
- * Returns the value of the last item placed on the stack.
- * <p/>
- * <p>The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.
- *
- * @return String The innermost diagnostic context.
- */
- public static String pop() {
- Stack<String> s = localStack.get();
- if (s == null || s.isEmpty()) {
- return "";
- }
- return s.pop();
- }
-
- /**
- * Looks at the last diagnostic context at the top of this NDC
- * without removing it.
- * <p/>
- * <p>The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.
- *
- * @return String The innermost diagnostic context.
- */
- public static String peek() {
- Stack<String> s = localStack.get();
- if (s == null || s.isEmpty()) {
- return "";
- }
- return s.peek();
- }
-
- /**
- * Push new diagnostic context information for the current thread.
- * <p/>
- * <p>The contents of the <code>message</code> parameter is
- * determined solely by the client.
- *
- * @param message The new diagnostic context information.
- */
- public static void push(String message) {
- Stack<String> stack = localStack.get();
- if (stack == null) {
- stack = new Stack<String>();
- }
- stack.push(message);
- }
-
- /**
- * Remove the diagnostic context for this thread.
- * <p/>
- * <p>Each thread that created a diagnostic context by calling
- * {@link #push} should call this method before exiting. Otherwise,
- * the memory used by the <b>thread</b> cannot be reclaimed by the
- * VM.
- * <p/>
- * <p>As this is such an important problem in heavy duty systems and
- * because it is difficult to always guarantee that the remove
- * method is called before exiting a thread, this method has been
- * augmented to lazily remove references to dead threads. In
- * practice, this means that you can be a little sloppy and
- * occasionally forget to call {@link #remove} before exiting a
- * thread. However, you must call <code>remove</code> sometime. If
- * you never call it, then your application is sure to run out of
- * memory.
- */
- public static void removeStack() {
- localStack.remove();
- }
-
- /**
- * Set maximum depth of this diagnostic context. If the current
- * depth is smaller or equal to <code>maxDepth</code>, then no
- * action is taken.
- * <p/>
- * <p>This method is a convenient alternative to multiple {@link
- * #pop} calls. Moreover, it is often the case that at the end of
- * complex call sequences, the depth of the NDC is
- * unpredictable. The <code>setMaxDepth</code> method circumvents
- * this problem.
- * <p/>
- * <p>For example, the combination
- * <pre>
- * void foo() {
- * int depth = NDC.getDepth();
- * <p/>
- * ... complex sequence of calls
- * <p/>
- * NDC.setMaxDepth(depth);
- * }
- * </pre>
- * <p/>
- * ensures that between the entry and exit of foo the depth of the
- * diagnostic stack is conserved.
- *
- * @see #getDepth
- * @param maxDepth The maximum depth of the stack.
- */
- public static void setMaxDepth(int maxDepth) {
-
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/BasicThreadInformation.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/BasicThreadInformation.java
deleted file mode 100644
index a31d941..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/BasicThreadInformation.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-/**
- * Generates information about the current Thread. Used internally by ThreadDumpMessage.
- */
-class BasicThreadInformation implements ThreadInformation {
- private static final int HASH_SHIFT = 32;
- private static final int HASH_MULTIPLIER = 31;
- private final long id;
- private final String name;
- private final String longName;
- private final Thread.State state;
- private final int priority;
- private final boolean isAlive;
- private final boolean isDaemon;
- private final String threadGroupName;
-
- /**
- * The Constructor.
- * @param thread The Thread to capture.
- */
- public BasicThreadInformation(Thread thread) {
- this.id = thread.getId();
- this.name = thread.getName();
- this.longName = thread.toString();
- this.state = thread.getState();
- this.priority = thread.getPriority();
- this.isAlive = thread.isAlive();
- this.isDaemon = thread.isDaemon();
- ThreadGroup group = thread.getThreadGroup();
- threadGroupName = group == null ? null : group.getName();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- BasicThreadInformation that = (BasicThreadInformation) o;
-
- if (id != that.id) {
- return false;
- }
- if (name != null ? !name.equals(that.name) : that.name != null) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = (int) (id ^ (id >>> HASH_SHIFT));
- result = HASH_MULTIPLIER * result + (name != null ? name.hashCode() : 0);
- return result;
- }
-
- /**
- * Print the thread information.
- * @param sb The StringBuilder.
- */
- public void printThreadInfo(StringBuilder sb) {
- sb.append("\"").append(name).append("\" ");
- if (isDaemon) {
- sb.append("daemon ");
- }
- sb.append("prio=").append(priority).append(" tid=").append(id).append(" ");
- if (threadGroupName != null) {
- sb.append("group=\"").append(threadGroupName).append("\"");
- }
- sb.append("\n");
- sb.append("\tThread state: ").append(state.name()).append("\n");
- }
-
- /**
- * Format the StackTraceElements.
- * @param sb The StringBuilder.
- * @param trace The stack trace element array to format.
- */
- public void printStack(StringBuilder sb, StackTraceElement[] trace) {
- for (StackTraceElement element : trace) {
- sb.append("\tat ").append(element).append("\n");
- }
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ExtendedThreadInformation.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ExtendedThreadInformation.java
deleted file mode 100644
index 6e0d873..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ExtendedThreadInformation.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import java.lang.management.LockInfo;
-import java.lang.management.MonitorInfo;
-import java.lang.management.ThreadInfo;
-
-/**
- * Provides information on locks and monitors in the thread dump. This class requires Java 1.6 to compile and
- * run.
- */
-class ExtendedThreadInformation implements ThreadInformation {
-
- private final ThreadInfo info;
-
-
- public ExtendedThreadInformation(ThreadInfo thread) {
- this.info = thread;
- }
-
- public void printThreadInfo(StringBuilder sb) {
- sb.append("\"").append(info.getThreadName()).append("\"");
- sb.append(" Id=").append(info.getThreadId()).append(" ");
- formatState(sb, info);
- if (info.isSuspended()) {
- sb.append(" (suspended)");
- }
- if (info.isInNative()) {
- sb.append(" (in native)");
- }
- sb.append('\n');
- }
-
- public void printStack(StringBuilder sb, StackTraceElement[] stack) {
- int i = 0;
- for (StackTraceElement element : stack) {
- sb.append("\tat ").append(element.toString());
- sb.append('\n');
- if (i == 0 && info.getLockInfo() != null) {
- Thread.State ts = info.getThreadState();
- switch (ts) {
- case BLOCKED:
- sb.append("\t- blocked on ");
- formatLock(sb, info.getLockInfo());
- sb.append('\n');
- break;
- case WAITING:
- sb.append("\t- waiting on ");
- formatLock(sb, info.getLockInfo());
- sb.append('\n');
- break;
- case TIMED_WAITING:
- sb.append("\t- waiting on ");
- formatLock(sb, info.getLockInfo());
- sb.append('\n');
- break;
- default:
- }
- }
-
- for (MonitorInfo mi : info.getLockedMonitors()) {
- if (mi.getLockedStackDepth() == i) {
- sb.append("\t- locked ");
- formatLock(sb, mi);
- sb.append('\n');
- }
- }
- ++i;
- }
-
- LockInfo[] locks = info.getLockedSynchronizers();
- if (locks.length > 0) {
- sb.append("\n\tNumber of locked synchronizers = ").append(locks.length).append('\n');
- for (LockInfo li : locks) {
- sb.append("\t- ");
- formatLock(sb, li);
- sb.append('\n');
- }
- }
- }
-
- private void formatLock(StringBuilder sb, LockInfo lock) {
- sb.append("<").append(lock.getIdentityHashCode()).append("> (a ");
- sb.append(lock.getClassName()).append(")");
- }
-
- private void formatState(StringBuilder sb, ThreadInfo info) {
- Thread.State state = info.getThreadState();
- sb.append(state);
- switch (state) {
- case BLOCKED: {
- sb.append(" (on object monitor owned by \"");
- sb.append(info.getLockOwnerName()).append("\" Id=").append(info.getLockOwnerId()).append(")");
- break;
- }
- case WAITING: {
- StackTraceElement element = info.getStackTrace()[0];
- String className = element.getClassName();
- String method = element.getMethodName();
- if (className.equals("java.lang.Object") && method.equals("wait")) {
- sb.append(" (on object monitor");
- if (info.getLockOwnerName() != null) {
- sb.append(" owned by \"");
- sb.append(info.getLockOwnerName()).append("\" Id=").append(info.getLockOwnerId());
- }
- sb.append(")");
- } else if (className.equals("java.lang.Thread") && method.equals("join")) {
- sb.append(" (on completion of thread ").append(info.getLockOwnerId()).append(")");
- } else {
- sb.append(" (parking for lock");
- if (info.getLockOwnerName() != null) {
- sb.append(" owned by \"");
- sb.append(info.getLockOwnerName()).append("\" Id=").append(info.getLockOwnerId());
- }
- sb.append(")");
- }
- break;
- }
- case TIMED_WAITING: {
- StackTraceElement element = info.getStackTrace()[0];
- String className = element.getClassName();
- String method = element.getMethodName();
- if (className.equals("java.lang.Object") && method.equals("wait")) {
- sb.append(" (on object monitor");
- if (info.getLockOwnerName() != null) {
- sb.append(" owned by \"");
- sb.append(info.getLockOwnerName()).append("\" Id=").append(info.getLockOwnerId());
- }
- sb.append(")");
- } else if (className.equals("java.lang.Thread") && method.equals("sleep")) {
- sb.append(" (sleeping)");
- } else if (className.equals("java.lang.Thread") && method.equals("join")) {
- sb.append(" (on completion of thread ").append(info.getLockOwnerId()).append(")");
- } else {
- sb.append(" (parking for lock");
- if (info.getLockOwnerName() != null) {
- sb.append(" owned by \"");
- sb.append(info.getLockOwnerName()).append("\" Id=").append(info.getLockOwnerId());
- }
- sb.append(")");
- }
- break;
- }
- default:
- break;
- }
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/FormattedMessage.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/FormattedMessage.java
deleted file mode 100644
index 8a4cf97..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/FormattedMessage.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-/**
- * A Message that can have a format String attached to it.
- */
-public interface FormattedMessage extends Message {
- /**
- * Set the message format.
- * @param format The message format.
- */
- void setFormat(String format);
-
- /**
- * Return the message format.
- * @return the message format String.
- */
- String getFormat();
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/LocalizedMessage.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/LocalizedMessage.java
deleted file mode 100644
index 0141c60..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/LocalizedMessage.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * This class is not the recommended way to Localize messages. It is provided to provide some level
- * of compatibility with Log4j 1.x.
- *
- * The recommended way to localize messages is to simply log a message id. Log events should
- * then be recorded without formatting into some kind of data store. The application that is
- * used to read the events and display them to the user should also localize and format the
- * messages for the end user.
- */
-public class LocalizedMessage extends ParameterizedMessage implements LoggerNameAwareMessage
-{
- private static final long serialVersionUID = 3893703791567290742L;
-
- private String bundleId;
-
- private transient ResourceBundle bundle;
-
- private Locale locale;
-
- private transient StatusLogger logger = StatusLogger.getLogger();
-
- private String loggerName = null;
-
- /**
- * The basic constructor.
- */
- public LocalizedMessage() {
- super();
- setup(null, null, null);
- }
-
- public LocalizedMessage(String messagePattern, String[] stringArgs, Throwable throwable) {
- super(messagePattern, stringArgs, throwable);
- setup(null, null, null);
- }
-
-
- public LocalizedMessage(String bundleId, String key, String[] stringArgs,
- Throwable throwable) {
- super(key, stringArgs, throwable);
- setup(bundleId, null, null);
- }
-
- public LocalizedMessage(ResourceBundle bundle, String key, String[] stringArgs,
- Throwable throwable) {
- super(key, stringArgs, throwable);
- setup(null, bundle, null);
- }
-
- public LocalizedMessage(String bundleId, Locale locale, String key, String[] stringArgs,
- Throwable throwable) {
- super(key, stringArgs, throwable);
- setup(bundleId, null, locale);
- }
-
- public LocalizedMessage(ResourceBundle bundle, Locale locale, String key, String[] stringArgs,
- Throwable throwable) {
- super(key, stringArgs, throwable);
- setup(null, bundle, locale);
- }
-
- public LocalizedMessage(Locale locale, String key, String[] stringArgs, Throwable throwable) {
- super(key, stringArgs, throwable);
- setup(null, null, locale);
- }
-
-
- /**
- * <p>This method returns a LocalizedMessage which contains the arguments converted to String
- * as well as an optional Throwable.</p>
- * <p/>
- * <p>If the last argument is a Throwable and is NOT used up by a placeholder in the message
- * pattern it is returned in LocalizedMessage.getThrowable() and won't be contained in the
- * created String[].<br/>
- * If it is used up ParameterizedMessage.getThrowable() will return null even if the last
- * argument was a Throwable!</p>
- *
- * @param messagePattern the message pattern that to be checked for placeholders.
- * @param arguments the argument array to be converted.
- */
- public LocalizedMessage(String messagePattern, Object[] arguments) {
- super(messagePattern, arguments);
- setup(null, null, null);
- }
-
- public LocalizedMessage(String bundleId, String key, Object[] arguments) {
- super(key, arguments);
- setup(bundleId, null, null);
- }
-
- public LocalizedMessage(ResourceBundle bundle, String key, Object[] arguments) {
- super(key, arguments);
- setup(null, bundle, null);
- }
-
- public LocalizedMessage(String bundleId, Locale locale, String key, Object[] arguments) {
- super(key, arguments);
- setup(bundleId, null, locale);
- }
-
- public LocalizedMessage(ResourceBundle bundle, Locale locale, String key, Object[] arguments) {
- super(key, arguments);
- setup(null, bundle, locale);
- }
-
- public LocalizedMessage(Locale locale, String key, Object[] arguments) {
- super(key, arguments);
- setup(null, null, locale);
- }
-
- public LocalizedMessage(String messagePattern, Object arg) {
- super(messagePattern, arg);
- setup(null, null, null);
- }
-
- public LocalizedMessage(String bundleId, String key, Object arg) {
- super(key, arg);
- setup(bundleId, null, null);
- }
-
- public LocalizedMessage(ResourceBundle bundle, String key, Object arg) {
- super(key, arg);
- setup(null, bundle, null);
- }
-
- public LocalizedMessage(String bundleId, Locale locale, String key, Object arg) {
- super(key, arg);
- setup(bundleId, null, locale);
- }
-
- public LocalizedMessage(ResourceBundle bundle, Locale locale, String key, Object arg) {
- super(key, arg);
- setup(null, bundle, locale);
- }
-
- public LocalizedMessage(Locale locale, String key, Object arg) {
- super(key, arg);
- setup(null, null, locale);
- }
-
- public LocalizedMessage(String messagePattern, Object arg1, Object arg2) {
- super(messagePattern, arg1, arg2);
- setup(null, null, null);
- }
-
- public LocalizedMessage(String bundleId, String key, Object arg1, Object arg2) {
- super(key, arg1, arg2);
- setup(bundleId, null, null);
- }
-
- public LocalizedMessage(ResourceBundle bundle, String key, Object arg1, Object arg2) {
- super(key, arg1, arg2);
- setup(null, bundle, null);
- }
-
- public LocalizedMessage(String bundleId, Locale locale, String key, Object arg1, Object arg2) {
- super(key, arg1, arg2);
- setup(bundleId, null, locale);
- }
-
- public LocalizedMessage(ResourceBundle bundle, Locale locale, String key, Object arg1,
- Object arg2) {
- super(key, arg1, arg2);
- setup(null, bundle, locale);
- }
-
- public LocalizedMessage(Locale locale, String key, Object arg1, Object arg2) {
- super(key, arg1, arg2);
- setup(null, null, locale);
- }
-
- /**
- * Set the name of the Logger.
- * @param name The name of the Logger.
- */
- public void setLoggerName(String name) {
- this.loggerName = name;
- }
-
- /**
- * Return the name of the Logger.
- * @return the name of the Logger.
- */
- public String getLoggerName() {
- return this.loggerName;
- }
-
- private void setup(String bundleId, ResourceBundle bundle, Locale locale) {
- this.bundleId = bundleId;
- this.bundle = bundle;
- this.locale = locale;
- }
-
- /**
- * Return the formatted message after looking up the format in the resource bundle.
- * @param messagePattern The key for the resource bundle or the pattern if the bundle doesn't contain the key.
- * @param args The parameters.
- * @return The formatted message String.
- */
- @Override
- public String formatMessage(String messagePattern, String[] args) {
- ResourceBundle bundle = this.bundle;
- if (bundle == null) {
- if (bundleId != null) {
- bundle = getBundle(bundleId, locale, false);
- } else {
- bundle = getBundle(loggerName, locale, true);
- }
- }
- String msgPattern = (bundle == null || !bundle.containsKey(messagePattern)) ?
- messagePattern : bundle.getString(messagePattern);
- return format(msgPattern, args);
- }
-
- /**
- * Override this to use a ResourceBundle.Control in Java 6
- * @param key The key to the bundle.
- * @param locale The locale to use when formatting the message.
- * @param loop If true the key will be treated as a package or class name and a resource bundle will
- * be located based on all or part of the package name. If false the key is expected to be the exact bundle id.
- * @return The ResourceBundle.
- */
- protected ResourceBundle getBundle(String key, Locale locale, boolean loop) {
- ResourceBundle rb = null;
-
- if (key == null) {
- return null;
- }
- try {
- if (locale != null) {
- rb = ResourceBundle.getBundle(key, locale);
- } else {
- rb = ResourceBundle.getBundle(key);
- }
- } catch (MissingResourceException ex) {
- if (!loop) {
- logger.debug("Unable to locate ResourceBundle " + key);
- return null;
- }
- }
-
- String substr = key;
- int i;
- while (rb == null && (i = substr.lastIndexOf(".")) > 0) {
- substr = substr.substring(0, i);
- try {
- if (locale != null) {
- rb = ResourceBundle.getBundle(substr, locale);
- } else {
- rb = ResourceBundle.getBundle(substr);
- }
- } catch (MissingResourceException ex) {
- logger.debug("Unable to locate ResourceBundle " + substr);
- }
- }
- return rb;
- }
-
- private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- bundle = null;
- logger = StatusLogger.getLogger();
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/LoggerNameAwareMessage.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/LoggerNameAwareMessage.java
deleted file mode 100644
index a4821a4..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/LoggerNameAwareMessage.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-/**
- * Message that is interested in the name of the Logger.
- */
-public interface LoggerNameAwareMessage {
- /**
- * The name of the Logger.
- * @param name The name of the Logger.
- */
- void setLoggerName(String name);
-
- /**
- * Returns the name of the Logger.
- * @return The name of the Logger.
- */
- String getLoggerName();
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
deleted file mode 100644
index baa1b66..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import java.io.ByteArrayOutputStream;
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-/**
- * Represents a Message that consists of a Map.
- */
-public class MapMessage implements FormattedMessage, Serializable {
- /**
- * When set as the format specifier causes the Map to be formatted as XML.
- */
- public static final String XML = "XML";
- private static final long serialVersionUID = -5031471831131487120L;
-
- private final Map<String, String> data;
-
- private String format = null;
-
- /**
- * Constructor.
- */
- public MapMessage() {
- data = new HashMap<String, String>();
- }
-
- /**
- * Constructor based on an existing Map.
- * @param map The Map.
- */
- public MapMessage(Map<String, String> map) {
- this.data = map;
- }
-
- /**
- * The format String. Specifying "xml" will cause the message to be XML.
- * @param format The message format.
- */
- public void setFormat(String format) {
- this.format = format;
- }
-
- /**
- * Return the format String.
- * @return the format String.
- */
- public String getFormat() {
- return this.format;
- }
-
-
- /**
- * Return the data elements as if they were parameters on the logging event.
- * @return the data elements.
- */
- public Object[] getParameters() {
- return data.values().toArray();
- }
-
- /**
- * Return the message.
- * @return the message.
- */
- public String getMessageFormat() {
- return "";
- }
-
- /**
- * Return the message data as an unmodifiable Map.
- * @return the message data as an unmodifiable map.
- */
- public Map<String, String> getData() {
- return Collections.unmodifiableMap(data);
- }
-
- /**
- * Clear the data.
- */
- public void clear() {
- data.clear();
- }
-
- /**
- * Add an item to the data Map.
- * @param key The name of the data item.
- * @param value The value of the data item.
- */
- public void put(String key, String value) {
- if (value == null) {
- throw new IllegalArgumentException("No value provided for key " + key);
- }
- validate(key, value);
- data.put(key, value);
- }
-
- protected void validate(String key, String value) {
-
- }
-
- /**
- * Add all the elements from the specified Map.
- * @param map The Map to add.
- */
- public void putAll(Map<String, String> map) {
- data.putAll(map);
- }
-
- /**
- * Retrieve the value of the element with the specified key or null if the key is not present.
- * @param key The name of the element.
- * @return The value of the element or null if the key is not present.
- */
- public String get(String key) {
- return data.get(key);
- }
-
- /**
- * Remove the element with the specified name.
- * @param key The name of the element.
- * @return The previous value of the element.
- */
- public String remove(String key) {
- return data.remove(key);
- }
-
- /**
- * Format the Structured data as described in RFC 5424.
- *
- * @return The formatted String.
- */
- public String asString() {
- return asString(format == null ? "" : format);
- }
-
- /**
- * Format the Structured data as described in RFC 5424.
- *
- * @param format The format identifier. Ignored in this implementation.
- * @return The formatted String.
- */
- public String asString(String format) {
- StringBuilder sb = new StringBuilder();
- if (format.equalsIgnoreCase(XML)) {
- asXML(sb);
- } else {
- appendMap(sb);
- }
- return sb.toString();
- }
-
- public void asXML(StringBuilder sb) {
- sb.append("<Map>\n");
- SortedMap<String, String> sorted = new TreeMap<String, String>(data);
- for (Map.Entry<String, String> entry : sorted.entrySet()) {
- sb.append(" <Entry key=").append(entry.getKey()).append(">").append(entry.getValue()).append("</Entry>\n");
- }
- sb.append("</Map>");
- }
-
- /**
- * Format the message and return it.
- * @return the formatted message.
- */
- public String getFormattedMessage() {
- return asString();
- }
-
- protected void appendMap(StringBuilder sb) {
- SortedMap<String, String> sorted = new TreeMap<String, String>(data);
- boolean first = true;
- for (Map.Entry<String, String> entry : sorted.entrySet()) {
- if (!first) {
- sb.append(" ");
- }
- first = false;
- sb.append(entry.getKey()).append("=\"").append(entry.getValue()).append("\"");
- }
- }
-
- public MapMessage newInstance(Map<String, String> map) {
- return new MapMessage(map);
- }
-
- public String toString() {
- return asString();
- }
-
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- MapMessage that = (MapMessage) o;
-
- return this.data.equals(that.data);
- }
-
- public int hashCode() {
- return data.hashCode();
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/Message.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/Message.java
deleted file mode 100644
index ad66933..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/Message.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import java.io.Serializable;
-
-/**
- * An interface for various Message implementations that can be logged. Messages can act as wrappers
- * around Objects so that user can have control over converting Objects to Strings when necessary without
- * requiring complicated formatters and as a way to manipulate the message based on information available
- * at runtime such as the locale of the system.
- *
- * Note: Message objects should not be considered to be thread safe nor should they be assumed to be
- * safely reusable even on the same thread. The logging system may provide information to the Message
- * objects and the Messages might be queued for asynchronous delivery. Thus, any modifications to a
- * Message object by an application should by avoided after the Message has been passed as a parameter on
- * a Logger method.
- * @doubt Interfaces should rarely extend Serializable according to Effective Java 2nd Ed pg 291.
- * (RG) That section also says "If a class or interface exists primarily to participate in a framework that
- * requires all participants to implement Serializable, then it makes perfect sense for the class or
- * interface to implement or extend Serializable". Such is the case here as the LogEvent must be Serializable.
- */
-public interface Message extends Serializable {
- /**
- * Returns the Message formatted as a String.
- *
- * @return The message String.
- */
- String getFormattedMessage();
-
- /**
- * Returns the format portion of the Message.
- *
- * @return The message format.
- * @doubt Do all messages have a format? What syntax? Using a Formatter object could be cleaner.
- * (RG) In SimpleMessage the format is identical to the formatted message. In ParameterizedMessage and
- * StructuredDataMessage itis not. It is up to the Message implementer to determine what this
- * method will return. A Formatter is inappropriate as this is very specific to the Message
- * implementation so it isn't clear to me how having a Formatter separate from the Message would be cleaner.
- */
- String getMessageFormat();
-
- /**
- * Returns parameter values, if any.
- *
- * @return An array of parameter values or null.
- */
- Object[] getParameters();
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java
deleted file mode 100644
index 6a374d0..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-/**
- * Handles messages that contain an Object.
- */
-public class ObjectMessage implements Message, Serializable {
-
- private static final long serialVersionUID = -5903272448334166185L;
-
- private transient Object obj;
-
- /**
- * Create the ObjectMessage.
- * @param obj The Object to format.
- */
- public ObjectMessage(Object obj) {
- this.obj = obj;
- }
-
- /**
- * Return the formatted object message.
- * @return the formatted object message.
- */
- public String getFormattedMessage() {
- return obj.toString();
- }
-
- /**
- * Returns the object formatted using its toString method.
- * @return the String representation of the object.
- */
- public String getMessageFormat() {
- return obj.toString();
- }
-
- /**
- * Returns the object as if it were a parameter.
- * @return The object.
- */
- public Object[] getParameters() {
- return new Object[]{obj};
- }
-
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- ObjectMessage that = (ObjectMessage) o;
-
- return !(obj != null ? !obj.equals(that.obj) : that.obj != null);
- }
-
- public int hashCode() {
- return obj != null ? obj.hashCode() : 0;
- }
-
- public String toString() {
- return "ObjectMessage[obj=" + obj.toString() + "]";
- }
-
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.defaultWriteObject();
- if (obj instanceof Serializable) {
- out.writeObject(obj);
- } else {
- out.writeObject(obj.toString());
- }
- }
-
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- obj = in.readObject();
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java
deleted file mode 100644
index f324c41..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java
+++ /dev/null
@@ -1,582 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import java.io.Serializable;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Handles messages that consist of a format string containing '{}' to represent each replaceable token, and
- * the parameters.
- * <p/>
- * This class was originally written for Lillith (http://mac.freshmeat.net/projects/lilith-viewer) by
- * Joern Huxhorn where it is licensed under the LGPL. It has been relicensed here with his permission
- * providing that this attribution remain.
- */
-public class ParameterizedMessage implements Message, Serializable {
-
- /**
- * Prefix for recursion.
- */
- public static final String RECURSION_PREFIX = "[...";
- /**
- * Suffix for recursion.
- */
- public static final String RECURSION_SUFFIX = "...]";
-
- /**
- * Prefix for errors.
- */
- public static final String ERROR_PREFIX = "[!!!";
- /**
- * Separator for errors.
- */
- public static final String ERROR_SEPARATOR = "=>";
- /**
- * Separator for error messages.
- */
- public static final String ERROR_MSG_SEPARATOR = ":";
- /**
- * Suffix for errors.
- */
- public static final String ERROR_SUFFIX = "!!!]";
-
- private static final long serialVersionUID = -665975803997290697L;
-
- private static final int HASHVAL = 31;
-
- private static final char DELIM_START = '{';
- private static final char DELIM_STOP = '}';
- private static final char ESCAPE_CHAR = '\\';
-
- private String messagePattern;
- private String[] stringArgs;
- private transient Object[] argArray;
- private transient String formattedMessage;
- private transient Throwable throwable;
-
- /**
- * Create the ParameterizedMessage.
- */
- public ParameterizedMessage() {
- this(null, null, null);
- }
-
- /**
- * Create the parameterizedMessage.
- * @param messagePattern The message "format" string. This will be a String containing "{}" placeholders
- * where parameters should be substituted.
- * @param stringArgs The arguments for substitution.
- * @param throwable A Throwable.
- */
- public ParameterizedMessage(String messagePattern, String[] stringArgs, Throwable throwable) {
- this.messagePattern = messagePattern;
- this.stringArgs = stringArgs;
- this.throwable = throwable;
- }
-
- public ParameterizedMessage(String messagePattern, Object[] arguments, Throwable throwable) {
- this.messagePattern = messagePattern;
- this.throwable = throwable;
- if (arguments != null) {
- parseArguments(arguments);
- }
- }
-
- /**
- * <p>This method returns a ParameterizedMessage which contains the arguments converted to String
- * as well as an optional Throwable.</p>
- * <p/>
- * <p>If the last argument is a Throwable and is NOT used up by a placeholder in the message pattern it is returned
- * in ParameterizedMessage.getThrowable() and won't be contained in the created String[].<br/>
- * If it is used up ParameterizedMessage.getThrowable() will return null even if the last argument was a
- * Throwable!</p>
- *
- * @param messagePattern the message pattern that to be checked for placeholders.
- * @param arguments the argument array to be converted.
- */
- public ParameterizedMessage(String messagePattern, Object[] arguments) {
- this.messagePattern = messagePattern;
- if (arguments == null) {
- return;
- }
- parseArguments(arguments);
- }
-
- /**
- * Constructor with a pattern and a single parameter.
- * @param messagePattern The message pattern.
- * @param arg The parameter.
- */
- public ParameterizedMessage(String messagePattern, Object arg) {
- this(messagePattern, new Object[]{arg});
- }
-
- /**
- * Constructor with a pattern and two parameters.
- * @param messagePattern The message pattern.
- * @param arg1 The first parameter.
- * @param arg2 The second parameter.
- */
- public ParameterizedMessage(String messagePattern, Object arg1, Object arg2) {
- this(messagePattern, new Object[]{arg1, arg2});
- }
-
- private void parseArguments(Object[] arguments) {
- int argsCount = countArgumentPlaceholders(messagePattern);
- int resultArgCount = arguments.length;
- if (argsCount < arguments.length) {
- if (throwable == null && arguments[arguments.length - 1] instanceof Throwable) {
- throwable = (Throwable) arguments[arguments.length - 1];
- resultArgCount--;
- }
- }
- argArray = new Object[resultArgCount];
- for (int i = 0; i < resultArgCount; ++i) {
- argArray[i] = arguments[i];
- }
-
- if (argsCount == 1 && throwable == null && arguments.length > 1) {
- // special case
- stringArgs = new String[1];
- stringArgs[0] = deepToString(arguments);
- } else {
- stringArgs = new String[resultArgCount];
- for (int i = 0; i < stringArgs.length; i++) {
- stringArgs[i] = deepToString(arguments[i]);
- }
- }
- }
-
- /**
- * Return the formatted message.
- * @return the formatted message.
- */
- public String getFormattedMessage() {
- if (formattedMessage == null) {
- formattedMessage = formatMessage(messagePattern, stringArgs);
- }
- return formattedMessage;
- }
-
- /**
- * Returns the message pattern.
- * @return the message pattern.
- */
- public String getMessageFormat() {
- return messagePattern;
- }
-
- /**
- * Set the message pattern.
- * @param messagePattern The message pattern.
- */
- public void setMessageFormat(String messagePattern) {
- this.messagePattern = messagePattern;
- this.formattedMessage = null;
- }
-
- /**
- * Returns the message parameters.
- * @return the message parameters.
- */
- public Object[] getParameters() {
- if (argArray != null) {
- return argArray;
- }
- return stringArgs;
- }
-
- /**
- * Sets the parameters for the message.
- * @param parameters The parameters.
- */
- public void setParameters(String[] parameters) {
- this.stringArgs = parameters;
- this.formattedMessage = null;
- }
-
- /**
- * Sets the parameters for the message.
- * @param parameters The parameters.
- */
- public void setParameters(Object[] parameters) {
- parseArguments(parameters);
- this.formattedMessage = null;
- }
-
- /**
- * Set the Throwable for the message.
- * @param throwable The Throwable.
- */
- public void setThrowable(Throwable throwable) {
- this.throwable = throwable;
- }
-
- /**
- * Returns the Throwable that was given as the last argument, if any.
- * It will not survive serialization. The Throwable exists as part of the message
- * primarily so that it can be extracted from the end of the list of parameters
- * and then be added to the LogEvent. As such, the Throwable in the event should
- * not be used once the LogEvent has been constructed.
- *
- * @return the Throwable, if any.
- */
- public Throwable getThrowable() {
- return throwable;
- }
-
- protected String formatMessage(String msgPattern, String[] sArgs) {
- return format(msgPattern, sArgs);
- }
-
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- ParameterizedMessage that = (ParameterizedMessage) o;
-
- if (messagePattern != null ? !messagePattern.equals(that.messagePattern) : that.messagePattern != null) {
- return false;
- }
- if (!Arrays.equals(stringArgs, that.stringArgs)) {
- return false;
- }
- //if (throwable != null ? !throwable.equals(that.throwable) : that.throwable != null) return false;
-
- return true;
- }
-
- public int hashCode() {
- int result = messagePattern != null ? messagePattern.hashCode() : 0;
- result = HASHVAL * result + (stringArgs != null ? Arrays.hashCode(stringArgs) : 0);
- return result;
- }
-
- /**
- * Replace placeholders in the given messagePattern with arguments.
- *
- * @param messagePattern the message pattern containing placeholders.
- * @param arguments the arguments to be used to replace placeholders.
- * @return the formatted message.
- */
- public static String format(String messagePattern, Object[] arguments) {
- if (messagePattern == null || arguments == null || arguments.length == 0) {
- return messagePattern;
- }
-
- StringBuilder result = new StringBuilder();
- int escapeCounter = 0;
- int currentArgument = 0;
- for (int i = 0; i < messagePattern.length(); i++) {
- char curChar = messagePattern.charAt(i);
- if (curChar == ESCAPE_CHAR) {
- escapeCounter++;
- } else {
- if (curChar == DELIM_START) {
- if (i < messagePattern.length() - 1) {
- if (messagePattern.charAt(i + 1) == DELIM_STOP) {
- // write escaped escape chars
- int escapedEscapes = escapeCounter / 2;
- for (int j = 0; j < escapedEscapes; j++) {
- result.append(ESCAPE_CHAR);
- }
-
- if (escapeCounter % 2 == 1) {
- // i.e. escaped
- // write escaped escape chars
- result.append(DELIM_START);
- result.append(DELIM_STOP);
- } else {
- // unescaped
- if (currentArgument < arguments.length) {
- result.append(arguments[currentArgument]);
- } else {
- result.append(DELIM_START).append(DELIM_STOP);
- }
- currentArgument++;
- }
- i++;
- escapeCounter = 0;
- continue;
- }
- }
- }
- // any other char beside ESCAPE or DELIM_START/STOP-combo
- // write unescaped escape chars
- if (escapeCounter > 0) {
- for (int j = 0; j < escapeCounter; j++) {
- result.append(ESCAPE_CHAR);
- }
- escapeCounter = 0;
- }
- result.append(curChar);
- }
- }
- return result.toString();
- }
-
- /**
- * Counts the number of unescaped placeholders in the given messagePattern.
- *
- * @param messagePattern the message pattern to be analyzed.
- * @return the number of unescaped placeholders.
- */
- public static int countArgumentPlaceholders(String messagePattern) {
- if (messagePattern == null) {
- return 0;
- }
-
- int delim = messagePattern.indexOf(DELIM_START);
-
- if (delim == -1) {
- // special case, no placeholders at all.
- return 0;
- }
- int result = 0;
- boolean isEscaped = false;
- for (int i = 0; i < messagePattern.length(); i++) {
- char curChar = messagePattern.charAt(i);
- if (curChar == ESCAPE_CHAR) {
- isEscaped = !isEscaped;
- } else if (curChar == DELIM_START) {
- if (!isEscaped) {
- if (i < messagePattern.length() - 1) {
- if (messagePattern.charAt(i + 1) == DELIM_STOP) {
- result++;
- i++;
- }
- }
- }
- isEscaped = false;
- } else {
- isEscaped = false;
- }
- }
- return result;
- }
-
- /**
- * This method performs a deep toString of the given Object.
- * Primitive arrays are converted using their respective Arrays.toString methods while
- * special handling is implemented for "container types", i.e. Object[], Map and Collection because those could
- * contain themselves.
- * <p/>
- * It should be noted that neither AbstractMap.toString() nor AbstractCollection.toString() implement such a
- * behavior. They only check if the container is directly contained in itself, but not if a contained container
- * contains the original one. Because of that, Arrays.toString(Object[]) isn't safe either.
- * Confusing? Just read the last paragraph again and check the respective toString() implementation.
- * <p/>
- * This means, in effect, that logging would produce a usable output even if an ordinary System.out.println(o)
- * would produce a relatively hard-to-debug StackOverflowError.
- * @param o The object.
- * @return The String representation.
- */
- public static String deepToString(Object o) {
- if (o == null) {
- return null;
- }
- if (o instanceof String) {
- return (String) o;
- }
- StringBuilder str = new StringBuilder();
- Set<String> dejaVu = new HashSet<String>(); // that's actually a neat name ;)
- recursiveDeepToString(o, str, dejaVu);
- return str.toString();
- }
-
- /**
- * This method performs a deep toString of the given Object.
- * Primitive arrays are converted using their respective Arrays.toString methods while
- * special handling is implemented for "container types", i.e. Object[], Map and Collection because those could
- * contain themselves.
- * <p/>
- * dejaVu is used in case of those container types to prevent an endless recursion.
- * <p/>
- * It should be noted that neither AbstractMap.toString() nor AbstractCollection.toString() implement such a
- * behavior.
- * They only check if the container is directly contained in itself, but not if a contained container contains the
- * original one. Because of that, Arrays.toString(Object[]) isn't safe either.
- * Confusing? Just read the last paragraph again and check the respective toString() implementation.
- * <p/>
- * This means, in effect, that logging would produce a usable output even if an ordinary System.out.println(o)
- * would produce a relatively hard-to-debug StackOverflowError.
- *
- * @param o the Object to convert into a String
- * @param str the StringBuilder that o will be appended to
- * @param dejaVu a list of container identities that were already used.
- */
- private static void recursiveDeepToString(Object o, StringBuilder str, Set<String> dejaVu) {
- if (o == null) {
- str.append("null");
- return;
- }
- if (o instanceof String) {
- str.append(o);
- return;
- }
-
- Class oClass = o.getClass();
- if (oClass.isArray()) {
- if (oClass == byte[].class) {
- str.append(Arrays.toString((byte[]) o));
- } else if (oClass == short[].class) {
- str.append(Arrays.toString((short[]) o));
- } else if (oClass == int[].class) {
- str.append(Arrays.toString((int[]) o));
- } else if (oClass == long[].class) {
- str.append(Arrays.toString((long[]) o));
- } else if (oClass == float[].class) {
- str.append(Arrays.toString((float[]) o));
- } else if (oClass == double[].class) {
- str.append(Arrays.toString((double[]) o));
- } else if (oClass == boolean[].class) {
- str.append(Arrays.toString((boolean[]) o));
- } else if (oClass == char[].class) {
- str.append(Arrays.toString((char[]) o));
- } else {
- // special handling of container Object[]
- String id = identityToString(o);
- if (dejaVu.contains(id)) {
- str.append(RECURSION_PREFIX).append(id).append(RECURSION_SUFFIX);
- } else {
- dejaVu.add(id);
- Object[] oArray = (Object[]) o;
- str.append("[");
- boolean first = true;
- for (Object current : oArray) {
- if (first) {
- first = false;
- } else {
- str.append(", ");
- }
- recursiveDeepToString(current, str, new HashSet<String>(dejaVu));
- }
- str.append("]");
- }
- //str.append(Arrays.deepToString((Object[]) o));
- }
- } else if (o instanceof Map) {
- // special handling of container Map
- String id = identityToString(o);
- if (dejaVu.contains(id)) {
- str.append(RECURSION_PREFIX).append(id).append(RECURSION_SUFFIX);
- } else {
- dejaVu.add(id);
- Map oMap = (Map) o;
- str.append("{");
- boolean isFirst = true;
- for (Object o1 : oMap.entrySet()) {
- Map.Entry current = (Map.Entry) o1;
- if (isFirst) {
- isFirst = false;
- } else {
- str.append(", ");
- }
- Object key = current.getKey();
- Object value = current.getValue();
- recursiveDeepToString(key, str, new HashSet<String>(dejaVu));
- str.append("=");
- recursiveDeepToString(value, str, new HashSet<String>(dejaVu));
- }
- str.append("}");
- }
- } else if (o instanceof Collection) {
- // special handling of container Collection
- String id = identityToString(o);
- if (dejaVu.contains(id)) {
- str.append(RECURSION_PREFIX).append(id).append(RECURSION_SUFFIX);
- } else {
- dejaVu.add(id);
- Collection oCol = (Collection) o;
- str.append("[");
- boolean isFirst = true;
- for (Object anOCol : oCol) {
- if (isFirst) {
- isFirst = false;
- } else {
- str.append(", ");
- }
- recursiveDeepToString(anOCol, str, new HashSet<String>(dejaVu));
- }
- str.append("]");
- }
- } else if (o instanceof Date) {
- Date date = (Date) o;
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
- // I'll leave it like this for the moment... this could probably be optimized using ThreadLocal...
- str.append(format.format(date));
- } else {
- // it's just some other Object, we can only use toString().
- try {
- str.append(o.toString());
- } catch (Throwable t) {
- str.append(ERROR_PREFIX);
- str.append(identityToString(o));
- str.append(ERROR_SEPARATOR);
- String msg = t.getMessage();
- String className = t.getClass().getName();
- str.append(className);
- if (!className.equals(msg)) {
- str.append(ERROR_MSG_SEPARATOR);
- str.append(msg);
- }
- str.append(ERROR_SUFFIX);
- }
- }
- }
-
- /**
- * This method returns the same as if Object.toString() would not have been
- * overridden in obj.
- * <p/>
- * Note that this isn't 100% secure as collisions can always happen with hash codes.
- * <p/>
- * Copied from Object.hashCode():
- * As much as is reasonably practical, the hashCode method defined by
- * class <tt>Object</tt> does return distinct integers for distinct
- * objects. (This is typically implemented by converting the internal
- * address of the object into an integer, but this implementation
- * technique is not required by the
- * Java<font size="-2"><sup>TM</sup></font>
- * programming language.)
- *
- * @param obj the Object that is to be converted into an identity string.
- * @return the identity string as also defined in Object.toString()
- */
- public static String identityToString(Object obj) {
- if (obj == null) {
- return null;
- }
- return obj.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(obj));
- }
-
- public String toString() {
- return "ParameterizedMessage[messagePattern=" + messagePattern + ", stringArgs=" +
- Arrays.toString(stringArgs) + ", throwable=" + throwable + "]";
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/SimpleMessage.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/SimpleMessage.java
deleted file mode 100644
index a38b0d7..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/SimpleMessage.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import java.io.Serializable;
-
-/**
- * The simplest possible implementation of Message. It just returns the String given as the constructor argument.
- */
-public class SimpleMessage implements Message, Serializable {
- private static final long serialVersionUID = -8398002534962715992L;
-
- private final String message;
-
- /**
- * Basic constructor.
- */
- public SimpleMessage() {
- this(null);
- }
-
- /**
- * Constructor that includes the message.
- * @param message The String message.
- */
- public SimpleMessage(String message) {
- this.message = message;
- }
-
- /**
- * Return the message.
- * @return the message.
- */
- public String getFormattedMessage() {
- return message;
- }
-
- /**
- * Return the message.
- * @return the message.
- */
- public String getMessageFormat() {
- return message;
- }
-
- /**
- * Returns null since there are no parameters.
- * @return null.
- */
- public Object[] getParameters() {
- return null;
- }
-
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- SimpleMessage that = (SimpleMessage) o;
-
- return !(message != null ? !message.equals(that.message) : that.message != null);
- }
-
- public int hashCode() {
- return message != null ? message.hashCode() : 0;
- }
-
- public String toString() {
- return "SimpleMessage[message=" + message + "]";
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java
deleted file mode 100644
index bc3553e..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import java.io.Serializable;
-
-/**
- * The StructuredData identifier.
- */
-public class StructuredDataId implements Serializable {
-
- /**
- * RFC 5424 Time Quality.
- */
- public static final StructuredDataId TIME_QUALITY = new StructuredDataId("timeQuality", null,
- new String[]{"tzKnown", "isSynced", "syncAccuracy"});
- /**
- * RFC 5424 Origin.
- */
- public static final StructuredDataId ORIGIN = new StructuredDataId("origin", null,
- new String[]{"ip", "enterpriseId", "software", "swVersion"});
- /**
- * RFC 5424 Meta.
- */
- public static final StructuredDataId META = new StructuredDataId("meta", null,
- new String[]{"sequenceId", "sysUpTime", "language"});
-
- /**
- * Reserved enterprise number.
- */
- public static final int RESERVED = -1;
-
- private static final long serialVersionUID = 9031746276396249990L;
- private static final int MAX_LENGTH = 32;
-
- private final String name;
- private final int enterpriseNumber;
- private final String[] required;
- private final String[] optional;
-
-
- protected StructuredDataId(String name, String[] required, String[] optional) {
- int index = -1;
- if (name != null) {
- if (name.length() > MAX_LENGTH) {
- throw new IllegalArgumentException("Length of id exceeds maximum of 32 characters: " + name);
- }
- index = name.indexOf("@");
- }
-
- if (index > 0) {
- this.name = name.substring(0, index);
- this.enterpriseNumber = Integer.parseInt(name.substring(index + 1));
- } else {
- this.name = name;
- this.enterpriseNumber = RESERVED;
- }
- this.required = required;
- this.optional = optional;
- }
-
- /**
- * A Constructor that helps conformance to RFC 5424.
- *
- * @param name The name portion of the id.
- * @param enterpriseNumber The enterprise number.
- * @param required The list of keys that are required for this id.
- * @param optional The list of keys that are optional for this id.
- */
- public StructuredDataId(String name, int enterpriseNumber, String[] required, String[] optional) {
- if (name == null) {
- throw new IllegalArgumentException("No structured id name was supplied");
- }
- if (name.contains("@")) {
- throw new IllegalArgumentException("Structured id name cannot contain an '@");
- }
- if (enterpriseNumber <= 0) {
- throw new IllegalArgumentException("No enterprise number was supplied");
- }
- this.name = name;
- this.enterpriseNumber = enterpriseNumber;
- String id = enterpriseNumber < 0 ? name : name + "@" + enterpriseNumber;
- if (id.length() > MAX_LENGTH) {
- throw new IllegalArgumentException("Length of id exceeds maximum of 32 characters: " + id);
- }
- this.required = required;
- this.optional = optional;
- }
-
- /**
- * Creates an id using another id to supply default values.
- * @param id The original StructuredDataId.
- * @return the new StructuredDataId.
- */
- public StructuredDataId makeId(StructuredDataId id) {
- if (id == null) {
- return this;
- }
- return makeId(id.getName(), id.getEnterpriseNumber());
- }
-
- /**
- * Creates an id based on the current id.
- * @param defaultId The default id to use if this StructuredDataId doesn't have a name.
- * @param enterpriseNumber The enterprise number.
- * @return a StructuredDataId.
- */
- public StructuredDataId makeId(String defaultId, int enterpriseNumber) {
- String id;
- String[] req;
- String[] opt;
- if (enterpriseNumber <= 0) {
- return this;
- }
- if (this.name != null) {
- id = this.name;
- req = this.required;
- opt = this.optional;
- } else {
- id = defaultId;
- req = null;
- opt = null;
- }
-
- return new StructuredDataId(id, enterpriseNumber, req, opt);
- }
-
- /**
- * Returns a list of required keys.
- * @return a List of required keys or null if none have been provided.
- */
- public String[] getRequired() {
- return required;
- }
-
- /**
- * Returns a list of optional keys.
- * @return a List of optional keys or null if none have been provided.
- */
- public String[] getOptional() {
- return optional;
- }
-
- /**
- * Return the StructuredDataId name.
- * @return the StructuredDataId name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Return the enterprise number.
- * @return the enterprise number.
- */
- public int getEnterpriseNumber() {
- return enterpriseNumber;
- }
-
- /**
- * Indicates if the id is reserved.
- * @return true if the id uses the reserved enterprise number, false otherwise.
- */
- public boolean isReserved() {
- return enterpriseNumber <= 0;
- }
-
- public String toString() {
- return isReserved() ? name : name + "@" + enterpriseNumber;
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/StructuredDataMessage.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/StructuredDataMessage.java
deleted file mode 100644
index 9500d73..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/StructuredDataMessage.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * Represents a Message that conforms to RFC 5424 (http://tools.ietf.org/html/rfc5424).
- */
-public class StructuredDataMessage extends MapMessage implements FormattedMessage, Serializable {
- /**
- * Full message format includes the type and message.
- */
- public static final String FULL = "full";
-
- private static final long serialVersionUID = 1703221292892071920L;
- private static final int MAX_LENGTH = 32;
- private static final int HASHVAL = 31;
-
- private StructuredDataId id;
-
- private String message;
-
- private String type;
-
- /**
- * Constructor based on a String id.
- * @param id The String id.
- * @param msg The message.
- * @param type The message type.
- */
- public StructuredDataMessage(final String id, final String msg, final String type) {
- this.id = new StructuredDataId(id, null, null);
- this.message = msg;
- this.type = type;
- }
- /**
- * Constructor based on a String id.
- * @param id The String id.
- * @param msg The message.
- * @param type The message type.
- * @param data The StructuredData map.
- */
- public StructuredDataMessage(final String id, final String msg, final String type,
- Map<String, String> data) {
- super(data);
- this.id = new StructuredDataId(id, null, null);
- this.message = msg;
- this.type = type;
- }
-
- /**
- * Constructor based on a StructuredDataId.
- * @param id The StructuredDataId.
- * @param msg The message.
- * @param type The message type.
- */
- public StructuredDataMessage(final StructuredDataId id, final String msg, final String type) {
- this.id = id;
- this.message = msg;
- this.type = type;
- }
-
- /**
- * Constructor based on a StructuredDataId.
- * @param id The StructuredDataId.
- * @param msg The message.
- * @param type The message type.
- * @param data The StructuredData map.
- */
- public StructuredDataMessage(final StructuredDataId id, final String msg, final String type,
- Map<String, String> data) {
- super(data);
- this.id = id;
- this.message = msg;
- this.type = type;
- }
-
-
- /**
- * Constructor based on a StructuredDataMessage.
- * @param msg The StructuredDataMessage.
- * @param map The StructuredData map.
- */
- private StructuredDataMessage(StructuredDataMessage msg, Map<String, String> map) {
- super(map);
- this.id = msg.id;
- this.message = msg.message;
- this.type = msg.type;
- }
-
-
- /**
- * Basic constructor.
- */
- protected StructuredDataMessage() {
-
- }
-
- /**
- * Return the id.
- * @return the StructuredDataId.
- */
- public StructuredDataId getId() {
- return id;
- }
-
- /**
- * Set the id from a String.
- * @param id The String id.
- */
- protected void setId(String id) {
- this.id = new StructuredDataId(id, null, null);
- }
-
- /**
- * Set the id.
- * @param id The StructuredDataId.
- */
- protected void setId(StructuredDataId id) {
- this.id = id;
- }
-
- /**
- * Set the type.
- * @return the type.
- */
- public String getType() {
- return type;
- }
-
- protected void setType(String type) {
- if (type.length() > MAX_LENGTH) {
- throw new IllegalArgumentException("Structured data type exceeds maximum length of 32 characters: " + type);
- }
- this.type = type;
- }
- /**
- * Return the message.
- * @return the message.
- */
- public String getMessageFormat() {
- return message;
- }
-
- protected void setMessageFormat(String msg) {
- this.message = msg;
- }
-
-
- @Override
- protected void validate(String key, String value) {
- if (value.length() > MAX_LENGTH) {
- throw new IllegalArgumentException("Structured data values are limited to 32 characters. key: " + key +
- " value: " + value);
- }
- }
-
- /**
- * Format the Structured data as described in RFC 5424.
- *
- * @return The formatted String.
- */
- @Override
- public String asString() {
- return asString(FULL, null);
- }
-
- /**
- * Format the Structured data as described in RFC 5424.
- *
- * @param format The format identifier. Ignored in this implementation.
- * @return The formatted String.
- */
-
- public String asString(String format) {
- return asString(format, null);
- }
-
- /**
- * Format the Structured data as described in RFC 5424.
- *
- * @param format "full" will include the type and message. null will return only the STRUCTURED-DATA as
- * described in RFC 5424
- * @param structuredDataId The SD-ID as described in RFC 5424. If null the value in the StructuredData
- * will be used.
- * @return The formatted String.
- */
- public final String asString(String format, StructuredDataId structuredDataId) {
- StringBuilder sb = new StringBuilder();
- boolean full = FULL.equals(format);
- if (full) {
- String type = getType();
- if (type == null) {
- return sb.toString();
- }
- sb.append(getType()).append(" ");
- }
- StructuredDataId id = getId();
- if (id != null) {
- id = id.makeId(structuredDataId);
- } else {
- id = structuredDataId;
- }
- if (id == null || id.getName() == null) {
- return sb.toString();
- }
- sb.append("[");
- sb.append(id);
- sb.append(" ");
- appendMap(sb);
- sb.append("]");
- if (full) {
- String msg = getMessageFormat();
- if (msg != null) {
- sb.append(" ").append(msg);
- }
- }
- return sb.toString();
- }
-
- /**
- * Format the message and return it.
- * @return the formatted message.
- */
- @Override
- public String getFormattedMessage() {
- return asString(FULL, null);
- }
-
- @Override
- public String toString() {
- return asString(null);
- }
-
-
- public MapMessage newInstance(Map<String, String> map) {
- return new StructuredDataMessage(this, map);
- }
-
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- StructuredDataMessage that = (StructuredDataMessage) o;
-
- if (!super.equals(o)) {
- return false;
- }
- if (type != null ? !type.equals(that.type) : that.type != null) {
- return false;
- }
- if (id != null ? !id.equals(that.id) : that.id != null) {
- return false;
- }
- if (message != null ? !message.equals(that.message) : that.message != null) {
- return false;
- }
-
- return true;
- }
-
- public int hashCode() {
- int result = super.hashCode();
- result = HASHVAL * result + (type != null ? type.hashCode() : 0);
- result = HASHVAL * result + (id != null ? id.hashCode() : 0);
- result = HASHVAL * result + (message != null ? message.hashCode() : 0);
- return result;
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
deleted file mode 100644
index 8478438..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.lang.management.ManagementFactory;
-import java.lang.management.ThreadInfo;
-import java.lang.management.ThreadMXBean;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Captures information about all running Threads.
- */
-public class ThreadDumpMessage implements Message {
-
- private static final long serialVersionUID = -1103400781608841088L;
-
- private static ThreadInfoFactory factory;
-
- private volatile Map<ThreadInformation, StackTraceElement[]> threads;
-
- private final String title;
-
- private String formattedMessage = null;
-
- static {
- Method[] methods = ThreadInfo.class.getMethods();
- boolean basic = true;
- for (Method method : methods) {
- if (method.getName().equals("getLockInfo")) {
- basic = false;
- break;
- }
- }
- factory = basic ? new BasicThreadInfoFactory() : new ExtendedThreadInfoFactory();
- }
-
- /**
- * Generate a ThreadDumpMessage with no title.
- */
- public ThreadDumpMessage() {
- this(null);
-
- }
-
- /**
- * Generate a ThreadDumpMessage with a title.
- * @param title The title.
- */
- public ThreadDumpMessage(String title) {
- this.title = title == null ? "" : title;
- threads = factory.createThreadInfo();
- }
-
- private ThreadDumpMessage(String formattedMsg, String title) {
- this.formattedMessage = formattedMsg;
- this.title = title;
- }
-
- /**
- * Return the ThreadDump in printable format.
- * @return the ThreadDump suitable for logging.
- */
- public String getFormattedMessage() {
- if (formattedMessage != null) {
- return formattedMessage;
- }
- StringBuilder sb = new StringBuilder(title);
- if (title.length() > 0) {
- sb.append("\n");
- }
- for (Map.Entry<ThreadInformation, StackTraceElement[]> entry : threads.entrySet()) {
- ThreadInformation info = entry.getKey();
- info.printThreadInfo(sb);
- info.printStack(sb, entry.getValue());
- sb.append("\n");
- }
- return sb.toString();
- }
-
- /**
- * Returns the title.
- * @return the title.
- */
- public String getMessageFormat() {
- return title == null ? "" : title;
- }
-
- /**
- * Returns an array with a single element, a Map containing the ThreadInformation as the key.
- * and the StackTraceElement array as the value;
- * @return the "parameters" to this Message.
- */
- public Object[] getParameters() {
- return null;
- }
-
- /**
- * Creates a ThreadDumpMessageProxy that can be serialized.
- * @return a ThreadDumpMessageProxy.
- */
- protected Object writeReplace() {
- return new ThreadDumpMessageProxy(this);
- }
-
- private void readObject(ObjectInputStream stream)
- throws InvalidObjectException {
- throw new InvalidObjectException("Proxy required");
- }
-
- /**
- * Proxy pattern used to serialize the ThreadDumpMessage.
- */
- private static class ThreadDumpMessageProxy implements Serializable {
-
- private static final long serialVersionUID = -3476620450287648269L;
- private String formattedMsg;
- private String title;
-
- public ThreadDumpMessageProxy(ThreadDumpMessage msg) {
- this.formattedMsg = msg.getFormattedMessage();
- this.title = msg.title;
- }
-
- /**
- * Return a ThreadDumpMessage using the data in the proxy.
- * @return a ThreadDumpMessage.
- */
- protected Object readResolve() {
- return new ThreadDumpMessage(formattedMsg, title);
- }
- }
-
- /**
- * Factory to create Thread information.
- */
- private interface ThreadInfoFactory {
- Map<ThreadInformation, StackTraceElement[]> createThreadInfo();
- }
-
- /**
- * Factory to create basic thread information.
- */
- private static class BasicThreadInfoFactory implements ThreadInfoFactory {
- public Map<ThreadInformation, StackTraceElement[]> createThreadInfo() {
- Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
- Map<ThreadInformation, StackTraceElement[]> threads =
- new HashMap<ThreadInformation, StackTraceElement[]>(map.size());
- for (Map.Entry<Thread, StackTraceElement[]> entry : map.entrySet()) {
- threads.put(new BasicThreadInformation(entry.getKey()), entry.getValue());
- }
- return threads;
- }
- }
-
- /**
- * Factory to create extended thread information.
- */
- private static class ExtendedThreadInfoFactory implements ThreadInfoFactory {
- public Map<ThreadInformation, StackTraceElement[]> createThreadInfo() {
- ThreadMXBean bean = ManagementFactory.getThreadMXBean();
- ThreadInfo[] array = bean.dumpAllThreads(true, true);
-
- Map<ThreadInformation, StackTraceElement[]> threads =
- new HashMap<ThreadInformation, StackTraceElement[]>(array.length);
- for (ThreadInfo info : array) {
- threads.put(new ExtendedThreadInformation(info), info.getStackTrace());
- }
- return threads;
- }
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadInformation.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadInformation.java
deleted file mode 100644
index 2db1777..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadInformation.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-/**
- * Interface used to print basic or extended thread information.
- */
-interface ThreadInformation {
- /**
- * Format the thread information into the provided StringBuilder.
- * @param sb The StringBuilder.
- */
- void printThreadInfo(StringBuilder sb);
-
- /**
- * Format the stack trace into the provided StringBuilder.
- * @param sb The StringBuilder.
- * @param trace The stack trace element array to format.
- */
- void printStack(StringBuilder sb, StackTraceElement[] trace);
-
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/TimestampMessage.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/TimestampMessage.java
deleted file mode 100644
index ad43010..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/TimestampMessage.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-/**
- * Messages that use this interface will cause the timestamp in the message to be used instead of the timestmap in
- * the LogEvent.
- */
-public interface TimestampMessage {
- /**
- * Returns the timestamp.
- * @return The timestamp.
- */
- long getTimestamp();
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/package-info.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/package-info.java
deleted file mode 100644
index b45f64b..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-/**
- * Public Message Types used for Log4j 2.0. User's may implement their own Messages.
- */
-package org.apache.logging.log4j.message;
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/package-info.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/package-info.java
deleted file mode 100644
index add24ea..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Public API for Log4j 2.0.
- */
-package org.apache.logging.log4j;
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
deleted file mode 100644
index e9e8041..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
+++ /dev/null
@@ -1,1480 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.spi;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.ObjectMessage;
-import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.apache.logging.log4j.message.SimpleMessage;
-
-/**
- * Base implementation of a Logger. It is highly recommended that any Logger implementation extend this class.
- *
- * @doubt See Jira LOG4J2-39.
- */
-public abstract class AbstractLogger implements Logger {
-
- /**
- * Marker for flow tracing.
- */
- public static final Marker FLOW_MARKER = MarkerManager.getMarker("FLOW");
- /**
- * Marker for method entry tracing.
- */
- public static final Marker ENTRY_MARKER = MarkerManager.getMarker("ENTRY", FLOW_MARKER);
- /**
- * Marker for method exit tracing.
- */
- public static final Marker EXIT_MARKER = MarkerManager.getMarker("EXIT", FLOW_MARKER);
- /**
- * Marker for exception tracing.
- */
- public static final Marker EXCEPTION_MARKER = MarkerManager.getMarker("EXCEPTION");
- /**
- * Marker for throwing exceptions.
- */
- public static final Marker THROWING_MARKER = MarkerManager.getMarker("THROWING", EXCEPTION_MARKER);
- /**
- * Marker for catching exceptions.
- */
- public static final Marker CATCHING_MARKER = MarkerManager.getMarker("CATCHING", EXCEPTION_MARKER);
-
- private static final String FQCN = AbstractLogger.class.getName();
-
- /**
- * Log entry to a method.
- */
- public void entry() {
- if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) {
- log(ENTRY_MARKER, FQCN, Level.TRACE, new SimpleMessage(" entry"), null);
- }
- }
-
-
- /**
- * Log entry to a method.
- *
- * @param params The parameters to the method.
- */
- public void entry(Object... params) {
- if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) {
- log(ENTRY_MARKER, FQCN, Level.TRACE, entryMsg(params.length, params), null);
- }
- }
-
- /**
- * Log exit from a method.
- */
- public void exit() {
- if (isEnabled(Level.TRACE, EXIT_MARKER, (Object) null, null)) {
- log(EXIT_MARKER, FQCN, Level.TRACE, exitMsg(null), null);
- }
- }
-
- /**
- * Log exiting from a method with the result.
- *
- * @param result The result being returned from the method call.
- * @return the Throwable.
- */
- public <R> R exit(R result) {
- if (isEnabled(Level.TRACE, EXIT_MARKER, (Object) null, null)) {
- log(EXIT_MARKER, FQCN, Level.TRACE, exitMsg(result), null);
- }
- return result;
- }
-
- /**
- * Log an exception or error to be thrown.
- *
- * @param t The Throwable.
- * @return the Throwable.
- */
- public <T extends Throwable> T throwing(T t) {
- if (isEnabled(Level.ERROR, THROWING_MARKER, (Object) null, null)) {
- log(THROWING_MARKER, FQCN, Level.ERROR, new SimpleMessage("throwing"), t);
- }
- return t;
- }
-
-
- /**
- * Log an exception or error to be thrown.
- *
- * @param level The logging Level.
- * @param t The Throwable.
- * @return the Throwable.
- */
- public <T extends Throwable> T throwing(Level level, T t) {
- if (isEnabled(level, THROWING_MARKER, (Object) null, null)) {
- log(THROWING_MARKER, FQCN, level, new SimpleMessage("throwing"), t);
- }
- return t;
- }
-
- /**
- * Log an exception or error that has been caught.
- *
- * @param t The Throwable.
- */
- public void catching(Throwable t) {
- if (isEnabled(Level.DEBUG, THROWING_MARKER, (Object) null, null)) {
- log(THROWING_MARKER, FQCN, Level.DEBUG, new SimpleMessage("catching"), t);
- }
- }
-
- /**
- * Log an exception or error that has been caught.
- *
- * @param level The logging Level.
- * @param t The Throwable.
- */
- public void catching(Level level, Throwable t) {
- if (isEnabled(level, THROWING_MARKER, (Object) null, null)) {
- log(THROWING_MARKER, FQCN, level, new SimpleMessage("catching"), t);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
- *
- * @param message the message object to log.
- */
- public void trace(String message) {
- if (isEnabled(Level.TRACE, null, message)) {
- log(null, FQCN, Level.TRACE, new SimpleMessage(message), null);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void trace(Marker marker, String message) {
- if (isEnabled(Level.TRACE, marker, message)) {
- log(marker, FQCN, Level.TRACE, new SimpleMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>TRACE</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- * <p/>
- * <p>
- * See {@link #debug(String)} form for more detailed information.
- * </p>
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void trace(String message, Throwable t) {
- if (isEnabled(Level.TRACE, null, message, t)) {
- log(null, FQCN, Level.TRACE, new SimpleMessage(message), t);
- }
- }
-
-
- /**
- * Log a message at the <code>TRACE</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- * <p/>
- * <p>
- * See {@link #debug(String)} form for more detailed information.
- * </p>
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void trace(Marker marker, String message, Throwable t) {
- if (isEnabled(Level.TRACE, marker, message, t)) {
- log(marker, FQCN, Level.TRACE, new SimpleMessage(message), t);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
- *
- * @param message the message object to log.
- */
- public void trace(Object message) {
- if (isEnabled(Level.TRACE, null, message, null)) {
- log(null, FQCN, Level.TRACE, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void trace(Marker marker, Object message) {
- if (isEnabled(Level.TRACE, marker, message, null)) {
- log(marker, FQCN, Level.TRACE, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>TRACE</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- * <p/>
- * <p>
- * See {@link #debug(String)} form for more detailed information.
- * </p>
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void trace(Object message, Throwable t) {
- if (isEnabled(Level.TRACE, null, message, t)) {
- log(null, FQCN, Level.TRACE, new ObjectMessage(message), t);
- }
- }
-
- /**
- * Log a message at the <code>TRACE</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- * <p/>
- * <p>
- * See {@link #debug(String)} form for more detailed information.
- * </p>
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void trace(Marker marker, Object message, Throwable t) {
- if (isEnabled(Level.TRACE, marker, message, t)) {
- log(marker, FQCN, Level.TRACE, new ObjectMessage(message), t);
- }
- }
-
- /**
- * Log a message with parameters at the <code>TRACE</code> level.
- *
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void trace(String message, Object... params) {
- if (isEnabled(Level.TRACE, null, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(null, FQCN, Level.TRACE, msg, msg.getThrowable());
- }
- }
-
- /**
- * Log a message with parameters at the <code>TRACE</code> level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void trace(Marker marker, String message, Object... params) {
- if (isEnabled(Level.TRACE, marker, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(marker, FQCN, Level.TRACE, msg, msg.getThrowable());
- }
- }
-
- /**
- * Check whether this Logger is enabled for the TRACE Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * TRACE, <code>false</code> otherwise.
- */
- public boolean isTraceEnabled() {
- return isEnabled(Level.TRACE, null, (Object) null, null);
- }
-
- /**
- * Check whether this Logger is enabled for the TRACE Level.
- *
- * @param marker The marker data.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * TRACE, <code>false</code> otherwise.
- */
- public boolean isTraceEnabled(Marker marker) {
- return isEnabled(Level.TRACE, marker, (Object) null, null);
- }
-
- /**
- * Log a message with the specific Marker at the TRACE level.
- *
- * @param msg the message string to be logged
- */
- public void trace(Message msg) {
- if (isEnabled(Level.TRACE, null, msg, null)) {
- log(null, FQCN, Level.TRACE, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the TRACE level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void trace(Message msg, Throwable t) {
- if (isEnabled(Level.TRACE, null, msg, t)) {
- log(null, FQCN, Level.TRACE, msg, t);
- }
- }
-
- /**
- * Log a message with the specific Marker at the TRACE level.
- *
- * @param marker the marker data specific to this log statement.
- * @param msg the message string to be logged
- */
- public void trace(Marker marker, Message msg) {
- if (isEnabled(Level.TRACE, marker, msg, null)) {
- log(marker, FQCN, Level.TRACE, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the TRACE level.
- *
- * @param marker the marker data specific to this log statement.
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void trace(Marker marker, Message msg, Throwable t) {
- if (isEnabled(Level.TRACE, marker, msg, t)) {
- log(marker, FQCN, Level.TRACE, msg, t);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
- *
- * @param message the message object to log.
- */
- public void debug(String message) {
- if (isEnabled(Level.DEBUG, null, message)) {
- log(null, FQCN, Level.DEBUG, new SimpleMessage(message), null);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void debug(Marker marker, String message) {
- if (isEnabled(Level.DEBUG, marker, message)) {
- log(marker, FQCN, Level.DEBUG, new SimpleMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>DEBUG</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message to log.
- * @param t the exception to log, including its stack trace.
- */
- public void debug(String message, Throwable t) {
- if (isEnabled(Level.DEBUG, null, message, t)) {
- log(null, FQCN, Level.DEBUG, new SimpleMessage(message), t);
- }
- }
-
- /**
- * Log a message at the <code>DEBUG</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message to log.
- * @param t the exception to log, including its stack trace.
- */
- public void debug(Marker marker, String message, Throwable t) {
- if (isEnabled(Level.DEBUG, marker, message, t)) {
- log(marker, FQCN, Level.DEBUG, new SimpleMessage(message), t);
- }
- }
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
- *
- * @param message the message object to log.
- */
- public void debug(Object message) {
- if (isEnabled(Level.DEBUG, null, message, null)) {
- log(null, FQCN, Level.DEBUG, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void debug(Marker marker, Object message) {
- if (isEnabled(Level.DEBUG, marker, message, null)) {
- log(marker, FQCN, Level.DEBUG, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>DEBUG</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message to log.
- * @param t the exception to log, including its stack trace.
- */
- public void debug(Object message, Throwable t) {
- if (isEnabled(Level.DEBUG, null, message, t)) {
- log(null, FQCN, Level.DEBUG, new ObjectMessage(message), t);
- }
- }
-
- /**
- * Log a message at the <code>DEBUG</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message to log.
- * @param t the exception to log, including its stack trace.
- */
- public void debug(Marker marker, Object message, Throwable t) {
- if (isEnabled(Level.DEBUG, marker, message, t)) {
- log(marker, FQCN, Level.DEBUG, new ObjectMessage(message), t);
- }
- }
-
- /**
- * Log a message with parameters at the <code>DEBUG</code> level.
- *
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void debug(String message, Object... params) {
- if (isEnabled(Level.DEBUG, null, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(null, FQCN, Level.DEBUG, msg, msg.getThrowable());
- }
- }
-
- /**
- * Log a message with parameters at the <code>DEBUG</code> level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void debug(Marker marker, String message, Object... params) {
- if (isEnabled(Level.DEBUG, marker, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(marker, FQCN, Level.DEBUG, msg, msg.getThrowable());
- }
- }
-
- /**
- * Check whether this Logger is enabled for the DEBUG Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * DEBUG, <code>false</code> otherwise.
- */
- public boolean isDebugEnabled() {
- return isEnabled(Level.DEBUG, null, null);
- }
-
- /**
- * Check whether this Logger is enabled for the DEBUG Level.
- *
- * @param marker The marker data.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * DEBUG, <code>false</code> otherwise.
- */
- public boolean isDebugEnabled(Marker marker) {
- return isEnabled(Level.DEBUG, marker, (Object) null, null);
- }
-
- /**
- * Log a message with the specific Marker at the DEBUG level.
- *
- * @param msg the message string to be logged
- */
- public void debug(Message msg) {
- if (isEnabled(Level.TRACE, null, msg, null)) {
- log(null, FQCN, Level.TRACE, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the DEBUG level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void debug(Message msg, Throwable t) {
- if (isEnabled(Level.TRACE, null, msg, t)) {
- log(null, FQCN, Level.TRACE, msg, t);
- }
- }
-
- /**
- * Log a message with the specific Marker at the DEBUG level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- */
- public void debug(Marker marker, Message msg) {
- if (isEnabled(Level.DEBUG, marker, msg, null)) {
- log(marker, FQCN, Level.DEBUG, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the DEBUG level.
- *
- * @param marker the marker data specific to this log statement.
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void debug(Marker marker, Message msg, Throwable t) {
- if (isEnabled(Level.DEBUG, marker, msg, t)) {
- log(marker, FQCN, Level.DEBUG, msg, t);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
- *
- * @param message the message object to log.
- */
- public void info(String message) {
- if (isEnabled(Level.INFO, null, message)) {
- log(null, FQCN, Level.INFO, new SimpleMessage(message), null);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void info(Marker marker, String message) {
- if (isEnabled(Level.INFO, marker, message)) {
- log(marker, FQCN, Level.INFO, new SimpleMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>INFO</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void info(String message, Throwable t) {
- if (isEnabled(Level.INFO, null, message, t)) {
- log(null, FQCN, Level.INFO, new SimpleMessage(message), t);
- }
- }
-
- /**
- * Log a message at the <code>INFO</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void info(Marker marker, String message, Throwable t) {
- if (isEnabled(Level.INFO, marker, message, t)) {
- log(marker, FQCN, Level.INFO, new SimpleMessage(message), t);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
- *
- * @param message the message object to log.
- */
- public void info(Object message) {
- if (isEnabled(Level.INFO, null, message, null)) {
- log(null, FQCN, Level.INFO, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void info(Marker marker, Object message) {
- if (isEnabled(Level.INFO, marker, message, null)) {
- log(marker, FQCN, Level.INFO, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>INFO</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void info(Object message, Throwable t) {
- if (isEnabled(Level.INFO, null, message, t)) {
- log(null, FQCN, Level.INFO, new ObjectMessage(message), t);
- }
- }
-
-
- /**
- * Log a message at the <code>INFO</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void info(Marker marker, Object message, Throwable t) {
- if (isEnabled(Level.INFO, marker, message, t)) {
- log(marker, FQCN, Level.INFO, new ObjectMessage(message), t);
- }
- }
-
- /**
- * Log a message with parameters at the <code>INFO</code> level.
- *
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void info(String message, Object... params) {
- if (isEnabled(Level.INFO, null, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(null, FQCN, Level.INFO, msg, msg.getThrowable());
- }
- }
-
- /**
- * Log a message with parameters at the <code>INFO</code> level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void info(Marker marker, String message, Object... params) {
- if (isEnabled(Level.INFO, marker, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(marker, FQCN, Level.INFO, msg, msg.getThrowable());
- }
- }
-
- /**
- * Check whether this Logger is enabled for the INFO Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * INFO, <code>false</code> otherwise.
- */
- public boolean isInfoEnabled() {
- return isEnabled(Level.INFO, null, (Object) null, null);
- }
-
- /**
- * Check whether this Logger is enabled for the INFO Level.
- * @param marker The marker data.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * INFO, <code>false</code> otherwise.
- */
- public boolean isInfoEnabled(Marker marker) {
- return isEnabled(Level.INFO, marker, (Object) null, null);
- }
-
- /**
- * Log a message with the specific Marker at the TRACE level.
- *
- * @param msg the message string to be logged
- */
- public void info(Message msg) {
- if (isEnabled(Level.INFO, null, msg, null)) {
- log(null, FQCN, Level.INFO, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the INFO level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void info(Message msg, Throwable t) {
- if (isEnabled(Level.INFO, null, msg, t)) {
- log(null, FQCN, Level.INFO, msg, t);
- }
- }
-
- /**
- * Log a message with the specific Marker at the INFO level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- */
- public void info(Marker marker, Message msg) {
- if (isEnabled(Level.INFO, null, msg, null)) {
- log(marker, FQCN, Level.INFO, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the INFO level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void info(Marker marker, Message msg, Throwable t) {
- if (isEnabled(Level.INFO, marker, msg, t)) {
- log(marker, FQCN, Level.INFO, msg, t);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
- *
- * @param message the message object to log.
- */
- public void warn(String message) {
- if (isEnabled(Level.WARN, null, message)) {
- log(null, FQCN, Level.WARN, new SimpleMessage(message), null);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void warn(Marker marker, String message) {
- if (isEnabled(Level.WARN, marker, message)) {
- log(marker, FQCN, Level.WARN, new SimpleMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>WARN</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void warn(String message, Throwable t) {
- if (isEnabled(Level.WARN, null, message, t)) {
- log(null, FQCN, Level.DEBUG, new SimpleMessage(message), t);
- }
- }
-
- /**
- * Log a message at the <code>WARN</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void warn(Marker marker, String message, Throwable t) {
- if (isEnabled(Level.WARN, marker, message, t)) {
- log(marker, FQCN, Level.DEBUG, new SimpleMessage(message), t);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void warn(Marker marker, Object message) {
- if (isEnabled(Level.WARN, marker, message, null)) {
- log(marker, FQCN, Level.WARN, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
- *
- * @param message the message object to log.
- */
- public void warn(Object message) {
- if (isEnabled(Level.WARN, null, message, null)) {
- log(null, FQCN, Level.WARN, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>WARN</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void warn(Object message, Throwable t) {
- if (isEnabled(Level.WARN, null, message, t)) {
- log(null, FQCN, Level.DEBUG, new ObjectMessage(message), t);
- }
- }
-
- /**
- * Log a message at the <code>WARN</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void warn(Marker marker, Object message, Throwable t) {
- if (isEnabled(Level.WARN, marker, message, t)) {
- log(marker, FQCN, Level.DEBUG, new ObjectMessage(message), t);
- }
- }
-
- /**
- * Log a message with parameters at the <code>WARN</code> level.
- *
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void warn(String message, Object... params) {
- if (isEnabled(Level.WARN, null, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(null, FQCN, Level.WARN, msg, msg.getThrowable());
- }
- }
-
- /**
- * Log a message with parameters at the <code>WARN</code> level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void warn(Marker marker, String message, Object... params) {
- if (isEnabled(Level.WARN, marker, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(marker, FQCN, Level.WARN, msg, msg.getThrowable());
- }
- }
-
- /**
- * Check whether this Logger is enabled for the WARN Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * WARN, <code>false</code> otherwise.
- */
- public boolean isWarnEnabled() {
- return isEnabled(Level.WARN, null, (Object) null, null);
- }
-
- /**
- * Check whether this Logger is enabled for the WARN Level.
- *
- * @param marker The marker data.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * WARN, <code>false</code> otherwise.
- */
- public boolean isWarnEnabled(Marker marker) {
- return isEnabled(Level.WARN, marker, (Object) null, null);
- }
-
- /**
- * Log a message with the specific Marker at the WARN level.
- *
- * @param msg the message string to be logged
- */
- public void warn(Message msg) {
- if (isEnabled(Level.WARN, null, msg, null)) {
- log(null, FQCN, Level.WARN, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the WARN level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void warn(Message msg, Throwable t) {
- if (isEnabled(Level.WARN, null, msg, t)) {
- log(null, FQCN, Level.WARN, msg, t);
- }
- }
-
- /**
- * Log a message with the specific Marker at the WARN level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- */
- public void warn(Marker marker, Message msg) {
- if (isEnabled(Level.WARN, null, msg, null)) {
- log(marker, FQCN, Level.WARN, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the WARN level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void warn(Marker marker, Message msg, Throwable t) {
- if (isEnabled(Level.WARN, marker, msg, t)) {
- log(marker, FQCN, Level.WARN, msg, t);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
- *
- * @param message the message object to log.
- */
- public void error(String message) {
- if (isEnabled(Level.ERROR, null, message)) {
- log(null, FQCN, Level.ERROR, new SimpleMessage(message), null);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void error(Marker marker, String message) {
- if (isEnabled(Level.ERROR, marker, message)) {
- log(marker, FQCN, Level.ERROR, new SimpleMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>ERROR</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void error(String message, Throwable t) {
- if (isEnabled(Level.ERROR, null, message, t)) {
- log(null, FQCN, Level.ERROR, new SimpleMessage(message), t);
- }
- }
-
- /**
- * Log a message at the <code>ERROR</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void error(Marker marker, String message, Throwable t) {
- if (isEnabled(Level.ERROR, marker, message, t)) {
- log(marker, FQCN, Level.ERROR, new SimpleMessage(message), t);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
- *
- * @param message the message object to log.
- */
- public void error(Object message) {
- if (isEnabled(Level.ERROR, null, message, null)) {
- log(null, FQCN, Level.ERROR, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void error(Marker marker, Object message) {
- if (isEnabled(Level.ERROR, marker, message, null)) {
- log(marker, FQCN, Level.ERROR, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>ERROR</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void error(Object message, Throwable t) {
- if (isEnabled(Level.ERROR, null, message, t)) {
- log(null, FQCN, Level.ERROR, new ObjectMessage(message), t);
- }
- }
-
- /**
- * Log a message at the <code>ERROR</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void error(Marker marker, Object message, Throwable t) {
- if (isEnabled(Level.ERROR, marker, message, t)) {
- log(marker, FQCN, Level.ERROR, new ObjectMessage(message), t);
- }
- }
-
- /**
- * Log a message with parameters at the <code>ERROR</code> level.
- *
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void error(String message, Object... params) {
- if (isEnabled(Level.ERROR, null, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(null, FQCN, Level.ERROR, msg, msg.getThrowable());
- }
- }
-
- /**
- * Log a message with parameters at the <code>ERROR</code> level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void error(Marker marker, String message, Object... params) {
- if (isEnabled(Level.ERROR, marker, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(marker, FQCN, Level.ERROR, msg, msg.getThrowable());
- }
- }
-
-
- /**
- * Check whether this Logger is enabled for the ERROR Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * ERROR, <code>false</code> otherwise.
- */
- public boolean isErrorEnabled() {
- return isEnabled(Level.ERROR, null, (Object) null, null);
- }
-
- /**
- * Check whether this Logger is enabled for the ERROR Level.
- *
- * @param marker The marker data.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * ERROR, <code>false</code> otherwise.
- */
- public boolean isErrorEnabled(Marker marker) {
- return isEnabled(Level.ERROR, marker, (Object) null, null);
- }
-
- /**
- * Log a message with the specific Marker at the ERROR level.
- *
- * @param msg the message string to be logged
- */
- public void error(Message msg) {
- if (isEnabled(Level.ERROR, null, msg, null)) {
- log(null, FQCN, Level.ERROR, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the ERROR level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void error(Message msg, Throwable t) {
- if (isEnabled(Level.ERROR, null, msg, t)) {
- log(null, FQCN, Level.ERROR, msg, t);
- }
- }
-
- /**
- * Log a message with the specific Marker at the ERROR level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- */
- public void error(Marker marker, Message msg) {
- if (isEnabled(Level.ERROR, null, msg, null)) {
- log(null, FQCN, Level.ERROR, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the ERROR level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void error(Marker marker, Message msg, Throwable t) {
- if (isEnabled(Level.TRACE, marker, msg, t)) {
- log(marker, FQCN, Level.TRACE, msg, t);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
- *
- * @param message the message object to log.
- */
- public void fatal(String message) {
- if (isEnabled(Level.FATAL, null, message)) {
- log(null, FQCN, Level.FATAL, new SimpleMessage(message), null);
- }
- }
-
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void fatal(Marker marker, String message) {
- if (isEnabled(Level.FATAL, marker, message)) {
- log(marker, FQCN, Level.FATAL, new SimpleMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>FATAL</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void fatal(String message, Throwable t) {
- if (isEnabled(Level.FATAL, null, message, t)) {
- log(null, FQCN, Level.FATAL, new SimpleMessage(message), t);
- }
- }
-
- /**
- * Log a message at the <code>FATAL</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void fatal(Marker marker, String message, Throwable t) {
- if (isEnabled(Level.FATAL, marker, message, t)) {
- log(marker, FQCN, Level.FATAL, new SimpleMessage(message), t);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
- *
- * @param message the message object to log.
- */
- public void fatal(Object message) {
- if (isEnabled(Level.FATAL, null, message, null)) {
- log(null, FQCN, Level.FATAL, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- */
- public void fatal(Marker marker, Object message) {
- if (isEnabled(Level.FATAL, marker, message, null)) {
- log(marker, FQCN, Level.FATAL, new ObjectMessage(message), null);
- }
- }
-
- /**
- * Log a message at the <code>FATAL</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void fatal(Object message, Throwable t) {
- if (isEnabled(Level.FATAL, null, message, t)) {
- log(null, FQCN, Level.FATAL, new ObjectMessage(message), t);
- }
- }
-
- /**
- * Log a message at the <code>FATAL</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- public void fatal(Marker marker, Object message, Throwable t) {
- if (isEnabled(Level.FATAL, marker, message, t)) {
- log(marker, FQCN, Level.FATAL, new ObjectMessage(message), t);
- }
- }
-
- /**
- * Log a message with parameters at the <code>FATAL</code> level.
- *
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void fatal(String message, Object... params) {
- if (isEnabled(Level.FATAL, null, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(null, FQCN, Level.FATAL, msg, msg.getThrowable());
- }
- }
-
- /**
- * Log a message with parameters at the <code>FATAL</code> level.
- *
- * @param marker the marker data specific to this log statement.
- * @param message the message to log.
- * @param params parameters to the message.
- */
- public void fatal(Marker marker, String message, Object... params) {
- if (isEnabled(Level.FATAL, marker, message, params)) {
- ParameterizedMessage msg = new ParameterizedMessage(message, params);
- log(marker, FQCN, Level.FATAL, msg, msg.getThrowable());
- }
- }
-
- /**
- * Check whether this Logger is enabled for the FATAL Level.
- *
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * FATAL, <code>false</code> otherwise.
- */
- public boolean isFatalEnabled() {
- return isEnabled(Level.ERROR, null, (Object) null, null);
- }
-
- /**
- * Check whether this Logger is enabled for the FATAL Level.
- *
- * @param marker The marker data.
- * @return boolean - <code>true</code> if this Logger is enabled for level
- * FATAL, <code>false</code> otherwise.
- */
- public boolean isFatalEnabled(Marker marker) {
- return isEnabled(Level.FATAL, marker, (Object) null, null);
- }
-
- /**
- * Log a message with the specific Marker at the FATAL level.
- *
- * @param msg the message string to be logged
- */
- public void fatal(Message msg) {
- if (isEnabled(Level.FATAL, null, msg, null)) {
- log(null, FQCN, Level.FATAL, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the FATAL level.
- *
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void fatal(Message msg, Throwable t) {
- if (isEnabled(Level.FATAL, null, msg, t)) {
- log(null, FQCN, Level.FATAL, msg, t);
- }
- }
-
- /**
- * Log a message with the specific Marker at the FATAL level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- */
- public void fatal(Marker marker, Message msg) {
- if (isEnabled(Level.FATAL, null, msg, null)) {
- log(null, FQCN, Level.FATAL, msg, null);
- }
- }
-
- /**
- * Log a message with the specific Marker at the FATAL level.
- *
- * @param marker the marker data specific to this log statement
- * @param msg the message string to be logged
- * @param t A Throwable or null.
- */
- public void fatal(Marker marker, Message msg, Throwable t) {
- if (isEnabled(Level.FATAL, marker, msg, t)) {
- log(marker, FQCN, Level.FATAL, msg, t);
- }
- }
-
- /**
- * Log a message with location information.
- *
- * @param marker The Marker
- * @param fqcn The fully qualified class name of the <b>caller</b>
- * @param level The logging level
- * @param data The Message.
- * @param t A Throwable or null.
- */
- protected abstract void log(Marker marker, String fqcn, Level level, Message data, Throwable t);
-
- /*
- * Instead of one single method with Object... declared the following methods explicitly specify
- * parameters because they perform dramatically better than having the JVM convert them to an
- * array.
- */
-
- /**
- * Determine if logging is enabled.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @return True if logging is enabled, false otherwise.
- */
- protected abstract boolean isEnabled(Level level, Marker marker, String data);
-
- /**
- * Determine if logging is enabled.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param t A Throwable.
- * @return True if logging is enabled, false otherwise.
- */
- protected abstract boolean isEnabled(Level level, Marker marker, String data, Throwable t);
-
- /**
- * Determine if logging is enabled.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param p1 The first parameter.
- * @return True if logging is enabled, false otherwise.
- */
- protected abstract boolean isEnabled(Level level, Marker marker, String data, Object p1);
-
- /**
- * Determine if logging is enabled.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param p1 The first parameter.
- * @param p2 The second parameter.
- * @return True if logging is enabled, false otherwise.
- */
- protected abstract boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2);
-
- /**
- * Determine if logging is enabled.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param p1 The first parameter.
- * @param p2 The second parameter.
- * @param p3 The third parameter.
- * @return True if logging is enabled, false otherwise.
- */
- protected abstract boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2, Object p3);
-
-
- /**
- * Determine if logging is enabled.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param p1 The first parameter.
- * @param p2 The second parameter.
- * @param p3 The third parameter.
- * @param params More message parameters.
- * @return True if logging is enabled, false otherwise.
- */
- protected abstract boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2,
- Object p3, Object... params);
-
- /**
- * Determine if logging is enabled.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param t A Throwable.
- * @return True if logging is enabled, false otherwise.
- */
- protected abstract boolean isEnabled(Level level, Marker marker, Object data, Throwable t);
-
- /**
- * Determine if logging is enabled.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The Message.
- * @param t A Throwable.
- * @return True if logging is enabled, false otherwise.
- */
- protected abstract boolean isEnabled(Level level, Marker marker, Message data, Throwable t);
-
- private Message entryMsg(int count, Object... params) {
- if (count == 0) {
- return new SimpleMessage(" entry");
- }
- StringBuilder sb = new StringBuilder(" entry parms(");
- int i = 0;
- for (Object parm : params) {
- if (parm != null) {
- sb.append(parm.toString());
- } else {
- sb.append("null");
- }
- if (++i < params.length) {
- sb.append(", ");
- }
- }
- sb.append(")");
- return new SimpleMessage(sb.toString());
- }
-
- private Message exitMsg(Object result) {
- if (result == null) {
- return new SimpleMessage(" exit");
- }
- return new SimpleMessage(" exit with (" + result + ")");
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
deleted file mode 100644
index 65c875a..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLoggerWrapper.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.spi;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.message.Message;
-
-/**
- * Wrapper class that exposes the protected AbstractLogger methods to support wrapped loggers.
- */
-public class AbstractLoggerWrapper extends AbstractLogger {
-
- /**
- * The wrapped Logger.
- */
- protected final AbstractLogger logger;
- /**
- * The name of the Logger.
- */
- protected final String name;
-
- /**
- * Constructor that wraps and existing Logger.
- * @param logger The Logger to wrap.
- * @param name The name of the Logger.
- */
- public AbstractLoggerWrapper(AbstractLogger logger, String name) {
- this.logger = logger;
- this.name = name;
- }
-
- /**
- * Log an event.
- * @param marker The Marker
- * @param fqcn The fully qualified class name of the <b>caller</b>
- * @param level The logging level
- * @param data The Message.
- * @param t A Throwable or null.
- */
- @Override
- public void log(Marker marker, String fqcn, Level level, Message data, Throwable t) {
- logger.log(marker, fqcn, level, data, t);
- }
-
- /**
- * Detect if the event would be logged.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @return true if the event would be logged for the Level, Marker and data, false otherwise.
- */
- @Override
- public boolean isEnabled(Level level, Marker marker, String data) {
- return logger.isEnabled(level, marker, data);
- }
-
- /**
- * Detect if the event would be logged.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param t A Throwable.
- * @return true if the event would be logged for the Level, Marker, data and Throwable, false otherwise.
- */
- @Override
- public boolean isEnabled(Level level, Marker marker, String data, Throwable t) {
- return logger.isEnabled(level, marker, data, t);
- }
-
- /**
- * Detect if the event would be logged.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param p1 The first parameter.
- * @return true if the event would be logged for the Level, Marker, data and parameter.
- */
- @Override
- public boolean isEnabled(Level level, Marker marker, String data, Object p1) {
- return logger.isEnabled(level, marker, data, p1);
- }
-
- /**
- * Detect if the event would be logged.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param p1 The first parameter.
- * @param p2 The second parameter.
- * @return true if the event would be logged for the Level, Marker, data and parameters.
- */
- @Override
- public boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2) {
- return logger.isEnabled(level, marker, data, p1, p2);
- }
-
- /**
- * Detect if the event would be logged.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param p1 The first parameter.
- * @param p2 The second parameter.
- * @param p3 The third parameter.
- * @return true if the event would be logged for the Level, Marker, data and parameters.
- */
- @Override
- public boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2, Object p3) {
- return logger.isEnabled(level, marker, data, p1, p2, p3);
- }
-
- /**
- * Detect if the event would be logged.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param p1 The first parameter.
- * @param p2 The second parameter.
- * @param p3 The third parameter.
- * @param params More message parameters.
- * @return true if the event would be logged for the Level, Marker, data and parameters.
- */
- @Override
- public boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2, Object p3,
- Object... params) {
- return logger.isEnabled(level, marker, data, p2, p2, p3, params);
- }
-
- /**
- * Detect if the event would be logged.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The message.
- * @param t A Throwable.
- * @return true if the event would be logged for the Level, Marker, Object and Throwable, false otherwise.
- */
- @Override
- public boolean isEnabled(Level level, Marker marker, Object data, Throwable t) {
- return logger.isEnabled(level, marker, data, t);
- }
-
- /**
- * Detect if the event would be logged.
- * @param level The logging Level to check.
- * @param marker A Marker or null.
- * @param data The Message.
- * @param t A Throwable.
- * @return true if the event would be logged for the Level, Marker, Message and Throwable, false otherwise.
- */
- @Override
- public boolean isEnabled(Level level, Marker marker, Message data, Throwable t) {
- return logger.isEnabled(level, marker, data, t);
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java
deleted file mode 100644
index e8c39a1..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerContext.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.spi;
-
-import org.apache.logging.log4j.Logger;
-
-/**
- * Anchor point for logging implementations.
- */
-public interface LoggerContext {
-
- /**
- * Return a Logger.
- * @param name The name of the Logger to return.
- * @return The logger with the specified name.
- */
- Logger getLogger(String name);
-
- /**
- * Detect if a Logger with the specified name exists.
- * @param name The Logger name to search for.
- * @return true if the Logger exists, false otherwise.
- */
- boolean hasLogger(String name);
-
- /**
- * An anchor for some other context, such as a ServletContext.
- * @return The external context.
- */
- Object getExternalContext();
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerContextFactory.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerContextFactory.java
deleted file mode 100644
index 79bc945..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/LoggerContextFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.spi;
-
-/**
- * Interface implemented by factories that create LoggerContext objects.
- */
-public interface LoggerContextFactory {
-
- /**
- * @param fqcn The fully qualified class name of the caller.
- * @param currentContext If true returns the current Context, if false returns the Context appropriate
- * for the caller if a more appropriate Context can be determined.
- * @return The LoggerContext.
- */
- LoggerContext getContext(String fqcn, boolean currentContext);
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/package-info.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/package-info.java
deleted file mode 100644
index 7de8836..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/spi/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Internal interfaces and classes to be used by authors of logging implementations.
- */
-package org.apache.logging.log4j.spi;
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java
deleted file mode 100644
index 39824da..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.status;
-
-import org.apache.logging.log4j.Level;
-
-/**
- * StatusListener that writes to the Console.
- */
-public class StatusConsoleListener implements StatusListener {
-
- private static final String STATUS_LEVEL = "org.apache.logging.log4j.StatusLevel";
-
- private Level level = Level.FATAL;
-
- private String[] filters = null;
-
- /**
- * Creates the StatusConsoleListener using either the level configured by the
- * "org.apache.logging.log4j.StatusLevel" system property if it is set or to a
- * default value of FATAL.
- */
- public StatusConsoleListener() {
- String str = System.getProperty(STATUS_LEVEL);
- if (str != null) {
- level = Level.toLevel(str, Level.FATAL);
- }
- }
-
- /**
- * Creates the StatusConsoleListener using the supplied Level.
- * @param level The Level of status messages that should appear on the console.
- */
- public StatusConsoleListener(Level level) {
- this.level = level;
- }
-
- /**
- * Sets the level to a new value.
- * @param level The new Level.
- */
- public void setLevel(Level level) {
- this.level = level;
- }
-
- /**
- * Writes status messages to the console.
- * @param data The StatusData.
- */
- public void log(StatusData data) {
- if (data.getLevel().isAtLeastAsSpecificAs(level) && !filtered(data)) {
- System.out.println(data.getFormattedStatus());
- }
- }
-
- /**
- * Adds package name filters to exclude.
- * @param filters An array of package names to exclude.
- */
- public void setFilters(String[] filters) {
- this.filters = filters;
- }
-
- private boolean filtered(StatusData data) {
- if (filters == null) {
- return false;
- }
- String caller = data.getStackTraceElement().getClassName();
- for (String filter : filters) {
- if (caller.startsWith(filter)) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusData.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusData.java
deleted file mode 100644
index 6921cd4..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusData.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.status;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.message.Message;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * The Status data.
- */
-public class StatusData {
-
- private final long timestamp;
-
- private final StackTraceElement caller;
-
- private final Level level;
-
- private final Message msg;
-
- private final Throwable throwable;
-
- /**
- * Creates the StatusData object.
- * @param caller The method that created the event.
- * @param level The logging level.
- * @param msg The message String.
- * @param t The Error or Exception that occurred.
- */
- public StatusData(StackTraceElement caller, Level level, Message msg, Throwable t) {
- this.timestamp = System.currentTimeMillis();
- this.caller = caller;
- this.level = level;
- this.msg = msg;
- this.throwable = t;
- }
-
- /**
- * Return the event's timestamp.
- * @return The event's timestamp.
- */
- public long getTimestamp() {
- return timestamp;
- }
-
- /**
- * Returns the StackTraceElement for the method that created the event.
- * @return The StackTraceElement.
- */
- public StackTraceElement getStackTraceElement() {
- return caller;
- }
-
- /**
- * Returns the logging level for the event.
- * @return The logging level.
- */
- public Level getLevel() {
- return level;
- }
-
- /**
- * Returns the message associated with the event.
- * @return The message associated with the event.
- */
- public Message getMessage() {
- return msg;
- }
-
- /**
- * Returns the Throwable associated with the event.
- * @return The Throwable associated with the event.
- */
- public Throwable getThrowable() {
- return throwable;
- }
-
- /**
- * Formats the StatusData for viewing.
- * @return The formatted status data as a String.
- */
- public String getFormattedStatus() {
- StringBuilder sb = new StringBuilder();
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
- sb.append(format.format(new Date(timestamp)));
- sb.append(" ");
- sb.append(level.toString());
- sb.append(" ");
- sb.append(msg.getFormattedMessage());
- Object[] params = msg.getParameters();
- Throwable t;
- if (throwable == null && params != null && params[params.length - 1] instanceof Throwable) {
- t = (Throwable) params[params.length - 1];
- } else {
- t = throwable;
- }
- if (t != null) {
- sb.append(" ");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- t.printStackTrace(new PrintStream(baos));
- sb.append(baos.toString());
- }
- return sb.toString();
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusListener.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusListener.java
deleted file mode 100644
index 887f167..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.status;
-
-/**
- * Interface that allows implementors to be notified of events in the logging system.
- */
-public interface StatusListener {
-
- /**
- * Called as events occur to process the StatusData.
- * @param data The StatusData for the event.
- */
- void log(StatusData data);
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
deleted file mode 100644
index 098d7d4..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.status;
-
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.message.Message;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- * Mechanism to record events that occur in the logging system.
- */
-public final class StatusLogger extends AbstractLogger {
-
- /**
- * System property that can be configured with the number of entries in the queue. Once the limit
- * is reached older entries will be removed as new entries are added.
- */
- public static final String MAX_STATUS_ENTRIES = "log4j2.status.entries";
-
- private static final String NOT_AVAIL = "?";
-
- private static final int MAX_ENTRIES = Integer.getInteger(MAX_STATUS_ENTRIES, 200);
-
- // private static final String FQCN = AbstractLogger.class.getName();
-
- private static StatusLogger statusLogger = new StatusLogger();
-
- private Logger logger = null;
-
- private CopyOnWriteArrayList<StatusListener> listeners = new CopyOnWriteArrayList<StatusListener>();
- private ReentrantReadWriteLock listenersLock = new ReentrantReadWriteLock();
-
- private Queue<StatusData> messages = new BoundedQueue<StatusData>(MAX_ENTRIES);
- private ReentrantLock msgLock = new ReentrantLock();
-
- private StatusLogger() {
- }
-
- /**
- * Retrieve the StatusLogger.
- * @return The StatusLogger.
- */
- public static StatusLogger getLogger() {
- return statusLogger;
- }
-
- /**
- * Register a new listener.
- * @param listener The StatusListener to register.
- */
- public void registerListener(StatusListener listener) {
- listenersLock.writeLock().lock();
- try {
- listeners.add(listener);
- } finally {
- listenersLock.writeLock().unlock();
- }
- }
-
- /**
- * Remove a StatusListener.
- * @param listener The StatusListener to remove.
- */
- public void removeListener(StatusListener listener) {
- listenersLock.writeLock().lock();
- try {
- listeners.remove(listener);
- } finally {
- listenersLock.writeLock().unlock();
- }
- }
-
- /**
- * Returns a thread safe Iterator for the StatusListener.
- * @return An Iterator for the list of StatusListeners.
- */
- public Iterator<StatusListener> getListeners() {
- return listeners.iterator();
- }
-
- /**
- * Clears the list of status events and listeners.
- */
- public void reset() {
- listeners.clear();
- clear();
- }
-
- /**
- * Returns a List of all events as StatusData objects.
- * @return The list of StatusData objects.
- */
- public List<StatusData> getStatusData() {
- msgLock.lock();
- try {
- return new ArrayList<StatusData>(messages);
- } finally {
- msgLock.unlock();
- }
- }
-
- /**
- * Clears the list of status events.
- */
- public void clear() {
- msgLock.lock();
- try {
- messages.clear();
- } finally {
- msgLock.unlock();
- }
- }
-
-
- /**
- * Add an event.
- * @param marker The Marker
- * @param fqcn The fully qualified class name of the <b>caller</b>
- * @param level The logging level
- * @param msg The message associated with the event.
- * @param t A Throwable or null.
- */
- @Override
- public void log(Marker marker, String fqcn, Level level, Message msg, Throwable t) {
- StackTraceElement element = null;
- if (fqcn != null) {
- element = getStackTraceElement(fqcn, Thread.currentThread().getStackTrace());
- }
- StatusData data = new StatusData(element, level, msg, t);
- msgLock.lock();
- try {
- messages.add(data);
- } finally {
- msgLock.unlock();
- }
- for (StatusListener listener : listeners) {
- listener.log(data);
- }
- }
-
- private StackTraceElement getStackTraceElement(String fqcn, StackTraceElement[] stackTrace) {
- if (fqcn == null) {
- return null;
- }
- boolean next = false;
- for (StackTraceElement element : stackTrace) {
- if (next) {
- return element;
- }
- String className = element.getClassName();
- if (fqcn.equals(className)) {
- next = true;
- } else if (NOT_AVAIL.equals(className)) {
- break;
- }
- }
- return null;
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String data) {
- return isEnabled(level, marker);
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String data, Throwable t) {
- return isEnabled(level, marker);
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String data, Object p1) {
- return isEnabled(level, marker);
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2) {
- return isEnabled(level, marker);
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2, Object p3) {
- return isEnabled(level, marker);
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String data, Object p1, Object p2, Object p3,
- Object... params) {
- return isEnabled(level, marker);
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, Object data, Throwable t) {
- return isEnabled(level, marker);
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, Message data, Throwable t) {
- return isEnabled(level, marker);
- }
-
- protected boolean isEnabled(Level level, Marker marker) {
- if (logger == null) {
- return true;
- }
- switch (level) {
- case FATAL:
- return logger.isFatalEnabled(marker);
- case TRACE:
- return logger.isTraceEnabled(marker);
- case DEBUG:
- return logger.isDebugEnabled(marker);
- case INFO:
- return logger.isInfoEnabled(marker);
- case WARN:
- return logger.isWarnEnabled(marker);
- case ERROR:
- return logger.isErrorEnabled(marker);
- }
- return false;
- }
-
- /**
- * Queue for status events.
- * @param <E> Object type to be stored in the queue.
- */
- private class BoundedQueue<E> extends ConcurrentLinkedQueue<E> {
-
- private final int size;
-
- public BoundedQueue(int size) {
- this.size = size;
- }
-
- public boolean add(E object) {
- while (messages.size() > size) {
- messages.poll();
- }
- return super.add(object);
- }
- }
-}
diff --git a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/package-info.java b/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/package-info.java
deleted file mode 100644
index f4d2c45..0000000
--- a/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/status/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-/** Status API for Log4j 2.0. Should not be used by typical applications performing logging but may be
- * used by applications reporting on the status of the logging system
- */
-package org.apache.logging.log4j.status;
diff --git a/rgoers/log4j2-api/src/main/resources/LICENSE b/rgoers/log4j2-api/src/main/resources/LICENSE
deleted file mode 100644
index 6279e52..0000000
--- a/rgoers/log4j2-api/src/main/resources/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- 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/rgoers/log4j2-api/src/main/resources/NOTICE b/rgoers/log4j2-api/src/main/resources/NOTICE
deleted file mode 100644
index 6233b56..0000000
--- a/rgoers/log4j2-api/src/main/resources/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache log4j Enhanced PatternLayout for log4j 1.2.x
-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/rgoers/log4j2-api/src/site/site.xml b/rgoers/log4j2-api/src/site/site.xml
deleted file mode 100644
index 832d7b8..0000000
--- a/rgoers/log4j2-api/src/site/site.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project name="Component">
- <bannerLeft>
- <name>Logging Services</name>
- <src>../images/ls-logo.jpg</src>
- <href>../index.html</href>
- </bannerLeft>
- <bannerRight>
- <src>../images/logo.jpg</src>
- </bannerRight>
- <body>
- <links>
- <item name="Apache" href="http://www.apache.org/" />
- <item name="Logging Services" href="http://logging.apache.org/"/>
- <item name="Log4j" href="../index.html"/>
- </links>
- <menu ref="reports"/>
- </body>
-</project>
diff --git a/rgoers/log4j2-api/src/site/xdoc/index.xml b/rgoers/log4j2-api/src/site/xdoc/index.xml
deleted file mode 100644
index b3bfbb5..0000000
--- a/rgoers/log4j2-api/src/site/xdoc/index.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4J 2.0 API</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Log4j 2.0 API">
-
- <p>
- The Log4Jj 2.0 API provides the interface that applications should code to and provides the
- adapter components required for implementers to create a logging implementation.
- </p>
-
- </section>
-
- <section name="Requirements">
- <p>
- The Log4j 2.0 API requires at least Java 5.
- </p>
- </section>
-
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/EventLoggerTest.java b/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/EventLoggerTest.java
deleted file mode 100644
index 40b7489..0000000
--- a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/EventLoggerTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Locale;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class EventLoggerTest {
-
- SimpleLogger logger = (SimpleLogger) LogManager.getLogger("EventLogger");
- List<String> results = logger.getEntries();
-
- @Before
- public void setup() {
- results.clear();
- }
-
- @Test
- public void structuredData() {
- ThreadContext.put("loginId", "JohnDoe");
- ThreadContext.put("ipAddress", "192.168.0.120");
- ThreadContext.put("locale", Locale.US.getDisplayName());
- StructuredDataMessage msg = new StructuredDataMessage("Transfer@18060", "Transfer Complete", "Audit");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "123457");
- msg.put("Amount", "200.00");
- EventLogger.logEvent(msg);
- ThreadContext.clear();
- assertEquals(1, results.size());
- String expected = " OFF Audit [Transfer@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete";
- assertTrue("Incorrect structured data: " + results.get(0) + ", expected: " ,results.get(0).startsWith(expected));
- }
-
-}
diff --git a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/LevelTest.java b/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/LevelTest.java
deleted file mode 100644
index 959021c..0000000
--- a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/LevelTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- *
- */
-public class LevelTest {
-
- @Test
- public void testGoodLevels() {
- Level level = Level.toLevel("INFO");
- assertNotNull(level);
- assertEquals(Level.INFO, level);
- }
-
- @Test
- public void testDefault() {
- Level level = Level.toLevel("Information", Level.ERROR);
- assertNotNull(level);
- assertEquals(Level.ERROR, level);
- }
-}
diff --git a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/LoggerTest.java b/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/LoggerTest.java
deleted file mode 100644
index 4dcdf40..0000000
--- a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/LoggerTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class LoggerTest {
-
- SimpleLogger logger = (SimpleLogger) LogManager.getLogger("LoggerTest");
- List<String> results = logger.getEntries();
-
- @Before
- public void setup() {
- results.clear();
- }
-
- @Test
- public void basicFlow() {
- logger.entry();
- logger.exit();
- assertEquals(2, results.size());
- assertTrue("Incorrect Entry", results.get(0).startsWith(" TRACE entry"));
- assertTrue("incorrect Exit", results.get(1).startsWith(" TRACE exit"));
-
- }
-
- @Test
- public void throwing() {
- logger.throwing(new IllegalArgumentException("Test Exception"));
- assertEquals(1, results.size());
- assertTrue("Incorrect Throwing",
- results.get(0).startsWith(" ERROR throwing java.lang.IllegalArgumentException: Test Exception"));
- }
-
- @Test
- public void catching() {
- try {
- throw new NullPointerException();
- } catch (Exception e) {
- logger.catching(e);
- assertEquals(1, results.size());
- assertTrue("Incorrect Catching",
- results.get(0).startsWith(" DEBUG catching java.lang.NullPointerException"));
- }
- }
-
- @Test
- public void debug() {
- logger.debug("Debug message");
- assertEquals(1, results.size());
- assertTrue("Incorrect message", results.get(0).startsWith(" DEBUG Debug message"));
- }
-
- @Test
- public void debugObject() {
- logger.debug(new Date());
- assertEquals(1, results.size());
- assertTrue("Invalid length", results.get(0).length() > 7);
- }
-
- @Test
- public void debugWithParms() {
- logger.debug("Hello, {}", "World");
- assertEquals(1, results.size());
- assertTrue("Incorrect substitution", results.get(0).startsWith(" DEBUG Hello, World"));
- }
-
- @Test
- public void debugWithParmsAndThrowable() {
- logger.debug("Hello, {}", "World", new RuntimeException("Test Exception"));
- assertEquals(1, results.size());
- assertTrue("Unexpected results: " + results.get(0),
- results.get(0).startsWith(" DEBUG Hello, World java.lang.RuntimeException: Test Exception"));
- }
-
- @Test
- public void mdc() {
-
- ThreadContext.put("TestYear", new Integer(2010).toString());
- logger.debug("Debug message");
- ThreadContext.clear();
- logger.debug("Debug message");
- assertEquals(2, results.size());
- assertTrue("Incorrect MDC: " + results.get(0),
- results.get(0).startsWith(" DEBUG Debug message {TestYear=2010}"));
- assertTrue("MDC not cleared?: " + results.get(1),
- results.get(1).startsWith(" DEBUG Debug message"));
- }
-
- @Test
- public void structuredData() {
- ThreadContext.put("loginId", "JohnDoe");
- ThreadContext.put("ipAddress", "192.168.0.120");
- ThreadContext.put("locale", Locale.US.getDisplayName());
- StructuredDataMessage msg = new StructuredDataMessage("Audit@18060", "Transfer Complete", "Transfer");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "123457");
- msg.put("Amount", "200.00");
- logger.info(MarkerManager.getMarker("EVENT"), msg);
- ThreadContext.clear();
- assertEquals(1, results.size());
- assertTrue("Incorrect structured data: " + results.get(0),results.get(0).startsWith(
- " INFO Transfer [Audit@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete"));
- }
-}
diff --git a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLogger.java b/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLogger.java
deleted file mode 100644
index 8c54d45..0000000
--- a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLogger.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.spi.AbstractLogger;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- *
- */
-public class SimpleLogger extends AbstractLogger {
- private List<String> array = new ArrayList<String>();
-
- public List<String> getEntries() {
- return array;
- }
-
- @Override
- public void log(Marker marker, String fqcn, Level level, Message msg, Throwable throwable) {
- StringBuilder sb = new StringBuilder();
- sb.append(" ");
- sb.append(level.toString());
- sb.append(" ");
- sb.append(msg.getFormattedMessage());
- Map<String, String> mdc = ThreadContext.getContext();
- if (mdc.size() > 0) {
- sb.append(" ");
- sb.append(mdc.toString());
- sb.append(" ");
- }
- Object[] params = msg.getParameters();
- Throwable t;
- if (throwable == null && params != null && params[params.length -1] instanceof Throwable ) {
- t = (Throwable) params[params.length - 1];
- } else {
- t = throwable;
- }
- if (t != null) {
- sb.append(" ");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- t.printStackTrace(new PrintStream(baos));
- sb.append(baos.toString());
- }
- array.add(sb.toString());
- //System.out.println(sb.toString());
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object p2, Object p3,
- Object...params) {
- return true;
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String msg) {
- return true;
- }
-
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String msg, Throwable t) {
- return true;
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String msg, Object p1) {
- return true;
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object p2) {
- return true;
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object p2, Object p3) {
- return true;
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, Object msg, Throwable t) {
- return true;
- }
-
- @Override
- protected boolean isEnabled(Level level, Marker marker, Message msg, Throwable t) {
- return true;
- }
-}
diff --git a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLoggerContext.java b/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLoggerContext.java
deleted file mode 100644
index c7d5e79..0000000
--- a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLoggerContext.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.spi.LoggerContext;
-
-/**
- *
- */
-public class SimpleLoggerContext implements LoggerContext {
- private Logger logger = new SimpleLogger();
-
- public Logger getLogger(String name) {
- return logger;
- }
-
- public boolean hasLogger(String name) {
- return false;
- }
-
- public Object getExternalContext() {
- return null;
- }
-
-}
diff --git a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLoggerContextFactory.java b/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLoggerContextFactory.java
deleted file mode 100644
index 13c622d..0000000
--- a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/SimpleLoggerContextFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.apache.logging.log4j.spi.LoggerContextFactory;
-
-/**
- *
- */
-public class SimpleLoggerContextFactory implements LoggerContextFactory {
-
- private static LoggerContext ctx = new SimpleLoggerContext();
-
- public LoggerContext getContext(String FQCN, boolean currentContext) {
- return ctx;
- }
-}
diff --git a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java b/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java
deleted file mode 100644
index b4b6d82..0000000
--- a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/MapMessageTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class MapMessageTest {
-
- @Test
- public void testMap() {
- String testMsg = "Test message {}";
- MapMessage msg = new MapMessage();
- msg.put("message", testMsg);
- msg.put("project", "Log4j");
- String result = msg.getFormattedMessage();
- String expected = "message=\"Test message {}\" project=\"Log4j\"";
- assertEquals(expected, result);
- }
-
- @Test
- public void testXML() {
- String testMsg = "Test message {}";
- MapMessage msg = new MapMessage();
- msg.setFormat("XML");
- msg.put("message", testMsg);
- msg.put("project", "Log4j");
- String result = msg.getFormattedMessage();
- String expected = "<Map>\n <Entry key=message>Test message {}</Entry>\n" +
- " <Entry key=project>Log4j</Entry>\n" +
- "</Map>";
- assertEquals(expected, result);
- }
-}
diff --git a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ParameterizedMessageTest.java b/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ParameterizedMessageTest.java
deleted file mode 100644
index 111f016..0000000
--- a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ParameterizedMessageTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class ParameterizedMessageTest {
-
- @Test
- public void testNoArgs() {
- String testMsg = "Test message {}";
- ParameterizedMessage msg = new ParameterizedMessage(testMsg, null);
- String result = msg.getFormattedMessage();
- assertEquals(testMsg, result);
- Object[] array = null;
- msg = new ParameterizedMessage(testMsg, array, null);
- result = msg.getFormattedMessage();
- assertEquals(testMsg, result);
- }
-}
diff --git a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/StructuredDataMessageTest.java b/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/StructuredDataMessageTest.java
deleted file mode 100644
index 3f5eea9..0000000
--- a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/StructuredDataMessageTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class StructuredDataMessageTest {
-
- @Test
- public void testMsg() {
- String testMsg = "Test message {}";
- StructuredDataMessage msg = new StructuredDataMessage("MsgId@12345", testMsg, "Alert");
- msg.put("message", testMsg);
- msg.put("project", "Log4j");
- String result = msg.getFormattedMessage();
- String expected = "Alert [MsgId@12345 message=\"Test message {}\" project=\"Log4j\"] Test message {}";
- assertEquals(expected, result);
- }
-}
diff --git a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java b/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
deleted file mode 100644
index 120429f..0000000
--- a/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.message;
-
-import org.junit.Test;
-
-import java.util.concurrent.locks.ReentrantLock;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class ThreadDumpMessageTest {
-
- @Test
- public void testMessage() {
- ThreadDumpMessage msg = new ThreadDumpMessage("Testing");
-
- String message = msg.getFormattedMessage();
- //System.out.print(message);
- assertTrue("No header", message.contains("Testing"));
- assertTrue("No RUNNABLE", message.contains("RUNNABLE"));
- assertTrue("No ThreadDumpMessage", message.contains("ThreadDumpMessage"));
- }
-
-
- @Test
- public void testMessageWithLocks() throws Exception {
- ReentrantLock lock = new ReentrantLock();
- lock.lock();
- Thread thread1 = new Thread1(lock);
- thread1.start();
- ThreadDumpMessage msg;
- synchronized(this) {
- Thread thread2 = new Thread2(this);
- thread2.start();
- try {
- Thread.sleep(200);
- msg = new ThreadDumpMessage("Testing");
- } finally {
- lock.unlock();
- }
- }
-
- String message = msg.getFormattedMessage();
- //System.out.print(message);
- assertTrue("No header", message.contains("Testing"));
- assertTrue("No RUNNABLE", message.contains("RUNNABLE"));
- assertTrue("No ThreadDumpMessage", message.contains("ThreadDumpMessage"));
- //assertTrue("No Locks", message.contains("waiting on"));
- //assertTrue("No syncronizers", message.contains("locked syncrhonizers"));
- }
-
- private class Thread1 extends Thread {
- private ReentrantLock lock;
-
- public Thread1(ReentrantLock lock) {
- this.lock = lock;
- }
-
- @Override
- public void run() {
- lock.lock();
- lock.unlock();
- }
- }
-
- private class Thread2 extends Thread {
- private Object obj;
-
- public Thread2(Object obj) {
- this.obj = obj;
- }
-
- @Override
- public void run() {
- synchronized (obj) {
-
- }
- }
- }
-}
diff --git a/rgoers/log4j2-api/src/test/resources/META-INF/log4j-provider.xml b/rgoers/log4j2-api/src/test/resources/META-INF/log4j-provider.xml
deleted file mode 100644
index 7284f25..0000000
--- a/rgoers/log4j2-api/src/test/resources/META-INF/log4j-provider.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
-<properties>
- <entry key="LoggerContextFactory">org.apache.logging.log4j.SimpleLoggerContextFactory</entry>
- <entry key="Log4jAPIVersion">1.99.0</entry>
-</properties>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/LICENSE b/rgoers/log4j2-core/LICENSE
deleted file mode 100644
index 6279e52..0000000
--- a/rgoers/log4j2-core/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- 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/rgoers/log4j2-core/NOTICE b/rgoers/log4j2-core/NOTICE
deleted file mode 100644
index 6233b56..0000000
--- a/rgoers/log4j2-core/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache log4j Enhanced PatternLayout for log4j 1.2.x
-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/rgoers/log4j2-core/build.xml b/rgoers/log4j2-core/build.xml
deleted file mode 100644
index 5b987de..0000000
--- a/rgoers/log4j2-core/build.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-
-<!--
-
-This is a minimal build file to support Gump.
-Use of Maven to build this component is recommended.
-
--->
-<project default="test">
- <!-- use build.properties file or command line to override these properties -->
- <property file="build.properties"/>
-
- <!-- project details -->
- <property name="project.name" value="apache-log4j-experimental-pattern-layout"/>
- <property name="project.title" value="Enhanced Pattern Layout Component for log4j X"/>
- <property name="project.version" value="0.1-SNAPSHOT"/>
- <property name="project.jar" value="${project.name}-${project.version}.jar"/>
-
- <!-- Location of local Maven 2 repository -->
- <property name="m2_repo" location="${user.home}/.m2/repository"/>
-
- <!-- Versions for dependencies -->
- <property name="log4j.version" value="1.2.14"/>
- <property name="junit.version" value="4.3.1"/>
- <property name="oro.version" value="2.0.8"/>
-
- <!-- Dependency locations - assumed to be in Maven 2 repository -->
- <property name="junit.jar"
- location="${m2_repo}/junit/junit/${junit.version}/junit-${junit.version}.jar"/>
- <property name="log4j.jar"
- location="${m2_repo}/log4j/log4j/${log4j.version}/log4j-${log4j.version}.jar"/>
- <property name="oro.jar"
- location="${m2_repo}/oro/oro/${oro.version}/oro-${oro.version}.jar"/>
-
-
- <!-- Java compiler settings -->
- <property name="javac.source" value="1.5"/>
- <property name="javac.target" value="1.5"/>
- <property name="javac.deprecation" value="true"/>
- <property name="javac.debug" value="true"/>
-
- <target name="init"/>
-
- <target name="clean" depends="init" description="Clean up generated files">
- <delete dir="target"/>
- </target>
-
-
- <target name="compile" depends="init" description="Compile implementation files">
- <mkdir dir="target/classes"/>
- <javac destdir="target/classes"
- srcdir="src/main/java"
- deprecation="${javac.deprecation}"
- debug="${javac.debug}"
- target="${javac.target}"
- source="${javac.source}"
- classpath="${log4j.jar}"/>
- <copy todir="target/classes">
- <fileset dir="src/main/resources"/>
- </copy>
- </target>
-
- <target name="jar" depends="compile" description="Create jar">
- <jar destfile="target/${project.jar}"
- basedir="target/classes">
- <manifest>
- <attribute name="Built-By" value="${user.name}"/>
- <section name="common">
- <attribute name="Specification-Title" value="${project.title}"/>
- <attribute name="Specification-Version" value="${project.version}"/>
- <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
- <attribute name="Implementation-Title" value="${project.title}"/>
- <attribute name="Implementation-Version" value="${project.version}"/>
- <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
- </section>
- </manifest>
- </jar>
- </target>
-
- <target name="test-compile" depends="compile" description="Compile test files">
- <mkdir dir="target/test-classes"/>
- <javac destdir="target/test-classes"
- srcdir="src/test/java"
- deprecation="${javac.deprecation}"
- debug="${javac.debug}"
- target="${javac.target}"
- source="${javac.source}"
- classpath="${log4j.jar}:${junit.jar}:target/classes:${oro.jar}"/>
- <copy todir="target/test-classes">
- <fileset dir="src/test/resources"/>
- </copy>
- </target>
-
-
- <target name="test" depends="test-compile" description="Run unit tests">
- <junit printsummary="yes">
- <classpath path="target/test-classes:target/classes:${log4j.jar}:${oro.jar}"/>
- <batchtest>
- <fileset dir="src/test/java/">
- <include name="**/*TestCase.java"/>
- <include name="**/*Test.java"/>
- </fileset>
- </batchtest>
- <formatter type="plain" usefile="false"/>
- </junit>
- </target>
-</project>
diff --git a/rgoers/log4j2-core/pom.xml b/rgoers/log4j2-core/pom.xml
deleted file mode 100644
index 220b7ab..0000000
--- a/rgoers/log4j2-core/pom.xml
+++ /dev/null
@@ -1,295 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2</artifactId>
- <version>1.99.0-SNAPSHOT</version>
- </parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-core</artifactId>
- <packaging>jar</packaging>
- <name>Log4J2 Core</name>
- <description>Log4j 2.0 Implementation.</description>
- <properties>
- <log4j.parent.dir>${basedir}/..</log4j.parent.dir>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-core-asl</artifactId>
- <version>1.9.2</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>1.9.2</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>oro</groupId>
- <artifactId>oro</artifactId>
- <version>2.0.8</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.16</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-ext</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.7</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockejb</groupId>
- <artifactId>mockejb</artifactId>
- <version>0.6-beta2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jms_1.1_spec</artifactId>
- <version>1.0</version>
- <optional>true</optional>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <forkMode>always</forkMode>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2.1</version>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <goals>
- <goal>java</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <mainClass>org.apache.logging.log4j.core.config.plugins.PluginManager</mainClass>
- <arguments>
- <argument>${project.build.outputDirectory}</argument>
- </arguments>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <version>2.6</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>changes-report</report>
- </reports>
- </reportSet>
- </reportSets>
- <configuration>
- <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.7</version>
- <configuration>
- <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
- <configLocation>${log4j.parent.dir}/checkstyle.xml</configLocation>
- <suppressionsLocation>${log4j.parent.dir}/checkstyle-suppressions.xml</suppressionsLocation>
- <enableRulesSummary>false</enableRulesSummary>
- <propertyExpansion>basedir=${basedir}</propertyExpansion>
- <propertyExpansion>licensedir=${log4j.parent.dir}/checkstyle-header.txt</propertyExpansion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8</version>
- <configuration>
- <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
- project -->
- <detectOfflineLinks>false</detectOfflineLinks>
- <linksource>true</linksource>
- <tags>
- <tag>
- <name>issue</name>
- <placement>a</placement>
- <head>JIRA issue:</head>
- </tag>
- <tag>
- <name>doubt</name>
- <placement>a</placement>
- <head>Troublesome:</head>
- </tag>
- <tag>
- <name>compare</name>
- <placement>a</placement>
- <head>Compare with:</head>
- </tag>
- </tags>
- </configuration>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <threshold>Normal</threshold>
- <effort>Default</effort>
- <excludeFilterFile>findbugs-exclude-filter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.3</version>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>jxr</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <targetJdk>1.5</targetJdk>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.2</version>
- <reportSets>
- <reportSet>
- <!-- Disabled at it kills the site generation via a NoClassDefFoundError -->
- <reports/>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
- <profiles>
- <profile>
- <!-- http://www.yourkit.com/docs/80/help/agent.jsp -->
- <id>yourkit</id>
-
- <properties>
- <yourkit.home>/Applications/YourKit_Java_Profiler_8.0.17.app</yourkit.home>
- </properties>
- <dependencies>
- <dependency>
- <groupId>com.yourkit</groupId>
- <artifactId>yjp-controller-api-redist</artifactId>
- <version>8.0.17</version>
- <scope>system</scope>
- <systemPath>${yourkit.home}/lib/yjp-controller-api-redist.jar</systemPath>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <argLine>-agentpath:"${yourkit.home}/bin/mac/libyjpagent.jnilib"</argLine>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
-
diff --git a/rgoers/log4j2-core/src/changes/changes.xml b/rgoers/log4j2-core/src/changes/changes.xml
deleted file mode 100644
index b92a5c0..0000000
--- a/rgoers/log4j2-core/src/changes/changes.xml
+++ /dev/null
Binary files differ
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/AbstractServer.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/AbstractServer.java
deleted file mode 100644
index 692c354..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/AbstractServer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import org.apache.logging.log4j.LogManager;
-
-/**
- *
- */
-public class AbstractServer {
-
- private LoggerContext context;
-
- protected AbstractServer() {
- context = (LoggerContext) LogManager.getContext();
- }
-
- protected void log(LogEvent event) {
- Logger logger = context.getLogger(event.getLoggerName());
- if (logger.config.filter(event.getLevel(), event.getMarker(), event.getMessage(), event.getThrown())) {
- logger.config.logEvent(event);
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Appender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Appender.java
deleted file mode 100644
index 67abdf7..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Appender.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-/**
- * @issue LOG4J2-36: Appender interface should be refactored
- */
-public interface Appender extends Lifecycle {
-
- /**
- * Log in <code>Appender</code> specific way. When appropriate,
- * Loggers will call the <code>doAppend</code> method of appender
- * implementations in order to log.
- *
- * @param event The LogEvent.
- */
- void append(LogEvent event);
-
-
- /**
- * Get the name of this appender.
- *
- * @return name, may be null.
- */
- String getName();
-
- /**
- * Returns this appenders layout.
- *
- * @return the Layout for the Appender or null if none is configured.
- * @issue LOG4J2-36 Refactor into Channel
- */
- Layout getLayout();
-
- /**
- * If set to true any exceptions thrown by the Appender will be logged but not thrown.
- * @return true if Exceptions should be suppressed, false otherwise.
- */
- boolean isExceptionSuppressed();
-
- ErrorHandler getHandler();
-
- void setHandler(ErrorHandler handler);
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/ErrorHandler.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/ErrorHandler.java
deleted file mode 100644
index bec0a20..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/ErrorHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-/**
- * Appenders may delegate their error handling to <code>ErrorHandlers</code>.
- * @doubt if the appender interface is simplified, then error handling could just be done by wrapping
- * a nested appender. (RG) Please look at DefaultErrorHandler. It's purpose is to make sure the console
- * or error log isn't flooded with messages. I'm still considering the Appender refactoring.
- */
-public interface ErrorHandler {
-
- /**
- * Handle an error with a message.
- * @param msg The message.
- */
- void error(String msg);
-
- /**
- * Handle an error with a message and an exception.
- * @param msg The message.
- * @param t The Throwable.
- */
- void error(String msg, Throwable t);
-
- /**
- * Handle an error with a message, and exception and a logging event.
- * @param msg The message.
- * @param event The LogEvent.
- * @param t The Throwable.
- */
- void error(String msg, LogEvent event, Throwable t);
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Filter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Filter.java
deleted file mode 100644
index 9168230..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Filter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.message.Message;
-
-/**
- * Interface that must be implemented to allow custom event filtering. It is highly recommended that
- * applications make use of the Filters provided with this implementation before creating their own.
- *
- * This interface supports "global" filters (i.e. - all events must pass through them first), attached to
- * specific loggers and associated with Appenders. It is recommended that, where possible, Filter implementations
- * create a generic filtering method that can be called from any of the filter methods.
- */
-public interface Filter {
-
- /**
- * The result that can returned from a filter method call.
- */
- public enum Result {
- /**
- * The event will be processed without further filtering based on the log Level.
- */
- ACCEPT,
- /**
- * No decision could be made, further filtering should occur.
- */
- NEUTRAL,
- /**
- * The event should not be processed.
- */
- DENY
- }
-
- /**
- * Return the result that should be returned when the filter does not match the event.
- * @return the Result that should be returned when the filter does not match the event.
- */
- Result getOnMismatch();
- /**
- * Return the result that should be returned when the filter matches the event.
- * @return the Result that should be returned when the filter matches the event.
- */
- Result getOnMatch();
-
- /**
- * Filter an event.
- * @param logger The Logger.
- * @param level The event logging Level.
- * @param marker The Marker for the event or null.
- * @param msg String text to filter on.
- * @param params An array of parameters or null.
- * @return the Result.
- */
- Result filter(Logger logger, Level level, Marker marker, String msg, Object... params);
-
- /**
- * Filter an event.
- * @param logger The Logger.
- * @param level The event logging Level.
- * @param marker The Marker for the event or null.
- * @param msg Any Object.
- * @param t A Throwable or null.
- * @return the Result.
- */
- Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t);
-
- /**
- * Filter an event.
- * @param logger The Logger.
- * @param level The event logging Level.
- * @param marker The Marker for the event or null.
- * @param msg The Message
- * @param t A Throwable or null.
- * @return the Result.
- */
- Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t);
-
- /**
- * Filter an event.
- * @param event The Event to filter on.
- * @return the Result.
- */
- Result filter(LogEvent event);
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Layout.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Layout.java
deleted file mode 100644
index 5421fdc..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Layout.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import java.io.Serializable;
-
-/**
- * @doubt There is still a need for a character-based layout for character based event sinks (databases, etc).
- * Would introduce an EventEncoder, EventRenderer or something similar for the logging event to byte encoding.
- * (RG) A layout can be configured with a Charset and then Strings can be converted to byte arrays. OTOH, it isn't
- * possible to write byte arrays as character streams.
- * @param <T> The Object type that will be returned on the formatAs call.
- */
-public interface Layout<T extends Serializable> {
- /**
- * Formats the event suitable for display.
- * @param event The Logging Event.
- * @return The formatted event.
- * @doubt Likely better to write to a OutputStream instead of return a byte[]. (RG) That limits how the
- * Appender can use the Layout. For example, it might concatenate information in front or behind the
- * data and then write it all to the OutputStream in one call.
- */
- byte[] format(LogEvent event);
-
- /**
- * Formats the event as an Object that can be serialized.
- * @param event The Logging Event.
- * @return The formatted event.
- */
- T formatAs(LogEvent event);
-
- /**
- * Returns the header for the layout format.
- * @return The header.
- * @doubt the concept of header and footer is not universal, should not be on the base interface.
- * (RG) I agree with this.
- */
- byte[] getHeader();
-
- /**
- * Returns the format for the layout format.
- * @return The footer.
- * @doubt the concept of header and footer is not universal, should not be on the base interface.
- * (RG) I agree with this.
- */
- byte[] getFooter();
-
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Lifecycle.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Lifecycle.java
deleted file mode 100644
index 65fe131..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Lifecycle.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-/**
- *
- */
-public interface Lifecycle {
- void start();
-
- void stop();
-
- boolean isStarted();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LogEvent.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LogEvent.java
deleted file mode 100644
index 22bf3b7..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LogEvent.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.message.Message;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Stack;
-
-/**
- *
- */
-public interface LogEvent extends Serializable {
-
- /**
- * Get level.
- * @return level.
- */
- Level getLevel();
-
- /**
- * Get logger name.
- * @return logger name, may be null.
- */
- String getLoggerName();
-
- /**
- * Get source of logging request.
- * @return source of logging request, may be null.
- */
- StackTraceElement getSource();
-
- /**
- * Get the message associated with the event.
- *
- * @return message.
- */
- Message getMessage();
-
- /**
- * Get the Marker associated with the event.
- * @return Marker
- */
- Marker getMarker();
-
- /**
- * Get thread name.
- * @return thread name, may be null.
- * @doubt guess this could go into a thread context object too.
- * (RG) Why?
- */
- String getThreadName();
-
-
- /**
- * Get event time in milliseconds since 1970.
- * @return milliseconds since 1970.
- */
- long getMillis();
-
-
- /**
- * Get throwable associated with logging request.
- * @return throwable, may be null.
- */
- Throwable getThrown();
-
-
- /**
- * Get the MDC data.
- *
- * @return A copy of the Mapped Diagnostic Context or null.
- * @doubt as mentioned elsewhere, think MDC and NDC should be combined into a thread context object.
- * (RG) Still to do.
- */
- Map<String, String> getContextMap();
-
- /**
- * Get the NDC data.
- *
- * @return A copy of the Nested Diagnostic Context of null;
- * @doubt as mentioned elsewhere, think MDC and NDC should be combined into a thread context object.
- * (RG) Still to do.
- */
- Stack<String> getContextStack();
-
- /**
- * Returns the fully qualified class name of the caller of the logging api.
- * @return The fully qualified class name of the caller.
- */
- String getFQCN();
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java
deleted file mode 100644
index e13066c..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.core.filter.CompositeFilter;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.spi.AbstractLogger;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @doubt All the isEnabled methods could be pushed into a filter interface. Not sure of the utility of having
- * isEnabled be able to examine the message pattern and parameters. (RG) Moving the isEnabled methods out of
- * Logger noticeably impacts performance. The message pattern and parameters are required so that they can be
- * used in global filters.
- */
-public class Logger extends AbstractLogger {
-
- /**
- * config should be consistent across threads.
- */
- protected volatile PrivateConfig config;
-
- private final String name;
-
- private final LoggerContext context;
-
- /**
- * The constructor.
- * @param context The LoggerContext this Logger is associated with.
- * @param name The name of the Logger.
- */
- protected Logger(LoggerContext context, String name) {
- this.context = context;
- this.name = name;
- config = new PrivateConfig(context.getConfiguration(), this);
- }
-
- /**
- * Returns the name of the Logger.
- * @return the name of the Logger.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Return the parent of this Logger. If it doesn't already exist return a temporary Logger.
- * @return The parent Logger.
- */
- public Logger getParent() {
- LoggerConfig lc = config.loggerConfig.getParent();
- if (lc == null) {
- return null;
- }
- if (context.hasLogger(lc.getName())) {
- return context.getLogger(name);
- }
- return new Logger(context, name);
- }
-
- /**
- * Return the LoggerContext this Logger is associated with.
- * @return the LoggerContext.
- */
- public LoggerContext getContext() {
- return context;
- }
-
- /**
- * This method is not exposed through the public API and is provided primarily for unit testing.
- * @param level The Level to use on this Logger.
- */
- public synchronized void setLevel(Level level) {
- if (level != null) {
- config = new PrivateConfig(config, level);
- }
- }
-
- /**
- * Return the Level associated with the Logger.
- * @return the Level associate with the Logger.
- */
- public Level getLevel() {
- return config.level;
- }
-
- @Override
- public void log(Marker marker, String fqcn, Level level, Message data, Throwable t) {
- if (data == null) {
- data = new SimpleMessage("");
- }
- config.loggerConfig.log(name, marker, fqcn, level, data, t);
- }
-
- @Override
- public boolean isEnabled(Level level, Marker marker, String msg) {
- return config.filter(level, marker, msg);
- }
-
- @Override
- public boolean isEnabled(Level level, Marker marker, String msg, Throwable t) {
- return config.filter(level, marker, msg, t);
- }
-
- @Override
- public boolean isEnabled(Level level, Marker marker, String msg, Object p1) {
- return config.filter(level, marker, msg, p1);
- }
-
- @Override
- public boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object p2) {
- return config.filter(level, marker, msg, p1, p2);
- }
-
- @Override
- public boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object p2, Object p3) {
- return config.filter(level, marker, msg, p1, p2, p3);
- }
-
- @Override
- public boolean isEnabled(Level level, Marker marker, String msg, Object p1, Object p2, Object p3,
- Object... params) {
- return config.filter(level, marker, msg, p1, p2, p3, params);
- }
-
- @Override
- public boolean isEnabled(Level level, Marker marker, Object msg, Throwable t) {
- return config.filter(level, marker, msg, t);
- }
-
- @Override
- public boolean isEnabled(Level level, Marker marker, Message msg, Throwable t) {
- return config.filter(level, marker, msg, t);
- }
-
- /**
- * This method is not exposed through the public API and is used primarily for unit testing.
- * @param appender The Appender to add to the Logger.
- */
- public void addAppender(Appender appender) {
- config.config.addLoggerAppender(this, appender);
- }
-
- /**
- * This method is not exposed through the public API and is used primarily for unit testing.
- * @param appender The Appender to remove from the Logger.
- */
- public void removeAppender(Appender appender) {
- config.loggerConfig.removeAppender(appender.getName());
- }
-
- /**
- * This method is not exposed through the public API and is used primarily for unit testing.
- * @return A Map containing the Appender's name as the key and the Appender as the value.
- */
- public Map<String, Appender> getAppenders() {
- return config.loggerConfig.getAppenders();
- }
-
- /**
- * This method is not exposed through the public API and is used primarily for unit testing.
- * @return An Iterator over all the Filters associated with the Logger.
- */
- public Iterator<Filter> getFilters() {
- Filter filter = config.loggerConfig.getFilter();
- if (filter == null) {
- return new ArrayList<Filter>().iterator();
- } else if (filter instanceof CompositeFilter) {
- return ((CompositeFilter) filter).iterator();
- } else {
- List<Filter> filters = new ArrayList<Filter>();
- filters.add(filter);
- return filters.iterator();
- }
- }
-
- /**
- * This method is not exposed through the public API and is used primarily for unit testing.
- * @return The number of Filters associated with the Logger.
- */
- public int filterCount() {
- Filter filter = config.loggerConfig.getFilter();
- if (filter == null) {
- return 0;
- } else if (filter instanceof CompositeFilter) {
- return ((CompositeFilter) filter).size();
- }
- return 1;
- }
-
- /**
- * This method is not exposed through the public API and is used primarily for unit testing.
- * @param filter The Filter to add.
- */
- public void addFilter(Filter filter) {
- config.config.addLoggerFilter(this, filter);
- }
-
- /**
- * This method is not exposed through the public API and is present only to support the Log4j 1.2
- * compatibility bridge.
- * @return true if the associated LoggerConfig is additive, false otherwise.
- */
- public boolean isAdditive() {
- return config.loggerConfig.isAdditive();
- }
-
- /**
- * This method is not exposed through the public API and is present only to support the Log4j 1.2
- * compatibility bridge.
- * @param additive Boolean value to indicate whether the Logger is additive or not.
- */
- public void setAdditive(boolean additive) {
- config.config.setLoggerAdditive(this, additive);
- }
-
- /**
- * Associates the Logger with a new Configuration. This method is not exposed through the
- * public API.
- *
- * There are two ways that could be used to guarantee all threads are aware of changes to
- * config. 1. synchronize this method. Accessors don't need to be synchronized as Java will
- * treat all variables within a synchronized block as volatile. 2. Declare the variable
- * volatile. Option 2 is used here as the performance cost is very low and it does a better
- * job at documenting how it is used.
- *
- * @param config The new Configuration.
- */
- void updateConfiguration(Configuration config) {
- this.config = new PrivateConfig(config, this);
- }
-
- /**
- * The binding between a Logger and its configuration.
- */
- protected class PrivateConfig {
- private final LoggerConfig loggerConfig;
- private final Configuration config;
- private final Level level;
- private final int intLevel;
- private final Logger logger;
-
- public PrivateConfig(Configuration config, Logger logger) {
- this.config = config;
- this.loggerConfig = config.getLoggerConfig(name);
- this.level = this.loggerConfig.getLevel();
- this.intLevel = this.level.intLevel();
- this.logger = logger;
- }
-
- public PrivateConfig(PrivateConfig pc, Level level) {
- this.config = pc.config;
- this.loggerConfig = pc.loggerConfig;
- this.level = level;
- this.intLevel = this.level.intLevel();
- this.logger = pc.logger;
- }
-
- public PrivateConfig(PrivateConfig pc, LoggerConfig lc) {
- this.config = pc.config;
- this.loggerConfig = lc;
- this.level = lc.getLevel();
- this.intLevel = this.level.intLevel();
- this.logger = pc.logger;
- }
-
- protected void logEvent(LogEvent event) {
- loggerConfig.log(event);
- }
-
- boolean filter(Level level, Marker marker, String msg) {
- Filter filter = config.getFilter();
- if (filter != null) {
- Filter.Result r = filter.filter(logger, level, marker, msg);
- if (r != Filter.Result.NEUTRAL) {
- return r == Filter.Result.ACCEPT;
- }
- }
-
- return intLevel >= level.intLevel();
- }
-
- boolean filter(Level level, Marker marker, String msg, Throwable t) {
- Filter filter = config.getFilter();
- if (filter != null) {
- Filter.Result r = filter.filter(logger, level, marker, msg, t);
- if (r != Filter.Result.NEUTRAL) {
- return r == Filter.Result.ACCEPT;
- }
- }
-
- return intLevel >= level.intLevel();
- }
-
- boolean filter(Level level, Marker marker, String msg, Object p1) {
- Filter filter = config.getFilter();
- if (filter != null) {
- Filter.Result r = filter.filter(logger, level, marker, msg, p1);
- if (r != Filter.Result.NEUTRAL) {
- return r == Filter.Result.ACCEPT;
- }
- }
-
- return intLevel >= level.intLevel();
- }
-
- boolean filter(Level level, Marker marker, String msg, Object p1, Object p2) {
- Filter filter = config.getFilter();
- if (filter != null) {
- Filter.Result r = filter.filter(logger, level, marker, msg, p1, p2);
- if (r != Filter.Result.NEUTRAL) {
- return r == Filter.Result.ACCEPT;
- }
- }
-
- return intLevel >= level.intLevel();
- }
-
- boolean filter(Level level, Marker marker, String msg, Object p1, Object p2, Object p3) {
- Filter filter = config.getFilter();
- if (filter != null) {
- Filter.Result r = filter.filter(logger, level, marker, msg, p1, p2, p3);
- if (r != Filter.Result.NEUTRAL) {
- return r == Filter.Result.ACCEPT;
- }
- }
-
- return intLevel >= level.intLevel();
- }
-
- boolean filter(Level level, Marker marker, String msg, Object p1, Object p2, Object p3,
- Object... params) {
- Filter filter = config.getFilter();
- if (filter != null) {
- Filter.Result r = filter.filter(logger, level, marker, msg, p1, p2, p3, params);
- if (r != Filter.Result.NEUTRAL) {
- return r == Filter.Result.ACCEPT;
- }
- }
-
- return intLevel >= level.intLevel();
- }
-
- boolean filter(Level level, Marker marker, Object msg, Throwable t) {
- Filter filter = config.getFilter();
- if (filter != null) {
- Filter.Result r = filter.filter(logger, level, marker, msg, t);
- if (r != Filter.Result.NEUTRAL) {
- return r == Filter.Result.ACCEPT;
- }
- }
-
- return intLevel >= level.intLevel();
- }
-
- boolean filter(Level level, Marker marker, Message msg, Throwable t) {
- Filter filter = config.getFilter();
- if (filter != null) {
- Filter.Result r = filter.filter(logger, level, marker, msg, t);
- if (r != Filter.Result.NEUTRAL) {
- return r == Filter.Result.ACCEPT;
- }
- }
-
- return intLevel >= level.intLevel();
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
deleted file mode 100644
index 4b55448..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.config.ConfigurationListener;
-import org.apache.logging.log4j.core.config.DefaultConfiguration;
-import org.apache.logging.log4j.core.config.NullConfiguration;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.io.File;
-import java.net.URI;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * The LoggerContext is the anchor for the logging system. It maintains a list of all the loggers requested by
- * applications and a reference to the Configuration. The Configuration will contain the configured loggers, appenders,
- * filters, etc and will be atomically updated whenever a reconfigure occurs.
- */
-public class LoggerContext implements org.apache.logging.log4j.spi.LoggerContext, ConfigurationListener, Lifecycle {
-
- private static StatusLogger logger = StatusLogger.getLogger();
-
- private final ConcurrentMap<String, Logger> loggers = new ConcurrentHashMap<String, Logger>();
-
- /**
- * The Configuration is volatile to guarantee that initialization of the Configuration has completed before
- * the reference is updated.
- */
- private volatile Configuration config = new DefaultConfiguration();
-
- private Object externalContext = null;
-
- private final String contextName;
-
- private final URI configLocation;
-
- private boolean isStarted;
-
- /**
- * Constructor taking only a name.
- * @param name The context name.
- */
- public LoggerContext(String name) {
- this(name, null, (URI) null);
- }
-
- /**
- * Constructor taking a name and a reference to an external context.
- * @param name The context name.
- * @param externalContext The external context.
- */
- public LoggerContext(String name, Object externalContext) {
- this(name, externalContext, (URI) null);
- }
-
- /**
- * Constructor taking a name, external context and a configuration URI.
- * @param name The context name.
- * @param externalContext The external context.
- * @param configLocn The location of the configuration as a URI.
- */
- public LoggerContext(String name, Object externalContext, URI configLocn) {
- contextName = name;
- this.externalContext = externalContext;
- this.configLocation = configLocn;
- }
-
- /**
- * Constructor taking a name external context and a configuration location String. The location
- * must be resolvable to a File.
- * @param name The configuration location.
- * @param externalContext The external context.
- * @param configLocn The configuration location.
- */
- public LoggerContext(String name, Object externalContext, String configLocn) {
- contextName = name;
- this.externalContext = externalContext;
- if (configLocn != null) {
- URI uri;
- try {
- uri = new File(configLocn).toURI();
- } catch (Exception ex) {
- uri = null;
- }
- configLocation = uri;
- } else {
- configLocation = null;
- }
- }
-
- public void start() {
- reconfigure();
- isStarted = true;
- }
-
- public synchronized void stop() {
- isStarted = false;
- updateLoggers(new NullConfiguration());
- config.stop();
- externalContext = null;
- }
-
- public boolean isStarted() {
- return isStarted;
- }
-
- /**
- * Set the external context.
- * @param context The external context.
- */
- public void setExternalContext(Object context) {
- this.externalContext = context;
- }
-
- /**
- * Return the external context.
- * @return The external context.
- */
- public Object getExternalContext() {
- return this.externalContext;
- }
-
- /**
- * Obtain a Logger from the Context.
- * @param name The name of the Logger to return.
- * @return The Logger.
- */
- public Logger getLogger(String name) {
-
- Logger logger = loggers.get(name);
- if (logger != null) {
- return logger;
- }
-
- logger = (Logger) newInstance(this, name);
- Logger prev = loggers.putIfAbsent(name, logger);
- return prev == null ? logger : prev;
- }
-
- /**
- * Determine if the specified Logger exists.
- * @param name The Logger name to search for.
- * @return True if the Logger exists, false otherwise.
- */
- public boolean hasLogger(String name) {
- return loggers.containsKey(name);
- }
-
- /**
- * Return the current Configuration. The Configuration will be replaced when a reconfigure occurs.
- * @return The Configuration.
- */
- public Configuration getConfiguration() {
- return config;
- }
-
- /**
- * Add a Filter to the Configuration. Filters that are added through the API will be lost
- * when a reconfigure occurs.
- * @param filter The Filter to add.
- */
- public void addFilter(Filter filter) {
- config.addFilter(filter);
- }
-
- /**
- * Removes a Filter from the current Configuration.
- * @param filter The Filter to remove.
- */
- public void removeFiler(Filter filter) {
- config.removeFilter(filter);
- }
-
- /**
- * Set the Configuration to be used.
- * @param config The new Configuration.
- * @return The previous Configuration.
- */
- public synchronized Configuration setConfiguration(Configuration config) {
- if (config == null) {
- throw new NullPointerException("No Configuration was provided");
- }
- Configuration prev = this.config;
- config.addListener(this);
- config.start();
- this.config = config;
- updateLoggers();
- if (prev != null) {
- prev.removeListener(this);
- prev.stop();
- }
- return prev;
- }
-
- /**
- * Reconfigure the context.
- */
- public synchronized void reconfigure() {
- logger.debug("Reconfiguration started for context " + contextName);
- Configuration instance = ConfigurationFactory.getInstance().getConfiguration(contextName, configLocation);
- setConfiguration(instance);
- /*instance.start();
- Configuration old = setConfiguration(instance);
- updateLoggers();
- if (old != null) {
- old.stop();
- } */
- logger.debug("Reconfiguration completed");
- }
-
- /**
- * Cause all Loggers to be updated against the current Configuration.
- */
- public void updateLoggers() {
- updateLoggers(this.config);
- }
-
- /**
- * Cause all Logger to be updated against the specified Configuration.
- * @param config The Configuration.
- */
- public void updateLoggers(Configuration config) {
- for (Logger logger : loggers.values()) {
- logger.updateConfiguration(config);
- }
- }
-
- /**
- * Cause a reconfiguration to take place when the underlying configuration file changes.
- */
- public void onChange() {
- reconfigure();
- }
-
-
- private Logger newInstance(LoggerContext ctx, String name) {
- return new Logger(ctx, name);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java
deleted file mode 100644
index 71bcacf..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractManager.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * Base class used to register managers.
- */
-public abstract class AbstractManager {
-
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
-
- // Need to lock that map instead of using a ConcurrentMap due to stop removing the
- // manager from the map and closing the stream, requiring the whole stop method to be locked.
- private static Map<String, AbstractManager> map = new HashMap<String, AbstractManager>();
-
- private static Lock lock = new ReentrantLock();
-
- private String name;
-
- private int count;
-
- protected AbstractManager(String name) {
- this.name = name;
- }
-
-
- /**
- * Retrieves a Manager if it has been previously created or creates a new Manager.
- * @param name The name of the Manager to retrieve.
- * @param factory The Factory to use to create the Manager.
- * @param data An Object that should be passed to the factory when creating the Manager.
- * @param <T> The Type of the Manager to be created.
- * @return A Manager with the specified name and type.
- */
- public static <T extends AbstractManager> T getManager(String name, ManagerFactory<T, Object> factory,
- Object data) {
- lock.lock();
- try {
- T manager = (T) map.get(name);
- if (manager == null) {
- manager = factory.createManager(name, data);
- if (manager == null) {
- throw new IllegalStateException("Unable to create a manager");
- }
- map.put(name, manager);
- }
- manager.count++;
- return manager;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * Determines if a Manager with the specified name exists.
- * @param name The name of the Manager.
- * @return True if the Manager exists, false otherwise.
- */
- public static boolean hasManager(String name) {
- lock.lock();
- try {
- return map.containsKey(name);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * May be overriden by Managers to perform processing while the Manager is being released and the
- * lock is held.
- */
- protected void releaseSub() {
- }
-
- protected int getCount() {
- return count;
- }
-
- /**
- * Called to signify that this Manager is no longer required by an Appender.
- */
- public void release() {
- lock.lock();
- try {
- --count;
- if (count <= 0) {
- map.remove(name);
- releaseSub();
- }
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * Return the name of the Manager.
- * @return The name of the Manager.
- */
- public String getName() {
- return name;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/AppenderBase.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/AppenderBase.java
deleted file mode 100644
index 1315517..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/AppenderBase.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.ErrorHandler;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Lifecycle;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.filter.Filterable;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.Logger;
-
-/**
- * Base class for Appenders. Although Appenders do not have to extend this class, doing so
- * will simplify their implementation.
- */
-public abstract class AppenderBase extends Filterable implements Appender, Lifecycle {
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
-
- /**
- * Appenders set this by calling super.start().
- */
- private boolean started = false;
-
- private Layout layout = null;
-
- private final String name;
-
- private final boolean handleException;
-
- private ErrorHandler handler = new DefaultErrorHandler(this);
-
- /**
- * Constructor that defaults to suppressing exceptions.
- * @param name The Appender name.
- * @param filter The Filter to associate with the Appender.
- * @param layout The layout to use to format the event.
- */
- protected AppenderBase(String name, Filter filter, Layout layout) {
- this(name, filter, layout, true);
- }
-
- /**
- * Constructor.
- * @param name The Appender name.
- * @param filter The Filter to associate with the Appender.
- * @param layout The layout to use to format the event.
- * @param handleException If true, exceptions will be logged and suppressed. If false errors will be
- * logged and then passed to the application.
- */
- protected AppenderBase(String name, Filter filter, Layout layout, boolean handleException) {
- super(filter);
- this.name = name;
- this.layout = layout;
- this.handleException = handleException;
- }
-
- /**
- * Return the ErrorHandler, if any.
- * @return The ErrorHandler.
- */
- public ErrorHandler getHandler() {
- return handler;
- }
-
- /**
- * The handler must be set before the appender is started.
- * @param handler The ErrorHandler to use.
- */
- public void setHandler(ErrorHandler handler) {
- if (handler == null) {
- LOGGER.error("The handler cannot be set to null");
- }
- if (isStarted()) {
- LOGGER.error("The handler cannot be changed once the appender is started");
- return;
- }
- this.handler = handler;
- }
-
- /**
- * Close the stream associated with the Appender.
- */
- public void close() {
-
- }
-
- /**
- * Returns the name of the Appender.
- * @return The name of the Appender.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns the Layout for the appender.
- * @return The Layout used to format the event.
- */
- public Layout getLayout() {
- return layout;
- }
-
- /**
- * Some appenders need to propogate exceptions back to the application. When suppressException is false the
- * AppenderControl will allow the exception to percolate.
- * @return true if exceptions will be supressed, false otherwise.
- */
- public boolean isExceptionSuppressed() {
- return handleException;
- }
-
- /**
- * Start the Appender.
- */
- public void start() {
- startFilter();
- this.started = true;
- }
-
- /**
- * Stop the Appender.
- */
- public void stop() {
- this.started = false;
- stopFilter();
- }
-
- /**
- * Returns true if the Appender is started, false otherwise.
- * @return true if the Appender is started, false otherwise.
- */
- public boolean isStarted() {
- return started;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- /**
- * Handle an error with a message.
- * @param msg The message.
- */
- public void error(String msg) {
- handler.error(msg);
- }
-
- /**
- * Handle an error with a message and an exception.
- * @param msg The message.
- * @param t The Throwable.
- */
- public void error(String msg, Throwable t) {
- handler.error(msg, t);
- }
-
- /**
- * Handle an error with a message, and exception and a logging event.
- * @param msg The message.
- * @param event The LogEvent.
- * @param t The Throwable.
- */
- public void error(String msg, LogEvent event, Throwable t) {
- handler.error(msg, event, t);
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/AppenderRuntimeException.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/AppenderRuntimeException.java
deleted file mode 100644
index a5eea16..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/AppenderRuntimeException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-/**
- * @doubt unchecked exception again (RG) Why is that a problem? A runtime exception
- * is appropriate in the case where the Appender encounters a checked exception and
- * needs to percolate the exception to the application.
- */
-public class AppenderRuntimeException extends RuntimeException {
-
- public AppenderRuntimeException(String msg) {
- super(msg);
- }
-
- public AppenderRuntimeException(String msg, Throwable ex) {
- super(msg, ex);
- }
-
- public AppenderRuntimeException(Throwable ex) {
- super(ex);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/CompressionType.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/CompressionType.java
deleted file mode 100644
index ddf9ab7..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/CompressionType.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-/**
- * An enumeration of the valid compression types.
- */
-public enum CompressionType {
- /** GZIP. */
- GZIP,
- /** No compression. */
- NONE,
- /** ZIP. */
- ZIP
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
deleted file mode 100644
index e9b82b6..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-
-import java.io.OutputStream;
-
-/**
- * ConsoleAppender appends log events to <code>System.out</code> or
- * <code>System.err</code> using a layout specified by the user. The
- * default target is <code>System.out</code>.
- * @doubt accessing System.out or .err as a byte stream instead of a writer
- * bypasses the JVM's knowledge of the proper encoding. (RG) Encoding
- * is handled within the Layout. Typically, a Layout will generate a String
- * and then call getBytes which may use a configured encoding or the system
- * default. OTOH, a Writer cannot print byte streams.
- */
-@Plugin(name = "Console", type = "Core", elementType = "appender", printObject = true)
-public final class ConsoleAppender extends OutputStreamAppender {
-
- private static ManagerFactory factory = new ConsoleManagerFactory();
-
- /**
- * Enumeration of console destinations.
- */
- public enum Target {
- /** Standard output. */
- SYSTEM_OUT,
- /** Standard error output. */
- SYSTEM_ERR
- }
-
- private ConsoleAppender(String name, Layout layout, Filter filter, OutputStreamManager manager,
- boolean handleExceptions) {
- super(name, layout, filter, handleExceptions, true, manager);
- }
-
- /**
- * Create a Console Appender.
- * @param layout The layout to use (required).
- * @param filter The Filter or null.
- * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
- * @param name The name of the Appender (required).
- * @param suppress "true" if exceptions should be hidden from the application, "false" otherwise.
- * The default is "true".
- * @return The ConsoleAppender.
- */
- @PluginFactory
- public static ConsoleAppender createAppender(@PluginElement("layout") Layout layout,
- @PluginElement("filters") Filter filter,
- @PluginAttr("target") String t,
- @PluginAttr("name") String name,
- @PluginAttr("suppressExceptions") String suppress) {
- if (name == null) {
- LOGGER.error("No name provided for ConsoleAppender");
- return null;
- }
- if (layout == null) {
- layout = PatternLayout.createLayout(null, null, null, null);
- }
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
- Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
- return new ConsoleAppender(name, layout, filter, getManager(target), handleExceptions);
- }
-
- private static OutputStreamManager getManager(Target target) {
- String type = target.name();
- OutputStream os = target == Target.SYSTEM_OUT ? System.out : System.err;
- OutputStreamManager manager = OutputStreamManager.getManager(target.name(), factory,
- new FactoryData(os, type));
- return manager;
- }
-
- /**
- * Data to pass to factory method.
- */
- private static class FactoryData {
- private OutputStream os;
- private String type;
-
- /**
- * Constructor.
- * @param os The OutputStream.
- * @param type The name of the target.
- */
- public FactoryData(OutputStream os, String type) {
- this.os = os;
- this.type = type;
- }
- }
-
- /**
- * Factory to create the Appender.
- */
- private static class ConsoleManagerFactory implements ManagerFactory<OutputStreamManager, FactoryData> {
-
- /**
- * Create an OutputStreamManager.
- * @param name The name of the entity to manage.
- * @param data The data required to create the entity.
- * @return The OutputStreamManager
- */
- public OutputStreamManager createManager(String name, FactoryData data) {
- return new OutputStreamManager(data.os, data.type);
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/DefaultErrorHandler.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/DefaultErrorHandler.java
deleted file mode 100644
index 9831dcd..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/DefaultErrorHandler.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.ErrorHandler;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- *
- */
-public class DefaultErrorHandler implements ErrorHandler {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private static final int MAX_EXCEPTIONS = 3;
-
- private static final int EXCEPTION_INTERVAL = 300000;
-
- private int exceptionCount = 0;
-
- private long lastException;
-
- private Appender appender;
-
- public DefaultErrorHandler(Appender appender) {
- this.appender = appender;
- }
-
-
- /**
- * Handle an error with a message.
- * @param msg The message.
- */
- public void error(String msg) {
- long current = System.currentTimeMillis();
- if (lastException + EXCEPTION_INTERVAL < current || exceptionCount++ < MAX_EXCEPTIONS) {
- LOGGER.error(msg);
- }
- lastException = current;
- }
-
- /**
- * Handle an error with a message and an exception.
- * @param msg The message.
- * @param t The Throwable.
- */
- public void error(String msg, Throwable t) {
- long current = System.currentTimeMillis();
- if (lastException + EXCEPTION_INTERVAL < current || exceptionCount++ < MAX_EXCEPTIONS) {
- LOGGER.error(msg, t);
- }
- lastException = current;
- if (!appender.isExceptionSuppressed() && t != null) {
- throw new AppenderRuntimeException(msg, t);
- }
- }
-
- /**
- * Handle an error with a message, and exception and a logging event.
- * @param msg The message.
- * @param event The LogEvent.
- * @param t The Throwable.
- */
- public void error(String msg, LogEvent event, Throwable t) {
- long current = System.currentTimeMillis();
- if (lastException + EXCEPTION_INTERVAL < current || exceptionCount++ < MAX_EXCEPTIONS) {
- LOGGER.error(msg, t);
- }
- lastException = current;
- if (!appender.isExceptionSuppressed() && t != null) {
- throw new AppenderRuntimeException(msg, t);
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java
deleted file mode 100644
index 276d277..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.AppenderControl;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * The FailoverAppender will capture exceptions in an Appender and then route the event
- * to a different appender. Hopefully it is obvious that the Appenders must be configured
- * to not suppress exceptions for the FailoverAppender to work.
- */
-@Plugin(name = "Failover", type = "Core", elementType = "appender", printObject = true)
-public final class FailoverAppender extends AppenderBase {
-
- private final String primaryRef;
-
- private final String[] failovers;
-
- private final Configuration config;
-
- private AppenderControl primary;
-
- private List<AppenderControl> failoverAppenders = new ArrayList<AppenderControl>();
-
- private FailoverAppender(String name, Filter filter, String primary, String[] failovers,
- Configuration config, boolean handleExceptions) {
- super(name, filter, null, handleExceptions);
- this.primaryRef = primary;
- this.failovers = failovers;
- this.config = config;
- }
-
-
- @Override
- public void start() {
- Map<String, Appender> map = config.getAppenders();
- int errors = 0;
- if (map.containsKey(primaryRef)) {
- primary = new AppenderControl(map.get(primaryRef));
- } else {
- LOGGER.error("Unable to locate primary Appender " + primaryRef);
- ++errors;
- }
- for (String name : failovers) {
- if (map.containsKey(name)) {
- failoverAppenders.add(new AppenderControl(map.get(name)));
- } else {
- LOGGER.error("Failover appender " + name + " is not configured");
- }
- }
- if (failoverAppenders.size() == 0) {
- LOGGER.error("No failover appenders are available");
- ++errors;
- }
- if (errors == 0) {
- super.start();
- }
- }
-
- /**
- * Handle the Log event.
- * @param event The LogEvent.
- */
- public void append(LogEvent event) {
- RuntimeException re = null;
- if (!isStarted()) {
- error("FailoverAppender " + getName() + " did not start successfully");
- return;
- }
- try {
- primary.callAppender(event);
- } catch (Exception ex) {
- re = new LoggingException(ex);
- boolean written = false;
- for (AppenderControl control : failoverAppenders) {
- try {
- control.callAppender(event);
- written = true;
- break;
- } catch (Exception fex) {
- // Try the next failover.
- }
- }
- if (!written && !isExceptionSuppressed()) {
- throw re;
- }
- }
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(getName());
- sb.append(" primary=").append(primary).append(", failover={");
- boolean first = true;
- for (String str : failovers) {
- if (!first) {
- sb.append(", ");
- }
- sb.append(str);
- first = false;
- }
- sb.append("}");
- return sb.toString();
- }
-
- /**
- * Create a Failover Appender.
- * @param name The name of the Appender (required).
- * @param primary The name of the primary Appender (required).
- * @param failovers The name of one or more Appenders to fail over to (at least one is required).
- * @param config The current Configuration (passed by the Configuration when the appender is created).
- * @param filter A Filter (optional).
- * @param suppress "true" if exceptions should be hidden from the application, "false" otherwise.
- * The default is "true".
- * @return The FailoverAppender that was created.
- */
- @PluginFactory
- public static FailoverAppender createAppender(@PluginAttr("name") String name,
- @PluginAttr("primary") String primary,
- @PluginElement("failovers") String[] failovers,
- @PluginConfiguration Configuration config,
- @PluginElement("filters") Filter filter,
- @PluginAttr("suppressExceptions") String suppress) {
- if (name == null) {
- LOGGER.error("A name for the Appender must be specified");
- return null;
- }
- if (primary == null) {
- LOGGER.error("A primary Appender must be specified");
- return null;
- }
- if (failovers == null || failovers.length == 0) {
- LOGGER.error("At least one failover Appender must be specified");
- return null;
- }
-
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
-
- return new FailoverAppender(name, filter, primary, failovers, config, handleExceptions);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoversPlugin.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoversPlugin.java
deleted file mode 100644
index 487b571..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoversPlugin.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * The array of failover Appenders.
- */
-@Plugin(name = "failovers", type = "Core")
-public final class FailoversPlugin {
-
- private static Logger logger = StatusLogger.getLogger();
-
- /**
- * Prevent instantiation.
- */
- private FailoversPlugin() {
- }
-
- /**
- * Return the appender references.
- * @param refs The references to return.
- * @return The appender references.
- */
- @PluginFactory
- public static String[] createFailovers(@PluginElement("appender-ref") String[] refs) {
-
- if (refs == null) {
- logger.error("failovers must contain an appender-refernce");
- }
- return refs;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java
deleted file mode 100644
index 395cfd4..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-
-/**
- * File Appender.
- */
-@Plugin(name = "File", type = "Core", elementType = "appender", printObject = true)
-public final class FileAppender extends OutputStreamAppender {
-
- private final String fileName;
-
- private FileAppender(String name, Layout layout, Filter filter, FileManager manager, String filename,
- boolean handleException, boolean immediateFlush) {
- super(name, layout, filter, handleException, immediateFlush, manager);
- this.fileName = filename;
- }
-
- /**
- * Return the file name this appender is associated with.
- * @return The File name.
- */
- public String getFileName() {
- return this.fileName;
- }
-
- /**
- * Create a File Appender.
- * @param fileName The name and path of the file.
- * @param append "True" if the file should be appended to, "false" if it should be overwritten.
- * The default is "true".
- * @param locking "True" if the file should be locked. The default is "false".
- * @param name The name of the Appender.
- * @param immediateFlush "true" if the contents should be flushed on every write, "false" otherwise. The default
- * is "true".
- * @param suppress "true" if exceptions should be hidden from the application, "false" otherwise.
- * The default is "true".
- * @param bufferedIO "true" if I/O should be buffered, "false" otherwise. The default is "true".
- * @param layout The layout to use to format the event. If no layout is provided the default PatternLayout
- * will be used.
- * @param filter The filter, if any, to use.
- * @return The FileAppender.
- */
- @PluginFactory
- public static FileAppender createAppender(@PluginAttr("fileName") String fileName,
- @PluginAttr("append") String append,
- @PluginAttr("locking") String locking,
- @PluginAttr("name") String name,
- @PluginAttr("immediateFlush") String immediateFlush,
- @PluginAttr("suppressExceptions") String suppress,
- @PluginAttr("bufferedIO") String bufferedIO,
- @PluginElement("layout") Layout layout,
- @PluginElement("filters") Filter filter) {
-
- boolean isAppend = append == null ? true : Boolean.valueOf(append);
- boolean isLocking = locking == null ? false : Boolean.valueOf(locking);
- boolean isBuffered = bufferedIO == null ? true : Boolean.valueOf(bufferedIO);
- if (isLocking && isBuffered) {
- if (bufferedIO != null) {
- LOGGER.warn("Locking and buffering are mutually exclusive. No buffereing will occur for " + fileName);
- }
- isBuffered = false;
- }
- boolean isFlush = immediateFlush == null ? true : Boolean.valueOf(immediateFlush);
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
-
- if (name == null) {
- LOGGER.error("No name provided for FileAppender");
- return null;
- }
-
- if (fileName == null) {
- LOGGER.error("No filename provided for FileAppender with name " + name);
- return null;
- }
-
- FileManager manager = FileManager.getFileManager(fileName, isAppend, isLocking, isBuffered);
- if (manager == null) {
- return null;
- }
- if (layout == null) {
- layout = PatternLayout.createLayout(null, null, null, null);
- }
- return new FileAppender(name, layout, filter, manager, fileName, handleExceptions, isFlush);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java
deleted file mode 100644
index a514030..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileLock;
-
-
-/**
- * Class that handles actual File I/O for File Appenders.
- */
-public class FileManager extends OutputStreamManager {
-
- private static ManagerFactory factory = new FileManagerFactory();
-
- private boolean isAppend;
- private boolean isLocking;
-
- protected FileManager(String fileName, OutputStream os, boolean append, boolean locking) {
- super(os, fileName);
- this.isAppend = append;
- this.isLocking = locking;
- }
-
- /**
- * Return the FileManager.
- * @param fileName The name of the file to manage.
- * @param append true if the file should be appended to, false if it should be overwritten.
- * @param locking true if the file should be locked while writing, false otherwise.
- * @param bufferedIO true if the contents should be buffered as they are written.
- * @return A FileManager for the File.
- */
- public static FileManager getFileManager(String fileName, boolean append, boolean locking, boolean bufferedIO) {
-
- if (locking && bufferedIO) {
- locking = false;
- }
- return (FileManager) getManager(fileName, factory, new FactoryData(append, locking, bufferedIO));
- }
-
- protected synchronized void write(byte[] bytes, int offset, int length) {
-
- if (isLocking) {
- FileChannel channel = ((FileOutputStream) getOutputStream()).getChannel();
- try {
- /* Lock the whole file. This could be optimized to only lock from the current file
- position. Note that locking may be advisory on some systems and mandatory on others,
- so locking just from the current position would allow reading on systems where
- locking is mandatory. Also, Java 6 will throw an exception if the region of the
- file is already locked by another FileChannel in the same JVM. Hopefully, that will
- be avoided since every file should have a single file manager - unless two different
- files strings are configured that somehow map to the same file.*/
- FileLock lock = channel.lock(0, Long.MAX_VALUE, false);
- try {
- super.write(bytes, offset, length);
- } finally {
- lock.release();
- }
- } catch (IOException ex) {
- throw new AppenderRuntimeException("Unable to obtain lock on " + getName(), ex);
- }
-
- } else {
- super.write(bytes, offset, length);
- }
- }
-
- /**
- * Return the name of the File being managed.
- * @return The name of the File being managed.
- */
- public String getFileName() {
- return getName();
- }
-
- /**
- * Return the append status.
- * @return true if the file will be appended to, false if it is overwritten.
- */
- public boolean isAppend() {
- return isAppend;
- }
-
- /**
- * Return the lock status.
- * @return true if the file will be locked when writing, false otherwise.
- */
- public boolean isLocking() {
- return isLocking;
- }
-
- /**
- * Factory Data.
- */
- private static class FactoryData {
- private boolean append;
- private boolean locking;
- private boolean bufferedIO;
-
- /**
- * Constructor.
- * @param append Append status.
- * @param locking Locking status.
- * @param bufferedIO Buffering flag.
- */
- public FactoryData(boolean append, boolean locking, boolean bufferedIO) {
- this.append = append;
- this.locking = locking;
- this.bufferedIO = bufferedIO;
- }
- }
-
- /**
- * Factory to create a FileManager.
- */
- private static class FileManagerFactory implements ManagerFactory<FileManager, FactoryData> {
-
- /**
- * Create a FileManager.
- * @param name The name of the File.
- * @param data The FactoryData
- * @return The FileManager for the File.
- */
- public FileManager createManager(String name, FactoryData data) {
- File file = new File(name);
- final File parent = file.getParentFile();
- if (null != parent && !parent.exists()) {
- parent.mkdirs();
- }
-
- OutputStream os;
- try {
- os = new FileOutputStream(name, data.append);
- if (data.bufferedIO) {
- os = new BufferedOutputStream(os);
- }
- return new FileManager(name, os, data.append, data.locking);
- } catch (FileNotFoundException ex) {
- LOGGER.error("FileManager (" + name + ") " + ex);
- }
- return null;
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
deleted file mode 100644
index fa886ed..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.SerializedLayout;
-import org.apache.logging.log4j.core.net.JMSQueueManager;
-
-/**
- * Appender to write to a JMS Queue.
- */
-@Plugin(name = "JMSQueue", type = "Core", elementType = "appender", printObject = true)
-public final class JMSQueueAppender extends AppenderBase {
-
- private final JMSQueueManager manager;
-
- private JMSQueueAppender(String name, Filter filter, Layout layout, JMSQueueManager manager,
- boolean handleExceptions) {
- super(name, filter, layout, handleExceptions);
- this.manager = manager;
- }
-
- /**
- * Actual writing occurs here.
- * <p/>
- * @param event The LogEvent.
- */
- public void append(LogEvent event) {
- try {
- manager.send(getLayout().formatAs(event));
- } catch (Exception ex) {
- throw new AppenderRuntimeException(ex);
- }
- }
-
- /**
- * Create a JMSQueueAppender.
- * @param factoryName The fully qualified class name of the InitialContextFactory.
- * @param providerURL The URL of the provider to use.
- * @param urlPkgPrefixes A colon-separated list of package prefixes for the class name of the factory class that
- * will create a URL context factory
- * @param securityPrincipalName The name of the identity of the Principal.
- * @param securityCredentials The security credentials of the Principal.
- * @param factoryBindingName The name to locate in the Context that provides the QueueConnectionFactory.
- * @param queueBindingName The name to use to locate the Queue.
- * @param userName The userid to use to create the Queue Connection.
- * @param password The password to use to create the Queue Connection.
- * @param layout The layout to use (defaults to SerlializedLayout).
- * @param filter The Filter or null.
- * @param suppress "true" if exceptions should be hidden from the application, "false" otherwise.
- * The default is "true".
- * @return The JMSQueueAppender.
- */
- @PluginFactory
- public static JMSQueueAppender createAppender(@PluginAttr("factoryName") String factoryName,
- @PluginAttr("providerURL") String providerURL,
- @PluginAttr("urlPkgPrefixes") String urlPkgPrefixes,
- @PluginAttr("securityPrincipalName") String securityPrincipalName,
- @PluginAttr("securityCredentials") String securityCredentials,
- @PluginAttr("factoryBindingName") String factoryBindingName,
- @PluginAttr("queueBindingName") String queueBindingName,
- @PluginAttr("userName") String userName,
- @PluginAttr("password") String password,
- @PluginElement("layout") Layout layout,
- @PluginElement("filter") Filter filter,
- @PluginAttr("suppressExceptions") String suppress) {
-
- String name = "JMSQueue" + factoryBindingName + "." + queueBindingName;
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
- JMSQueueManager manager = JMSQueueManager.getJMSQueueManager(factoryName, providerURL, urlPkgPrefixes,
- securityPrincipalName, securityCredentials, factoryBindingName, queueBindingName, userName, password);
- if (manager == null) {
- return null;
- }
- if (layout == null) {
- layout = SerializedLayout.createLayout();
- }
- return new JMSQueueAppender(name, filter, layout, manager, handleExceptions);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java
deleted file mode 100644
index bf3fae5..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSTopicAppender.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.SerializedLayout;
-import org.apache.logging.log4j.core.net.JMSTopicManager;
-
-/**
- * Appender to write to a JMS Topic.
- */
-@Plugin(name = "JMSTopic", type = "Core", elementType = "appender", printObject = true)
-public final class JMSTopicAppender extends AppenderBase {
-
- private final JMSTopicManager manager;
-
- private JMSTopicAppender(String name, Filter filter, Layout layout, JMSTopicManager manager,
- boolean handleExceptions) {
- super(name, filter, layout, handleExceptions);
- this.manager = manager;
- }
-
- /**
- * Actual writing occurs here.
- * <p/>
- * @param event The LogEvent.
- */
- public void append(LogEvent event) {
- try {
- manager.send(getLayout().formatAs(event));
- } catch (Exception ex) {
- throw new AppenderRuntimeException(ex);
- }
- }
-
- /**
- * Create a JMSTopicAppender.
- * @param factoryName The fully qualified class name of the InitialContextFactory.
- * @param providerURL The URL of the provider to use.
- * @param urlPkgPrefixes A colon-separated list of package prefixes for the class name of the factory class that
- * will create a URL context factory
- * @param securityPrincipalName The name of the identity of the Principal.
- * @param securityCredentials The security credentials of the Principal.
- * @param factoryBindingName The name to locate in the Context that provides the TopicConnectionFactory.
- * @param topicBindingName The name to use to locate the Topic.
- * @param userName The userid to use to create the Topic Connection.
- * @param password The password to use to create the Topic Connection.
- * @param layout The layout to use (defaults to SerlializedLayout).
- * @param filter The Filter or null.
- * @param suppress "true" if exceptions should be hidden from the application, "false" otherwise.
- * The default is "true".
- * @return The JMSTopicAppender.
- */
- @PluginFactory
- public static JMSTopicAppender createAppender(@PluginAttr("factoryName") String factoryName,
- @PluginAttr("providerURL") String providerURL,
- @PluginAttr("urlPkgPrefixes") String urlPkgPrefixes,
- @PluginAttr("securityPrincipalName") String securityPrincipalName,
- @PluginAttr("securityCredentials") String securityCredentials,
- @PluginAttr("factoryBindingName") String factoryBindingName,
- @PluginAttr("topicBindingName") String topicBindingName,
- @PluginAttr("userName") String userName,
- @PluginAttr("password") String password,
- @PluginElement("layout") Layout layout,
- @PluginElement("filters") Filter filter,
- @PluginAttr("suppressExceptions") String suppress) {
-
- String name = "JMSTopic" + factoryBindingName + "." + topicBindingName;
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
- JMSTopicManager manager = JMSTopicManager.getJMSTopicManager(factoryName, providerURL, urlPkgPrefixes,
- securityPrincipalName, securityCredentials, factoryBindingName, topicBindingName, userName, password);
- if (manager == null) {
- return null;
- }
- if (layout == null) {
- layout = SerializedLayout.createLayout();
- }
- return new JMSTopicAppender(name, filter, layout, manager, handleExceptions);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ManagerFactory.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ManagerFactory.java
deleted file mode 100644
index b56c8fd..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/ManagerFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-/**
- * Create a Manager.
- * @param <F> The Manager type.
- * @param <T> The Factory data type.
- */
-public interface ManagerFactory<F, T> {
-
- /**
- * Create a Manager.
- * @param name The name of the entity to manage.
- * @param data The data required to create the entity.
- * @return A Manager for the entity.
- */
- F createManager(String name, T data);
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamAppender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamAppender.java
deleted file mode 100644
index e63b5bc..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamAppender.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- * Writes the byte output stream. The stream will already have been encoded.
- */
-public abstract class OutputStreamAppender extends AppenderBase {
-
- /**
- * Immediate flush means that the underlying writer or output stream
- * will be flushed at the end of each append operation. Immediate
- * flush is slower but ensures that each append request is actually
- * written. If <code>immediateFlush</code> is set to
- * <code>false</code>, then there is a good chance that the last few
- * logs events are not actually written to persistent media if and
- * when the application crashes.
- * <p/>
- * <p>The <code>immediateFlush</code> variable is set to
- * <code>true</code> by default.
- */
- protected boolean immediateFlush = true;
-
- private volatile OutputStreamManager manager;
-
- private ReadWriteLock rwLock = new ReentrantReadWriteLock();
- private Lock readLock = rwLock.readLock();
- private Lock writeLock = rwLock.writeLock();
-
- /**
- * Instantiate a WriterAppender and set the output destination to a
- * new {@link java.io.OutputStreamWriter} initialized with <code>os</code>
- * as its {@link java.io.OutputStream}.
- * @param name The name of the Appender.
- * @param layout The layout to format the message.
- * @param manager The OutputStreamManager.
- */
- protected OutputStreamAppender(String name, Layout layout, Filter filter, boolean handleException,
- boolean immediateFlush, OutputStreamManager manager) {
- super(name, filter, layout, handleException);
- if (layout != null) {
- manager.setHeader(layout.getHeader());
- manager.setFooter(layout.getFooter());
- }
- this.manager = manager;
- this.immediateFlush = immediateFlush;
- }
-
- protected OutputStreamManager getManager() {
- return manager;
- }
-
- protected void replaceManager(OutputStreamManager newManager) {
-
- writeLock.lock();
- try {
- OutputStreamManager old = manager;
- manager = newManager;
- old.release();
- } finally {
- writeLock.unlock();
- }
-
- }
-
- @Override
- public void start() {
- if (getLayout() == null) {
- LOGGER.error("No layout set for the appender named [" + getName() + "].");
- }
- if (manager == null) {
- LOGGER.error("No OutputStreamManager set for the appender named [" + getName() + "].");
- }
- super.start();
- }
-
- @Override
- public void stop() {
- super.stop();
- manager.release();
- }
-
- /**
- * Actual writing occurs here.
- * <p/>
- * <p>Most subclasses of <code>OutputStreamAppender</code> will need to
- * override this method.
- * @param event The LogEvent.
- */
- public void append(LogEvent event) {
- readLock.lock();
- try {
- manager.write(getLayout().format(event));
- if (this.immediateFlush) {
- manager.flush();
- }
- } catch (AppenderRuntimeException ex) {
- error("Unable to write to stream " + manager.getName() + " for appender " + getName());
- throw ex;
- } finally {
- readLock.unlock();
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
deleted file mode 100644
index 8520ce3..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Manage an OutputStream so that it can be shared by multiple Appenders and will
- * allow appenders to reconfigure without requiring a new stream.
- */
-public class OutputStreamManager extends AbstractManager {
-
- private OutputStream os;
-
- private byte[] footer = null;
-
- protected OutputStreamManager(OutputStream os, String streamName) {
- super(streamName);
- this.os = os;
- }
-
- /**
- * Create a Manager.
- * @param name The name of the stream to manage.
- * @param factory The factory to use to create the Manager.
- * @param data The data to pass to the Manager.
- * @return An OutputStreamManager.
- */
- public static OutputStreamManager getManager(String name, ManagerFactory<OutputStreamManager, Object> factory,
- Object data) {
- return AbstractManager.getManager(name, factory, data);
- }
-
- /**
- * Set the header to write when the stream is opened.
- * @param header The header.
- */
- public synchronized void setHeader(byte[] header) {
- if (header != null) {
- try {
- this.os.write(header, 0, header.length);
- } catch (IOException ioe) {
- LOGGER.error("Unable to write header", ioe);
- }
- }
- }
-
- /**
- * Set the footer to write when the stream is closed.
- * @param footer The footer.
- */
- public synchronized void setFooter(byte[] footer) {
- if (footer != null) {
- this.footer = footer;
- }
- }
-
- /**
- * Default hook to write footer during close.
- */
- public void releaseSub() {
- if (footer != null) {
- write(footer);
- }
- close();
- }
-
- /**
- * Return the status of the stream.
- * @return true if the stream is open, false if it is not.
- */
- public boolean isOpen() {
- return getCount() > 0;
- }
-
- protected OutputStream getOutputStream() {
- return os;
- }
-
- protected void setOutputStream(OutputStream os) {
- this.os = os;
- }
-
- /**
- * Some output streams synchronize writes while others do not. Synchronizing here insures that
- * log events won't be intertwined.
- * @param bytes The serialized Log event.
- * @param offset The offset into the byte array.
- * @param length The number of bytes to write.
- * @throws AppenderRuntimeException if an error occurs.
- */
- protected synchronized void write(byte[] bytes, int offset, int length) {
- //System.out.println("write " + count);
- try {
- os.write(bytes, offset, length);
- } catch (IOException ex) {
- String msg = "Error writing to stream " + getName();
- throw new AppenderRuntimeException(msg, ex);
- }
- }
-
- /**
- * Some output streams synchronize writes while others do not. Synchronizing here insures that
- * log events won't be intertwined.
- * @param bytes The serialized Log event.
- * @throws AppenderRuntimeException if an error occurs.
- */
- protected void write(byte[] bytes) {
- write(bytes, 0, bytes.length);
- }
-
- protected void close() {
- if (os == System.out || os == System.err) {
- return;
- }
- try {
- os.close();
- } catch (IOException ex) {
- LOGGER.error("Unable to close stream " + getName() + ". " + ex);
- }
- }
-
- /**
- * Flush any buffers.
- */
- public void flush() {
- try {
- os.flush();
- } catch (IOException ex) {
- String msg = "Error flushing stream " + getName();
- throw new AppenderRuntimeException(msg, ex);
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
deleted file mode 100644
index 845908b..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
-import org.apache.logging.log4j.core.appender.rolling.RollingFileManager;
-import org.apache.logging.log4j.core.appender.rolling.RolloverStrategy;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-
-/**
- * An appender that writes to files andd can roll over at intervals.
- */
-@Plugin(name = "RollingFile", type = "Core", elementType = "appender", printObject = true)
-public final class RollingFileAppender extends OutputStreamAppender {
-
- private final String fileName;
- private final String filePattern;
- private final TriggeringPolicy policy;
- private final RolloverStrategy strategy;
-
- private RollingFileAppender(String name, Layout layout, TriggeringPolicy policy, RolloverStrategy strategy,
- Filter filter, RollingFileManager manager, String fileName, String filePattern,
- boolean handleException, boolean immediateFlush) {
- super(name, layout, filter, handleException, immediateFlush, manager);
- this.fileName = fileName;
- this.filePattern = filePattern;
- this.policy = policy;
- this.strategy = strategy;
- policy.initialize(manager);
- }
-
- /**
- * Write the log entry rolling over the file when required.
-
- * @param event The LogEvent.
- */
- @Override
- public void append(LogEvent event) {
- ((RollingFileManager) getManager()).checkRollover(event, policy, strategy);
- super.append(event);
- }
-
- /**
- * Return the File name for the Appender.
- * @return The file name.
- */
- public String getFileName() {
- return fileName;
- }
-
- /**
- * Returns the file pattern used when rolling over.
- * @return The file pattern.
- */
- public String getFilePattern() {
- return filePattern;
- }
-
- /**
- * Create a RollingFileAppender.
- * @param fileName The name of the file that is actively written to. (required).
- * @param filePattern The pattern of the file name to use on rollover. (required).
- * @param append If true, events are appended to the file. If false, the file
- * is overwritten when opened. Defaults to "true"
- * @param name The name of the Appender (required).
- * @param bufferedIO When true, I/O will be buffered. Defaults to "true".
- * @param immediateFlush When true, events are immediately flushed. Defaults to "true".
- * @param policy The triggering policy. (required).
- * @param strategy The rollover strategy. Defaults to DefaultRolloverStrategy.
- * @param layout The layout to use (defaults to the default PatternLayout).
- * @param filter The Filter or null.
- * @param suppress "true" if exceptions should be hidden from the application, "false" otherwise.
- * The default is "true".
- * @param config The Configuration.
- * @return A RollingFileAppender.
- */
- @PluginFactory
- public static RollingFileAppender createAppender(@PluginAttr("fileName") String fileName,
- @PluginAttr("filePattern") String filePattern,
- @PluginAttr("append") String append,
- @PluginAttr("name") String name,
- @PluginAttr("bufferedIO") String bufferedIO,
- @PluginAttr("immediateFlush") String immediateFlush,
- @PluginElement("policy") TriggeringPolicy policy,
- @PluginElement("strategy") RolloverStrategy strategy,
- @PluginElement("layout") Layout layout,
- @PluginElement("filter") Filter filter,
- @PluginAttr("suppressExceptions") String suppress,
- @PluginConfiguration Configuration config) {
-
- boolean isAppend = append == null ? true : Boolean.valueOf(append);
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
- boolean isBuffered = bufferedIO == null ? true : Boolean.valueOf(bufferedIO);
- boolean isFlush = immediateFlush == null ? true : Boolean.valueOf(immediateFlush);
-
- if (name == null) {
- LOGGER.error("No name provided for FileAppender");
- return null;
- }
-
- if (fileName == null) {
- LOGGER.error("No filename was provided for FileAppender with name " + name);
- return null;
- }
-
- if (filePattern == null) {
- LOGGER.error("No filename pattern provided for FileAppender with name " + name);
- return null;
- }
-
- if (policy == null) {
- LOGGER.error("A TriggeringPolicy must be provided");
- return null;
- }
-
- if (strategy == null) {
- strategy = DefaultRolloverStrategy.createStrategy(null, null, config);
- }
-
- RollingFileManager manager = RollingFileManager.getFileManager(fileName, filePattern, isAppend, isBuffered);
- if (manager == null) {
- return null;
- }
-
- if (layout == null) {
- layout = PatternLayout.createLayout(null, null, null, null);
- }
-
- return new RollingFileAppender(name, layout, policy, strategy, filter, manager, fileName, filePattern,
- handleExceptions, isFlush);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/SocketAppender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/SocketAppender.java
deleted file mode 100644
index 038f721..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/SocketAppender.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.SerializedLayout;
-import org.apache.logging.log4j.core.net.AbstractSocketManager;
-import org.apache.logging.log4j.core.net.DatagramSocketManager;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.apache.logging.log4j.core.net.TCPSocketManager;
-
-/**
- * An Appender that delivers events over socket connections. Supports both TCP and UDP.
- */
-@Plugin(name = "Socket", type = "Core", elementType = "appender", printObject = true)
-public class SocketAppender extends OutputStreamAppender {
-
-
- protected SocketAppender(String name, Layout layout, Filter filter, AbstractSocketManager manager,
- boolean handleException, boolean immediateFlush) {
- super(name, layout, filter, handleException, immediateFlush, manager);
-
- }
-
- /**
- *
- * @param host The name of the host to connect to.
- * @param portNum The port to connect to on the target host.
- * @param protocol The Protocol to use.
- * @param delay The interval in which failed writes should be retried.
- * @param name The name of the Appender.
- * @param immediateFlush "true" if data should be flushed on each write.
- * @param suppress "true" if exceptions should be hidden from the application, "false" otherwise.
- * The default is "true".
- * @param layout The layout to use (defaults to SerlializedLayout).
- * @param filter The Filter or null.
- * @return A SocketAppender.
- */
- @PluginFactory
- public static SocketAppender createAppender(@PluginAttr("host") String host,
- @PluginAttr("port") String portNum,
- @PluginAttr("protocol") String protocol,
- @PluginAttr("reconnectionDelay") String delay,
- @PluginAttr("name") String name,
- @PluginAttr("immediateFlush") String immediateFlush,
- @PluginAttr("suppressExceptions") String suppress,
- @PluginElement("layout") Layout layout,
- @PluginElement("filters") Filter filter) {
-
- boolean isFlush = immediateFlush == null ? true : Boolean.valueOf(immediateFlush);
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
- int reconnectDelay = delay == null ? 0 : Integer.parseInt(delay);
- int port = portNum == null ? 0 : Integer.parseInt(portNum);
- if (layout == null) {
- layout = SerializedLayout.createLayout();
- }
-
- if (name == null) {
- LOGGER.error("No name provided for SocketAppender");
- return null;
- }
-
- AbstractSocketManager manager = createSocketManager(protocol, host, port, reconnectDelay);
- if (manager == null) {
- return null;
- }
- return new SocketAppender(name, layout, filter, manager, handleExceptions, isFlush);
- }
-
- protected static AbstractSocketManager createSocketManager(String protocol, String host, int port, int delay) {
- Protocol p = Protocol.valueOf(protocol.toUpperCase());
- switch (p) {
- case TCP:
- return TCPSocketManager.getSocketManager(host, port, delay);
- case UDP:
- return DatagramSocketManager.getSocketManager(host, port);
- default:
- return null;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/SyslogAppender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/SyslogAppender.java
deleted file mode 100644
index d2392e9..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/SyslogAppender.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.RFC5424Layout;
-import org.apache.logging.log4j.core.layout.SyslogLayout;
-import org.apache.logging.log4j.core.net.AbstractSocketManager;
-
-import java.nio.charset.Charset;
-
-/**
- * The Syslog Appender.
- */
-@Plugin(name = "Syslog", type = "Core", elementType = "appender", printObject = true)
-public class SyslogAppender extends SocketAppender {
-
- private static final String BSD = "bsd";
-
- private static final String RFC5424 = "RFC5424";
-
- protected SyslogAppender(String name, Layout layout, Filter filter,
- boolean handleException, boolean immediateFlush, AbstractSocketManager manager) {
- super(name, layout, filter, manager, handleException, immediateFlush);
-
- }
-
- /**
- * Create a SyslogAppender.
- * @param host The name of the host to connect to.
- * @param portNum The port to connect to on the target host.
- * @param protocol The Protocol to use.
- * @param delay The interval in which failed writes should be retried.
- * @param name The name of the Appender.
- * @param immediateFlush "true" if data should be flushed on each write.
- * @param suppress "true" if exceptions should be hidden from the application, "false" otherwise.
- * The default is "true".
- * @param facility The Facility is used to try to classify the message.
- * @param id The default structured data id to use when formatting according to RFC 5424.
- * @param ein The IANA enterprise number.
- * @param includeMDC Indicates whether data from the ThreadContextMap will be included in the RFC 5424 Syslog
- * record. Defaults to "true:.
- * @param mdcId The id to use for the MDC Structured Data Element.
- * @param includeNL If true, a newline will be appended to the end of the syslog record. The default is false.
- * @param appName The value to use as the APP-NAME in the RFC 5424 syslog record.
- * @param msgId The default value to be used in the MSGID field of RFC 5424 syslog records.
- * @param excludes A comma separated list of mdc keys that should be excluded from the LogEvent.
- * @param includes A comma separated list of mdc keys that should be included in the FlumeEvent.
- * @param required A comma separated list of mdc keys that must be present in the MDC.
- * @param format If set to "RFC5424" the data will be formatted in accordance with RFC 5424. Otherwise,
- * it will be formatted as a BSD Syslog record.
- * @param filter A Filter to determine if the event should be handled by this Appender.
- * @param config The Configuration.
- * @param charset The character set to use when converting the syslog String to a byte array.
- * @return A SyslogAppender.
- */
- @PluginFactory
- public static SyslogAppender createAppender(@PluginAttr("host") String host,
- @PluginAttr("port") String portNum,
- @PluginAttr("protocol") String protocol,
- @PluginAttr("reconnectionDelay") String delay,
- @PluginAttr("name") String name,
- @PluginAttr("immediateFlush") String immediateFlush,
- @PluginAttr("suppressExceptions") String suppress,
- @PluginAttr("facility") String facility,
- @PluginAttr("id") String id,
- @PluginAttr("enterpriseNumber") String ein,
- @PluginAttr("includeMDC") String includeMDC,
- @PluginAttr("mdcId") String mdcId,
- @PluginAttr("newLine") String includeNL,
- @PluginAttr("appName") String appName,
- @PluginAttr("messageId") String msgId,
- @PluginAttr("mdcExcludes") String excludes,
- @PluginAttr("mdcIncludes") String includes,
- @PluginAttr("mdcRequired") String required,
- @PluginAttr("format") String format,
- @PluginElement("filters") Filter filter,
- @PluginConfiguration Configuration config,
- @PluginAttr("charset") String charset) {
-
- boolean isFlush = immediateFlush == null ? true : Boolean.valueOf(immediateFlush);
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
- int reconnectDelay = delay == null ? 0 : Integer.parseInt(delay);
- int port = portNum == null ? 0 : Integer.parseInt(portNum);
- Charset c = Charset.isSupported("UTF-8") ? Charset.forName("UTF-8") : Charset.defaultCharset();
- if (charset != null) {
- if (Charset.isSupported(charset)) {
- c = Charset.forName(charset);
- } else {
- LOGGER.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
- }
- }
- Layout layout = (format.equalsIgnoreCase(RFC5424)) ?
- RFC5424Layout.createLayout(facility, id, ein, includeMDC, mdcId, includeNL, appName, msgId,
- excludes, includes, required, charset, config) :
- SyslogLayout.createLayout(facility, includeNL, charset);
-
- if (name == null) {
- LOGGER.error("No name provided for SyslogAppender");
- return null;
- }
- AbstractSocketManager manager = createSocketManager(protocol, host, port, reconnectDelay);
- if (manager == null) {
- return null;
- }
-
- return new SyslogAppender(name, layout, filter, handleExceptions, isFlush, manager);
- }
-
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/package-info.java
deleted file mode 100644
index 5a4e2e5..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 Appenders.
- */
-package org.apache.logging.log4j.core.appender;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicy.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicy.java
deleted file mode 100644
index c7ff7e0..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicy.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rewrite;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.helpers.KeyValuePair;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.MapMessage;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * This policy modifies events by replacing or possibly adding keys and values to the MapMessage.
- */
-@Plugin(name = "MapRewritePolicy", type = "Core", elementType = "rewritePolicy", printObject = true)
-public final class MapRewritePolicy implements RewritePolicy {
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
-
- private final Map<String, String> map;
-
- private final Mode mode;
-
- private MapRewritePolicy(Map<String, String> map, Mode mode) {
- this.map = map;
- this.mode = mode;
- }
-
- /**
- * Rewrite the event.
- * @param source a logging event that may be returned or
- * used to create a new logging event.
- * @return The LogEvent after rewriting.
- */
- public LogEvent rewrite(LogEvent source) {
- Message msg = source.getMessage();
- if (msg == null || !(msg instanceof MapMessage)) {
- return source;
- }
-
- Map<String, String> newMap = new HashMap<String, String>(((MapMessage) msg).getData());
- switch (mode) {
- case Add: {
- newMap.putAll(map);
- break;
- }
- default: {
- for (Map.Entry<String, String> entry : map.entrySet()) {
- if (newMap.containsKey(entry.getKey())) {
- newMap.put(entry.getKey(), entry.getValue());
- }
- }
- }
- }
- newMap.putAll(map);
- MapMessage message = ((MapMessage) msg).newInstance(newMap);
- return new Log4jLogEvent(source.getLoggerName(), source.getMarker(), source.getFQCN(), source.getLevel(),
- message, source.getThrown(), source.getContextMap(), source.getContextStack(), source.getThreadName(),
- source.getSource(), source.getMillis());
- }
-
- /**
- * An enumeration to identify whether keys not in the MapMessage should be added or whether only existing
- * keys should be updated.
- */
- public enum Mode {
- /**
- * Keys should be added.
- */
- Add,
- /**
- * Keys should be updated.
- */
- Update
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("mode=").append(mode);
- sb.append(" {");
- boolean first = true;
- for (Map.Entry<String, String> entry : map.entrySet()) {
- if (!first) {
- sb.append(", ");
- }
- sb.append(entry.getKey()).append("=").append(entry.getValue());
- first = false;
- }
- sb.append("}");
- return sb.toString();
- }
-
- /**
- * The factory method to create the MapRewritePolicy.
- * @param mode The string representation of the Mode.
- * @param pairs key/value pairs for the new Map keys and values.
- * @return The MapRewritePolicy.
- */
- @PluginFactory
- public static MapRewritePolicy createPolicy(@PluginAttr("mode") String mode,
- @PluginElement("KeyValuePair") KeyValuePair[] pairs) {
- Mode op;
- if (mode == null) {
- op = Mode.Add;
- } else {
- op = Mode.valueOf(mode);
- if (op == null) {
- LOGGER.error("Undefined mode " + mode);
- return null;
- }
- }
- if (pairs == null || pairs.length == 0) {
- LOGGER.error("keys and values must be specified for the MapRewritePolicy");
- return null;
- }
- Map<String, String> map = new HashMap<String, String>();
- for (KeyValuePair pair : pairs) {
- String key = pair.getKey();
- if (key == null) {
- LOGGER.error("A null key is not valid in MapRewritePolicy");
- continue;
- }
- String value = pair.getValue();
- if (value == null) {
- LOGGER.error("A null value for key " + key + " is not allowed in MapRewritePolicy");
- continue;
- }
- map.put(pair.getKey(), pair.getValue());
- }
- if (map.size() == 0) {
- LOGGER.error("MapRewritePolicy is not configured with any valid key value pairs");
- return null;
- }
- return new MapRewritePolicy(map, op);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java
deleted file mode 100644
index ece5af8..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rewrite;
-
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.AppenderBase;
-import org.apache.logging.log4j.core.config.AppenderControl;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * This Appender allows the logging event to be manipulated before it is processed by other Appenders.
- */
-@Plugin(name = "Rewrite", type = "Core", elementType = "appender", printObject = true)
-public final class RewriteAppender extends AppenderBase {
- private final Configuration config;
- private ConcurrentMap<String, AppenderControl> appenders = new ConcurrentHashMap<String, AppenderControl>();
- private final RewritePolicy rewritePolicy;
- private final String[] appenderRefs;
-
- private RewriteAppender(String name, Filter filter, boolean handleException, String[] appenderRefs,
- RewritePolicy rewritePolicy, Configuration config) {
- super(name, filter, null, handleException);
- this.config = config;
- this.rewritePolicy = rewritePolicy;
- this.appenderRefs = appenderRefs;
- }
-
- @Override
- public void start() {
- Map<String, Appender> map = config.getAppenders();
- for (String ref : appenderRefs) {
- Appender appender = map.get(ref);
- if (appender != null) {
- appenders.put(ref, new AppenderControl(appender));
- } else {
- LOGGER.error("Appender " + ref + " cannot be located. Reference ignored");
- }
- }
- super.start();
- }
-
- @Override
- public void stop() {
- super.stop();
- for (AppenderControl control : appenders.values()) {
- if (control instanceof AppenderWrapper) {
- control.getAppender().stop();
- }
- }
- }
-
- /**
- * Modify the event and pass to the subordinate Appenders.
- * @param event The LogEvent.
- */
- public void append(LogEvent event) {
- if (rewritePolicy != null) {
- event = rewritePolicy.rewrite(event);
- }
- for (AppenderControl control : appenders.values()) {
- control.callAppender(event);
- }
- }
-
- /**
- * Create a RewriteAppender.
- * @param name The name of the Appender.
- * @param suppress If true, exceptions will be handled in the Appender.
- * @param appenderRefs An array of Appender names to call.
- * @param config The Configuration.
- * @param rewritePolicy The policy to use to modify the event.
- * @param filter A Filter to filter events.
- * @return The created RewriteAppender.
- */
- @PluginFactory
- public static RewriteAppender createAppender(@PluginAttr("name") String name,
- @PluginAttr("suppressExceptions") String suppress,
- @PluginElement("appender-ref") String[] appenderRefs,
- @PluginConfiguration Configuration config,
- @PluginElement("rewritePolicy") RewritePolicy rewritePolicy,
- @PluginElement("filter") Filter filter) {
-
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
-
- if (name == null) {
- LOGGER.error("No name provided for RewriteAppender");
- return null;
- }
- if (appenderRefs == null) {
- LOGGER.error("No appender references defined for RewriteAppender");
- return null;
- }
- return new RewriteAppender(name, filter, handleExceptions, appenderRefs, rewritePolicy, config);
- }
-
- /**
- * Wrap the AppenderControl simply so it can be used here.
- */
- private static class AppenderWrapper extends AppenderControl {
- /**
- * Constructor.
- * @param appender The Appender to wrap.
- */
- public AppenderWrapper(Appender appender) {
- super(appender);
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewritePolicy.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewritePolicy.java
deleted file mode 100644
index 531fcb5..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewritePolicy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rewrite;
-
-import org.apache.logging.log4j.core.LogEvent;
-
-/**
- * Interface to be implemented by components that support modifications to the LogEvent.
- */
-
-public interface RewritePolicy {
- /**
- * Rewrite a logging event.
- * @param source a logging event that may be returned or
- * used to create a new logging event.
- * @return a logging event or null to suppress processing.
- */
- LogEvent rewrite(final LogEvent source);
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/package-info.java
deleted file mode 100644
index 1837556..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Apache Flume Appender. Requires the user specifically include Flume and its dependencies.
- */
-package org.apache.logging.log4j.core.appender.rewrite;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/CompositeTriggeringPolicy.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/CompositeTriggeringPolicy.java
deleted file mode 100644
index 775bb7d..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/CompositeTriggeringPolicy.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-/**
- * Triggering policy that wraps other policies.
- */
-@Plugin(name = "Policies", type = "Core", printObject = true)
-public final class CompositeTriggeringPolicy implements TriggeringPolicy {
-
- private TriggeringPolicy[] policies;
-
- private CompositeTriggeringPolicy(TriggeringPolicy[] policies) {
- this.policies = policies;
- }
-
- /**
- * Initializes the policy.
- * @param manager The RollingFileManager.
- */
- public void initialize(RollingFileManager manager) {
- for (TriggeringPolicy policy : policies) {
- policy.initialize(manager);
- }
- }
-
- /**
- * Determines if a rollover should occur.
- * @param event A reference to the currently event.
- * @return true if a rollover should occur, false otherwise.
- */
- public boolean isTriggeringEvent(LogEvent event) {
- for (TriggeringPolicy policy : policies) {
- if (policy.isTriggeringEvent(event)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("CompositeTriggeringPolicy{");
- boolean first = true;
- for (TriggeringPolicy policy : policies) {
- if (!first) {
- sb.append(", ");
- }
- sb.append(policy.toString());
- first = false;
- }
- sb.append("}");
- return sb.toString();
- }
-
- /**
- * Create a CompositeTriggeringPolicy.
- * @param policies The triggering policies.
- * @return A CompositeTriggeringPolicy.
- */
- @PluginFactory
- public static CompositeTriggeringPolicy createPolicy(@PluginElement("policies") TriggeringPolicy[] policies) {
- return new CompositeTriggeringPolicy(policies);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
deleted file mode 100644
index 9c07043..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.rolling.helper.Action;
-import org.apache.logging.log4j.core.appender.rolling.helper.FileRenameAction;
-import org.apache.logging.log4j.core.appender.rolling.helper.GZCompressAction;
-import org.apache.logging.log4j.core.appender.rolling.helper.ZipCompressAction;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.lookup.StrSubstitutor;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * When rolling over, <code>FixedWindowRollingPolicy</code> renames files
- * according to a fixed window algorithm as described below.
- * <p/>
- * <p>The <b>ActiveFileName</b> property, which is required, represents the name
- * of the file where current logging output will be written.
- * The <b>FileNamePattern</b> option represents the file name pattern for the
- * archived (rolled over) log files. If present, the <b>FileNamePattern</b>
- * option must include an integer token, that is the string "%i" somewhere
- * within the pattern.
- * <p/>
- * <p>Let <em>max</em> and <em>min</em> represent the values of respectively
- * the <b>MaxIndex</b> and <b>MinIndex</b> options. Let "foo.log" be the value
- * of the <b>ActiveFile</b> option and "foo.%i.log" the value of
- * <b>FileNamePattern</b>. Then, when rolling over, the file
- * <code>foo.<em>max</em>.log</code> will be deleted, the file
- * <code>foo.<em>max-1</em>.log</code> will be renamed as
- * <code>foo.<em>max</em>.log</code>, the file <code>foo.<em>max-2</em>.log</code>
- * renamed as <code>foo.<em>max-1</em>.log</code>, and so on,
- * the file <code>foo.<em>min+1</em>.log</code> renamed as
- * <code>foo.<em>min+2</em>.log</code>. Lastly, the active file <code>foo.log</code>
- * will be renamed as <code>foo.<em>min</em>.log</code> and a new active file name
- * <code>foo.log</code> will be created.
- * <p/>
- * <p>Given that this rollover algorithm requires as many file renaming
- * operations as the window size, large window sizes are discouraged. The
- * current implementation will automatically reduce the window size to 12 when
- * larger values are specified by the user.
- */
-@Plugin(name = "DefaultRolloverStrategy", type = "Core", printObject = true)
-public class DefaultRolloverStrategy implements RolloverStrategy {
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
-
- private static final int MIN_WINDOW_SIZE = 1;
- private static final int DEFAULT_WINDOW_SIZE = 7;
-
- /**
- * Index for oldest retained log file.
- */
- private final int maxIndex;
-
- /**
- * Index for most recent log file.
- */
- private final int minIndex;
-
- private final StrSubstitutor subst;
-
- /**
- * Constructs a new instance.
- * @param min The minimum index.
- * @param max The maximum index.
- */
- protected DefaultRolloverStrategy(int min, int max, StrSubstitutor subst) {
- minIndex = min;
- maxIndex = max;
- this.subst = subst;
- }
-
- /**
- * Perform the rollover.
- * @param manager The RollingFileManager name for current active log file.
- * @return A RolloverDescription.
- * @throws SecurityException if an error occurs.
- */
- public RolloverDescription rollover(RollingFileManager manager) throws SecurityException {
- if (maxIndex >= 0) {
- int purgeStart = minIndex;
-
- if (!purge(purgeStart, maxIndex, manager)) {
- return null;
- }
-
- StringBuilder buf = new StringBuilder();
- manager.getProcessor().formatFileName(purgeStart, buf);
- String currentFileName = manager.getFileName();
-
- String renameTo = subst.replace(buf);
- String compressedName = renameTo;
- Action compressAction = null;
-
- if (renameTo.endsWith(".gz")) {
- renameTo = renameTo.substring(0, renameTo.length() - 3);
- compressAction = new GZCompressAction(new File(renameTo), new File(compressedName), true);
- } else if (renameTo.endsWith(".zip")) {
- renameTo = renameTo.substring(0, renameTo.length() - 4);
- compressAction = new ZipCompressAction(new File(renameTo), new File(compressedName), true);
- }
-
- FileRenameAction renameAction =
- new FileRenameAction(new File(currentFileName), new File(renameTo), false);
-
- return new RolloverDescriptionImpl(currentFileName, false, renameAction, compressAction);
- }
-
- return null;
- }
-
- /**
- * Purge and rename old log files in preparation for rollover
- *
- * @param lowIndex low index
- * @param highIndex high index. Log file associated with high index will be deleted if needed.
- * @param manager The RollingFileManager
- * @return true if purge was successful and rollover should be attempted.
- */
- private boolean purge(final int lowIndex, final int highIndex, RollingFileManager manager) {
- int suffixLength = 0;
-
- List<FileRenameAction> renames = new ArrayList<FileRenameAction>();
- StringBuilder buf = new StringBuilder();
- manager.getProcessor().formatFileName(lowIndex, buf);
-
- String lowFilename = subst.replace(buf);
-
- if (lowFilename.endsWith(".gz")) {
- suffixLength = 3;
- } else if (lowFilename.endsWith(".zip")) {
- suffixLength = 4;
- }
-
- for (int i = lowIndex; i <= highIndex; i++) {
- File toRename = new File(lowFilename);
- boolean isBase = false;
-
- if (suffixLength > 0) {
- File toRenameBase =
- new File(lowFilename.substring(0, lowFilename.length() - suffixLength));
-
- if (toRename.exists()) {
- if (toRenameBase.exists()) {
- toRenameBase.delete();
- }
- } else {
- toRename = toRenameBase;
- isBase = true;
- }
- }
-
- if (toRename.exists()) {
- //
- // if at upper index then
- // attempt to delete last file
- // if that fails then abandon purge
- if (i == highIndex) {
- if (!toRename.delete()) {
- return false;
- }
-
- break;
- }
-
- //
- // if intermediate index
- // add a rename action to the list
- buf.setLength(0);
- manager.getProcessor().formatFileName(i + 1, buf);
-
- String highFilename = subst.replace(buf);
- String renameTo = highFilename;
-
- if (isBase) {
- renameTo = highFilename.substring(0, highFilename.length() - suffixLength);
- }
-
- renames.add(new FileRenameAction(toRename, new File(renameTo), true));
- lowFilename = highFilename;
- } else {
- break;
- }
- }
-
- //
- // work renames backwards
- //
- for (int i = renames.size() - 1; i >= 0; i--) {
- Action action = renames.get(i);
-
- try {
- if (!action.execute()) {
- return false;
- }
- } catch (Exception ex) {
- LOGGER.warn("Exception during purge in RollingFileAppender", ex);
- return false;
- }
- }
-
- return true;
- }
-
- @Override
- public String toString() {
- return "DefaultRolloverStrategy(min=" + minIndex + ", max=" + maxIndex + ")";
- }
-
- /**
- * Create the DefaultRolloverStrategy.
- * @param max The maximum number of files to keep.
- * @param min The minimum number of files to keep.
- * @param config The Configuration.
- * @return A DefaultRolloverStrategy.
- */
- @PluginFactory
- public static DefaultRolloverStrategy createStrategy(@PluginAttr("max") String max,
- @PluginAttr("min") String min,
- @PluginConfiguration Configuration config) {
-
- int minIndex;
- if (min != null) {
- minIndex = Integer.parseInt(min);
- if (minIndex < 1) {
- LOGGER.error("Minimum window size too small. Limited to " + MIN_WINDOW_SIZE);
- minIndex = MIN_WINDOW_SIZE;
- }
- } else {
- minIndex = MIN_WINDOW_SIZE;
- }
- int maxIndex;
- if (max != null) {
- maxIndex = Integer.parseInt(max);
- if (maxIndex < minIndex) {
- maxIndex = minIndex < DEFAULT_WINDOW_SIZE ? DEFAULT_WINDOW_SIZE : minIndex;
- LOGGER.error("Maximum window size must be greater than the minimum windows size. Set to " + maxIndex);
- }
- } else {
- maxIndex = DEFAULT_WINDOW_SIZE;
- }
- return new DefaultRolloverStrategy(minIndex, maxIndex, config.getSubst());
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java
deleted file mode 100644
index 249419c..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-import java.lang.management.ManagementFactory;
-
-/**
- * Trigger a rollover on every restart. The target file's timestamp is compared with the JVM start time
- * and if it is older isTriggeringEvent will return true. After isTriggeringEvent has been called it will
- * always return false.
- */
-
-@Plugin(name = "OnStartupTriggeringPolicy", type = "Core", printObject = true)
-public class OnStartupTriggeringPolicy implements TriggeringPolicy {
- private static final long JVM_START_TIME = ManagementFactory.getRuntimeMXBean().getStartTime();
-
- private boolean evaluated = false;
-
- private RollingFileManager manager;
-
- /**
- * Provide the RollingFileManager to the policy.
- * @param manager The RollingFileManager.
- */
- public void initialize(RollingFileManager manager) {
- this.manager = manager;
- }
-
- /**
- * Determine if a rollover should be triggered.
- * @param event A reference to the current event.
- * @return true if the target file's timestamp is older than the JVM start time.
- */
- public boolean isTriggeringEvent(LogEvent event) {
- if (evaluated) {
- return false;
- }
- evaluated = true;
- return manager.getFileTime() < JVM_START_TIME;
- }
-
- @Override
- public String toString() {
- return "OnStartupTriggeringPolicy";
- }
-
- @PluginFactory
- public static OnStartupTriggeringPolicy createPolicy() {
- return new OnStartupTriggeringPolicy();
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java
deleted file mode 100644
index 3e55d79..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.core.pattern.ArrayPatternConverter;
-import org.apache.logging.log4j.core.pattern.DatePatternConverter;
-import org.apache.logging.log4j.core.pattern.FormattingInfo;
-import org.apache.logging.log4j.core.pattern.PatternConverter;
-import org.apache.logging.log4j.core.pattern.PatternParser;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-/**
- * Parse the rollover pattern.
- */
-public class PatternProcessor {
-
- private static final String KEY = "FileConverter";
-
- private static final char YEAR_CHAR = 'y';
- private static final char MONTH_CHAR = 'M';
- private static final char[] WEEK_CHARS = {'w', 'W'};
- private static final char[] DAY_CHARS = {'D', 'd', 'F', 'E'};
- private static final char[] HOUR_CHARS = {'H', 'K', 'h', 'k'};
- private static final char MINUTE_CHAR = 'm';
- private static final char SECOND_CHAR = 's';
- private static final char MILLIS_CHAR = 'S';
-
- private final ArrayPatternConverter[] patternConverters;
- private final FormattingInfo[] patternFields;
-
- private RolloverFrequency frequency = null;
-
- /**
- * Constructor.
- * @param pattern The file pattern.
- */
- public PatternProcessor(String pattern) {
- PatternParser parser = createPatternParser();
- List<PatternConverter> converters = new ArrayList<PatternConverter>();
- List<FormattingInfo> fields = new ArrayList<FormattingInfo>();
- parser.parse(pattern, converters, fields);
- FormattingInfo[] infoArray = new FormattingInfo[fields.size()];
- patternFields = fields.toArray(infoArray);
- ArrayPatternConverter[] converterArray = new ArrayPatternConverter[converters.size()];
- patternConverters = converters.toArray(converterArray);
-
- for (ArrayPatternConverter converter : patternConverters) {
- if (converter instanceof DatePatternConverter) {
- DatePatternConverter dateConverter = (DatePatternConverter) converter;
- frequency = calculateFrequency(dateConverter.getPattern());
- }
- }
- }
-
- /**
- * Return the next expire time.
- * @param current The current time.
- * @return The next expire time.
- */
- public long getNextTime(long current) {
- return getNextTime(current, 1);
- }
-
- /**
- * Return the next potential rollover time.
- * @param current The current time.
- * @param increment The increment to the next time.
- * @return the next potential rollover time.
- */
- public long getNextTime(long current, int increment) {
- if (frequency == null) {
- throw new IllegalStateException("Pattern does not contain a date");
- }
- Calendar currentCal = Calendar.getInstance();
- currentCal.setTimeInMillis(current);
- Calendar cal = Calendar.getInstance();
- cal.set(currentCal.get(Calendar.YEAR), 0, 1, 0, 0, 0);
- cal.set(Calendar.MILLISECOND, 0);
- if (frequency == RolloverFrequency.ANNUALLY) {
- cal.add(Calendar.YEAR, increment);
- return cal.getTimeInMillis();
- }
- if (frequency == RolloverFrequency.MONTHLY) {
- cal.add(Calendar.MONTH, increment);
- return cal.getTimeInMillis();
- }
- if (frequency == RolloverFrequency.WEEKLY) {
- cal.set(Calendar.WEEK_OF_YEAR, currentCal.get(Calendar.WEEK_OF_YEAR) + increment);
- return cal.getTimeInMillis();
- }
- cal.set(Calendar.DAY_OF_YEAR, currentCal.get(Calendar.DAY_OF_YEAR));
- if (frequency == RolloverFrequency.DAILY) {
- cal.add(Calendar.DAY_OF_YEAR, increment);
- return cal.getTimeInMillis();
- }
- cal.set(Calendar.HOUR, currentCal.get(Calendar.HOUR));
- if (frequency == RolloverFrequency.HOURLY) {
- cal.add(Calendar.HOUR, increment);
- return cal.getTimeInMillis();
- }
- cal.set(Calendar.MINUTE, currentCal.get(Calendar.MINUTE));
- if (frequency == RolloverFrequency.EVERY_MINUTE) {
- cal.add(Calendar.MINUTE, increment);
- return cal.getTimeInMillis();
- }
- cal.set(Calendar.SECOND, currentCal.get(Calendar.SECOND));
- if (frequency == RolloverFrequency.EVERY_SECOND) {
- cal.add(Calendar.SECOND, increment);
- return cal.getTimeInMillis();
- }
- cal.set(Calendar.MILLISECOND, currentCal.get(Calendar.MILLISECOND) + increment);
- return cal.getTimeInMillis();
- }
-
- /**
- * Format file name.
- *
- * @param obj object to be evaluated in formatting, may not be null.
- * @param buf string buffer to which formatted file name is appended, may not be null.
- */
- protected final void formatFileName(final Object obj, final StringBuilder buf) {
- Object[] objects = new Object[] {new Date(System.currentTimeMillis()), obj};
- formatFileName(objects, buf);
- }
-
- /**
- * Format file name.
- *
- * @param objects objects to be evaluated in formatting, may not be null.
- * @param buf string buffer to which formatted file name is appended, may not be null.
- */
- protected final void formatFileName(final Object[] objects, final StringBuilder buf) {
- for (int i = 0; i < patternConverters.length; i++) {
- int fieldStart = buf.length();
- patternConverters[i].format(objects, buf);
-
- if (patternFields[i] != null) {
- patternFields[i].format(fieldStart, buf);
- }
- }
- }
-
- private RolloverFrequency calculateFrequency(String pattern) {
- if (patternContains(pattern, MILLIS_CHAR)) {
- return RolloverFrequency.EVERY_MILLISECOND;
- }
- if (patternContains(pattern, SECOND_CHAR)) {
- return RolloverFrequency.EVERY_SECOND;
- }
- if (patternContains(pattern, MINUTE_CHAR)) {
- return RolloverFrequency.EVERY_MINUTE;
- }
- if (patternContains(pattern, HOUR_CHARS)) {
- return RolloverFrequency.HOURLY;
- }
- if (patternContains(pattern, DAY_CHARS)) {
- return RolloverFrequency.DAILY;
- }
- if (patternContains(pattern, WEEK_CHARS)) {
- return RolloverFrequency.WEEKLY;
- }
- if (patternContains(pattern, MONTH_CHAR)) {
- return RolloverFrequency.MONTHLY;
- }
- if (patternContains(pattern, YEAR_CHAR)) {
- return RolloverFrequency.ANNUALLY;
- }
- return null;
- }
-
- private PatternParser createPatternParser() {
-
- return new PatternParser(null, KEY, null);
- }
-
- private boolean patternContains(String pattern, char[] chars) {
- for (char character : chars) {
- if (patternContains(pattern, character)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean patternContains(String pattern, char character) {
- return pattern.indexOf(character) >= 0;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
deleted file mode 100644
index 92c1336..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManager.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.FileManager;
-import org.apache.logging.log4j.core.appender.ManagerFactory;
-import org.apache.logging.log4j.core.appender.rolling.helper.Action;
-import org.apache.logging.log4j.core.appender.rolling.helper.ActionBase;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.concurrent.Semaphore;
-
-/**
- * The Rolling File Manager.
- */
-public class RollingFileManager extends FileManager {
-
- private static ManagerFactory factory = new RollingFileManagerFactory();
-
- private long size;
- private long initialTime;
- private PatternProcessor processor;
- private final Semaphore semaphore = new Semaphore(1);
-
- protected RollingFileManager(String fileName, String pattern, OutputStream os, boolean append, long size,
- long time) {
- super(fileName, os, append, false);
- this.size = size;
- this.initialTime = time;
- processor = new PatternProcessor(pattern);
- }
-
- /**
- * Return a RollingFileManager.
- * @param fileName The file name.
- * @param pattern The pattern for rolling file.
- * @param append true if the file should be appended to.
- * @param bufferedIO true if data should be buffered.
- * @return A RollingFileManager.
- */
- public static RollingFileManager getFileManager(String fileName, String pattern, boolean append,
- boolean bufferedIO) {
-
- return (RollingFileManager) getManager(fileName, factory, new FactoryData(pattern, append,
- bufferedIO));
- }
-
- protected synchronized void write(byte[] bytes, int offset, int length) {
- size += length;
- super.write(bytes, offset, length);
- }
-
- /**
- * Return the current size of the file.
- * @return The size of the file in bytes.
- */
- public long getFileSize() {
- return size;
- }
-
- /**
- * Return the time the file was created.
- * @return The time the file was created.
- */
- public long getFileTime() {
- return initialTime;
- }
-
- /**
- * Determine if a rollover should occur.
- * @param event The LogEvent.
- * @param policy The TriggeringPolicy.
- * @param strategy The RolloverStrategy.
- */
- public synchronized void checkRollover(LogEvent event, TriggeringPolicy policy, RolloverStrategy strategy) {
- if (policy.isTriggeringEvent(event) && rollover(strategy)) {
- try {
- size = 0;
- initialTime = System.currentTimeMillis();
- OutputStream os = new FileOutputStream(getFileName(), isAppend());
- setOutputStream(os);
- } catch (FileNotFoundException ex) {
- LOGGER.error("FileManager (" + getFileName() + ") " + ex);
- }
- }
- }
-
- /**
- * Return the pattern processor.
- * @return The PatternProcessor.
- */
- public PatternProcessor getProcessor() {
- return processor;
- }
-
- private boolean rollover(RolloverStrategy strategy) {
-
- try {
- // Block until the asynchronous operation is completed.
- semaphore.acquire();
- } catch (InterruptedException ie) {
- LOGGER.error("Thread interrupted while attempting to check rollover", ie);
- return false;
- }
-
- boolean success = false;
- Thread thread = null;
-
- try {
- RolloverDescription descriptor = strategy.rollover(this);
-
- if (descriptor != null) {
-
- close();
-
- if (descriptor.getSynchronous() != null) {
-
- try {
- success = descriptor.getSynchronous().execute();
- } catch (Exception ex) {
- LOGGER.error("Error in synchronous task", ex);
- }
- }
-
- if (success) {
- thread = new Thread(new AsyncAction(descriptor.getAsynchronous(), this));
- thread.start();
- }
- return true;
- }
- return false;
- } finally {
- if (thread == null) {
- semaphore.release();
- }
- }
-
- }
-
- /**
- * Performs actions asynchronously.
- */
- private static class AsyncAction extends ActionBase {
-
- private final Action action;
- private final RollingFileManager manager;
-
- /**
- * Constructor.
- * @param act The action to perform.
- * @param manager The manager.
- */
- public AsyncAction(Action act, RollingFileManager manager) {
- this.action = act;
- this.manager = manager;
- }
-
- /**
- * Perform an action.
- *
- * @return true if action was successful. A return value of false will cause
- * the rollover to be aborted if possible.
- * @throws java.io.IOException if IO error, a thrown exception will cause the rollover
- * to be aborted if possible.
- */
- public boolean execute() throws IOException {
- try {
- return action.execute();
- } finally {
- manager.semaphore.release();
- }
- }
-
- /**
- * Cancels the action if not already initialized or waits till completion.
- */
- public void close() {
- action.close();
- }
-
- /**
- * Determines if action has been completed.
- *
- * @return true if action is complete.
- */
- public boolean isComplete() {
- return action.isComplete();
- }
- }
-
- /**
- * Factory data.
- */
- private static class FactoryData {
- private String pattern;
- private boolean append;
- private boolean bufferedIO;
-
- /**
- * Create the data for the factory.
- * @param pattern The pattern.
- * @param append The append flag.
- * @param bufferedIO The bufferedIO flag.
- */
- public FactoryData(String pattern, boolean append, boolean bufferedIO) {
- this.pattern = pattern;
- this.append = append;
- this.bufferedIO = bufferedIO;
- }
- }
-
- /**
- * Factory to create a RollingFileManager.
- */
- private static class RollingFileManagerFactory implements ManagerFactory<RollingFileManager, FactoryData> {
-
- /**
- * Create the RollingFileManager.
- * @param name The name of the entity to manage.
- * @param data The data required to create the entity.
- * @return a RollingFileManager.
- */
- public RollingFileManager createManager(String name, FactoryData data) {
- File file = new File(name);
- final File parent = file.getParentFile();
- if (null != parent && !parent.exists()) {
- parent.mkdirs();
- }
- try {
- file.createNewFile();
- } catch (IOException ioe) {
- LOGGER.error("Unable to create file " + name, ioe);
- return null;
- }
- long size = data.append ? file.length() : 0;
- long time = file.lastModified();
-
- OutputStream os;
- try {
- os = new FileOutputStream(name, data.append);
- if (data.bufferedIO) {
- os = new BufferedOutputStream(os);
- }
- return new RollingFileManager(name, data.pattern, os, data.append, size, time);
- } catch (FileNotFoundException ex) {
- LOGGER.error("FileManager (" + name + ") " + ex);
- }
- return null;
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescription.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescription.java
deleted file mode 100644
index 985b7bd..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescription.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.core.appender.rolling.helper.Action;
-
-/**
- * Description of actions needed to complete rollover.
- */
-public interface RolloverDescription {
- /**
- * Active log file name after rollover.
- *
- * @return active log file name after rollover.
- */
- String getActiveFileName();
-
- /**
- * Specifies if active file should be opened for appending.
- *
- * @return if true, active file should be opened for appending.
- */
- boolean getAppend();
-
- /**
- * Action to be completed after close of current active log file
- * before returning control to caller.
- *
- * @return action, may be null.
- */
- Action getSynchronous();
-
- /**
- * Action to be completed after close of current active log file
- * and before next rollover attempt, may be executed asynchronously.
- *
- * @return action, may be null.
- */
- Action getAsynchronous();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescriptionImpl.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescriptionImpl.java
deleted file mode 100644
index 9dcc7d5..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescriptionImpl.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.core.appender.rolling.helper.Action;
-
-/**
- * Description of actions needed to complete rollover.
- */
-public final class RolloverDescriptionImpl implements RolloverDescription {
- /**
- * Active log file name after rollover.
- */
- private final String activeFileName;
-
- /**
- * Should active file be opened for appending.
- */
- private final boolean append;
-
- /**
- * Action to be completed after close of current active log file
- * before returning control to caller.
- */
- private final Action synchronous;
-
- /**
- * Action to be completed after close of current active log file
- * and before next rollover attempt, may be executed asynchronously.
- */
- private final Action asynchronous;
-
- /**
- * Create new instance.
- *
- * @param activeFileName active log file name after rollover, may not be null.
- * @param append true if active log file after rollover should be opened for appending.
- * @param synchronous action to be completed after close of current active log file, may be null.
- * @param asynchronous action to be completed after close of current active log file and
- * before next rollover attempt.
- */
- public RolloverDescriptionImpl(final String activeFileName, final boolean append, final Action synchronous,
- final Action asynchronous) {
- if (activeFileName == null) {
- throw new NullPointerException("activeFileName");
- }
-
- this.append = append;
- this.activeFileName = activeFileName;
- this.synchronous = synchronous;
- this.asynchronous = asynchronous;
- }
-
- /**
- * Active log file name after rollover.
- *
- * @return active log file name after rollover.
- */
- public String getActiveFileName() {
- return activeFileName;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean getAppend() {
- return append;
- }
-
- /**
- * Action to be completed after close of current active log file
- * before returning control to caller.
- *
- * @return action, may be null.
- */
- public Action getSynchronous() {
- return synchronous;
- }
-
- /**
- * Action to be completed after close of current active log file
- * and before next rollover attempt, may be executed asynchronously.
- *
- * @return action, may be null.
- */
- public Action getAsynchronous() {
- return asynchronous;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverFrequency.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverFrequency.java
deleted file mode 100644
index 318f3eb..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverFrequency.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-/**
- * Enumeration of rollover frequency values.
- */
-public enum RolloverFrequency {
- /** Rollover annually. */
- ANNUALLY,
- /** Rollover monthly. */
- MONTHLY,
- /** Rollover weekly. */
- WEEKLY,
- /** Rollover daily. */
- DAILY,
- /** Rollover every hour. */
- HOURLY,
- /** Rollover every minute. */
- EVERY_MINUTE,
- /** Rollover every second. */
- EVERY_SECOND,
- /** Rollover every millisecond. */
- EVERY_MILLISECOND
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategy.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategy.java
deleted file mode 100644
index 10e8a5a..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-/**
- * A <code>RollingPolicy</code> specifies the actions taken on a logging file rollover.
- *
- */
-public interface RolloverStrategy {
- /**
- * Prepare for a rollover. This method is called prior to closing the active log file, performs any necessary
- * preliminary actions and describes actions needed after close of current log file.
- *
- * @param manager The RollingFileManager name for current active log file.
- * @return Description of pending rollover, may be null to indicate no rollover at this time.
- * @throws SecurityException if denied access to log files.
- */
- RolloverDescription rollover(final RollingFileManager manager) throws SecurityException;
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategyBase.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategyBase.java
deleted file mode 100644
index 23b0f81..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategyBase.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- *
- */
-public abstract class RolloverStrategyBase implements RolloverStrategy {
-
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/SizeBasedTriggeringPolicy.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/SizeBasedTriggeringPolicy.java
deleted file mode 100644
index f4a34c4..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/SizeBasedTriggeringPolicy.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- *
- */
-@Plugin(name = "SizeBasedTriggeringPolicy", type = "Core", printObject = true)
-public class SizeBasedTriggeringPolicy implements TriggeringPolicy {
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
-
- private static final long KB = 1024;
- private static final long MB = KB * KB;
- private static final long GB = KB * MB;
-
- /**
- * Rollover threshold size in bytes.
- */
- private static final long MAX_FILE_SIZE = 10 * 1024 * 1024; // let 10 MB the default max size
-
-
- /**
- * Pattern for string parsing.
- */
- private static final Pattern VALUE_PATTERN =
- Pattern.compile("([0-9]+([\\.,][0-9]+)?)\\s*(|K|M|G)B?", Pattern.CASE_INSENSITIVE);
-
- private final long maxFileSize;
-
- private RollingFileManager manager;
-
- /**
- * Constructs a new instance.
- */
- protected SizeBasedTriggeringPolicy() {
- this.maxFileSize = MAX_FILE_SIZE;
- }
-
- /**
- * Constructs a new instance.
- *
- * @param maxFileSize rollover threshold size in bytes.
- */
- protected SizeBasedTriggeringPolicy(final long maxFileSize) {
- this.maxFileSize = maxFileSize;
- }
-
- /**
- * Initialize the TriggeringPolicy.
- * @param manager The RollingFileManager.
- */
- public void initialize(RollingFileManager manager) {
- this.manager = manager;
- }
-
-
- /**
- * Returns true if a rollover should occur.
- * @param event A reference to the currently event.
- * @return true if a rollover should take place, false otherwise.
- */
- public boolean isTriggeringEvent(LogEvent event) {
- return manager.getFileSize() > maxFileSize;
- }
-
- @Override
- public String toString() {
- return "SizeBasedTriggeringPolicy(size=" + maxFileSize + ")";
- }
-
- /**
- * Create a SizeBasedTriggeringPolicy.
- * @param size The size of the file before rollover is required.
- * @return A SizeBasedTriggeringPolicy.
- */
- @PluginFactory
- public static SizeBasedTriggeringPolicy createPolicy(@PluginAttr("size") String size) {
-
- long maxSize = size == null ? MAX_FILE_SIZE : valueOf(size);
- return new SizeBasedTriggeringPolicy(maxSize);
- }
-
- /**
- * Converts a string to a number of bytes. Strings consist of a floating point value followed by
- * K, M, or G for kilobytes, megabytes, gigabytes, respectively. The
- * abbreviations KB, MB, and GB are also accepted. Matching is case insensitive.
- *
- * @param string The string to convert
- * @return The Bytes value for the string
- */
- private static long valueOf(final String string) {
- final Matcher matcher = VALUE_PATTERN.matcher(string);
-
- // Valid input?
- if (matcher.matches()) {
- try {
- // Get double precision value
- final long value = NumberFormat.getNumberInstance(Locale.getDefault()).parse(
- matcher.group(1)).longValue();
-
- // Get units specified
- final String units = matcher.group(3);
-
- if (units.equalsIgnoreCase("")) {
- return value;
- } else if (units.equalsIgnoreCase("K")) {
- return value * KB;
- } else if (units.equalsIgnoreCase("M")) {
- return value * MB;
- } else if (units.equalsIgnoreCase("G")) {
- return value * GB;
- } else {
- LOGGER.error("Units not recognized: " + string);
- return MAX_FILE_SIZE;
- }
- } catch (ParseException e) {
- LOGGER.error("Unable to parse numeric part: " + string, e);
- return MAX_FILE_SIZE;
- }
- } else {
- LOGGER.error("Unable to parse bytes: " + string);
- return MAX_FILE_SIZE;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java
deleted file mode 100644
index 99eb80b..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-/**
- * Triggering Policy that causes a rollover based on time.
- */
-@Plugin(name = "TimeBasedTriggeringPolicy", type = "Core", printObject = true)
-public final class TimeBasedTriggeringPolicy implements TriggeringPolicy {
-
- private long nextRollover;
-
- private RollingFileManager manager;
-
- private TimeBasedTriggeringPolicy() {
- }
-
- /**
- * Initialize the policy.
- * @param manager The RollingFileManager.
- */
- public void initialize(RollingFileManager manager) {
- this.manager = manager;
- nextRollover = manager.getProcessor().getNextTime(manager.getFileTime());
- }
-
- /**
- * Determine whether a rollover should occur.
- * @param event A reference to the currently event.
- * @return true if a rollover should occur.
- */
- public boolean isTriggeringEvent(LogEvent event) {
- if (manager.getFileSize() == 0) {
- return false;
- }
- long now = System.currentTimeMillis();
- if (now > nextRollover) {
- nextRollover = manager.getProcessor().getNextTime(now);
- return true;
- }
- return false;
- }
-
- @Override
- public String toString() {
- return "TimeBasedTriggeringPolicy";
- }
-
- /**
- * Create a TimeBasedTriggeringPolicy.
- * @return a TimeBasedTriggeringPolicy.
- */
- @PluginFactory
- public static TimeBasedTriggeringPolicy createPolicy() {
- return new TimeBasedTriggeringPolicy();
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.java
deleted file mode 100644
index 9f3001c..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.core.LogEvent;
-
-/**
- * A <code>TriggeringPolicy</code> controls the conditions under which rollover
- * occurs. Such conditions include time of day, file size, an
- * external event, the log request or a combination thereof.
- */
-public interface TriggeringPolicy {
-
- /**
- * Initialize the Policy.
- * @param manager The RollingFileManager.
- */
-
- void initialize(final RollingFileManager manager);
-
- /**
- * Determines if a rollover may be appropriate at this time. If
- * true is returned, RolloverPolicy.rollover will be called but it
- * can determine that a rollover is not warranted.
- *
- * @param event A reference to the currently event.
- * @return true if a rollover should occur.
- */
- boolean isTriggeringEvent(final LogEvent event);
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/Action.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/Action.java
deleted file mode 100644
index cad1d7b..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/Action.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling.helper;
-
-import java.io.IOException;
-
-
-/**
- * The Action interface should be implemented by any class that performs
- * file system actions for RollingFileAppenders after the close of
- * the active log file.
- */
-public interface Action extends Runnable {
- /**
- * Perform an action.
- *
- * @return true if action was successful. A return value of false will cause
- * the rollover to be aborted if possible.
- * @throws IOException if IO error, a thrown exception will cause the rollover
- * to be aborted if possible.
- */
- boolean execute() throws IOException;
-
- /**
- * Cancels the action if not already initialized or waits till completion.
- */
- void close();
-
- /**
- * Determines if action has been completed.
- *
- * @return true if action is complete.
- */
- boolean isComplete();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ActionBase.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ActionBase.java
deleted file mode 100644
index 80b373f..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ActionBase.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling.helper;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.io.IOException;
-
-
-/**
- * Abstract base class for implementations of Action.
- */
-public abstract class ActionBase implements Action {
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
- /**
- * Is action complete.
- */
- private boolean complete = false;
-
- /**
- * Is action interrupted.
- */
- private boolean interrupted = false;
-
- /**
- * Constructor.
- */
- protected ActionBase() {
- }
-
- /**
- * Perform action.
- *
- * @return true if successful.
- * @throws IOException if IO error.
- */
- public abstract boolean execute() throws IOException;
-
- /**
- * {@inheritDoc}
- */
- public synchronized void run() {
- if (!interrupted) {
- try {
- execute();
- } catch (IOException ex) {
- reportException(ex);
- }
-
- complete = true;
- interrupted = true;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public synchronized void close() {
- interrupted = true;
- }
-
- /**
- * Tests if the action is complete.
- *
- * @return true if action is complete.
- */
- public boolean isComplete() {
- return complete;
- }
-
- /**
- * Capture exception.
- *
- * @param ex exception.
- */
- protected void reportException(final Exception ex) {
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/CompositeAction.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/CompositeAction.java
deleted file mode 100644
index 2522327..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/CompositeAction.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling.helper;
-
-import java.io.IOException;
-
-import java.util.List;
-
-
-/**
- * A group of Actions to be executed in sequence.
- */
-public class CompositeAction extends ActionBase {
- /**
- * Actions to perform.
- */
- private final Action[] actions;
-
- /**
- * Stop on error.
- */
- private final boolean stopOnError;
-
- /**
- * Construct a new composite action.
- *
- * @param actions list of actions, may not be null.
- * @param stopOnError if true, stop on the first false return value or exception.
- */
- public CompositeAction(final List actions,
- final boolean stopOnError) {
- this.actions = new Action[actions.size()];
- actions.toArray(this.actions);
- this.stopOnError = stopOnError;
- }
-
- /**
- * {@inheritDoc}
- */
- public void run() {
- try {
- execute();
- } catch (IOException ex) {
- LOGGER.warn("Exception during file rollover.", ex);
- }
- }
-
- /**
- * Execute sequence of actions.
- *
- * @return true if all actions were successful.
- * @throws IOException on IO error.
- */
- public boolean execute() throws IOException {
- if (stopOnError) {
- for (Action action : actions) {
- if (!action.execute()) {
- return false;
- }
- }
-
- return true;
- } else {
- boolean status = true;
- IOException exception = null;
-
- for (Action action : actions) {
- try {
- status &= action.execute();
- } catch (IOException ex) {
- status = false;
-
- if (exception == null) {
- exception = ex;
- }
- }
- }
-
- if (exception != null) {
- throw exception;
- }
-
- return status;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/FileRenameAction.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/FileRenameAction.java
deleted file mode 100644
index 0f6c367..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/FileRenameAction.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling.helper;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.channels.FileChannel;
-
-
-/**
- * File rename action.
- */
-public final class FileRenameAction extends ActionBase {
- /**
- * Source.
- */
- private final File source;
-
- /**
- * Destination.
- */
- private final File destination;
-
- /**
- * If true, rename empty files, otherwise delete empty files.
- */
- private final boolean renameEmptyFiles;
-
- /**
- * Creates an FileRenameAction.
- *
- * @param src current file name.
- * @param dst new file name.
- * @param renameEmptyFiles if true, rename file even if empty, otherwise delete empty files.
- */
- public FileRenameAction(final File src, final File dst, boolean renameEmptyFiles) {
- source = src;
- destination = dst;
- this.renameEmptyFiles = renameEmptyFiles;
- }
-
- /**
- * Rename file.
- *
- * @return true if successfully renamed.
- */
- public boolean execute() {
- return execute(source, destination, renameEmptyFiles);
- }
-
- /**
- * Rename file.
- *
- * @param source current file name.
- * @param destination new file name.
- * @param renameEmptyFiles if true, rename file even if empty, otherwise delete empty files.
- * @return true if successfully renamed.
- */
- public static boolean execute(final File source, final File destination, boolean renameEmptyFiles) {
- if (renameEmptyFiles || (source.length() > 0)) {
- try {
-
- boolean result = source.renameTo(destination);
- //System.out.println("Rename of " + source.getName() + " to " + destination.getName() + ": " + result);
- return result;
- } catch (Exception ex) {
- try {
- copyFile(source, destination);
- return source.delete();
- } catch (IOException iex) {
- iex.printStackTrace();
- }
- }
- }
-
- return false;
- }
-
- private static void copyFile(final File source, final File destination) throws IOException {
- if (!destination.exists()) {
- destination.createNewFile();
- }
-
- FileChannel srcChannel = null;
- FileChannel destChannel = null;
- FileInputStream srcStream = null;
- FileOutputStream destStream = null;
- try {
- srcStream = new FileInputStream(source);
- destStream = new FileOutputStream(destination);
- srcChannel = srcStream.getChannel();
- destChannel = destStream.getChannel();
- destChannel.transferFrom(srcChannel, 0, srcChannel.size());
- } finally {
- if (srcChannel != null) {
- srcChannel.close();
- }
- if (srcStream != null) {
- srcStream.close();
- }
- if (destChannel != null) {
- destChannel.close();
- }
- if (destStream != null) {
- destStream.close();
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/GZCompressAction.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/GZCompressAction.java
deleted file mode 100644
index 6ec0866..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/GZCompressAction.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling.helper;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import java.util.zip.GZIPOutputStream;
-
-/**
- * Compresses a file using GZ compression.
- */
-public final class GZCompressAction extends ActionBase {
-
- private static final int BUF_SIZE = 8102;
-
- /**
- * Source file.
- */
- private final File source;
-
- /**
- * Destination file.
- */
- private final File destination;
-
- /**
- * If true, attempt to delete file on completion.
- */
- private final boolean deleteSource;
-
- /**
- * Create new instance of GZCompressAction.
- *
- * @param source file to compress, may not be null.
- * @param destination compressed file, may not be null.
- * @param deleteSource if true, attempt to delete file on completion. Failure to delete
- * does not cause an exception to be thrown or affect return value.
- */
- public GZCompressAction(final File source, final File destination, final boolean deleteSource) {
- if (source == null) {
- throw new NullPointerException("source");
- }
-
- if (destination == null) {
- throw new NullPointerException("destination");
- }
-
- this.source = source;
- this.destination = destination;
- this.deleteSource = deleteSource;
- }
-
- /**
- * Compress.
- *
- * @return true if successfully compressed.
- * @throws IOException on IO exception.
- */
- public boolean execute() throws IOException {
- return execute(source, destination, deleteSource);
- }
-
- /**
- * Compress a file.
- *
- * @param source file to compress, may not be null.
- * @param destination compressed file, may not be null.
- * @param deleteSource if true, attempt to delete file on completion. Failure to delete
- * does not cause an exception to be thrown or affect return value.
- * @return true if source file compressed.
- * @throws IOException on IO exception.
- */
- public static boolean execute(final File source, final File destination, final boolean deleteSource)
- throws IOException {
- if (source.exists()) {
- FileInputStream fis = new FileInputStream(source);
- FileOutputStream fos = new FileOutputStream(destination);
- GZIPOutputStream gzos = new GZIPOutputStream(fos);
- BufferedOutputStream os = new BufferedOutputStream(gzos);
- byte[] inbuf = new byte[BUF_SIZE];
- int n;
-
- while ((n = fis.read(inbuf)) != -1) {
- os.write(inbuf, 0, n);
- }
-
- os.close();
- fis.close();
-
- if (deleteSource && !source.delete()) {
- LOGGER.warn("Unable to delete " + source.toString() + ".");
- }
-
- return true;
- }
-
- return false;
- }
-
-
- /**
- * Capture exception.
- *
- * @param ex exception.
- */
- protected void reportException(final Exception ex) {
- LOGGER.warn("Exception during compression of '" + source.toString() + "'.", ex);
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ZipCompressAction.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ZipCompressAction.java
deleted file mode 100644
index 83c2dee..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ZipCompressAction.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling.helper;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-
-/**
- * Compresses a file using Zip compression.
- */
-public final class ZipCompressAction extends ActionBase {
-
- private static final int BUF_SIZE = 8102;
-
- /**
- * Source file.
- */
- private final File source;
-
- /**
- * Destination file.
- */
- private final File destination;
-
- /**
- * If true, attempt to delete file on completion.
- */
- private final boolean deleteSource;
-
- /**
- * Create new instance of GZCompressAction.
- *
- * @param source file to compress, may not be null.
- * @param destination compressed file, may not be null.
- * @param deleteSource if true, attempt to delete file on completion. Failure to delete
- * does not cause an exception to be thrown or affect return value.
- */
- public ZipCompressAction(final File source, final File destination, final boolean deleteSource) {
- if (source == null) {
- throw new NullPointerException("source");
- }
-
- if (destination == null) {
- throw new NullPointerException("destination");
- }
-
- this.source = source;
- this.destination = destination;
- this.deleteSource = deleteSource;
- }
-
- /**
- * Compress.
- *
- * @return true if successfully compressed.
- * @throws IOException on IO exception.
- */
- public boolean execute() throws IOException {
- return execute(source, destination, deleteSource);
- }
-
- /**
- * Compress a file.
- *
- * @param source file to compress, may not be null.
- * @param destination compressed file, may not be null.
- * @param deleteSource if true, attempt to delete file on completion. Failure to delete
- * does not cause an exception to be thrown or affect return value.
- * @return true if source file compressed.
- * @throws IOException on IO exception.
- */
- public static boolean execute(final File source, final File destination, final boolean deleteSource)
- throws IOException {
- if (source.exists()) {
- FileInputStream fis = new FileInputStream(source);
- FileOutputStream fos = new FileOutputStream(destination);
- ZipOutputStream zos = new ZipOutputStream(fos);
-
- ZipEntry zipEntry = new ZipEntry(source.getName());
- zos.putNextEntry(zipEntry);
-
- byte[] inbuf = new byte[BUF_SIZE];
- int n;
-
- while ((n = fis.read(inbuf)) != -1) {
- zos.write(inbuf, 0, n);
- }
-
- zos.close();
- fis.close();
-
- if (deleteSource && !source.delete()) {
- LOGGER.warn("Unable to delete " + source.toString() + ".");
- }
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Capture exception.
- *
- * @param ex exception.
- */
- protected void reportException(final Exception ex) {
- LOGGER.warn("Exception during compression of '" + source.toString() + "'.", ex);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/package-info.java
deleted file mode 100644
index 9bf5595..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Support classes for the Rolling File Appender.
- */
-package org.apache.logging.log4j.core.appender.rolling.helper;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/package-info.java
deleted file mode 100644
index 899fef0..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Rolling File Appender and support classes.
- */
-package org.apache.logging.log4j.core.appender.rolling;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Route.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Route.java
deleted file mode 100644
index 783c43d..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Route.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.routing;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.Node;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.config.plugins.PluginNode;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * A Route to an appender.
- */
-@Plugin(name = "Route", type = "Core", printObject = true, deferChildren = true)
-public final class Route {
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private final Node node;
- private final String appenderRef;
- private final String key;
-
- private Route(Node node, String appenderRef, String key) {
- this.node = node;
- this.appenderRef = appenderRef;
- this.key = key;
- }
-
- /**
- * Return the Dynamic Appender Node.
- * @return The Node.
- */
- public Node getNode() {
- return node;
- }
-
- /**
- * Returns the appender reference.
- * @return The Appender reference.
- */
- public String getAppenderRef() {
- return appenderRef;
- }
-
- /**
- * Return the key for this Route.
- * @return the key for this Route.
- */
- public String getKey() {
- return key;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("Route(");
- sb.append("type=");
- if (appenderRef != null) {
- sb.append("static Reference=").append(appenderRef);
- } else {
- sb.append("dynamic");
- }
- if (key != null) {
- sb.append(" key='").append(key).append("'");
- } else {
- sb.append(" default");
- }
- sb.append(")");
- return sb.toString();
- }
-
- /**
- * Create the Route.
- * @param appenderRef The Appender reference.
- * @param key The key.
- * @param node The Node.
- * @return A Route.
- */
- @PluginFactory
- public static Route createRoute(@PluginAttr("appender-ref") String appenderRef,
- @PluginAttr("key") String key,
- @PluginNode Node node) {
- if (node != null && node.hasChildren()) {
- for (Node child : node.getChildren()) {
-
- }
- if (appenderRef != null) {
- LOGGER.error("A route cannot be configured with an appender reference and an appender definition");
- return null;
- }
- } else {
- if (appenderRef == null) {
- LOGGER.error("A route must specify an appender reference or an appender definition");
- return null;
- }
- }
- return new Route(node, appenderRef, key);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java
deleted file mode 100644
index c380aba..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.routing;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Used to contain the individual Route elements.
- */
-@Plugin(name = "Routes", type = "Core", printObject = true)
-public final class Routes {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private final String pattern;
- private final Route[] routes;
-
- private Routes(String pattern, Route[] routes) {
- this.pattern = pattern;
- this.routes = routes;
- }
-
- /**
- * Return the pattern.
- * @return the pattern.
- */
- public String getPattern() {
- return pattern;
- }
-
- /**
- * Return the array of Route elements.
- * @return an array of Route elements.
- */
- public Route[] getRoutes() {
- return routes;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("{");
- boolean first = true;
- for (Route route : routes) {
- if ((!first)) {
- sb.append(",");
- }
- first = false;
- sb.append(route.toString());
- }
- sb.append("}");
- return sb.toString();
-
- }
-
- /**
- * Create the Routes.
- * @param pattern The pattern.
- * @param routes An array of Route elements.
- * @return The Routes container.
- */
- @PluginFactory
- public static Routes createRoutes(@PluginAttr("pattern") String pattern,
- @PluginElement("routes") Route[] routes) {
- if (pattern == null) {
- LOGGER.error("A pattern is required");
- return null;
- }
- if (routes == null || routes.length == 0) {
- LOGGER.error("No routes configured");
- return null;
- }
- return new Routes(pattern, routes);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
deleted file mode 100644
index 89b70ca..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.routing;
-
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.AppenderBase;
-import org.apache.logging.log4j.core.appender.rewrite.RewritePolicy;
-import org.apache.logging.log4j.core.config.AppenderControl;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.Node;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * This Appender "routes" between various Appenders, some of which can be references to
- * Appenders defined earlier in the configuration while others can be dynamically created
- * within this Appender as required. Routing is achieved by specifying a pattern on
- * the Routing appender declaration. The pattern should contain one or more substitution patterns of
- * the form "$${[key:]token}". The pattern will be resolved each time the Appender is called using
- * the built in StrSubstitutor and the StrLookup plugin that matches the specified key.
- */
-@Plugin(name = "Routing", type = "Core", elementType = "appender", printObject = true)
-public final class RoutingAppender extends AppenderBase {
- private static final String DEFAULT_KEY = "ROUTING_APPENDER_DEFAULT";
- private final Routes routes;
- private final Configuration config;
- private ConcurrentMap<String, AppenderControl> appenders = new ConcurrentHashMap<String, AppenderControl>();
- private final RewritePolicy rewritePolicy;
-
- private RoutingAppender(String name, Filter filter, boolean handleException, Routes routes,
- RewritePolicy rewritePolicy, Configuration config) {
- super(name, filter, null, handleException);
- this.routes = routes;
- this.config = config;
- this.rewritePolicy = rewritePolicy;
- }
-
- @Override
- public void start() {
- Map<String, Appender> map = config.getAppenders();
- for (Route route : routes.getRoutes()) {
- if (route.getAppenderRef() != null) {
- Appender appender = map.get(route.getAppenderRef());
- if (appender != null) {
- String key = route.getKey() == null ? DEFAULT_KEY : route.getKey();
- if (appenders.containsKey(key)) {
- if (DEFAULT_KEY.equals(key)) {
- LOGGER.error("Multiple default routes. Only the first will be used");
- } else {
- LOGGER.error("Duplicate route " + key + " is ignored");
- }
- } else {
- appenders.put(key, new AppenderControl(appender));
- }
- } else {
- LOGGER.error("Appender " + route.getAppenderRef() + " cannot be located. Route ignored");
- }
- }
- }
- super.start();
- }
-
- @Override
- public void stop() {
- super.stop();
- for (AppenderControl control : appenders.values()) {
- if (control instanceof AppenderWrapper) {
- control.getAppender().stop();
- }
- }
- }
-
- public void append(LogEvent event) {
- if (rewritePolicy != null) {
- event = rewritePolicy.rewrite(event);
- }
- String key = config.getSubst().replace(event, routes.getPattern());
- AppenderControl control = getControl(key, event);
- if (control != null) {
- control.callAppender(event);
- }
- }
-
- private synchronized AppenderControl getControl(String key, LogEvent event) {
- AppenderControl control = appenders.get(key);
- boolean defaultRoute = false;
- if (control != null) {
- return control;
- }
- Route route = null;
- for (Route r : routes.getRoutes()) {
- if (r.getAppenderRef() == null && key.equals(r.getKey())) {
- route = r;
- break;
- }
- }
- if (route == null) {
- control = appenders.get(DEFAULT_KEY);
- if (control != null) {
- return control;
- }
- for (Route r : routes.getRoutes()) {
- if (r.getAppenderRef() == null && r.getKey() == null) {
- route = r;
- defaultRoute = true;
- break;
- }
- }
- }
- if (route != null) {
- Appender app = createAppender(route, event);
- if (app == null) {
- return null;
- }
- control = new AppenderWrapper(app);
- appenders.put(key, control);
- if (defaultRoute) {
- appenders.put(DEFAULT_KEY, control);
- }
- }
-
- return control;
- }
-
- private Appender createAppender(Route route, LogEvent event) {
- Node routeNode = route.getNode();
- for (Node node : routeNode.getChildren()) {
- if (node.getType().getElementName().equals("appender")) {
- config.createConfiguration(node, event);
- if (node.getObject() instanceof Appender) {
- Appender app = (Appender) node.getObject();
- app.start();
- return (Appender) node.getObject();
- }
- LOGGER.error("Unable to create Appender of type " + node.getName());
- return null;
- }
- }
- LOGGER.error("No Appender was configured for route " + route.getKey());
- return null;
- }
-
- /**
- * Create a RoutingAppender.
- * @param name The name of the Appender.
- * @param suppress "true" if exceptions should be hidden from the application, "false" otherwise.
- * The default is "true".
- * @param routes The routing definitions.
- * @param config The Configuration (automatically added by the Configuration).
- * @param rewritePolicy A RewritePolicy, if any.
- * @param filter A Filter to restrict events processed by the Appender or null.
- * @return The RoutingAppender
- */
- @PluginFactory
- public static RoutingAppender createAppender(@PluginAttr("name") String name,
- @PluginAttr("suppressExceptions") String suppress,
- @PluginElement("routes") Routes routes,
- @PluginConfiguration Configuration config,
- @PluginElement("rewritePolicy") RewritePolicy rewritePolicy,
- @PluginElement("filters") Filter filter) {
-
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
-
- if (name == null) {
- LOGGER.error("No name provided for RoutingAppender");
- return null;
- }
- if (routes == null) {
- LOGGER.error("No routes defined for RoutingAppender");
- return null;
- }
- return new RoutingAppender(name, filter, handleExceptions, routes, rewritePolicy, config);
- }
-
- /**
- * Wrapper to allow AppenderControl to be used here.
- */
- private static class AppenderWrapper extends AppenderControl {
- public AppenderWrapper(Appender appender) {
- super(appender);
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/package-info.java
deleted file mode 100644
index 3e295dd..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Apache Flume Appender. Requires the user specifically include Flume and its dependencies.
- */
-package org.apache.logging.log4j.core.appender.routing;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
deleted file mode 100644
index f24a27c..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Lifecycle;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.AppenderRuntimeException;
-import org.apache.logging.log4j.core.filter.Filtering;
-
-/**
- * Wraps appenders with details the appender implementation shouldn't need to know about.
- */
-public class AppenderControl {
-
- private ThreadLocal<AppenderControl> recursive = new ThreadLocal<AppenderControl>();
-
- private final Appender appender;
-
- /**
- * Constructor.
- * @param appender The target Appender.
- */
- public AppenderControl(Appender appender) {
- this.appender = appender;
- }
-
- /**
- * Return the Appender.
- * @return the Appender.
- */
- public Appender getAppender() {
- return appender;
- }
-
- /**
- * Call the appender.
- * @param event The event to process.
- */
- public void callAppender(LogEvent event) {
- if (recursive.get() != null) {
- appender.getHandler().error("Recursive call to appender " + appender.getName());
- return;
- }
- try {
- recursive.set(this);
-
- if (appender instanceof Lifecycle && !appender.isStarted()) {
- appender.getHandler().error("Attempted to append to non-started appender " + appender.getName());
-
- if (!appender.isExceptionSuppressed()) {
- throw new AppenderRuntimeException(
- "Attempted to append to non-started appender " + appender.getName());
- }
- }
-
- if (appender instanceof Filtering && ((Filtering) appender).isFiltered(event)) {
- return;
- }
-
- try {
- appender.append(event);
- } catch (RuntimeException ex) {
- appender.getHandler().error("An exception occurred processing Appender " + appender.getName(), ex);
- if (!appender.isExceptionSuppressed()) {
- throw ex;
- }
- } catch (Exception ex) {
- appender.getHandler().error("An exception occurred processing Appender " + appender.getName(), ex);
- if (!appender.isExceptionSuppressed()) {
- throw new AppenderRuntimeException(ex);
- }
- }
- } finally {
- recursive.set(null);
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
deleted file mode 100644
index 85af509..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.config.plugins.PluginManager;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginNode;
-import org.apache.logging.log4j.core.config.plugins.PluginType;
-import org.apache.logging.log4j.core.config.plugins.PluginValue;
-import org.apache.logging.log4j.core.filter.Filterable;
-import org.apache.logging.log4j.core.helpers.NameUtil;
-import org.apache.logging.log4j.core.lookup.Interpolator;
-import org.apache.logging.log4j.core.lookup.StrLookup;
-import org.apache.logging.log4j.core.lookup.StrSubstitutor;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * The Base Configuration. Many configuration implementations will extend this class.
- */
-public class BaseConfiguration extends Filterable implements Configuration {
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
-
- /**
- * The root node of the configuration.
- */
- protected Node rootNode;
-
- /**
- * The Plugin Manager.
- */
- protected PluginManager pluginManager;
-
- /**
- * Listeners for configuration changes.
- */
- protected final List<ConfigurationListener> listeners =
- new CopyOnWriteArrayList<ConfigurationListener>();
-
- /**
- * The ConfigurationMonitor that checks for configuration changes.
- */
- protected ConfigurationMonitor monitor = new DefaultConfigurationMonitor();
-
- private String name;
-
- private ConcurrentMap<String, Appender> appenders = new ConcurrentHashMap<String, Appender>();
-
- private ConcurrentMap<String, LoggerConfig> loggers = new ConcurrentHashMap<String, LoggerConfig>();
-
- private StrSubstitutor subst = new StrSubstitutor();
-
- private LoggerConfig root = new LoggerConfig();
-
- private boolean started = false;
-
- private ConcurrentMap<String, Object> componentMap = new ConcurrentHashMap<String, Object>();
-
- /**
- * Constructor.
- */
- protected BaseConfiguration() {
- pluginManager = new PluginManager("Core");
- rootNode = new Node();
- }
-
- /**
- * Initialize the configuration.
- */
- public void start() {
- pluginManager.collectPlugins();
- setup();
- doConfigure();
- for (LoggerConfig logger : loggers.values()) {
- logger.startFilter();
- }
- for (Appender appender : appenders.values()) {
- appender.start();
- }
-
- startFilter();
- }
-
- /**
- * Tear down the configuration.
- */
- public void stop() {
- for (LoggerConfig logger : loggers.values()) {
- logger.clearAppenders();
- logger.stopFilter();
- }
- for (Appender appender : appenders.values()) {
- appender.stop();
- }
- stopFilter();
- }
-
- protected void setup() {
- }
-
- public Object getComponent(String name) {
- return componentMap.get(name);
- }
-
- public void addComponent(String name, Object obj) {
- componentMap.putIfAbsent(name, obj);
- }
-
- protected void doConfigure() {
- boolean setRoot = false;
- boolean setLoggers = false;
- for (Node child : rootNode.getChildren()) {
- createConfiguration(child, null);
- if (child.getObject() == null) {
- continue;
- }
- if (child.getName().equalsIgnoreCase("properties")) {
- if (subst.getVariableResolver() == null) {
- subst.setVariableResolver((StrLookup) child.getObject());
- } else {
- LOGGER.error("Properties declaration must be the first element in the configuration");
- }
- continue;
- } else if (subst.getVariableResolver() == null) {
- subst.setVariableResolver(new Interpolator(null));
- }
- if (child.getName().equalsIgnoreCase("appenders")) {
- appenders = (ConcurrentMap<String, Appender>) child.getObject();
- } else if (child.getObject() instanceof Filter) {
- addFilter((Filter) child.getObject());
- } else if (child.getName().equalsIgnoreCase("loggers")) {
- Loggers l = (Loggers) child.getObject();
- loggers = l.getMap();
- setLoggers = true;
- if (l.getRoot() != null) {
- root = l.getRoot();
- setRoot = true;
- }
- } else {
- LOGGER.error("Unknown object \"" + child.getName() + "\" of type " +
- child.getObject().getClass().getName() + " is ignored");
- }
- }
-
- if (!setLoggers) {
- LOGGER.warn("No Loggers were configured, using default");
- } else if (!setRoot) {
- LOGGER.warn("No Root logger was configured, using default");
- }
-
- root.setConfigurationMonitor(monitor);
-
- for (Map.Entry<String, LoggerConfig> entry : loggers.entrySet()) {
- LoggerConfig l = entry.getValue();
- l.setConfigurationMonitor(monitor);
- for (String ref : l.getAppenderRefs()) {
- Appender app = appenders.get(ref);
- if (app != null) {
- l.addAppender(app);
- } else {
- LOGGER.error("Unable to locate appender " + ref + " for logger " + l.getName());
- }
- }
-
- }
-
- setParents();
- }
-
- protected PluginManager getPluginManager() {
- return pluginManager;
- }
-
- /**
- * Set the name of the configuration.
- * @param name The name.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Return the name of the configuration.
- * @return the name of the configuration.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Add a listener for changes on the configuration.
- * @param listener The ConfigurationListener to add.
- */
- public void addListener(ConfigurationListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Remove a ConfigurationListener.
- * @param listener The ConfigurationListener to remove.
- */
- public void removeListener(ConfigurationListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * Return the Appender with the specified name.
- * @param name The name of the Appender.
- * @return the Appender with the specified name or null if the Appender cannot be located.
- */
- public Appender getAppender(String name) {
- return appenders.get(name);
- }
-
- /**
- * Return a Map containing all the Appenders and their name.
- * @return A Map containing each Appender's naem and the Appender object.
- */
- public Map<String, Appender> getAppenders() {
- return appenders;
- }
-
- /**
- * Adds an Appender to the configuration.
- * @param appender The Appender to add.
- */
- public void addAppender(Appender appender) {
- appenders.put(appender.getName(), appender);
- }
-
- public StrSubstitutor getSubst() {
- return subst;
- }
-
- /**
- * Associates an Appender with a LoggerConfig. This method is synchronized in case a Logger with the
- * same name is being updated at the same time.
- *
- * Note: This method is not used when configuring via configuration. It is primarily used by
- * unit tests.
- * @param logger The Logger the Appender will be associated with.
- * @param appender The Appender.
- */
- public synchronized void addLoggerAppender(org.apache.logging.log4j.core.Logger logger, Appender appender) {
- String name = logger.getName();
- appenders.putIfAbsent(name, appender);
- LoggerConfig lc = getLoggerConfig(name);
- if (lc.getName().equals(name)) {
- lc.addAppender(appender);
- } else {
- LoggerConfig nlc = new LoggerConfig(name, lc.getLevel(), lc.isAdditive());
- nlc.setConfigurationMonitor(monitor);
- nlc.addAppender(appender);
- nlc.setParent(lc);
- loggers.putIfAbsent(name, nlc);
- setParents();
- logger.getContext().updateLoggers();
- }
- }
- /**
- * Associates a Filter with a LoggerConfig. This method is synchronized in case a Logger with the
- * same name is being updated at the same time.
- *
- * Note: This method is not used when configuring via configuration. It is primarily used by
- * unit tests.
- * @param logger The Logger the Fo;ter will be associated with.
- * @param filter The Filter.
- */
- public synchronized void addLoggerFilter(org.apache.logging.log4j.core.Logger logger, Filter filter) {
- String name = logger.getName();
- LoggerConfig lc = getLoggerConfig(name);
- if (lc.getName().equals(name)) {
-
- lc.addFilter(filter);
- } else {
- LoggerConfig nlc = new LoggerConfig(name, lc.getLevel(), lc.isAdditive());
- nlc.setConfigurationMonitor(monitor);
- nlc.addFilter(filter);
- nlc.setParent(lc);
- loggers.putIfAbsent(name, nlc);
- setParents();
- logger.getContext().updateLoggers();
- }
- }
- /**
- * Marks a LoggerConfig as additive. This method is synchronized in case a Logger with the
- * same name is being updated at the same time.
- *
- * Note: This method is not used when configuring via configuration. It is primarily used by
- * unit tests.
- * @param logger The Logger the Appender will be associated with.
- * @param additive True if the LoggerConfig should be additive, false otherwise.
- */
- public synchronized void setLoggerAdditive(org.apache.logging.log4j.core.Logger logger, boolean additive) {
- String name = logger.getName();
- LoggerConfig lc = getLoggerConfig(name);
- if (lc.getName().equals(name)) {
- lc.setAdditive(additive);
- } else {
- LoggerConfig nlc = new LoggerConfig(name, lc.getLevel(), additive);
- nlc.setConfigurationMonitor(monitor);
- nlc.setParent(lc);
- loggers.putIfAbsent(name, nlc);
- setParents();
- logger.getContext().updateLoggers();
- }
- }
-
- /**
- * Remove an Appender. First removes any associations between LoggerContigs and the Appender, removes
- * the Appender from this appender list and then stops the appender. This method is synchronized in
- * case an Appender with the same name is being added during the removal.
- * @param name the name of the appender to remove.
- */
- public synchronized void removeAppender(String name) {
- for (LoggerConfig logger : loggers.values()) {
- logger.removeAppender(name);
- }
- Appender app = appenders.remove(name);
-
- if (app != null) {
- app.stop();
- }
- }
-
- /**
- * Locates the appropriate LoggerConfig for a Logger name. This will remove tokens from the
- * package name as necessary or return the root LoggerConfig if no other matches were found.
- * @param name The Logger name.
- * @return The located LoggerConfig.
- */
- public LoggerConfig getLoggerConfig(String name) {
- if (loggers.containsKey(name)) {
- return loggers.get(name);
- }
- String substr = name;
- while ((substr = NameUtil.getSubName(substr)) != null) {
- if (loggers.containsKey(substr)) {
- return loggers.get(substr);
- }
- }
- return root;
- }
-
- /**
- * Returns the root Logger.
- * @return the root Logger.
- */
- public LoggerConfig getRootLogger() {
- return root;
- }
-
- /**
- * Return a Map of all the LoggerConfigs.
- * @return a Map with each entry containing the name of the Logger and the LoggerConfig.
- */
- public Map<String, LoggerConfig> getLoggers() {
- return Collections.unmodifiableMap(loggers);
- }
-
- /**
- * Returns the LoggerConfig with the specified name.
- * @param name The Logger name.
- * @return The LoggerConfig or null if no match was found.
- */
- public LoggerConfig getLogger(String name) {
- return loggers.get(name);
- }
-
- /**
- * Adding a logger cannot be done atomically so is not allowed in an active configuration. Adding
- * or removing a Logger requires creating a new configuration and then switching.
- *
- * @param name The name of the Logger.
- * @param loggerConfig The LoggerConfig.
- */
- public void addLogger(String name, LoggerConfig loggerConfig) {
- if (started) {
- String msg = "Cannot add logger " + name + " to an active configuration";
- LOGGER.warn(msg);
- throw new IllegalStateException(msg);
- }
- loggers.put(name, loggerConfig);
- setParents();
- }
-
- /**
- * Removing a logger cannot be done atomically so is not allowed in an active configuration. Adding
- * or removing a Logger requires creating a new configuration and then switching.
- *
- * @param name The name of the Logger.
- */
- public void removeLogger(String name) {
- if (started) {
- String msg = "Cannot remove logger " + name + " in an active configuration";
- LOGGER.warn(msg);
- throw new IllegalStateException(msg);
- }
- loggers.remove(name);
- setParents();
- }
-
- public void createConfiguration(Node node, LogEvent event) {
- PluginType type = node.getType();
- if (type != null && type.isDeferChildren()) {
- node.setObject(createPluginObject(type, node, event));
- } else {
- for (Node child : node.getChildren()) {
- createConfiguration(child, event);
- }
-
- if (type == null) {
- if (node.getParent() != null) {
- LOGGER.error("Unable to locate plugin for " + node.getName());
- }
- } else {
- node.setObject(createPluginObject(type, node, event));
- }
- }
- }
-
- /*
- * Retrieve a static public 'method to create the desired object. Every parameter
- * will be annotated to identify the appropriate attribute or element to use to
- * set the value of the paraemter.
- * Parameters annotated with PluginAttr will always be set as Strings.
- * Parameters annotated with PluginElement may be Objects or arrays. Collections
- * and Maps are currently not supported, although the factory method that is called
- * can create these from an array.
- *
- * Although the happy path works, more work still needs to be done to log incorrect
- * parameters. These will generally result in unhelpful InvocationTargetExceptions.
- * @param classClass the class.
- * @return the instantiate method or null if there is none by that
- * description.
- */
- private Object createPluginObject(PluginType type, Node node, LogEvent event)
- {
- Class clazz = type.getPluginClass();
-
- if (Map.class.isAssignableFrom(clazz)) {
- try {
- Map<String, Object> map = (Map<String, Object>) clazz.newInstance();
- for (Node child : node.getChildren()) {
- map.put(child.getName(), child.getObject());
- }
- return map;
- } catch (Exception ex) {
- LOGGER.warn("Unable to create Map for " + type.getElementName() + " of class " +
- clazz);
- }
- }
-
- if (List.class.isAssignableFrom(clazz)) {
- try {
- List<Object> list = (List<Object>) clazz.newInstance();
- for (Node child : node.getChildren()) {
- list.add(child.getObject());
- }
- return list;
- } catch (Exception ex) {
- LOGGER.warn("Unable to create List for " + type.getElementName() + " of class " +
- clazz);
- }
- }
-
- Method factoryMethod = null;
-
- for (Method method : clazz.getMethods()) {
- if (method.isAnnotationPresent(PluginFactory.class)) {
- factoryMethod = method;
- break;
- }
- }
- if (factoryMethod == null) {
- return null;
- }
-
- Annotation[][] parmArray = factoryMethod.getParameterAnnotations();
- Class[] parmClasses = factoryMethod.getParameterTypes();
- if (parmArray.length != parmClasses.length) {
- LOGGER.error("Number of parameter annotations does not equal the number of paramters");
- }
- Object[] parms = new Object[parmClasses.length];
-
- int index = 0;
- Map<String, String> attrs = node.getAttributes();
- List<Node> children = node.getChildren();
- StringBuilder sb = new StringBuilder();
- List<Node> used = new ArrayList<Node>();
-
- /*
- * For each parameter:
- * If the parameter is an attribute store the value of the attribute in the parameter array.
- * If the parameter is an element:
- * Determine if the required parameter is an array.
- * If so, if a child contains the array, use it,
- * otherwise create the array from all child nodes of the correct type.
- * Store the array into the parameter array.
- * If not an array, store the object in the child node into the parameter array.
- */
- for (Annotation[] parmTypes : parmArray) {
- for (Annotation a : parmTypes) {
- if (sb.length() == 0) {
- sb.append(" with params(");
- } else {
- sb.append(", ");
- }
- if (a instanceof PluginNode) {
- parms[index] = node;
- sb.append("Node=").append(node.getName());
- } else if (a instanceof PluginConfiguration) {
- parms[index] = this;
- if (this.name != null) {
- sb.append("Configuration(").append(name).append(")");
- } else {
- sb.append("Configuration");
- }
- } else if (a instanceof PluginValue) {
- String name = ((PluginValue) a).value();
- String v = node.getValue();
- if (v == null) {
- v = getAttrValue("value", attrs);
- }
- String value = subst.replace(event, v);
- sb.append(name).append("=\"").append(value).append("\"");
- parms[index] = value;
- } else if (a instanceof PluginAttr) {
- String name = ((PluginAttr) a).value();
- String value = subst.replace(event, getAttrValue(name, attrs));
- sb.append(name).append("=\"").append(value).append("\"");
- parms[index] = value;
- } else if (a instanceof PluginElement) {
- PluginElement elem = (PluginElement) a;
- String name = elem.value();
- if (parmClasses[index].isArray()) {
- Class parmClass = parmClasses[index].getComponentType();
- List<Object> list = new ArrayList<Object>();
- sb.append(name).append("={");
- boolean first = true;
- for (Node child : children) {
- PluginType childType = child.getType();
- if (elem.value().equalsIgnoreCase(childType.getElementName()) ||
- parmClass.isAssignableFrom(childType.getPluginClass())) {
- used.add(child);
- if (!first) {
- sb.append(", ");
- }
- first = false;
- Object obj = child.getObject();
- if (obj == null) {
- System.out.println("Null object returned for " + child.getName());
- }
- if (obj.getClass().isArray()) {
- printArray(sb, (Object[]) obj);
- parms[index] = obj;
- break;
- }
- sb.append(child.toString());
- list.add(obj);
- }
- }
- sb.append("}");
- if (parms[index] != null) {
- break;
- }
- Object[] array = (Object[]) Array.newInstance(parmClass, list.size());
- int i = 0;
- for (Object obj : list) {
- array[i] = obj;
- ++i;
- }
- parms[index] = array;
- } else {
- Class parmClass = parmClasses[index];
- boolean present = false;
- for (Node child : children) {
- PluginType childType = child.getType();
- if (elem.value().equals(childType.getElementName()) ||
- parmClass.isAssignableFrom(childType.getPluginClass())) {
- sb.append(child.getName()).append("(").append(child.toString()).append(")");
- present = true;
- used.add(child);
- parms[index] = child.getObject();
- break;
- }
- }
- if (!present) {
- sb.append("null");
- }
- }
- }
- }
- ++index;
- }
- if (sb.length() > 0) {
- sb.append(")");
- }
-
- if (attrs.size() > 0) {
- StringBuilder eb = new StringBuilder();
- for (String key : attrs.keySet()) {
- if (eb.length() == 0) {
- eb.append(node.getName());
- eb.append(" contains ");
- if (attrs.size() == 1) {
- eb.append("an invalid element or attribute ");
- } else {
- eb.append("invalid attributes ");
- }
- } else {
- eb.append(", ");
- }
- eb.append("\"");
- eb.append(key);
- eb.append("\"");
-
- }
- LOGGER.error(eb.toString());
- }
-
- if (!type.isDeferChildren() && used.size() != children.size()) {
- for (Node child : children) {
- if (used.contains(child)) {
- continue;
- }
- String nodeType = node.getType().getElementName();
- String start = nodeType.equals(node.getName()) ? node.getName() : nodeType + " " + node.getName();
- LOGGER.error(start + " has no parameter that matches element " + child.getName());
- }
- }
-
- try {
- int mod = factoryMethod.getModifiers();
- if (!Modifier.isStatic(mod)) {
- LOGGER.error(factoryMethod.getName() + " method is not static on class " +
- clazz.getName() + " for element " + node.getName());
- return null;
- }
- LOGGER.debug("Calling {} on class {} for element {}", factoryMethod.getName(), clazz.getName(),
- node.getName(), sb.toString());
- //if (parms.length > 0) {
- return factoryMethod.invoke(null, parms);
- //}
- //return factoryMethod.invoke(null, node);
- } catch (Exception e) {
- LOGGER.error("Unable to invoke method " + factoryMethod.getName() + " in class " +
- clazz.getName() + " for element " + node.getName(), e);
- }
- return null;
- }
-
- private void printArray(StringBuilder sb, Object[] array) {
- boolean first = true;
- for (Object obj : array) {
- if (!first) {
- sb.append(", ");
- }
- sb.append(obj.toString());
- first = false;
- }
- }
-
- private String getAttrValue(String name, Map<String, String> attrs) {
- for (String key : attrs.keySet()) {
- if (key.equalsIgnoreCase(name)) {
- String attr = attrs.get(key);
- attrs.remove(key);
- return attr;
- }
- }
- return null;
- }
-
- private void setParents() {
- for (Map.Entry<String, LoggerConfig> entry : loggers.entrySet()) {
- LoggerConfig logger = entry.getValue();
- String name = entry.getKey();
- if (!name.equals("")) {
- int i = name.lastIndexOf(".");
- if (i > 0) {
- name = name.substring(0, i);
- LoggerConfig parent = getLoggerConfig(name);
- if (parent == null) {
- parent = root;
- }
- logger.setParent(parent);
- }
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
deleted file mode 100644
index b9280d0..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.filter.Filtering;
-import org.apache.logging.log4j.core.lookup.StrSubstitutor;
-
-import java.util.Map;
-
-/**
- * Interface that must be implemented to create a configuration.
- */
-public interface Configuration extends Filtering {
-
- /**
- * Return the configuration name.
- * @return the name of the configuration.
- */
- String getName();
-
- /**
- * Locates the appropriate LoggerConfig for a Logger name. This will remove tokens from the
- * package name as necessary or return the root LoggerConfig if no other matches were found.
- * @param name The Logger name.
- * @return The located LoggerConfig.
- */
- LoggerConfig getLoggerConfig(String name);
-
- /**
- * Return a Map containing all the Appenders and their name.
- * @return A Map containing each Appender's naem and the Appender object.
- */
- Map<String, Appender> getAppenders();
-
- Map<String, LoggerConfig> getLoggers();
-
- void addLoggerAppender(Logger logger, Appender appender);
-
- void addLoggerFilter(Logger logger, Filter filter);
-
- void setLoggerAdditive(Logger logger, boolean additive);
-
- void start();
-
- void stop();
-
- void addListener(ConfigurationListener listener);
-
- void removeListener(ConfigurationListener listener);
-
- StrSubstitutor getSubst();
-
- void createConfiguration(Node node, LogEvent event);
-
- Object getComponent(String name);
-
- void addComponent(String name, Object object);
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationException.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationException.java
deleted file mode 100644
index c7cd58a..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-/**
- *
- */
-public class ConfigurationException extends RuntimeException {
-
- public ConfigurationException(String msg) {
- super(msg);
- }
-
- public ConfigurationException(String msg, Exception ex) {
- super(msg, ex);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
deleted file mode 100644
index 98f9fe2..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.plugins.PluginManager;
-import org.apache.logging.log4j.core.config.plugins.PluginType;
-import org.apache.logging.log4j.core.helpers.FileUtils;
-import org.apache.logging.log4j.core.helpers.Loader;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.xml.sax.InputSource;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * ConfigurationFactory allows the configuration implementation to be dynamically chosen in 1
- * of 3 ways:
- * 1. A system property named "log4j.configurationFactory" can be set with the name of the
- * ConfigurationFactory to be used.
- * 2. setConfigurationFactory can be called with the instance of the ConfigurationFactory to
- * be used. This must be called before any other calls to Log4j.
- * 3. A ConfigurationFactory implementation can be added to the classpath and configured as a
- * plugin. The Order annotation should be used to configure the factory to be the first one
- * inspected. See XMLConfigurationFactory for an example.
- *
- * If the ConfigurationFactory that was added returns null on a call to getConfiguration the
- * any other ConfigurationFactories found as plugins will be called in their respective order.
- * DefaultConfiguration is always called last if no configuration has been returned.
- */
-public abstract class ConfigurationFactory {
- /**
- * Allow the ConfigurationFactory class to be specified as a system property.
- */
- public static final String CONFIGURATION_FACTORY_PROPERTY = "log4j.configurationFactory";
-
- /**
- * Allow the location of the configuration file to be specified as a system property.
- */
- public static final String CONFIGURATION_FILE_PROPERTY = "log4j.configurationFile";
-
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
-
- /**
- * File name prefix for test configurations.
- */
- protected static final String TEST_PREFIX = "log4j2-test";
-
- /**
- * File name prefix for standard configurations.
- */
- protected static final String DEFAULT_PREFIX = "log4j2";
-
- private static List<ConfigurationFactory> factories = new ArrayList<ConfigurationFactory>();
-
- private static ConfigurationFactory configFactory = new Factory();
-
- /**
- * The configuration File.
- */
- protected File configFile = null;
-
- /**
- * Return the ConfigurationFactory.
- * @return the ConfigurationFactory.
- */
- public static ConfigurationFactory getInstance() {
- String factoryClass = System.getProperty(CONFIGURATION_FACTORY_PROPERTY);
- if (factoryClass != null) {
- addFactory(factoryClass);
- }
- PluginManager manager = new PluginManager("ConfigurationFactory");
- manager.collectPlugins();
- Map<String, PluginType> plugins = manager.getPlugins();
- Set<WeightedFactory> ordered = new TreeSet<WeightedFactory>();
- for (PluginType type : plugins.values()) {
- try {
- Class<ConfigurationFactory> clazz = type.getPluginClass();
- Order o = clazz.getAnnotation(Order.class);
- Integer weight = o.value();
- if (o != null) {
- ordered.add(new WeightedFactory(weight, clazz));
- }
- } catch (Exception ex) {
- LOGGER.warn("Unable to add class " + type.getPluginClass());
- }
- }
- for (WeightedFactory wf : ordered) {
- addFactory(wf.factoryClass);
- }
- return configFactory;
- }
-
- private static void addFactory(String factoryClass) {
- try {
- Class clazz = Class.forName(factoryClass);
- addFactory(clazz);
- } catch (ClassNotFoundException ex) {
- LOGGER.error("Unable to load class " + factoryClass, ex);
- } catch (Exception ex) {
- LOGGER.error("Unable to load class " + factoryClass, ex);
- }
- }
-
- private static void addFactory(Class factoryClass) {
- try {
- factories.add((ConfigurationFactory) factoryClass.newInstance());
- } catch (Exception ex) {
- LOGGER.error("Unable to create instance of " + factoryClass.getName(), ex);
- }
- }
-
- /**
- * Set the configuration factory.
- * @param factory the ConfigurationFactory.
- */
- public static void setConfigurationFactory(ConfigurationFactory factory) {
- configFactory = factory;
- }
-
- /**
- * Reset the ConfigurationFactory to the default.
- */
- public static void resetConfigurationFactory() {
- configFactory = new Factory();
- }
-
- /**
- * Remove the ConfigurationFactory.
- * @param factory The factory to remove.
- */
- public static void removeConfigurationFactory(ConfigurationFactory factory) {
- factories.remove(factory);
- }
-
- protected abstract String[] getSupportedTypes();
-
- protected boolean isActive() {
- return true;
- }
-
- public abstract Configuration getConfiguration(InputSource source);
-
- /**
- * Return the Configuration.
- * @param name The configuration name.
- * @param configLocation The configuration location.
- * @return The Configuration.
- */
- public Configuration getConfiguration(String name, URI configLocation) {
- if (!isActive()) {
- return null;
- }
- if (configLocation != null) {
- InputSource source = getInputFromURI(configLocation);
- if (source != null) {
- return getConfiguration(source);
- }
- }
- return null;
- }
-
- protected InputSource getInputFromURI(URI configLocation) {
- configFile = FileUtils.fileFromURI(configLocation);
- if (configFile != null && configFile.exists() && configFile.canRead()) {
- try {
- InputSource source = new InputSource(new FileInputStream(configFile));
- source.setSystemId(configLocation.getPath());
- return source;
- } catch (FileNotFoundException ex) {
- LOGGER.error("Cannot locate file " + configLocation.getPath(), ex);
- }
- }
- try {
- InputSource source = new InputSource(configLocation.toURL().openStream());
- source.setSystemId(configLocation.getPath());
- return source;
- } catch (MalformedURLException ex) {
- LOGGER.error("Invalid URL " + configLocation.toString(), ex);
- } catch (IOException ex) {
- LOGGER.error("Unable to access " + configLocation.toString(), ex);
- }
- return null;
- }
-
- protected InputSource getInputFromString(ClassLoader loader, String configFile) {
- InputSource source;
- try {
- URL url = new URL(configFile);
- source = new InputSource(url.openStream());
- source.setSystemId(configFile);
- return source;
- } catch (Exception ex) {
- source = getInputFromResource(configFile, loader);
- if (source == null) {
- try {
- InputStream is = new FileInputStream(configFile);
- source = new InputSource(is);
- source.setSystemId(configFile);
- } catch (FileNotFoundException fnfe) {
- // Ignore the exception
- }
- }
- }
- return source;
- }
-
- protected InputSource getInputFromResource(String resource, ClassLoader loader) {
- InputStream is = Loader.getResourceAsStream(resource, loader);
- if (is == null) {
- return null;
- }
- InputSource source = new InputSource(is);
- source.setSystemId(resource);
- return source;
- }
-
- /**
- * Factory that chooses a ConfigurationFactory based on weighting.
- */
- private static class WeightedFactory implements Comparable<WeightedFactory> {
- private int weight;
- private Class<ConfigurationFactory> factoryClass;
-
- /**
- * Constructor.
- * @param weight The weight.
- * @param clazz The class.
- */
- public WeightedFactory(int weight, Class<ConfigurationFactory> clazz) {
- this.weight = weight;
- this.factoryClass = clazz;
- }
-
- public int compareTo(WeightedFactory wf) {
- int w = wf.weight;
- if (weight == w) {
- return 0;
- } else if (weight > w) {
- return -1;
- } else {
- return 1;
- }
- }
- }
-
- /**
- * Default Factory.
- */
- private static class Factory extends ConfigurationFactory {
-
- /**
- * Default Factory Constructor.
- * @param name The configuration name.
- * @param configLocation The configuration location.
- * @return The Configuration.
- */
- public Configuration getConfiguration(String name, URI configLocation) {
-
- if (configLocation == null) {
- String config = System.getProperty(CONFIGURATION_FILE_PROPERTY);
- if (config != null) {
- ClassLoader loader = this.getClass().getClassLoader();
- InputSource source = getInputFromString(loader, config);
- if (source != null) {
- for (ConfigurationFactory factory : factories) {
- String[] types = factory.getSupportedTypes();
- if (types != null) {
- for (String type : types) {
- if (type.equals("*") || config.endsWith(type)) {
- Configuration c = factory.getConfiguration(source);
- if (c != null) {
- return c;
- }
- }
- }
- }
- }
- }
- }
- } else {
- for (ConfigurationFactory factory : factories) {
- Configuration config = factory.getConfiguration(name, configLocation);
- if (config != null) {
- return config;
- }
- }
- }
-
- Configuration config = getConfiguration(true, name);
- if (config == null) {
- config = getConfiguration(true, null);
- if (config == null) {
- config = getConfiguration(false, name);
- if (config == null) {
- config = getConfiguration(false, null);
- }
- }
- }
- return config != null ? config : new DefaultConfiguration();
- }
-
- private Configuration getConfiguration(boolean isTest, String name) {
- boolean named = (name != null && name.length() > 0);
- ClassLoader loader = this.getClass().getClassLoader();
- for (ConfigurationFactory factory : factories) {
- String configName;
- String prefix = isTest ? TEST_PREFIX : DEFAULT_PREFIX;
- String [] types = factory.getSupportedTypes();
- if (types == null) {
- continue;
- }
-
- for (String suffix : types) {
- if (suffix.equals("*")) {
- continue;
- }
- configName = named ? prefix + name + suffix : prefix + suffix;
-
- InputSource source = getInputFromResource(configName, loader);
- if (source != null) {
- return factory.getConfiguration(source);
- }
- }
- }
- return null;
- }
-
- public String[] getSupportedTypes() {
- return null;
- }
-
- public Configuration getConfiguration(InputSource source) {
- return null;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationListener.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationListener.java
deleted file mode 100644
index 2c1a301..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-/**
- * Interface used to allow components to be notified when the configuration changes.
- */
-public interface ConfigurationListener {
-
- void onChange();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationMonitor.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationMonitor.java
deleted file mode 100644
index baf97b2..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationMonitor.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-/**
- * Interface that must be implemented to provide notification of configuration changes.
- */
-public interface ConfigurationMonitor {
-
- /**
- * Called to determine if the configuration has changed.
- */
- void checkConfiguration();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java
deleted file mode 100644
index e2df1d5..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-
-/**
- * The default configuration. It writes all output to the Console using the default logging level
- * that is configured by setting the "org.apache.logging.log4j.level" system property or the ERROR
- * Level if the system property is not specified. Log Events will be printed using the basic
- * formatting provided by each Message.
- */
-public class DefaultConfiguration extends BaseConfiguration {
-
- /**
- * The name of the default configuration.
- */
- public static final String DEFAULT_NAME = "Default";
- /**
- * The System Proerty used to specify the logging level.
- */
- public static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";
-
- /**
- * Constructor to create the default configuration.
- */
- public DefaultConfiguration() {
-
- setName(DEFAULT_NAME);
- Layout layout = PatternLayout.createLayout("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n",
- null, null, null);
- Appender appender = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT", "Console", "true");
- addAppender(appender);
- LoggerConfig root = getRootLogger();
- root.addAppender(appender);
-
- String l = System.getProperty(DEFAULT_LEVEL);
- Level level = (l != null && Level.valueOf(l) != null) ? Level.valueOf(l) : Level.ERROR;
- root.setLevel(level);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfigurationMonitor.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfigurationMonitor.java
deleted file mode 100644
index 7a46b2d..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfigurationMonitor.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-/**
- *
- */
-public class DefaultConfigurationMonitor implements ConfigurationMonitor {
-
- public void checkConfiguration() {
-
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/FileConfigurationMonitor.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/FileConfigurationMonitor.java
deleted file mode 100644
index 2c67731..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/FileConfigurationMonitor.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import java.io.File;
-import java.util.List;
-
-/**
- * Configuration monitor that periodically checks the timestamp of the configuration file and calls the
- * ConfigurationListeners when an update occurs.
- */
-public class FileConfigurationMonitor implements ConfigurationMonitor {
-
- private static final int MASK = 0x0f;
-
- private static final int MIN_INTERVAL = 30;
-
- private static final int MILLIS_PER_SECOND = 1000;
-
- private final File file;
-
- private long lastModified;
-
- private final List<ConfigurationListener> listeners;
-
- private final int interval;
-
- private long nextCheck;
-
- private volatile int counter = 0;
-
- /**
- * Constructor.
- * @param file The File to monitor.
- * @param listeners The List of ConfigurationListeners to notify upon a change.
- * @param interval The monitor interval in seconds. The minimum interval is 30 seconds.
- */
- public FileConfigurationMonitor(File file, List<ConfigurationListener> listeners, int interval) {
- this.file = file;
- this.lastModified = file.lastModified();
- this.listeners = listeners;
- this.interval = (interval < MIN_INTERVAL ? MIN_INTERVAL : interval) * MILLIS_PER_SECOND;
- this.nextCheck = System.currentTimeMillis() + interval;
- }
-
- /**
- * Called to determine if the configuration has changed.
- */
- public void checkConfiguration() {
- if ((++counter & MASK) == 0) {
- synchronized (this) {
- long current = System.currentTimeMillis();
- if (current >= nextCheck) {
- nextCheck = current + interval;
- if (lastModified >= file.lastModified()) {
- lastModified = file.lastModified();
- for (ConfigurationListener listener : listeners) {
- listener.onChange();
- }
- }
- }
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
deleted file mode 100644
index bc2601d..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.config.plugins.PluginManager;
-import org.apache.logging.log4j.core.config.plugins.PluginType;
-import org.apache.logging.log4j.core.config.plugins.ResolverUtil;
-import org.apache.logging.log4j.status.StatusConsoleListener;
-import org.apache.logging.log4j.status.StatusListener;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.JsonParser;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.xml.sax.InputSource;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Creates a Node hierarchy from a JSON file.
- */
-public class JSONConfiguration extends BaseConfiguration {
-
- private static final String[] VERBOSE_CLASSES = new String[] {ResolverUtil.class.getName()};
-
- private static final int BUF_SIZE = 16384;
-
- private List<Status> status = new ArrayList<Status>();
-
- private JsonNode root;
-
- public JSONConfiguration(InputSource source, File configFile) {
- byte[] buffer;
-
- try {
- buffer = toByteArray(source.getByteStream());
- InputStream is = new ByteArrayInputStream(buffer);
- source = new InputSource(is);
- ObjectMapper mapper = new ObjectMapper().configure(JsonParser.Feature.ALLOW_COMMENTS, true);
- root = mapper.readTree(is);
- if (root.size() == 1) {
- Iterator<JsonNode> i = root.getElements();
- root = i.next();
- }
- processAttributes(rootNode, root);
- Level status = Level.OFF;
- boolean verbose = false;
- for (Map.Entry<String, String> entry : rootNode.getAttributes().entrySet()) {
- if ("status".equalsIgnoreCase(entry.getKey())) {
- status = Level.toLevel(entry.getValue().toUpperCase(), Level.OFF);
- } else if ("verbose".equalsIgnoreCase(entry.getKey())) {
- verbose = Boolean.parseBoolean(entry.getValue());
- } else if ("packages".equalsIgnoreCase(entry.getKey())) {
- String[] packages = entry.getValue().split(",");
- for (String p : packages) {
- PluginManager.addPackage(p);
- }
- } else if ("name".equalsIgnoreCase(entry.getKey())) {
- setName(entry.getValue());
- } else if ("monitorInterval".equalsIgnoreCase(entry.getKey())) {
- int interval = Integer.parseInt(entry.getValue());
- if (interval > 0 && configFile != null) {
- monitor = new FileConfigurationMonitor(configFile, listeners, interval);
- }
- }
- }
-
- Iterator<StatusListener> statusIter = ((StatusLogger) LOGGER).getListeners();
- boolean found = false;
- while (statusIter.hasNext()) {
- StatusListener listener = statusIter.next();
- if (listener instanceof StatusConsoleListener) {
- found = true;
- ((StatusConsoleListener) listener).setLevel(status);
- if (!verbose) {
- ((StatusConsoleListener) listener).setFilters(VERBOSE_CLASSES);
- }
- }
- }
- if (!found && status != Level.OFF) {
- StatusConsoleListener listener = new StatusConsoleListener(status);
- if (!verbose) {
- listener.setFilters(VERBOSE_CLASSES);
- }
- ((StatusLogger) LOGGER).registerListener(listener);
- }
- if (getName() == null) {
- setName(source.getSystemId());
- }
- } catch (Exception ex) {
- LOGGER.error("Error parsing " + source.getSystemId(), ex);
- ex.printStackTrace();
- }
- }
-
- public void setup() {
- Iterator<Map.Entry<String, JsonNode>> iter = root.getFields();
- List<Node> children = rootNode.getChildren();
- while (iter.hasNext()) {
- Map.Entry<String, JsonNode> entry = iter.next();
- JsonNode n = entry.getValue();
- if (n.isObject()) {
- LOGGER.debug("Processing node for object " + entry.getKey());
- children.add(constructNode(entry.getKey(), rootNode, n));
- } else if (n.isArray()) {
- LOGGER.error("Arrays are not supported at the root configuration.");
- }
- }
- LOGGER.debug("Completed parsing configuration");
- if (status.size() > 0) {
- for (Status s : status) {
- LOGGER.error("Error processing element " + s.name + ": " + s.errorType);
- }
- return;
- }
- }
-
- private Node constructNode(String name, Node parent, JsonNode jsonNode) {
- PluginType type = getPluginManager().getPluginType(name);
- Node node = new Node(parent, name, type);
- processAttributes(node, jsonNode);
- Iterator<Map.Entry<String, JsonNode>> iter = jsonNode.getFields();
- List<Node> children = node.getChildren();
- while (iter.hasNext()) {
- Map.Entry<String, JsonNode> entry = iter.next();
- JsonNode n = entry.getValue();
- if (n.isArray() || n.isObject()) {
- if (type == null) {
- status.add(new Status(name, n, ErrorType.CLASS_NOT_FOUND));
- }
- if (n.isArray()) {
- LOGGER.debug("Processing node for array " + entry.getKey());
- for (int i = 0; i < n.size(); ++i) {
- String pluginType = getType(n.get(i), entry.getKey());
- PluginType entryType = getPluginManager().getPluginType(pluginType);
- Node item = new Node(node, entry.getKey(), entryType);
- processAttributes(item, n.get(i));
- if (pluginType.equals(entry.getKey())) {
- LOGGER.debug("Processing " + entry.getKey() + "[" + i + "]");
- } else {
- LOGGER.debug("Processing " + pluginType + " " + entry.getKey() + "[" + i + "]");
- }
- Iterator<Map.Entry<String, JsonNode>> itemIter = n.get(i).getFields();
- List<Node> itemChildren = item.getChildren();
- while (itemIter.hasNext()) {
- Map.Entry<String, JsonNode> itemEntry = itemIter.next();
- if (itemEntry.getValue().isObject()) {
- LOGGER.debug("Processing node for object " + itemEntry.getKey());
- itemChildren.add(constructNode(itemEntry.getKey(), item, itemEntry.getValue()));
- }
- }
- children.add(item);
- }
- } else {
- LOGGER.debug("Processing node for object " + entry.getKey());
- children.add(constructNode(entry.getKey(), node, n));
- }
- }
- }
-
- String t;
- if (type == null) {
- t = "null";
- } else {
- t = type.getElementName() + ":" + type.getPluginClass();
- }
-
- String p = node.getParent() == null ? "null" : node.getParent().getName() == null ?
- "root" : node.getParent().getName();
- LOGGER.debug("Returning " + node.getName() + " with parent " + p + " of type " + t);
- return node;
- }
-
- private String getType(JsonNode node, String name) {
- Iterator<Map.Entry<String, JsonNode>> iter = node.getFields();
- while (iter.hasNext()) {
- Map.Entry<String, JsonNode> entry = iter.next();
- if (entry.getKey().equalsIgnoreCase("type")) {
- JsonNode n = entry.getValue();
- if (n.isValueNode()) {
- return n.asText();
- }
- }
- }
- return name;
- }
-
- private void processAttributes(Node parent, JsonNode node) {
- Map<String, String> attrs = parent.getAttributes();
- Iterator<Map.Entry<String, JsonNode>> iter = node.getFields();
- while (iter.hasNext()) {
- Map.Entry<String, JsonNode> entry = iter.next();
- if (!entry.getKey().equalsIgnoreCase("type")) {
- JsonNode n = entry.getValue();
- if (n.isValueNode()) {
- attrs.put(entry.getKey(), n.asText());
- }
- }
- }
- }
-
- protected byte[] toByteArray(InputStream is) throws IOException {
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-
- int nRead;
- byte[] data = new byte[BUF_SIZE];
-
- while ((nRead = is.read(data, 0, data.length)) != -1) {
- buffer.write(data, 0, nRead);
- }
-
- return buffer.toByteArray();
- }
-
- /**
- * The error that occurred.
- */
- private enum ErrorType {
- CLASS_NOT_FOUND
- }
-
- /**
- * Status for recording errors.
- */
- private class Status {
- private JsonNode node;
- private String name;
- private ErrorType errorType;
-
- public Status(String name, JsonNode node, ErrorType errorType) {
- this.name = name;
- this.node = node;
- this.errorType = errorType;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfigurationFactory.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfigurationFactory.java
deleted file mode 100644
index 79ee800..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfigurationFactory.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.xml.sax.InputSource;
-
-import java.io.File;
-
-/**
- *
- */
-@Plugin(name = "JSONConfigurationFactory", type = "ConfigurationFactory")
-@Order(6)
-public class JSONConfigurationFactory extends ConfigurationFactory {
-
- /**
- * The file extensions supported by this factory.
- */
- public static final String[] SUFFIXES = new String[] {".json", ".jsn"};
-
- private static String[] dependencies = new String[] {
- "org.codehaus.jackson.JsonNode",
- "org.codehaus.jackson.map.ObjectMapper"
- };
-
- private File configFile = null;
-
- private boolean isActive;
-
- public JSONConfigurationFactory() {
- try {
- for (String item : dependencies) {
- Class.forName(item);
- }
- } catch (ClassNotFoundException ex) {
- LOGGER.debug("Missing dependencies for Json support");
- isActive = false;
- return;
- }
- isActive = true;
- }
-
- @Override
- protected boolean isActive() {
- return isActive;
- }
-
- public Configuration getConfiguration(InputSource source) {
- if (!isActive) {
- return null;
- }
- return new JSONConfiguration(source, configFile);
- }
-
- public String[] getSupportedTypes() {
- return SUFFIXES;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
deleted file mode 100644
index fdb31e9..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.filter.Filterable;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.LogEventFactory;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.message.Message;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Logger object that is created via configuration.
- */
-@Plugin(name = "logger", type = "Core", printObject = true)
-public class LoggerConfig extends Filterable implements LogEventFactory {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private List<String> appenderRefs = new ArrayList<String>();
- private Map<String, AppenderControl> appenders = new ConcurrentHashMap<String, AppenderControl>();
- private final String name;
- private LogEventFactory logEventFactory;
- private Level level;
- private boolean additive = true;
- private LoggerConfig parent;
- private ConfigurationMonitor monitor = new DefaultConfigurationMonitor();
-
- /**
- * Default constructor.
- */
- public LoggerConfig() {
- this.logEventFactory = this;
- this.level = Level.ERROR;
- this.name = "";
- }
-
- /**
- * Constructor that sets the name, level and additive values.
- * @param name The Logger name.
- * @param level The Level.
- * @param additive true if the Logger is additive, false otherwise.
- */
- public LoggerConfig(String name, Level level, boolean additive) {
- this.logEventFactory = this;
- this.name = name;
- this.level = level;
- this.additive = additive;
- }
-
- protected LoggerConfig(String name, List<String> appenders, Filter filter, Level level,
- boolean additive) {
- super(filter);
- this.logEventFactory = this;
- this.name = name;
- this.appenderRefs = appenders;
- this.level = level;
- this.additive = additive;
- }
-
- @Override
- public Filter getFilter() {
- monitor.checkConfiguration();
- return super.getFilter();
- }
-
- /**
- * Set the ConfigurationMonitor that will detect configuration changes.
- * @param monitor The ConfigurationMonitor.
- */
- public void setConfigurationMonitor(ConfigurationMonitor monitor) {
- this.monitor = monitor;
- }
-
- /**
- * Return the name of the LoggerConfig.
- * @return the name of the LoggerConfig.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Set the parent of this LoggerConfig.
- * @param parent the parent LoggerConfig.
- */
- public void setParent(LoggerConfig parent) {
- this.parent = parent;
- }
-
- /**
- * Return the parent of this LoggerConfig.
- * @return the LoggerConfig that is the parent of this one.
- */
- public LoggerConfig getParent() {
- return this.parent;
- }
-
- /**
- * Add an Appender to the LoggerConfig.
- * @param appender The Appender to add.
- */
- public void addAppender(Appender appender) {
- appenders.put(appender.getName(), new AppenderControl(appender));
- }
-
- /**
- * Remove the Appender with the specific name.
- * @param name The name of the Appender.
- */
- public void removeAppender(String name) {
- appenders.remove(name);
- }
-
- /**
- * Return all Appenders as a Map.
- * @return a Map with the Appender name as the key and the Appender as the value.
- */
- public Map<String, Appender> getAppenders() {
- Map<String, Appender> map = new HashMap<String, Appender>();
- for (Map.Entry<String, AppenderControl> entry : appenders.entrySet()) {
- map.put(entry.getKey(), entry.getValue().getAppender());
- }
- return map;
- }
-
- /**
- * Remove all Appenders.
- */
- protected void clearAppenders() {
- appenders.clear();
- }
-
- /**
- * Return the Appender references.
- * @return a List of all the Appender names attached to this LoggerConfig.
- */
- public List<String> getAppenderRefs() {
- return appenderRefs;
- }
-
- /**
- * Set the logging Level.
- * @param level The logging Level.
- */
- public void setLevel(Level level) {
- this.level = level;
- }
-
- /**
- * Return the logging Level.
- * @return the logging Level.
- */
- public Level getLevel() {
- return level;
- }
-
- /**
- * Return the LogEventFactory.
- * @return the LogEventFactory.
- */
- public LogEventFactory getLogEventFactory() {
- return logEventFactory;
- }
-
- /**
- * Set the LogEventFactory. Usually the LogEventFactory will be this LoggerConfig.
- * @param logEventFactory the LogEventFactory.
- */
- public void setLogEventFactory(LogEventFactory logEventFactory) {
- this.logEventFactory = logEventFactory;
- }
-
- /**
- * Return the valid of the additive flag.
- * @return true if the LoggerConfig is additive, false otherwise.
- */
- public boolean isAdditive() {
- return additive;
- }
-
- /**
- * Set the additive setting.
- * @param additive true if thee LoggerConfig should be additive, false otherwise.
- */
- public void setAdditive(boolean additive) {
- this.additive = additive;
- }
-
- /**
- * Log an event.
- * @param loggerName The name of the Logger.
- * @param marker A Marker or null if none is present.
- * @param fqcn The fully qualified class name of the caller.
- * @param level The event Level.
- * @param data The Message.
- * @param t A Throwable or null.
- */
- public void log(String loggerName, Marker marker, String fqcn, Level level, Message data, Throwable t) {
- LogEvent event = logEventFactory.createEvent(loggerName, marker, fqcn, level, data, t);
- log(event);
- }
-
- /**
- * Logs an event.
- * @param event Yhe log event.
- */
- public void log(LogEvent event) {
- monitor.checkConfiguration();
- if (isFiltered(event)) {
- return;
- }
-
- callAppenders(event);
-
- if (additive && parent != null) {
- parent.log(event);
- }
- }
-
- private void callAppenders(LogEvent event) {
- for (AppenderControl control : appenders.values()) {
- control.callAppender(event);
- }
- }
-
- /**
- * Create a log event.
- * @param loggerName The name of the Logger.
- * @param marker An optional Marker.
- * @param fqcn The fully qualified class name of the caller.
- * @param level The event Level.
- * @param data The Message.
- * @param t An optional Throwable.
- * @return The LogEvent.
- */
- public LogEvent createEvent(String loggerName, Marker marker, String fqcn, Level level, Message data,
- Throwable t) {
- return new Log4jLogEvent(loggerName, marker, fqcn, level, data, t);
- }
-
- @Override
- public String toString() {
- return name == null || name.length() == 0 ? "root" : name;
- }
-
- /**
- * Factory method to create a LoggerConfig.
- * @param additivity True if additive, false otherwise.
- * @param loggerLevel The Level to be associated with the Logger.
- * @param loggerName The name of the Logger.
- * @param refs An array of Appender names.
- * @param filter A Filter.
- * @return A new LoggerConfig.
- */
- @PluginFactory
- public static LoggerConfig createLogger(@PluginAttr("additivity") String additivity,
- @PluginAttr("level") String loggerLevel,
- @PluginAttr("name") String loggerName,
- @PluginElement("appender-ref") String[] refs,
- @PluginElement("filters") Filter filter) {
- if (loggerName == null) {
- LOGGER.error("Loggers cannot be configured without a name");
- return null;
- }
-
- List<String> appenderRefs = Arrays.asList(refs);
- Level level = loggerLevel == null ? Level.ERROR : Level.valueOf(loggerLevel.toUpperCase());
- String name = loggerName.equals("root") ? "" : loggerName;
- boolean additive = additivity == null ? true : Boolean.parseBoolean(additivity);
-
- return new LoggerConfig(name, appenderRefs, filter, level, additive);
- }
-
- /**
- * The root Logger.
- */
- @Plugin(name = "root", type = "Core", printObject = true)
- public static class RootLogger extends LoggerConfig {
-
- @PluginFactory
- public static LoggerConfig createLogger(@PluginAttr("additivity") String additivity,
- @PluginAttr("level") String loggerLevel,
- @PluginElement("appender-ref") String[] refs,
- @PluginElement("filters") Filter filter) {
- List<String> appenderRefs = Arrays.asList(refs);
- Level level = loggerLevel == null ? Level.ERROR : Level.valueOf(loggerLevel.toUpperCase());
- boolean additive = additivity == null ? true : Boolean.parseBoolean(additivity);
-
- return new LoggerConfig(LogManager.ROOT_LOGGER_NAME, appenderRefs, filter, level, additive);
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Loggers.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Loggers.java
deleted file mode 100644
index 556b3f7..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Loggers.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import java.util.concurrent.ConcurrentMap;
-
-/**
- *
- */
-public class Loggers {
- private final ConcurrentMap<String, LoggerConfig> map;
- private final LoggerConfig root;
-
- public Loggers(ConcurrentMap map, LoggerConfig root) {
- this.map = map;
- this.root = root;
- }
-
- public ConcurrentMap<String, LoggerConfig> getMap() {
- return map;
- }
-
- public LoggerConfig getRoot() {
- return root;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Node.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Node.java
deleted file mode 100644
index 0bc4fb6..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Node.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.core.config.plugins.PluginType;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Represents a Configuration element.
- */
-
-public class Node {
-
- private Node parent;
- private String name;
- private String value;
- private PluginType type;
- private Map<String, String> attributes = new HashMap<String, String>();
- private List<Node> children = new ArrayList<Node>();
- private Object object;
-
-
- /**
- * Creates a new instance of <code>Node</code> and initializes it
- * with a name and the corresponding XML element.
- *
- * @param parent the node's parent.
- * @param name the node's name.
- * @param type The Plugin Type associated with the node.
- */
- public Node(Node parent, String name, PluginType type) {
- this.parent = parent;
- this.name = name;
- this.type = type;
- }
-
- public Node() {
- }
-
- public Map<String, String> getAttributes() {
- return attributes;
- }
-
- public List<Node> getChildren() {
- return children;
- }
-
- public boolean hasChildren() {
- return children.size() > 0;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public Node getParent() {
- return parent;
- }
-
- public String getName() {
- return name;
- }
-
- public boolean isRoot() {
- return parent == null;
- }
-
- public void setObject(Object obj) {
- object = obj;
- }
-
- public Object getObject() {
- return object;
- }
-
- public PluginType getType() {
- return type;
- }
-
- @Override
- public String toString() {
- return type.isObjectPrintable() ? object.toString() :
- type.getPluginClass().getName() + " with name " + name;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/NullConfiguration.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/NullConfiguration.java
deleted file mode 100644
index 7fc6151..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/NullConfiguration.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.Level;
-
-/**
- * This configuration defaults to no logging.
- */
-public class NullConfiguration extends BaseConfiguration {
-
- private static final String NULL_NAME = "Null";
-
- public NullConfiguration() {
-
- setName(NULL_NAME);
- LoggerConfig root = getRootLogger();
- root.setLevel(Level.OFF);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Order.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Order.java
deleted file mode 100644
index eadc931..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Order.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Identifies the relative ordering of the Configuration.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface Order {
- int value();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Property.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Property.java
deleted file mode 100644
index 36fdf14..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Property.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.config.plugins.PluginValue;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Represents a key/value pair in the configuration.
- */
-@Plugin(name = "property", type = "Core", printObject = true)
-public final class Property {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private String name;
- private String value;
-
- private Property(String name, String value) {
- this.name = name;
- this.value = value;
- }
-
- /**
- * Return the property name.
- * @return the property name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Return the property value.
- * @return the value of the property.
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Create a Property.
- * @param key The key.
- * @param value The value.
- * @return A Property.
- */
- @PluginFactory
- public static Property createProperty(@PluginAttr("name") String key,
- @PluginValue("value") String value) {
- if (key == null) {
- LOGGER.error("Property key cannot be null");
- }
- return new Property(key, value);
- }
-
- @Override
- public String toString() {
- return name + "=" + value;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
deleted file mode 100644
index 1131ddf..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.config.plugins.PluginManager;
-import org.apache.logging.log4j.core.config.plugins.PluginType;
-import org.apache.logging.log4j.core.config.plugins.ResolverUtil;
-import org.apache.logging.log4j.status.StatusConsoleListener;
-import org.apache.logging.log4j.status.StatusListener;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Creates a Node hierarchy from an XML file.
- */
-public class XMLConfiguration extends BaseConfiguration {
-
- private static final String[] VERBOSE_CLASSES = new String[] {ResolverUtil.class.getName()};
-
- private static final String LOG4J_XSD = "Log4J-V2.0.xsd";
-
- private static final int BUF_SIZE = 16384;
-
- private List<Status> status = new ArrayList<Status>();
-
- private Element rootElement = null;
-
- private boolean strict = false;
-
- private String schema = null;
-
- private Validator validator;
-
- public XMLConfiguration(InputSource source, File configFile) {
- byte[] buffer = null;
-
- try {
- buffer = toByteArray(source.getByteStream());
- source = new InputSource(new ByteArrayInputStream(buffer));
- DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document document = builder.parse(source);
- rootElement = document.getDocumentElement();
- Map<String, String> attrs = processAttributes(rootNode, rootElement);
- Level status = Level.OFF;
- boolean verbose = false;
-
- for (Map.Entry<String, String> entry : attrs.entrySet()) {
- if ("status".equalsIgnoreCase(entry.getKey())) {
- status = Level.toLevel(entry.getValue().toUpperCase(), Level.OFF);
- } else if ("verbose".equalsIgnoreCase(entry.getKey())) {
- verbose = Boolean.parseBoolean(entry.getValue());
- } else if ("packages".equalsIgnoreCase(entry.getKey())) {
- String[] packages = entry.getValue().split(",");
- for (String p : packages) {
- PluginManager.addPackage(p);
- }
- } else if ("name".equalsIgnoreCase(entry.getKey())) {
- setName(entry.getValue());
- } else if ("strict".equalsIgnoreCase(entry.getKey())) {
- strict = Boolean.parseBoolean(entry.getValue());
- } else if ("schema".equalsIgnoreCase(entry.getKey())) {
- schema = entry.getValue();
- } else if ("monitorInterval".equalsIgnoreCase(entry.getKey())) {
- int interval = Integer.parseInt(entry.getValue());
- if (interval > 0 && configFile != null) {
- monitor = new FileConfigurationMonitor(configFile, listeners, interval);
- }
- }
- }
- Iterator<StatusListener> iter = ((StatusLogger) LOGGER).getListeners();
- boolean found = false;
- while (iter.hasNext()) {
- StatusListener listener = iter.next();
- if (listener instanceof StatusConsoleListener) {
- found = true;
- ((StatusConsoleListener) listener).setLevel(status);
- if (!verbose) {
- ((StatusConsoleListener) listener).setFilters(VERBOSE_CLASSES);
- }
- }
- }
- if (!found && status != Level.OFF) {
- StatusConsoleListener listener = new StatusConsoleListener(status);
- if (!verbose) {
- listener.setFilters(VERBOSE_CLASSES);
- }
- ((StatusLogger) LOGGER).registerListener(listener);
- }
-
- } catch (SAXException domEx) {
- LOGGER.error("Error parsing " + source.getSystemId(), domEx);
- } catch (IOException ioe) {
- LOGGER.error("Error parsing " + source.getSystemId(), ioe);
- } catch (ParserConfigurationException pex) {
- LOGGER.error("Error parsing " + source.getSystemId(), pex);
- }
- if (strict && schema != null && buffer != null) {
- InputStream is = null;
- try {
- is = getClass().getClassLoader().getResourceAsStream(schema);
- } catch (Exception ex) {
- LOGGER.error("Unable to access schema " + schema);
- }
- if (is != null) {
- Source src = new StreamSource(is, LOG4J_XSD);
- SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- Schema schema = null;
- try {
- schema = factory.newSchema(src);
- } catch (SAXException ex) {
- LOGGER.error("Error parsing Log4j schema", ex);
- }
- if (schema != null) {
- validator = schema.newValidator();
- try {
- validator.validate(new StreamSource(new ByteArrayInputStream(buffer)));
- } catch (IOException ioe) {
- LOGGER.error("Error reading configuration for validation", ioe);
- } catch (SAXException ex) {
- LOGGER.error("Error validating configuration", ex);
- }
- }
- }
- }
-
- if (getName() == null) {
- setName(source.getSystemId());
- }
- }
-
- public void setup() {
- constructHierarchy(rootNode, rootElement);
- if (status.size() > 0) {
- for (Status s : status) {
- LOGGER.error("Error processing element " + s.name + ": " + s.errorType);
- }
- return;
- }
- rootElement = null;
- }
-
- private void constructHierarchy(Node node, Element element) {
- processAttributes(node, element);
- StringBuffer buffer = new StringBuffer();
- NodeList list = element.getChildNodes();
- List<Node> children = node.getChildren();
- for (int i = 0; i < list.getLength(); i++) {
- org.w3c.dom.Node w3cNode = list.item(i);
- if (w3cNode instanceof Element) {
- Element child = (Element) w3cNode;
- String name = getType(child);
- PluginType type = getPluginManager().getPluginType(name);
- Node childNode = new Node(node, name, type);
- constructHierarchy(childNode, child);
- if (type == null) {
- String value = childNode.getValue();
- if (!childNode.hasChildren() && value != null) {
- node.getAttributes().put(name, value);
- } else {
- status.add(new Status(name, element, ErrorType.CLASS_NOT_FOUND));
- }
- } else {
- children.add(childNode);
- }
- } else if (w3cNode instanceof Text) {
- Text data = (Text) w3cNode;
- buffer.append(data.getData());
- }
- }
-
- String text = buffer.toString().trim();
- if (text.length() > 0 || (!node.hasChildren() && !node.isRoot())) {
- node.setValue(text);
- }
- }
-
- private String getType(Element element) {
- if (strict) {
- NamedNodeMap attrs = element.getAttributes();
- for (int i = 0; i < attrs.getLength(); ++i) {
- org.w3c.dom.Node w3cNode = attrs.item(i);
- if (w3cNode instanceof Attr) {
- Attr attr = (Attr) w3cNode;
- if (attr.getName().equalsIgnoreCase("type")) {
- String type = attr.getValue();
- attrs.removeNamedItem(attr.getName());
- return type;
- }
- }
- }
- }
- return element.getTagName();
- }
-
- private byte[] toByteArray(InputStream is) throws IOException {
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-
- int nRead;
- byte[] data = new byte[BUF_SIZE];
-
- while ((nRead = is.read(data, 0, data.length)) != -1) {
- buffer.write(data, 0, nRead);
- }
-
- return buffer.toByteArray();
- }
-
- private Map<String, String> processAttributes(Node node, Element element) {
- NamedNodeMap attrs = element.getAttributes();
- Map<String, String> attributes = node.getAttributes();
-
- for (int i = 0; i < attrs.getLength(); ++i) {
- org.w3c.dom.Node w3cNode = attrs.item(i);
- if (w3cNode instanceof Attr) {
- Attr attr = (Attr) w3cNode;
- attributes.put(attr.getName(), attr.getValue());
- }
- }
- return attributes;
- }
-
- /**
- * The error that occurred.
- */
- private enum ErrorType {
- CLASS_NOT_FOUND
- }
-
- /**
- * Status for recording errors.
- */
- private class Status {
- private Element element;
- private String name;
- private ErrorType errorType;
-
- public Status(String name, Element element, ErrorType errorType) {
- this.name = name;
- this.element = element;
- this.errorType = errorType;
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfigurationFactory.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfigurationFactory.java
deleted file mode 100644
index 7ff0b68..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfigurationFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.xml.sax.InputSource;
-
-/**
- * Factory to coonstruct an XMLConfiguration.
- */
-@Plugin(name = "XMLConfigurationFactory", type = "ConfigurationFactory")
-@Order(5)
-public class XMLConfigurationFactory extends ConfigurationFactory {
-
- /**
- * Valid file extensions for XML files.
- */
- public static final String[] SUFFIXES = new String[] {".xml", "*"};
-
- /**
- * Return the Configuration.
- * @param source The InputSource.
- * @return The Configuration.
- */
- public Configuration getConfiguration(InputSource source) {
- return new XMLConfiguration(source, configFile);
- }
-
- /**
- * Returns the file suffixes for XML files.
- * @return An array of File extensions.
- */
- public String[] getSupportedTypes() {
- return SUFFIXES;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/package-info.java
deleted file mode 100644
index 507ff7a..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Configuration of Log4j 2.0.
- */
-package org.apache.logging.log4j.core.config;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/AppenderRefPlugin.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/AppenderRefPlugin.java
deleted file mode 100644
index d79a6b4..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/AppenderRefPlugin.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * An Appender reference.
- */
-@Plugin(name = "appender-ref", type = "Core", printObject = true)
-public final class AppenderRefPlugin {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private AppenderRefPlugin() {
- }
-
- /**
- * Create an Appender reference.
- * @param ref The name of the Appender.
- * @return The name of the Appender.
- */
- @PluginFactory
- public static String createAppenderRef(@PluginAttr("ref") String ref) {
-
- if (ref == null) {
- LOGGER.error("Appender references must contain a reference");
- }
- return ref;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/AppendersPlugin.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/AppendersPlugin.java
deleted file mode 100644
index 1a55e04..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/AppendersPlugin.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import org.apache.logging.log4j.core.Appender;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * An Appender container.
- */
-@Plugin(name = "appenders", type = "Core")
-public final class AppendersPlugin {
-
- private AppendersPlugin() {
- }
-
- /**
- * Create a Map of the Appenders.
- * @param appenders An array of Appenders.
- * @return The Appender Map.
- */
- @PluginFactory
- public static ConcurrentMap<String, Appender> createAppenders(@PluginElement("appenders") Appender[] appenders) {
- ConcurrentMap<String, Appender> map = new ConcurrentHashMap<String, Appender>();
-
- for (Appender appender : appenders) {
- map.put(appender.getName(), appender);
- }
-
- return map;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/LoggersPlugin.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/LoggersPlugin.java
deleted file mode 100644
index e97b32c..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/LoggersPlugin.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.core.config.Loggers;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * Container of Logger objects.
- */
-@Plugin(name = "loggers", type = "Core")
-public final class LoggersPlugin {
-
- private LoggersPlugin() {
- }
-
- /**
- * Create a Loggers object to contain all the Loggers.
- * @param loggers An array of Loggers.
- * @return A Loggers object.
- */
- @PluginFactory
- public static Loggers createLoggers(@PluginElement("loggers") LoggerConfig[] loggers) {
- ConcurrentMap<String, LoggerConfig> loggerMap = new ConcurrentHashMap<String, LoggerConfig>();
- LoggerConfig root = null;
-
- for (LoggerConfig logger : loggers) {
- if (logger != null) {
- if (logger.getName().length() == 0) {
- root = logger;
- }
- loggerMap.put(logger.getName(), logger);
- }
- }
-
- return new Loggers(loggerMap, root);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/Plugin.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/Plugin.java
deleted file mode 100644
index 5984129..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/Plugin.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation that identifies a Class as a Plugin.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface Plugin {
- /**
- * Value of the elementType when none is specified.
- */
- String EMPTY = "";
-
- String name();
- String type();
- String elementType() default EMPTY;
- boolean printObject() default false;
- boolean deferChildren() default false;
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginAttr.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginAttr.java
deleted file mode 100644
index 4d54602..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginAttr.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Identifies a Plugin Attribute.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.PARAMETER)
-public @interface PluginAttr {
-
- String value();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginConfiguration.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginConfiguration.java
deleted file mode 100644
index efe2021..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginConfiguration.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Identifies a parameter as a Configuration.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.PARAMETER)
-public @interface PluginConfiguration {
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginElement.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginElement.java
deleted file mode 100644
index a72ca09..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginElement.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Identifies a parameter as an element.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.PARAMETER)
-public @interface PluginElement {
-
- String value();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginFactory.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginFactory.java
deleted file mode 100644
index 3f0eecd..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Identifies a Method as the factory to create the plugin.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface PluginFactory {
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
deleted file mode 100644
index f51375a..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.helpers.Loader;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.text.DecimalFormat;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * Component that loads and manages all the plugins.
- */
-public class PluginManager {
-
- private static final long NANOS_PER_SECOND = 1000000000L;
-
- private static ConcurrentMap<String, ConcurrentMap<String, PluginType>> pluginTypeMap =
- new ConcurrentHashMap<String, ConcurrentMap<String, PluginType>>();
-
- private static CopyOnWriteArrayList<String> packages = new CopyOnWriteArrayList<String>();
- private static final String PATH = "org/apache/logging/log4j/core/config/plugins/";
- private static final String FILENAME = "Log4j2Plugins.dat";
- private static final String LOG4J_PACKAGES = "org.apache.logging.log4j.core";
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private static String rootDir;
-
- private Map<String, PluginType> plugins = new HashMap<String, PluginType>();
- private final String type;
- private final Class clazz;
-
- /**
- * Constructor that takes only a type name.
- * @param type The type name.
- */
- public PluginManager(String type) {
- this.type = type;
- this.clazz = null;
- }
-
- /**
- * Constructor that takes a type name and a Class.
- * @param type The type that must be matched.
- * @param clazz The Class each match must be an instance of.
- */
- public PluginManager(String type, Class clazz) {
- this.type = type;
- this.clazz = clazz;
- }
-
- public static void main(String[] args) throws Exception {
- if (args == null || args.length < 1) {
- System.err.println("A target directory must be specified");
- System.exit(-1);
- }
- rootDir = args[0].endsWith("/") || args[0].endsWith("\\") ? args[0] : args[0] + "/";
-
- PluginManager manager = new PluginManager("Core");
- manager.collectPlugins(false);
- encode(pluginTypeMap);
- }
-
- /**
- * Adds a package name to be scanned for plugins. Must be invoked prior to plugins being collected.
- * @param p The package name.
- */
- public static void addPackage(String p) {
- packages.addIfAbsent(p);
- }
-
- /**
- * Returns the type of a specified plugin.
- * @param name The name of the plugin.
- * @return The plugin's type.
- */
- public PluginType getPluginType(String name) {
- return plugins.get(name.toLowerCase());
- }
-
- /**
- * Returns all the matching plugins.
- * @return A Map containing the name of the plugin and its type.
- */
- public Map<String, PluginType> getPlugins() {
- return plugins;
- }
-
- /**
- * Locates all the plugins.
- */
- public void collectPlugins() {
- collectPlugins(true);
- }
-
- /**
- * Collects plugins, optionally obtaining them from a preload map.
- * @param preLoad if true, plugins will be obtained from the preload map.
- */
- public void collectPlugins(boolean preLoad) {
- if (pluginTypeMap.containsKey(type)) {
- plugins = pluginTypeMap.get(type);
- preLoad = false;
- }
- long start = System.nanoTime();
- ResolverUtil<?> r = new ResolverUtil();
- ClassLoader loader = Loader.getClassLoader();
- if (loader != null) {
- r.setClassLoader(loader);
- }
- if (preLoad) {
- ConcurrentMap<String, ConcurrentMap<String, PluginType>> map = decode(loader);
- if (map != null) {
- pluginTypeMap = map;
- plugins = map.get(type);
- } else {
- LOGGER.warn("Plugin preloads not available");
- }
- }
- if (plugins.size() == 0) {
- packages.add(LOG4J_PACKAGES);
- }
- ResolverUtil.Test test = new PluginTest(clazz);
- for (String pkg : packages) {
- r.findInPackage(test, pkg);
- }
- for (Class<?> item : r.getClasses()) {
- Plugin p = item.getAnnotation(Plugin.class);
- String pluginType = p.type();
- if (!pluginTypeMap.containsKey(pluginType)) {
- pluginTypeMap.putIfAbsent(pluginType, new ConcurrentHashMap<String, PluginType>());
- }
- Map<String, PluginType> map = pluginTypeMap.get(pluginType);
- String type = p.elementType().equals(Plugin.EMPTY) ? p.name() : p.elementType();
- map.put(p.name().toLowerCase(), new PluginType(item, type, p.printObject(), p.deferChildren()));
- }
- long elapsed = System.nanoTime() - start;
- plugins = pluginTypeMap.get(type);
- StringBuilder sb = new StringBuilder("Generated plugins");
- sb.append(" in ");
- DecimalFormat numFormat = new DecimalFormat("#0");
- long seconds = elapsed / NANOS_PER_SECOND;
- elapsed %= NANOS_PER_SECOND;
- sb.append(numFormat.format(seconds)).append(".");
- numFormat = new DecimalFormat("000000000");
- sb.append(numFormat.format(elapsed)).append(" seconds");
- LOGGER.debug(sb.toString());
- }
-
- private static ConcurrentMap<String, ConcurrentMap<String, PluginType>> decode(ClassLoader loader) {
- String resource = PATH + FILENAME;
- try {
- InputStream is = loader.getResourceAsStream(resource);
- BufferedInputStream bis = new BufferedInputStream(is);
- DataInputStream dis = new DataInputStream(bis);
- int count = dis.readInt();
- ConcurrentMap<String, ConcurrentMap<String, PluginType>> map =
- new ConcurrentHashMap<String, ConcurrentMap<String, PluginType>>(count);
- for (int j = 0; j < count; ++j) {
- String type = dis.readUTF();
- int entries = dis.readInt();
- ConcurrentMap<String, PluginType> types = new ConcurrentHashMap<String, PluginType>(count);
- for (int i = 0; i < entries; ++i) {
- String key = dis.readUTF();
- String className = dis.readUTF();
- String name = dis.readUTF();
- boolean printable = dis.readBoolean();
- boolean defer = dis.readBoolean();
- Class clazz = Class.forName(className);
- types.put(key, new PluginType(clazz, name, printable, defer));
- }
- map.putIfAbsent(type, types);
- }
- dis.close();
- return map;
- } catch (Exception ex) {
- LOGGER.warn("Unable to preload plugins", ex);
- return null;
- }
- }
-
- private static void encode(ConcurrentMap<String, ConcurrentMap<String, PluginType>> map) {
- String fileName = rootDir + PATH + FILENAME;
- try {
- FileOutputStream fos = new FileOutputStream(fileName);
- BufferedOutputStream bos = new BufferedOutputStream(fos);
- DataOutputStream dos = new DataOutputStream(bos);
- dos.writeInt(map.size());
- for (Map.Entry<String, ConcurrentMap<String, PluginType>> outer : map.entrySet()) {
- dos.writeUTF(outer.getKey());
- dos.writeInt(outer.getValue().size());
- for (Map.Entry<String, PluginType> entry : outer.getValue().entrySet()) {
- dos.writeUTF(entry.getKey());
- PluginType pt = entry.getValue();
- dos.writeUTF(pt.getPluginClass().getName());
- dos.writeUTF(pt.getElementName());
- dos.writeBoolean(pt.isObjectPrintable());
- dos.writeBoolean(pt.isDeferChildren());
- }
- }
- dos.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- /**
- * A Test that checks to see if each class is annotated with a specific annotation. If it
- * is, then the test returns true, otherwise false.
- */
- public static class PluginTest extends ResolverUtil.ClassTest {
- private final Class isA;
-
- /**
- * Constructs an AnnotatedWith test for the specified annotation type.
- * @param isA The class to compare against.
- */
- public PluginTest(Class isA) {
- this.isA = isA;
- }
-
- /**
- * Returns true if the type is annotated with the class provided to the constructor.
- * @param type The type to check for.
- * @return true if the Class is of the specified type.
- */
- public boolean matches(Class type) {
- return type != null && type.isAnnotationPresent(Plugin.class) &&
- (isA == null || isA.isAssignableFrom(type));
- }
-
- @Override
- public String toString() {
- StringBuilder msg = new StringBuilder("annotated with @" + Plugin.class.getSimpleName());
- if (isA != null) {
- msg.append(" is assignable to " + isA.getSimpleName());
- }
- return msg.toString();
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginNode.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginNode.java
deleted file mode 100644
index f8086fe..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginNode.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- *
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.PARAMETER)
-public @interface PluginNode {
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginType.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginType.java
deleted file mode 100644
index ebb100b..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginType.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-
-import java.io.Serializable;
-
-/**
- * Plugin Descriptor.
- */
-public class PluginType implements Serializable {
-
- private Class pluginClass;
- private String elementName;
- private boolean printObject = false;
- private boolean deferChildren = false;
-
- public PluginType(Class clazz, String name, boolean printObj, boolean deferChildren) {
- this.pluginClass = clazz;
- this.elementName = name;
- this.printObject = printObj;
- this.deferChildren = deferChildren;
- }
-
- public Class getPluginClass() {
- return this.pluginClass;
- }
-
- public String getElementName() {
- return this.elementName;
- }
-
- public boolean isObjectPrintable() {
- return this.printObject;
- }
-
- public boolean isDeferChildren() {
- return this.deferChildren;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginValue.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginValue.java
deleted file mode 100644
index 5620287..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginValue.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Identifies a parameter as a value.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.PARAMETER)
-public @interface PluginValue {
-
- String value();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PropertiesPlugin.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PropertiesPlugin.java
deleted file mode 100644
index a54bce5..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PropertiesPlugin.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config.plugins;
-
-import org.apache.logging.log4j.core.config.Property;
-import org.apache.logging.log4j.core.lookup.Interpolator;
-import org.apache.logging.log4j.core.lookup.MapLookup;
-import org.apache.logging.log4j.core.lookup.StrLookup;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Handles properties defined in the configuration.
- */
-@Plugin(name = "properties", type = "Core", printObject = true)
-public final class PropertiesPlugin {
-
- private PropertiesPlugin() {
- }
-
- /**
- * Create the Properties component.
- * @param properties An array of Property elements.
- * @return An Interpolator that includes the configuration properties.
- */
- @PluginFactory
- public static StrLookup configureSubstitutor(@PluginElement("properties") Property[] properties) {
- if (properties == null) {
- return new Interpolator(null);
- }
- Map<String, String> map = new HashMap<String, String>();
-
- for (Property prop : properties) {
- map.put(prop.getName(), prop.getValue());
- }
-
- return new Interpolator(new MapLookup(map));
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
deleted file mode 100644
index 5ecc07d..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/* Copyright 2005-2006 Tim Fennell
- *
- * 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.logging.log4j.core.config.plugins;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-
-/**
- * <p>ResolverUtil is used to locate classes that are available in the/a class path and meet
- * arbitrary conditions. The two most common conditions are that a class implements/extends
- * another class, or that is it annotated with a specific annotation. However, through the use
- * of the {@link Test} class it is possible to search using arbitrary conditions.</p>
- *
- * <p>A ClassLoader is used to locate all locations (directories and jar files) in the class
- * path that contain classes within certain packages, and then to load those classes and
- * check them. By default the ClassLoader returned by
- * {@code Thread.currentThread().getContextClassLoader()} is used, but this can be overridden
- * by calling {@link #setClassLoader(ClassLoader)} prior to invoking any of the {@code find()}
- * methods.</p>
- *
- * <p>General searches are initiated by calling the
- * {@link #find(org.apache.logging.log4j.core..util.ResolverUtil.Test, String...)} ()} method and supplying
- * a package name and a Test instance. This will cause the named package <b>and all sub-packages</b>
- * to be scanned for classes that meet the test. There are also utility methods for the common
- * use cases of scanning multiple packages for extensions of particular classes, or classes
- * annotated with a specific annotation.</p>
- *
- * <p>The standard usage pattern for the ResolverUtil class is as follows:</p>
- *
- *<pre>
- *ResolverUtil<ActionBean> resolver = new ResolverUtil<ActionBean>();
- *resolver.findImplementation(ActionBean.class, pkg1, pkg2);
- *resolver.find(new CustomTest(), pkg1);
- *resolver.find(new CustomTest(), pkg2);
- *Collection<ActionBean> beans = resolver.getClasses();
- *</pre>
- *
- * <p>This class was copied from Stripes - http://stripes.mc4j.org/confluence/display/stripes/Home
- * </p>
- *
- * @author Tim Fennell
- * @param <T> The type of the Class that can be returned.
- */
-public class ResolverUtil<T> {
- /** An instance of Log to use for logging in this class. */
- private static final Logger LOG = StatusLogger.getLogger();
-
- /** The set of matches being accumulated. */
- private Set<Class<? extends T>> classMatches = new HashSet<Class<?extends T>>();
-
- /** The set of matches being accumulated. */
- private Set<URI> resourceMatches = new HashSet<URI>();
-
- /**
- * The ClassLoader to use when looking for classes. If null then the ClassLoader returned
- * by Thread.currentThread().getContextClassLoader() will be used.
- */
- private ClassLoader classloader;
-
- /**
- * Provides access to the classes discovered so far. If no calls have been made to
- * any of the {@code find()} methods, this set will be empty.
- *
- * @return the set of classes that have been discovered.
- */
- public Set<Class<? extends T>> getClasses() {
- return classMatches;
- }
-
- /**
- * Return the matching resources.
- * @return A Set of URIs that match the criteria.
- */
- public Set<URI> getResources() {
- return resourceMatches;
- }
-
-
- /**
- * Returns the classloader that will be used for scanning for classes. If no explicit
- * ClassLoader has been set by the calling, the context class loader will be used.
- *
- * @return the ClassLoader that will be used to scan for classes
- */
- public ClassLoader getClassLoader() {
- return classloader == null ? Thread.currentThread().getContextClassLoader() : classloader;
- }
-
- /**
- * Sets an explicit ClassLoader that should be used when scanning for classes. If none
- * is set then the context classloader will be used.
- *
- * @param classloader a ClassLoader to use when scanning for classes
- */
- public void setClassLoader(ClassLoader classloader) { this.classloader = classloader; }
-
- /**
- * Attempts to discover classes that are assignable to the type provided. In the case
- * that an interface is provided this method will collect implementations. In the case
- * of a non-interface class, subclasses will be collected. Accumulated classes can be
- * accessed by calling {@link #getClasses()}.
- *
- * @param parent the class of interface to find subclasses or implementations of
- * @param packageNames one or more package names to scan (including subpackages) for classes
- */
- public void findImplementations(Class parent, String... packageNames) {
- if (packageNames == null) {
- return;
- }
-
- Test test = new IsA(parent);
- for (String pkg : packageNames) {
- findInPackage(test, pkg);
- }
- }
-
- /**
- * Attempts to discover classes who's name ends with the provided suffix. Accumulated classes can be
- * accessed by calling {@link #getClasses()}.
- *
- * @param suffix The class name suffix to match
- * @param packageNames one or more package names to scan (including subpackages) for classes
- */
- public void findSuffix(String suffix, String... packageNames) {
- if (packageNames == null) {
- return;
- }
-
- Test test = new NameEndsWith(suffix);
- for (String pkg : packageNames) {
- findInPackage(test, pkg);
- }
- }
-
- /**
- * Attempts to discover classes that are annotated with to the annotation. Accumulated
- * classes can be accessed by calling {@link #getClasses()}.
- *
- * @param annotation the annotation that should be present on matching classes
- * @param packageNames one or more package names to scan (including subpackages) for classes
- */
- public void findAnnotated(Class<? extends Annotation> annotation, String... packageNames) {
- if (packageNames == null) {
- return;
- }
-
- Test test = new AnnotatedWith(annotation);
- for (String pkg : packageNames) {
- findInPackage(test, pkg);
- }
- }
-
- public void findNamedResource(String name, String... pathNames) {
- if (pathNames == null) {
- return;
- }
-
- Test test = new NameIs(name);
- for (String pkg : pathNames) {
- findInPackage(test, pkg);
- }
- }
-
- /**
- * Attempts to discover classes that pass the test. Accumulated
- * classes can be accessed by calling {@link #getClasses()}.
- *
- * @param test the test to determine matching classes
- * @param packageNames one or more package names to scan (including subpackages) for classes
- */
- public void find(Test test, String... packageNames) {
- if (packageNames == null) {
- return;
- }
-
- for (String pkg : packageNames) {
- findInPackage(test, pkg);
- }
- }
-
- /**
- * Scans for classes starting at the package provided and descending into subpackages.
- * Each class is offered up to the Test as it is discovered, and if the Test returns
- * true the class is retained. Accumulated classes can be fetched by calling
- * {@link #getClasses()}.
- *
- * @param test an instance of {@link Test} that will be used to filter classes
- * @param packageName the name of the package from which to start scanning for
- * classes, e.g. {@code net.sourceforge.stripes}
- */
- public void findInPackage(Test test, String packageName) {
- packageName = packageName.replace('.', '/');
- ClassLoader loader = getClassLoader();
- Enumeration<URL> urls;
-
- try {
- urls = loader.getResources(packageName);
- } catch (IOException ioe) {
- LOG.warn("Could not read package: " + packageName, ioe);
- return;
- }
-
- while (urls.hasMoreElements()) {
- try {
- String urlPath = urls.nextElement().getFile();
- urlPath = URLDecoder.decode(urlPath, "UTF-8");
-
- // If it's a file in a directory, trim the stupid file: spec
- if (urlPath.startsWith("file:")) {
- urlPath = urlPath.substring(5);
- }
-
- // Else it's in a JAR, grab the path to the jar
- if (urlPath.indexOf('!') > 0) {
- urlPath = urlPath.substring(0, urlPath.indexOf('!'));
- }
-
- LOG.info("Scanning for classes in [" + urlPath + "] matching criteria: " + test);
- File file = new File(urlPath);
- if (file.isDirectory()) {
- loadImplementationsInDirectory(test, packageName, file);
- } else {
- loadImplementationsInJar(test, packageName, file);
- }
- } catch (IOException ioe) {
- LOG.warn("could not read entries", ioe);
- }
- }
- }
-
-
- /**
- * Finds matches in a physical directory on a filesystem. Examines all
- * files within a directory - if the File object is not a directory, and ends with <i>.class</i>
- * the file is loaded and tested to see if it is acceptable according to the Test. Operates
- * recursively to find classes within a folder structure matching the package structure.
- *
- * @param test a Test used to filter the classes that are discovered
- * @param parent the package name up to this directory in the package hierarchy. E.g. if
- * /classes is in the classpath and we wish to examine files in /classes/org/apache then
- * the values of <i>parent</i> would be <i>org/apache</i>
- * @param location a File object representing a directory
- */
- private void loadImplementationsInDirectory(Test test, String parent, File location) {
- File[] files = location.listFiles();
- StringBuilder builder;
-
- for (File file : files) {
- builder = new StringBuilder();
- builder.append(parent).append("/").append(file.getName());
- String packageOrClass = parent == null ? file.getName() : builder.toString();
-
- if (file.isDirectory()) {
- loadImplementationsInDirectory(test, packageOrClass, file);
- } else if (isTestApplicable(test, file.getName())) {
- addIfMatching(test, packageOrClass);
- }
- }
- }
-
- private boolean isTestApplicable(Test test, String path) {
- return test.doesMatchResource() || path.endsWith(".class") && test.doesMatchClass();
- }
-
- /**
- * Finds matching classes within a jar files that contains a folder structure
- * matching the package structure. If the File is not a JarFile or does not exist a warning
- * will be logged, but no error will be raised.
- *
- * @param test a Test used to filter the classes that are discovered
- * @param parent the parent package under which classes must be in order to be considered
- * @param jarfile the jar file to be examined for classes
- */
- private void loadImplementationsInJar(Test test, String parent, File jarfile) {
-
- try {
- JarEntry entry;
- JarInputStream jarStream = new JarInputStream(new FileInputStream(jarfile));
-
- while ((entry = jarStream.getNextJarEntry()) != null) {
- String name = entry.getName();
- if (!entry.isDirectory() && name.startsWith(parent) && isTestApplicable(test, name)) {
- addIfMatching(test, name);
- }
- }
- } catch (IOException ioe) {
- LOG.error("Could not search jar file '" + jarfile + "' for classes matching criteria: " +
- test + " due to an IOException", ioe);
- }
- }
-
- /**
- * Add the class designated by the fully qualified class name provided to the set of
- * resolved classes if and only if it is approved by the Test supplied.
- *
- * @param test the test used to determine if the class matches
- * @param fqn the fully qualified name of a class
- */
- protected void addIfMatching(Test test, String fqn) {
- try {
- ClassLoader loader = getClassLoader();
- if (test.doesMatchClass()) {
- String externalName = fqn.substring(0, fqn.indexOf('.')).replace('/', '.');
- if (LOG.isDebugEnabled()) {
- LOG.debug("Checking to see if class " + externalName + " matches criteria [" + test + "]");
- }
-
- Class type = loader.loadClass(externalName);
- if (test.matches(type)) {
- classMatches.add((Class<T>) type);
- }
- }
- if (test.doesMatchResource()) {
- URL url = loader.getResource(fqn);
- if (url == null) {
- url = loader.getResource(fqn.substring(1));
- }
- if (url != null && test.matches(url.toURI())) {
- resourceMatches.add(url.toURI());
- }
- }
- } catch (Throwable t) {
- LOG.warn("Could not examine class '" + fqn + "' due to a " +
- t.getClass().getName() + " with message: " + t.getMessage());
- }
- }
-
- /**
- * A simple interface that specifies how to test classes to determine if they
- * are to be included in the results produced by the ResolverUtil.
- */
- public interface Test {
- /**
- * Will be called repeatedly with candidate classes. Must return True if a class
- * is to be included in the results, false otherwise.
- * @param type The Class to match against.
- * @return true if the Class matches.
- */
- boolean matches(Class type);
-
- /**
- * Test for a resource.
- * @param resource The URI to the resource.
- * @return true if the resource matches.
- */
- boolean matches(URI resource);
-
- boolean doesMatchClass();
- boolean doesMatchResource();
- }
-
- /**
- * Test against a Class.
- */
- public abstract static class ClassTest implements Test {
- public boolean matches(URI resource) {
- throw new UnsupportedOperationException();
- }
-
- public boolean doesMatchClass() {
- return true;
- }
- public boolean doesMatchResource() {
- return false;
- }
- }
-
- /**
- * Test against a resource.
- */
- public abstract static class ResourceTest implements Test {
- public boolean matches(Class cls) {
- throw new UnsupportedOperationException();
- }
-
- public boolean doesMatchClass() {
- return false;
- }
- public boolean doesMatchResource() {
- return true;
- }
- }
-
- /**
- * A Test that checks to see if each class is assignable to the provided class. Note
- * that this test will match the parent type itself if it is presented for matching.
- */
- public static class IsA extends ClassTest {
- private Class parent;
-
- /**
- * Constructs an IsA test using the supplied Class as the parent class/interface.
- * @param parentType The parent class to check for.
- */
- public IsA(Class parentType) { this.parent = parentType; }
-
- /**
- * Returns true if type is assignable to the parent type supplied in the constructor.
- * @param type The Class to check.
- * @return true if the Class matches.
- */
- public boolean matches(Class type) {
- return type != null && parent.isAssignableFrom(type);
- }
-
- @Override
- public String toString() {
- return "is assignable to " + parent.getSimpleName();
- }
- }
-
- /**
- * A Test that checks to see if each class name ends with the provided suffix.
- */
- public static class NameEndsWith extends ClassTest {
- private String suffix;
-
- /**
- * Constructs a NameEndsWith test using the supplied suffix.
- * @param suffix the String suffix to check for.
- */
- public NameEndsWith(String suffix) { this.suffix = suffix; }
-
- /**
- * Returns true if type name ends with the suffix supplied in the constructor.
- * @param type The Class to check.
- * @return true if the Class matches.
- */
- public boolean matches(Class type) {
- return type != null && type.getName().endsWith(suffix);
- }
-
- @Override
- public String toString() {
- return "ends with the suffix " + suffix;
- }
- }
-
- /**
- * A Test that checks to see if each class is annotated with a specific annotation. If it
- * is, then the test returns true, otherwise false.
- */
- public static class AnnotatedWith extends ClassTest {
- private Class<? extends Annotation> annotation;
-
- /**
- * Constructs an AnnotatedWith test for the specified annotation type.
- * @param annotation The annotation to check for.
- */
- public AnnotatedWith(Class<? extends Annotation> annotation) {
- this.annotation = annotation;
- }
-
- /**
- * Returns true if the type is annotated with the class provided to the constructor.
- * @param type the Class to match against.
- * @return true if the Classes match.
- */
- public boolean matches(Class type) {
- return type != null && type.isAnnotationPresent(annotation);
- }
-
- @Override
- public String toString() {
- return "annotated with @" + annotation.getSimpleName();
- }
- }
-
- /**
- * A Test that checks to see if the class name matches.
- */
- public static class NameIs extends ResourceTest {
- private String name;
-
- public NameIs(String name) { this.name = "/" + name; }
-
- public boolean matches(URI resource) {
- return (resource.getPath().endsWith(name));
- }
-
- @Override public String toString() {
- return "named " + name;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/package-info.java
deleted file mode 100644
index 5feee7f..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Configuration of Log4j 2.0 via Plugins.
- */
-package org.apache.logging.log4j.core.config.plugins;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
deleted file mode 100644
index d418619..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.message.Message;
-
-import java.util.Iterator;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.DelayQueue;
-import java.util.concurrent.Delayed;
-import java.util.concurrent.TimeUnit;
-
-/**
- * The <code>BurstFilter</code> is a logging filter that regulates logging
- * traffic. Use this filter when you want to control the maximum burst of log
- * statements that can be sent to an appender. The filter is configured in the
- * log4j configuration file. For example, the following configuration limits the
- * number of INFO level (as well as DEBUG and TRACE) log statements that can be sent to the
- * console to a burst of 100 with an average rate of 16 per second. WARN, ERROR and FATAL messages would continue to
- * be delivered.<br>
- * <br>
- * <p/>
- * <code>
- * <Console name="console"><br>
- * <PatternLayout pattern="%-5p %d{dd-MMM-yyyy HH:mm:ss} %x %t %m%n"/><br>
- * <filters><br>
- * <Burst level="INFO" rate="16" maxBurst="100"/><br>
- * </filters><br>
- * </Console><br>
- * </code><br>
- */
-
-@Plugin(name = "BurstFilter", type = "Core", elementType = "filter", printObject = true)
-public final class BurstFilter extends FilterBase {
-
- private static final long NANOS_IN_SECONDS = 1000000000;
-
- private static final int DEFAULT_RATE = 10;
-
- private static final int DEFAULT_RATE_MULTIPLE = 100;
-
- private static final int HASH_SHIFT = 32;
-
- /**
- * Level of messages to be filtered. Anything at or below this level will be
- * filtered out if <code>maxBurst</code> has been exceeded. The default is
- * WARN meaning any messages that are higher than warn will be logged
- * regardless of the size of a burst.
- */
- private final Level level;
-
- private final long burstInterval;
-
- private final DelayQueue<LogDelay> history = new DelayQueue<LogDelay>();
-
- private final Queue<LogDelay> available = new ConcurrentLinkedQueue<LogDelay>();
-
- private BurstFilter(Level level, float rate, long maxBurst, Result onMatch, Result onMismatch) {
- super(onMatch, onMismatch);
- this.level = level;
- this.burstInterval = (long) (NANOS_IN_SECONDS * (maxBurst / rate));
- for (int i = 0; i < maxBurst; ++i) {
- available.add(new LogDelay());
- }
- }
-
- public Result filter(Logger logger, Level level, Marker marker, String msg, Object[] params) {
- return filter(level);
- }
-
- public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
- return filter(level);
- }
-
- public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
- return filter(level);
- }
-
- @Override
- public Result filter(LogEvent event) {
- return filter(event.getLevel());
- }
-
- /**
- * Decide if we're going to log <code>event</code> based on whether the
- * maximum burst of log statements has been exceeded.
- *
- * @param level The log level.
- * @return The onMatch value if the filter passes, onMismatch otherwise.
- */
- private Result filter(Level level) {
- if (this.level.isAtLeastAsSpecificAs(level)) {
- LogDelay delay = history.poll();
- while (delay != null) {
- available.add(delay);
- delay = history.poll();
- }
- delay = available.poll();
- if (delay != null) {
- delay.setDelay(burstInterval);
- history.add(delay);
- return onMatch;
- }
- return onMismatch;
- }
- return onMatch;
-
- }
-
- /**
- * Returns the number of available slots. Used for unit testing.
- * @return The number of available slots.
- */
- public int getAvailable() {
- return available.size();
- }
-
- /**
- * Clear the history. Used for unit testing.
- */
- public void clear() {
- Iterator<LogDelay> iter = history.iterator();
- while (iter.hasNext()) {
- LogDelay delay = iter.next();
- history.remove(delay);
- available.add(delay);
- }
- }
-
- public String toString() {
- return "level=" + level.toString() + ", interval=" + burstInterval + ", max=" + history.size();
- }
-
- /**
- * Delay object to represent each log event that has occurred within the timespan.
- */
- private class LogDelay implements Delayed {
-
- private long expireTime;
-
- public LogDelay() {
- }
-
- public void setDelay(long delay) {
- this.expireTime = delay + System.nanoTime();
- }
-
- public long getDelay(TimeUnit timeUnit) {
- return timeUnit.convert(expireTime - System.nanoTime(), TimeUnit.NANOSECONDS);
- }
-
- public int compareTo(Delayed delayed) {
- if (this.expireTime < ((LogDelay) delayed).expireTime) {
- return -1;
- } else if (this.expireTime > ((LogDelay) delayed).expireTime) {
- return 1;
- }
- return 0;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- LogDelay logDelay = (LogDelay) o;
-
- if (expireTime != logDelay.expireTime) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return (int) (expireTime ^ (expireTime >>> HASH_SHIFT));
- }
- }
-
- /**
- * @param level The logging level.
- * @param rate The average number of events per second to allow.
- * @param maxBurst The maximum number of events that can occur before events are filtered for exceeding the
- * average rate. The default is 10 times the rate.
- * @param match The Result to return when the filter matches. Defaults to Result.NEUTRAL.
- * @param mismatch The Result to return when the filter does not match. The default is Result.DENY.
- * @return A BurstFilter.
- */
- @PluginFactory
- public static BurstFilter createFilter(@PluginAttr("level") String level,
- @PluginAttr("rate") String rate,
- @PluginAttr("maxBurst") String maxBurst,
- @PluginAttr("onmatch") String match,
- @PluginAttr("onmismatch") String mismatch) {
- Result onMatch = match == null ? null : Result.valueOf(match);
- Result onMismatch = mismatch == null ? null : Result.valueOf(mismatch);
- Level lvl = Level.toLevel(level, Level.WARN);
- float eventRate = rate == null ? DEFAULT_RATE : Float.parseFloat(rate);
- if (eventRate <= 0) {
- eventRate = DEFAULT_RATE;
- }
- long max = maxBurst == null ? (long) (eventRate * DEFAULT_RATE_MULTIPLE) : Long.parseLong(maxBurst);
- if (onMatch == null) {
- onMatch = Result.NEUTRAL;
- }
- if (onMismatch == null) {
- onMismatch = Result.DENY;
- }
- return new BurstFilter(lvl, eventRate, max, onMatch, onMismatch);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.java
deleted file mode 100644
index 34f6c5d..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Lifecycle;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.message.Message;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Filter that invokes multiple filters.
- */
-@Plugin(name = "filters", type = "Core", printObject = true)
-public final class CompositeFilter implements Iterable<Filter>, Filter, Lifecycle {
-
- private final List<Filter> filters;
- private final boolean hasFilters;
-
- private boolean isStarted;
-
- private CompositeFilter() {
- this.filters = new ArrayList<Filter>();
- this.hasFilters = false;
- }
-
- private CompositeFilter(List<Filter> filters) {
- if (filters == null) {
- this.filters = Collections.unmodifiableList(new ArrayList<Filter>());
- this.hasFilters = false;
- return;
- }
- this.filters = Collections.unmodifiableList(filters);
- this.hasFilters = this.filters.size() > 0;
- }
-
- public CompositeFilter addFilter(Filter filter) {
- List<Filter> filters = new ArrayList<Filter>(this.filters);
- filters.add(filter);
- return new CompositeFilter(Collections.unmodifiableList(filters));
- }
-
- public CompositeFilter removeFilter(Filter filter) {
- List<Filter> filters = new ArrayList<Filter>(this.filters);
- filters.remove(filter);
- return new CompositeFilter(Collections.unmodifiableList(filters));
- }
-
- public Iterator<Filter> iterator() {
- return filters.iterator();
- }
-
- public List<Filter> getFilters() {
- return filters;
- }
-
- public boolean hasFilters() {
- return hasFilters;
- }
-
- public int size() {
- return filters.size();
- }
-
- public void start() {
- for (Filter filter : filters) {
- if (filter instanceof Lifecycle) {
- ((Lifecycle) filter).start();
- }
- }
- isStarted = true;
- }
-
- public void stop() {
- for (Filter filter : filters) {
- if (filter instanceof Lifecycle) {
- ((Lifecycle) filter).stop();
- }
- }
- isStarted = false;
- }
-
- public boolean isStarted() {
- return isStarted;
- }
-
- /**
- * Return the result that should be returned when the filter does not match the event.
- * @return the Result that should be returned when the filter does not match the event.
- */
- public Result getOnMismatch() {
- return Result.NEUTRAL;
- }
- /**
- * Return the result that should be returned when the filter matches the event.
- * @return the Result that should be returned when the filter matches the event.
- */
- public Result getOnMatch() {
- return Result.NEUTRAL;
- }
-
- /**
- * Filter an event.
- * @param logger The Logger.
- * @param level The event logging Level.
- * @param marker The Marker for the event or null.
- * @param msg String text to filter on.
- * @param params An array of parameters or null.
- * @return the Result.
- */
- public Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) {
- Result result = Result.NEUTRAL;
- for (Filter filter : filters) {
- result = filter.filter(logger, level, marker, msg, params);
- if (result == Result.ACCEPT || result == Result.DENY) {
- return result;
- }
- }
- return result;
- }
-
- /**
- * Filter an event.
- * @param logger The Logger.
- * @param level The event logging Level.
- * @param marker The Marker for the event or null.
- * @param msg Any Object.
- * @param t A Throwable or null.
- * @return the Result.
- */
- public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
- Result result = Result.NEUTRAL;
- for (Filter filter : filters) {
- result = filter.filter(logger, level, marker, msg, t);
- if (result == Result.ACCEPT || result == Result.DENY) {
- return result;
- }
- }
- return result;
- }
-
- /**
- * Filter an event.
- * @param logger The Logger.
- * @param level The event logging Level.
- * @param marker The Marker for the event or null.
- * @param msg The Message
- * @param t A Throwable or null.
- * @return the Result.
- */
- public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
- Result result = Result.NEUTRAL;
- for (Filter filter : filters) {
- result = filter.filter(logger, level, marker, msg, t);
- if (result == Result.ACCEPT || result == Result.DENY) {
- return result;
- }
- }
- return result;
- }
-
- /**
- * Filter an event.
- * @param event The Event to filter on.
- * @return the Result.
- */
- public Result filter(LogEvent event) {
- Result result = Result.NEUTRAL;
- for (Filter filter : filters) {
- result = filter.filter(event);
- if (result == Result.ACCEPT || result == Result.DENY) {
- return result;
- }
- }
- return result;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- for (Filter filter : filters) {
- if (sb.length() == 0) {
- sb.append("{");
- } else {
- sb.append(", ");
- }
- sb.append(filter.toString());
- }
- if (sb.length() > 0) {
- sb.append("}");
- }
- return sb.toString();
- }
-
- /**
- * Create a CompositeFilter.
- * @param filters An array of Filters to call.
- * @return The CompositeFilter.
- */
- @PluginFactory
- public static CompositeFilter createFilters(@PluginElement("filters") Filter[] filters) {
- List<Filter> f = filters == null || filters.length == 0 ? new ArrayList<Filter>() : Arrays.asList(filters);
- return new CompositeFilter(f);
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
deleted file mode 100644
index 0ca4880..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.message.Message;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Compare against a log level that is associated with an MDC value.
- */
-@Plugin(name = "DynamicThresholdFilter", type = "Core", elementType = "filter", printObject = true)
-public final class DynamicThresholdFilter extends FilterBase {
- private Map<String, Level> levelMap = new HashMap<String, Level>();
- private Level defaultThreshold = Level.ERROR;
- private String key;
-
- private DynamicThresholdFilter(String key, Map<String, Level> pairs, Level defaultLevel,
- Result onMatch, Result onMismatch) {
- super(onMatch, onMismatch);
- if (key == null) {
- throw new NullPointerException("key cannot be null");
- }
- this.key = key;
- this.levelMap = pairs;
- this.defaultThreshold = defaultLevel;
- }
-
- public String getKey() {
- return this.key;
- }
-
- public Result filter(Logger logger, Level level, Marker marker, String msg, Object[] params) {
- return filter(level);
- }
-
- public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
- return filter(level);
- }
-
- public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
- return filter(level);
- }
-
- @Override
- public Result filter(LogEvent event) {
- return filter(event.getLevel());
- }
-
- private Result filter(Level level) {
- Object value = ThreadContext.get(key);
- if (value != null) {
- Level ctxLevel = levelMap.get(value);
- if (ctxLevel == null) {
- ctxLevel = defaultThreshold;
- }
- return level.isAtLeastAsSpecificAs(ctxLevel) ? onMatch : onMismatch;
- }
- return Result.NEUTRAL;
-
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("key=").append(key);
- sb.append(", default=").append(defaultThreshold);
- if (levelMap.size() > 0) {
- sb.append("{");
- boolean first = true;
- for (Map.Entry<String, Level> entry : levelMap.entrySet()) {
- if (!first) {
- sb.append(", ");
- first = false;
- }
- sb.append(entry.getKey()).append("=").append(entry.getValue());
- }
- sb.append("}");
- }
- return sb.toString();
- }
-
- /**
- * Create the DynamicThresholdFilter.
- * @param key The name of the key to compare.
- * @param pairs An array of value and Level pairs.
- * @param level The default Level.
- * @param match The action to perform if a match occurs.
- * @param mismatch The action to perform if no match occurs.
- * @return The DynamicThresholdFilter.
- */
- @PluginFactory
- public static DynamicThresholdFilter createFilter(@PluginAttr("key") String key,
- @PluginElement("pairs") ValueLevelPair[] pairs,
- @PluginAttr("defaultThreshold") String level,
- @PluginAttr("onmatch") String match,
- @PluginAttr("onmismatch") String mismatch) {
- Result onMatch = match == null ? null : Result.valueOf(match);
- Result onMismatch = mismatch == null ? null : Result.valueOf(mismatch);
- Map<String, Level> map = new HashMap<String, Level>();
- for (ValueLevelPair pair : pairs) {
- map.put(pair.getKey(), pair.getLevel());
- }
- Level l = Level.toLevel(level, Level.ERROR);
- return new DynamicThresholdFilter(key, map, l, onMatch, onMismatch);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/FilterBase.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/FilterBase.java
deleted file mode 100644
index 83b7852..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/FilterBase.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Lifecycle;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.message.Message;
-
-/**
- * Users should extend this class to implement filters. Filters can be either context wide or attached to
- * an appender. A filter may choose to support being called only from the context or only from an appender in
- * which case it will only implement the required method(s). The rest will default to return NEUTRAL.
- *
- */
-public abstract class FilterBase implements Filter, Lifecycle {
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final org.apache.logging.log4j.Logger LOGGER = StatusLogger.getLogger();
-
- /**
- * The onMatch Result.
- */
- protected final Result onMatch;
-
- /**
- * The onMismatch Result.
- */
- protected final Result onMismatch;
-
- private boolean started;
-
- /**
- * The default constructor.
- */
- protected FilterBase() {
- this(null, null);
- }
-
- /**
- * Constructor that allows the onMatch and onMismatch actions to be set.
- * @param onMatch The result to return when a match occurs.
- * @param onMismatch The result to return when a match dos not occur.
- */
- protected FilterBase(Result onMatch, Result onMismatch) {
- this.onMatch = onMatch == null ? Result.NEUTRAL : onMatch;
- this.onMismatch = onMismatch == null ? Result.DENY : onMismatch;
- }
-
- /**
- * Mark the Filter as started.
- */
- public void start() {
- started = true;
- }
-
- /**
- * Determine if the the Filter has started.
- * @return true if the Filter is started, false otherwise.
- */
- public boolean isStarted() {
- return started;
- }
-
- /**
- * Mark the Filter as stopped.
- */
- public void stop() {
- started = false;
- }
-
- /**
- * Return the Result to be returned when a match does not occur.
- * @return the onMismatch Result.
- */
- public final Result getOnMismatch() {
- return onMismatch;
- }
-
- /**
- * Return the Result to be returned when a match occurs.
- * @return the onMatch Result.
- */
- public final Result getOnMatch() {
- return onMatch;
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- /**
- * Appender Filter method. The default returns NEUTRAL.
- * @param logger the Logger.
- * @param level The logging Level.
- * @param marker The Marker, if any.
- * @param msg The message, if present.
- * @param params An array of parameters or null.
- * @return The Result of filtering.
- */
- public Result filter(Logger logger, Level level, Marker marker, String msg, Object[] params) {
- return Result.NEUTRAL;
- }
-
- /**
- * Appender Filter method. The default returns NEUTRAL.
- * @param logger the Logger.
- * @param level The logging Level.
- * @param marker The Marker, if any.
- * @param msg The message, if present.
- * @param t A throwable or null.
- * @return The Result of filtering.
- */
- public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
- return Result.NEUTRAL;
- }
-
- /**
- * Appender Filter method. The default returns NEUTRAL.
- * @param logger the Logger.
- * @param level The logging Level.
- * @param marker The Marker, if any.
- * @param msg The message, if present.
- * @param t A throwable or null.
- * @return The Result of filtering.
- */
- public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
- return Result.NEUTRAL;
- }
-
- /**
- * Context Filter method. The default returns NEUTRAL.
- * @param event The LogEvent.
- * @return The Result of filtering.
- */
- public Result filter(LogEvent event) {
- return Result.NEUTRAL;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/Filterable.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/Filterable.java
deleted file mode 100644
index 213219e..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/Filterable.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Lifecycle;
-import org.apache.logging.log4j.core.LogEvent;
-
-import java.util.Iterator;
-
-/**
- * Enhances a Class by allowing it to contain Filters.
- */
-public class Filterable implements Filtering {
-
- private volatile Filter filter = null;
-
- protected Filterable(Filter filter) {
- this.filter = filter;
- }
-
- protected Filterable() {
- }
-
- /**
- * Return the Filter.
- * @return the Filter.
- */
- public Filter getFilter() {
- return filter;
- }
-
- /**
- * Add a filter.
- * @param filter The Filter to add.
- */
- public synchronized void addFilter(Filter filter) {
- if (this.filter == null) {
- this.filter = filter;
- } else if (filter instanceof CompositeFilter) {
- this.filter = ((CompositeFilter) this.filter).addFilter(filter);
- } else {
- Filter[] filters = new Filter[] {this.filter, filter};
- this.filter = CompositeFilter.createFilters(filters);
- }
- }
-
- /**
- * Remove a Filter.
- * @param filter The Filter to remove.
- */
- public synchronized void removeFilter(Filter filter) {
- if (this.filter == filter) {
- this.filter = null;
- } else if (filter instanceof CompositeFilter) {
- CompositeFilter composite = (CompositeFilter) filter;
- composite = composite.removeFilter(filter);
- if (composite.size() > 1) {
- this.filter = composite;
- } else if (composite.size() == 1) {
- Iterator<Filter> iter = composite.iterator();
- this.filter = iter.next();
- } else {
- this.filter = null;
- }
- }
- }
-
- /**
- * Determines if a Filter is present.
- * @return false if no Filter is present.
- */
- public boolean hasFilter() {
- return filter != null;
- }
-
- /**
- * Make the Filter available for use.
- */
- public void startFilter() {
- if (filter != null && filter instanceof Lifecycle) {
- ((Lifecycle) filter).start();
- }
- }
-
- /**
- * Cleanup the Filter.
- */
- public void stopFilter() {
- if (filter != null && filter instanceof Lifecycle) {
- ((Lifecycle) filter).stop();
- }
- }
-
- /**
- * Determine if the LogEvent should be processed or ignored.
- * @param event The LogEvent.
- * @return true if the LogEvent should be processed.
- */
- public boolean isFiltered(LogEvent event) {
- return filter != null && filter.filter(event) == Filter.Result.DENY;
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/Filtering.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/Filtering.java
deleted file mode 100644
index 5a92124..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/Filtering.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-
-/**
- * Interface implemented by Classes that allow filtering to occur.
- */
-public interface Filtering {
-
- /**
- * Adds a new Filter. If a Filter already exists it is converted to a CompositeFilter.
- * @param filter The Filter to add.
- */
- void addFilter(Filter filter);
-
- /**
- * Removes a Filter.
- * @param filter The Filter to remove.
- */
- void removeFilter(Filter filter);
-
- /**
- * Returns an Iterator for all the Filters.
- * @return an Iterator for all the Filters.
- */
- Filter getFilter();
-
- /**
- * Determine if a Filter is present.
- * @return true if a Filter is present, false otherwise.
- */
- boolean hasFilter();
-
- /**
- * Determines if the event should be filtered.
- * @param event The LogEvent.
- * @return true if the event should be filtered, false otherwise.
- */
- boolean isFiltered(LogEvent event);
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/MapFilter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/MapFilter.java
deleted file mode 100644
index a25d8f5..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/MapFilter.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.helpers.KeyValuePair;
-import org.apache.logging.log4j.message.MapMessage;
-import org.apache.logging.log4j.message.Message;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A Filter that operates on a Map.
- */
-@Plugin(name = "MapFilter", type = "Core", elementType = "filter", printObject = true)
-public class MapFilter extends FilterBase {
- private final Map<String, String> map;
-
- private final boolean isAnd;
-
- protected MapFilter(Map<String, String> map, boolean oper, Result onMatch, Result onMismatch) {
- super(onMatch, onMismatch);
- if (map == null) {
- throw new NullPointerException("key cannot be null");
- }
- this.isAnd = oper;
- this.map = map;
- }
-
- @Override
- public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
- if (msg instanceof MapMessage) {
- return filter((MapMessage) msg);
- }
- return Result.NEUTRAL;
- }
-
- @Override
- public Result filter(LogEvent event) {
- Message msg = event.getMessage();
- if (msg instanceof MapMessage) {
- return filter((MapMessage) msg);
- }
- return Result.NEUTRAL;
- }
-
- protected Result filter(MapMessage msg) {
- boolean match = false;
- for (String key : map.keySet()) {
- String data = msg.getData().get(key);
- match = map.get(key).equals(data);
- if ((!isAnd && match) || (isAnd && !match)) {
- break;
- }
- }
- return match ? onMatch : onMismatch;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("isAnd=").append(isAnd);
- if (map.size() > 0) {
- sb.append(", {");
- boolean first = true;
- for (Map.Entry<String, String> entry : map.entrySet()) {
- if (!first) {
- sb.append(", ");
- }
- first = false;
- sb.append(entry.getKey()).append("=").append(entry.getValue());
- }
- sb.append("}");
- }
- return sb.toString();
- }
-
- protected boolean isAnd() {
- return isAnd;
- }
-
- protected Map<String, String> getMap() {
- return map;
- }
-
- @PluginFactory
- public static MapFilter createFilter(@PluginAttr("pairs") KeyValuePair[] pairs,
- @PluginAttr("operator") String oper,
- @PluginAttr("onmatch") String match,
- @PluginAttr("onmismatch") String mismatch) {
- if (pairs == null || pairs.length == 0) {
- LOGGER.error("keys and values must be specified for the MapFilter");
- return null;
- }
- Map<String, String> map = new HashMap<String, String>();
- for (KeyValuePair pair : pairs) {
- String key = pair.getKey();
- if (key == null) {
- LOGGER.error("A null key is not valid in MapFilter");
- continue;
- }
- String value = pair.getValue();
- if (value == null) {
- LOGGER.error("A null value for key " + key + " is not allowed in MapFilter");
- continue;
- }
- map.put(pair.getKey(), pair.getValue());
- }
- if (map.size() == 0) {
- LOGGER.error("MapFilter is not configured with any valid key value pairs");
- return null;
- }
- boolean isAnd = oper == null || !oper.equalsIgnoreCase("or");
- Result onMatch = match == null ? null : Result.valueOf(match);
- Result onMismatch = mismatch == null ? null : Result.valueOf(mismatch);
- return new MapFilter(map, isAnd, onMatch, onMismatch);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/MarkerFilter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/MarkerFilter.java
deleted file mode 100644
index 95900d8..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/MarkerFilter.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.message.Message;
-
-/**
- * This filter returns the onMatch result if the marker in the LogEvent is the same as or has the
- * configured marker as a parent.
- *
- */
-@Plugin(name = "MarkerFilter", type = "Core", elementType = "filter", printObject = true)
-public final class MarkerFilter extends FilterBase {
-
- private final Marker marker;
-
- private MarkerFilter(Marker marker, Result onMatch, Result onMismatch) {
- super(onMatch, onMismatch);
- this.marker = marker;
- }
-
- public Result filter(Logger logger, Level level, Marker marker, String msg, Object[] params) {
- return filter(marker);
- }
-
- public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
- return filter(marker);
- }
-
- public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
- return filter(marker);
- }
-
- @Override
- public Result filter(LogEvent event) {
- return filter(event.getMarker());
- }
-
- private Result filter(Marker marker) {
- return marker != null && marker.isInstanceOf(this.marker) ? onMatch : onMismatch;
- }
-
- @Override
- public String toString() {
- return marker.getName();
- }
-
- /**
- * Create the MarkerFilter.
- * @param marker The Marker to match.
- * @param match The action to take if a match occurs.
- * @param mismatch The action to take if no match occurs.
- * @return A MarkerFilter.
- */
- @PluginFactory
- public static MarkerFilter createFilter(@PluginAttr("marker") String marker,
- @PluginAttr("onMatch") String match,
- @PluginAttr("onMismatch") String mismatch) {
-
- if (marker == null) {
- LOGGER.error("A marker must be provided for MarkerFilter");
- return null;
- }
- Marker m = MarkerManager.getMarker(marker);
- Result onMatch = match == null ? null : Result.valueOf(match);
- Result onMismatch = mismatch == null ? null : Result.valueOf(mismatch);
-
- return new MarkerFilter(m, onMatch, onMismatch);
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java
deleted file mode 100644
index 09ce458..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.message.Message;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * This filter returns the onMatch result if the message matches the regular expression.
- *
- * The "useRawMsg" attribute can be used to indicate whether the regular expression should be
- * applied to the result of calling Message.getMessageFormat (true) or Message.getFormattedMessage()
- * (false). The default is false.
- *
- */
-@Plugin(name = "RegexFilter", type = "Core", elementType = "filter", printObject = true)
-public final class RegexFilter extends FilterBase {
-
- private final Pattern pattern;
- private final boolean useRawMessage;
-
- private RegexFilter(boolean raw, Pattern pattern, Result onMatch, Result onMismatch) {
- super(onMatch, onMismatch);
- this.pattern = pattern;
- this.useRawMessage = raw;
- }
-
- public Result filter(Logger logger, Level level, Marker marker, String msg, Object[] params) {
- return filter(msg);
- }
-
- public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
- return filter(msg.toString());
- }
-
- public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
- String text = useRawMessage ? msg.getMessageFormat() : msg.getFormattedMessage();
- return filter(text);
- }
-
- @Override
- public Result filter(LogEvent event) {
- String text = useRawMessage ? event.getMessage().getMessageFormat() : event.getMessage().getFormattedMessage();
- return filter(text);
- }
-
- private Result filter(String msg) {
- if (msg == null) {
- return onMismatch;
- }
- Matcher m = pattern.matcher(msg);
- return m.matches() ? onMatch : onMismatch;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("useRaw=").append(useRawMessage);
- sb.append(", pattern=").append(pattern.toString());
- return sb.toString();
- }
-
- /**
- * Create a Filter that matches a regular expression.
- * @param regex The regular expression to match.
- * @param useRawMsg If true, the raw message will be used, otherwise the formatted message will be used.
- * @param match The action to perform when a match occurs.
- * @param mismatch The action to perform when a mismatch occurs.
- * @return The RegexFilter.
- */
- @PluginFactory
- public static RegexFilter createFilter(@PluginAttr("regex") String regex,
- @PluginAttr("useRawMsg") String useRawMsg,
- @PluginAttr("onMatch") String match,
- @PluginAttr("onMismatch") String mismatch) {
-
- if (regex == null) {
- LOGGER.error("A regular expression must be provided for RegexFilter");
- return null;
- }
- boolean raw = useRawMsg == null ? false : Boolean.parseBoolean(useRawMsg);
- Pattern pattern;
- try {
- pattern = Pattern.compile(regex);
- } catch (Exception ex) {
- LOGGER.error("RegexFilter caught exception compiling pattern: " + regex + " cause: " + ex.getMessage());
- return null;
- }
- Result onMatch = match == null ? null : Result.valueOf(match);
- Result onMismatch = mismatch == null ? null : Result.valueOf(mismatch);
-
- return new RegexFilter(raw, pattern, onMatch, onMismatch);
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/StructuredDataFilter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/StructuredDataFilter.java
deleted file mode 100644
index 2c75099..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/StructuredDataFilter.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.helpers.KeyValuePair;
-import org.apache.logging.log4j.message.MapMessage;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Filter based on data in a StructuredDataMessage.
- */
-@Plugin(name = "StructuredDataFilter", type = "Core", elementType = "filter", printObject = true)
-public final class StructuredDataFilter extends MapFilter {
-
- private StructuredDataFilter(Map<String, String> map, boolean oper, Result onMatch, Result onMismatch) {
- super(map, oper, onMatch, onMismatch);
- }
-
- @Override
- public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
- if (msg instanceof StructuredDataMessage) {
- return filter((StructuredDataMessage) msg);
- }
- return Result.NEUTRAL;
- }
-
- @Override
- public Result filter(LogEvent event) {
- Message msg = event.getMessage();
- if (msg instanceof StructuredDataMessage) {
- return filter((StructuredDataMessage) msg);
- }
- return Result.NEUTRAL;
- }
-
- protected Result filter(MapMessage message) {
- if (!(message instanceof StructuredDataMessage)) {
- return super.filter(message);
- }
- StructuredDataMessage msg = (StructuredDataMessage) message;
- boolean match = false;
- Map<String, String> map = getMap();
- for (String key : map.keySet()) {
- if (key.equalsIgnoreCase("id")) {
- match = map.get(key).equals(msg.getId().toString());
- } else if (key.equalsIgnoreCase("id.name")) {
- match = map.get(key).equals(msg.getId().getName());
- } else if (key.equalsIgnoreCase("type")) {
- match = map.get(key).equals(msg.getType());
- } else if (key.equalsIgnoreCase("message")) {
- match = map.get(key).equals(msg.getFormattedMessage().toString());
- } else {
- String data = msg.getData().get(key).toString();
- match = map.get(key).equals(data);
- }
- if ((!isAnd() && match) || (isAnd() && !match)) {
- break;
- }
- }
- return match ? onMatch : onMismatch;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("isAnd=").append(isAnd());
- if (getMap().size() > 0) {
- sb.append(", {");
- boolean first = true;
- for (Map.Entry<String, String> entry : getMap().entrySet()) {
- if (!first) {
- sb.append(", ");
- }
- first = false;
- sb.append(entry.getKey()).append("=").append(entry.getValue());
- }
- sb.append("}");
- }
- return sb.toString();
- }
-
- /**
- * Create the StructuredDataFilter.
- * @param pairs Key and value pairs.
- * @param oper The operator to perform. If not "or" the operation will be an "and".
- * @param match The action to perform on a match.
- * @param mismatch The action to perform on a mismatch.
- * @return The StructuredDataFilter.
- */
- @PluginFactory
- public static StructuredDataFilter createFilter(@PluginAttr("pairs") KeyValuePair[] pairs,
- @PluginAttr("operator") String oper,
- @PluginAttr("onmatch") String match,
- @PluginAttr("onmismatch") String mismatch) {
- if (pairs == null || pairs.length == 0) {
- LOGGER.error("keys and values must be specified for the StructuredDataFilter");
- return null;
- }
- Map<String, String> map = new HashMap<String, String>();
- for (KeyValuePair pair : pairs) {
- String key = pair.getKey();
- if (key == null) {
- LOGGER.error("A null key is not valid in StructuredDataFilter");
- continue;
- }
- String value = pair.getValue();
- if (value == null) {
- LOGGER.error("A null value for key " + key + " is not allowed in StructuredDataFilter");
- continue;
- }
- map.put(pair.getKey(), pair.getValue());
- }
- if (map.size() == 0) {
- LOGGER.error("StructuredDataFilter is not configured with any valid key value pairs");
- return null;
- }
- boolean isAnd = oper == null || !oper.equalsIgnoreCase("or");
- Result onMatch = match == null ? null : Result.valueOf(match);
- Result onMismatch = mismatch == null ? null : Result.valueOf(mismatch);
- return new StructuredDataFilter(map, isAnd, onMatch, onMismatch);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilter.java
deleted file mode 100644
index c393076..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilter.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.helpers.KeyValuePair;
-import org.apache.logging.log4j.message.Message;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Filter based on a value in the Thread Context Map (MDC).
- */
-@Plugin(name = "ThreadContextMapFilter", type = "Core", elementType = "filter", printObject = true)
-public class ThreadContextMapFilter extends FilterBase {
- private final Map<String, String> map;
-
- private final String key;
- private final String value;
-
- private final boolean isAnd;
-
- private final boolean useMap;
-
- public ThreadContextMapFilter(Map<String, String> pairs, boolean oper, Result onMatch, Result onMismatch) {
- super(onMatch, onMismatch);
- if (pairs.size() == 1) {
- Iterator<Map.Entry<String, String>> iter = pairs.entrySet().iterator();
- Map.Entry<String, String> entry = iter.next();
- this.key = entry.getKey();
- this.value = entry.getValue();
- this.map = null;
- this.isAnd = false;
- this.useMap = false;
- } else {
- this.map = pairs;
- this.isAnd = oper;
- this.key = null;
- this.value = null;
- this.useMap = true;
- }
- }
-
- @Override
- public Result filter(Logger logger, Level level, Marker marker, String msg, Object[] params) {
- return filter();
- }
-
- @Override
- public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
- return filter();
- }
-
- @Override
- public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
- return filter();
- }
-
- private Result filter() {
- boolean match = false;
- if (useMap) {
- for (String key : map.keySet()) {
- match = map.get(key).equals(ThreadContext.get(key));
- if ((!isAnd && match) || (isAnd && !match)) {
- break;
- }
- }
- } else {
- match = key.equals(ThreadContext.get(key));
- }
- return match ? onMatch : onMismatch;
- }
-
- @Override
- public Result filter(LogEvent event) {
- Map<String, String> ctx = event.getContextMap();
- boolean match = false;
- for (String key : map.keySet()) {
- match = map.get(key).equals(ctx.get(key));
- if ((!isAnd && match) || (isAnd && !match)) {
- break;
- }
- }
- return match ? onMatch : onMismatch;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("isAnd=").append(isAnd);
- if (useMap) {
- if (map.size() > 0) {
- sb.append(", {");
- boolean first = true;
- for (Map.Entry<String, String> entry : map.entrySet()) {
- if (!first) {
- sb.append(", ");
- }
- first = false;
- sb.append(entry.getKey()).append("=").append(entry.getValue());
- }
- sb.append("}");
- }
- } else {
- sb.append(", {").append(key).append("=").append(value).append("}");
- }
- return sb.toString();
- }
-
- @PluginFactory
- public static ThreadContextMapFilter createFilter(@PluginElement("pairs") KeyValuePair[] pairs,
- @PluginAttr("operator") String oper,
- @PluginAttr("onmatch") String match,
- @PluginAttr("onmismatch") String mismatch) {
- if (pairs == null || pairs.length == 0) {
- LOGGER.error("key and value pairs must be specified for the ThreadContextMapFilter");
- return null;
- }
- Map<String, String> map = new HashMap<String, String>();
- for (KeyValuePair pair : pairs) {
- String key = pair.getKey();
- if (key == null) {
- LOGGER.error("A null key is not valid in ThreadContextMapFilter");
- continue;
- }
- String value = pair.getValue();
- if (value == null) {
- LOGGER.error("A null value for key " + key + " is not allowed in ThreadContextMapFilter");
- continue;
- }
- map.put(pair.getKey(), pair.getValue());
- }
- if (map.size() == 0) {
- LOGGER.error("ThreadContextMapFilter is not configured with any valid key value pairs");
- return null;
- }
- boolean isAnd = oper == null || !oper.equalsIgnoreCase("or");
- Result onMatch = match == null ? null : Result.valueOf(match);
- Result onMismatch = mismatch == null ? null : Result.valueOf(mismatch);
- return new ThreadContextMapFilter(map, isAnd, onMatch, onMismatch);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/ThresholdFilter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/ThresholdFilter.java
deleted file mode 100644
index b2f904c..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/ThresholdFilter.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.message.Message;
-
-/**
- * This filter returns the onMatch result if the level in the LogEvent is the same or more specific
- * than the configured level and the onMismatch value otherwise. For example, if the ThresholdFilter
- * is configured with Level ERROR and the LogEvent contains Level DEBUG then the onMismatch value will
- * be returned since ERROR events are more specific than DEBUG.
- *
- * The default Level is ERROR.
- */
-@Plugin(name = "ThresholdFilter", type = "Core", elementType = "filter", printObject = true)
-public final class ThresholdFilter extends FilterBase {
-
- private final Level level;
-
- private ThresholdFilter(Level level, Result onMatch, Result onMismatch) {
- super(onMatch, onMismatch);
- this.level = level;
- }
-
- public Result filter(Logger logger, Level level, Marker marker, String msg, Object[] params) {
- return filter(level);
- }
-
- public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
- return filter(level);
- }
-
- public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
- return filter(level);
- }
-
- @Override
- public Result filter(LogEvent event) {
- return filter(event.getLevel());
- }
-
- private Result filter(Level level) {
- return level.isAtLeastAsSpecificAs(this.level) ? onMatch : onMismatch;
- }
-
- @Override
- public String toString() {
- return level.toString();
- }
-
- /**
- * Create a ThresholdFilter.
- * @param loggerLevel The log Level.
- * @param match The action to take on a match.
- * @param mismatch The action to take on a mismatch.
- * @return The created ThresholdFilter.
- */
- @PluginFactory
- public static ThresholdFilter createFilter(@PluginAttr("level") String loggerLevel,
- @PluginAttr("onMatch") String match,
- @PluginAttr("onMismatch") String mismatch) {
- Level level = loggerLevel == null ? Level.ERROR : Level.toLevel(loggerLevel.toUpperCase());
- Result onMatch = match == null ? Result.NEUTRAL : Result.valueOf(match);
- Result onMismatch = mismatch == null ? Result.DENY : Result.valueOf(mismatch);
-
- return new ThresholdFilter(level, onMatch, onMismatch);
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/TimeFilter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/TimeFilter.java
deleted file mode 100644
index 6eed00f..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/TimeFilter.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.TimeZone;
-
-/**
- * Filters events that fall within a specified time period in each day.
- */
-@Plugin(name = "TimeFilter", type = "Core", elementType = "filter", printObject = true)
-public final class TimeFilter extends FilterBase {
- /**
- * Length of hour in milliseconds.
- */
- private static final long HOUR_MS = 3600000;
-
- /**
- * Length of minute in milliseconds.
- */
- private static final long MINUTE_MS = 60000;
-
- /**
- * Length of second in milliseconds.
- */
- private static final long SECOND_MS = 1000;
-
- /**
- * Starting offset from midnight in milliseconds.
- */
- private final long start;
- /**
- * Ending offset from midnight in milliseconds.
- */
- private final long end;
- /**
- * Timezone.
- */
- private final TimeZone timezone;
-
-
- private TimeFilter(long start, long end, TimeZone tz, Result onMatch, Result onMismatch) {
- super(onMatch, onMismatch);
- this.start = start;
- this.end = end;
- timezone = tz;
- }
-
- @Override
- public Result filter(LogEvent event) {
- Calendar calendar = Calendar.getInstance(timezone);
- calendar.setTimeInMillis(event.getMillis());
- //
- // get apparent number of milliseconds since midnight
- // (ignores extra or missing hour on daylight time changes).
- //
- long apparentOffset = calendar.get(Calendar.HOUR_OF_DAY) * HOUR_MS +
- calendar.get(Calendar.MINUTE) * MINUTE_MS +
- calendar.get(Calendar.SECOND) * SECOND_MS +
- calendar.get(Calendar.MILLISECOND);
- return (apparentOffset >= start && apparentOffset < end) ? onMatch : onMismatch;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("start=").append(start);
- sb.append(", end=").append(end);
- sb.append(", timezone=").append(timezone.toString());
- return sb.toString();
- }
-
- /**
- * Create a TimeFilter.
- * @param start The start time.
- * @param end The end time.
- * @param tz timezone.
- * @param match Action to perform if the time matches.
- * @param mismatch Action to perform if the action does not match.
- * @return A TimeFilter.
- */
- @PluginFactory
- public static TimeFilter createFilter(@PluginAttr("start") String start,
- @PluginAttr("end") String end,
- @PluginAttr("timezone") String tz,
- @PluginAttr("onMatch") String match,
- @PluginAttr("onMismatch") String mismatch) {
- SimpleDateFormat stf = new SimpleDateFormat("HH:mm:ss");
- long s = 0;
- if (start != null) {
- stf.setTimeZone(TimeZone.getTimeZone("UTC"));
- try {
- s = stf.parse(start).getTime();
- } catch (ParseException ex) {
- LOGGER.warn("Error parsing start value " + start, ex);
- }
- }
- long e = Long.MAX_VALUE;
- if (end != null) {
- stf.setTimeZone(TimeZone.getTimeZone("UTC"));
- try {
- e = stf.parse(end).getTime();
- } catch (ParseException ex) {
- LOGGER.warn("Error parsing start value " + end, ex);
- }
- }
- TimeZone timezone = (tz == null) ? TimeZone.getDefault() : TimeZone.getTimeZone(tz);
- Result onMatch = match == null ? Result.NEUTRAL : Result.valueOf(match);
- Result onMismatch = mismatch == null ? Result.DENY : Result.valueOf(mismatch);
-
- return new TimeFilter(s, e, timezone, onMatch, onMismatch);
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/ValueLevelPair.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/ValueLevelPair.java
deleted file mode 100644
index bba7e37..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/ValueLevelPair.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-/**
- * A key and its value.
- */
-@Plugin(name = "ValueLevelPair", type = "Core")
-public class ValueLevelPair {
-
- private String key;
- private Level level;
-
- public ValueLevelPair(String key, Level level) {
- this.key = key;
- this.level = level;
- }
-
- public String getKey() {
- return key;
- }
-
- public Level getLevel() {
- return level;
- }
-
- /**
- * Create a Value/Level pair using the Log Levels.
- * @param key The key.
- * @param value Its value.
- * @return A ValueLevelPair.
- */
- @PluginFactory
- public static ValueLevelPair createPair(@PluginAttr("key") String key,
- @PluginAttr("threshold") String value) {
-
- Level level = Level.toLevel(value);
- return new ValueLevelPair(key, level);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/package-info.java
deleted file mode 100644
index 7f840e9..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 Filter support.
- */
-package org.apache.logging.log4j.core.filter;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Constants.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Constants.java
deleted file mode 100644
index 87b4555..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Constants.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.helpers;
-
-/**
- * Log4j Constants.
- */
-public final class Constants {
-
- /**
- * Name of the system property to use to identify the ContextSelector Class.
- */
- public static final String LOG4J_CONTEXT_SELECTOR = "Log4jContextSelector";
-
- /**
- * JNDI context name string literal.
- */
- public static final String JNDI_CONTEXT_NAME = "java:comp/env/log4j/context-name";
-
- /**
- * Prevent class instantiation.
- */
- private Constants() {
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/FileUtils.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/FileUtils.java
deleted file mode 100644
index bf4968f..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/FileUtils.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.helpers;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URLDecoder;
-
-/**
- * File utilities.
- */
-public final class FileUtils {
-
- /** Constant for the file URL protocol.*/
- private static final String PROTOCOL_FILE = "file";
-
- private static Logger logger = StatusLogger.getLogger();
-
- private FileUtils() {
- }
-
- /**
- * Tries to convert the specified URL to a file object. If this fails,
- * <b>null</b> is returned.
- *
- * @param uri the URI
- * @return the resulting file object
- */
- public static File fileFromURI(URI uri) {
- if (uri == null || !uri.getScheme().equals(PROTOCOL_FILE)) {
- return null;
- } else {
- try {
- return new File(URLDecoder.decode(uri.toURL().getFile(), "UTF8"));
- } catch (MalformedURLException ex) {
- logger.warn("Invalid URL " + uri, ex);
- } catch (UnsupportedEncodingException uee) {
- logger.warn("Invalid encoding: UTF8", uee);
- }
- return null;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/KeyValuePair.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/KeyValuePair.java
deleted file mode 100644
index 5a8776e..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/KeyValuePair.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.helpers;
-
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-/**
- * Key/Value pair configuration item.
- */
-@Plugin(name = "KeyValuePair", type = "Core", printObject = true)
-public class KeyValuePair {
-
- private final String key;
- private final String value;
-
- /**
- * Constructs a key/value pair. The constructor should only be called from test classes.
- * @param key The key.
- * @param value The value.
- */
- public KeyValuePair(String key, String value) {
- this.key = key;
- this.value = value;
- }
-
- /**
- * Return the key.
- * @return the key.
- */
- public String getKey() {
- return key;
- }
-
- /**
- * Return the value.
- * @return The value.
- */
- public String getValue() {
- return value;
- }
-
- @Override
- public String toString() {
- return key + "=" + value;
- }
-
- /**
- * Create a Key/Value pair.
- * @param key The key.
- * @param value The value.
- * @return A KeyValuePair.
- */
- @PluginFactory
- public static KeyValuePair createPair(@PluginAttr("key") String key,
- @PluginAttr("value") String value) {
-
- return new KeyValuePair(key, value);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Loader.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Loader.java
deleted file mode 100644
index 4da8ce0..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Loader.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.helpers;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-
-/**
- * Load resources (or images) from various sources.
- */
-
-public final class Loader {
-
- private static final String TSTR = "Caught Exception while in Loader.getResource. This may be innocuous.";
-
- private static boolean ignoreTCL = false;
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- static {
- String ignoreTCLProp = OptionConverter.getSystemProperty("log4j.ignoreTCL", null);
- if (ignoreTCLProp != null) {
- ignoreTCL = OptionConverter.toBoolean(ignoreTCLProp, true);
- }
- }
-
- private Loader() {
- }
-
- /**
- * This method will search for <code>resource</code> in different
- * places. The search order is as follows:
- * <p/>
- * <ol>
- * <p/>
- * <p><li>Search for <code>resource</code> using the thread context
- * class loader under Java2. If that fails, search for
- * <code>resource</code> using the class loader that loaded this
- * class (<code>Loader</code>). Under JDK 1.1, only the the class
- * loader that loaded this class (<code>Loader</code>) is used.
- * <p/>
- * <p><li>Try one last time with
- * <code>ClassLoader.getSystemResource(resource)</code>, that is is
- * using the system class loader in JDK 1.2 and virtual machine's
- * built-in class loader in JDK 1.1.
- * <p/>
- * </ol>
- * @param resource The resource to load.
- * @return A URL to the resource.
- */
- public static URL getResource(String resource) {
- ClassLoader classLoader;
- URL url;
-
- try {
- classLoader = getTCL();
- if (classLoader != null) {
- LOGGER.trace("Trying to find [" + resource + "] using context classloader "
- + classLoader + ".");
- url = classLoader.getResource(resource);
- if (url != null) {
- return url;
- }
- }
-
- // We could not find resource. Let us now try with the classloader that loaded this class.
- classLoader = Loader.class.getClassLoader();
- if (classLoader != null) {
- LOGGER.trace("Trying to find [" + resource + "] using " + classLoader + " class loader.");
- url = classLoader.getResource(resource);
- if (url != null) {
- return url;
- }
- }
- } catch (IllegalAccessException t) {
- LOGGER.warn(TSTR, t);
- } catch (InvocationTargetException t) {
- if (t.getTargetException() instanceof InterruptedException
- || t.getTargetException() instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.warn(TSTR, t);
- } catch (Throwable t) {
- //
- // can't be InterruptedException or InterruptedIOException
- // since not declared, must be error or RuntimeError.
- LOGGER.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.
- LOGGER.trace("Trying to find [" + resource + "] using ClassLoader.getSystemResource().");
- return ClassLoader.getSystemResource(resource);
- }
-
- /**
- * This method will search for <code>resource</code> in different
- * places. The search order is as follows:
- * <p/>
- * <ol>
- * <p/>
- * <p><li>Search for <code>resource</code> using the thread context
- * class loader under Java2. If that fails, search for
- * <code>resource</code> using the class loader that loaded this
- * class (<code>Loader</code>). Under JDK 1.1, only the the class
- * loader that loaded this class (<code>Loader</code>) is used.
- * <p/>
- * <p><li>Try one last time with
- * <code>ClassLoader.getSystemResource(resource)</code>, that is is
- * using the system class loader in JDK 1.2 and virtual machine's
- * built-in class loader in JDK 1.1.
- * <p/>
- * </ol>
- * @param resource The resource to load.
- * @param defaultLoader The default ClassLoader.
- * @return An InputStream to read the resouce.
- */
- public static InputStream getResourceAsStream(String resource, ClassLoader defaultLoader) {
- ClassLoader classLoader;
- InputStream is;
-
- try {
- classLoader = getTCL();
- if (classLoader != null) {
- LOGGER.trace("Trying to find [" + resource + "] using context classloader " + classLoader + ".");
- is = classLoader.getResourceAsStream(resource);
- if (is != null) {
- return is;
- }
- }
-
- // We could not find resource. Let us now try with the classloader that loaded this class.
- classLoader = Loader.class.getClassLoader();
- if (classLoader != null) {
- LOGGER.trace("Trying to find [" + resource + "] using " + classLoader + " class loader.");
- is = classLoader.getResourceAsStream(resource);
- if (is != null) {
- return is;
- }
- }
-
- // We could not find resource. Finally try with the default ClassLoader.
- if (defaultLoader != null) {
- LOGGER.trace("Trying to find [" + resource + "] using " + defaultLoader + " class loader.");
- is = defaultLoader.getResourceAsStream(resource);
- if (is != null) {
- return is;
- }
- }
- } catch (IllegalAccessException t) {
- LOGGER.warn(TSTR, t);
- } catch (InvocationTargetException t) {
- if (t.getTargetException() instanceof InterruptedException
- || t.getTargetException() instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.warn(TSTR, t);
- } catch (Throwable t) {
- //
- // can't be InterruptedException or InterruptedIOException
- // since not declared, must be error or RuntimeError.
- LOGGER.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.
- LOGGER.trace("Trying to find [" + resource + "] using ClassLoader.getSystemResource().");
- return ClassLoader.getSystemResourceAsStream(resource);
- }
-
- /**
- * Load a Class by name.
- * @param clazz The class name.
- * @return The Class.
- * @throws ClassNotFoundException if the Class could not be found.
- */
- public static Class loadClass(String clazz) throws ClassNotFoundException {
- // Just call Class.forName(clazz) if we are instructed to ignore the TCL.
- if (ignoreTCL) {
- return Class.forName(clazz);
- } else {
- try {
- return getTCL().loadClass(clazz);
- } catch (Throwable e) {
- return Class.forName(clazz);
- }
- }
- }
-
- /**
- * Return the ClassLoader to use.
- * @return the ClassLoader.
- */
- public static ClassLoader getClassLoader() {
- ClassLoader cl = null;
-
- try {
- cl = getTCL();
- } catch (Exception ex) {
- // Ignore the exception. The ClassLoader will be located.
- }
- if (cl == null) {
- cl = Loader.getClassLoader();
- }
- return cl;
- }
-
- private static ClassLoader getTCL() throws IllegalAccessException, InvocationTargetException {
- ClassLoader cl;
- if (System.getSecurityManager() == null) {
- cl = Thread.currentThread().getContextClassLoader();
- } else {
- cl = (ClassLoader) java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
- return Thread.currentThread().getContextClassLoader();
- }
- }
- );
- }
-
- return cl;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/NameUtil.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/NameUtil.java
deleted file mode 100644
index 5612ec8..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/NameUtil.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.helpers;
-
-/**
- *
- */
-public final class NameUtil {
-
- private NameUtil() {
- }
-
- public static String getSubName(String name) {
- if (name.length() == 0) {
- return null;
- }
- int i = name.lastIndexOf(".");
- return i > 0 ? name.substring(0, i) : "";
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java
deleted file mode 100644
index 6516312..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.helpers;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.util.Properties;
-
-/**
- * A convenience class to convert property values to specific types.
- */
-public final class OptionConverter {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private static final String DELIM_START = "${";
- private static final char DELIM_STOP = '}';
- private static final int DELIM_START_LEN = 2;
- private static final int DELIM_STOP_LEN = 1;
- private static final int ONE_K = 1024;
-
- /**
- * OptionConverter is a static class.
- */
- private OptionConverter() {
- }
-
- public static String[] concatanateArrays(String[] l, String[] r) {
- int len = l.length + r.length;
- String[] a = new String[len];
-
- System.arraycopy(l, 0, a, 0, l.length);
- System.arraycopy(r, 0, a, l.length, r.length);
-
- return a;
- }
-
- public static String convertSpecialChars(String s) {
- char c;
- int len = s.length();
- StringBuffer sbuf = new StringBuffer(len);
-
- int i = 0;
- while (i < len) {
- c = s.charAt(i++);
- if (c == '\\') {
- c = s.charAt(i++);
- if (c == 'n') {
- c = '\n';
- } else if (c == 'r') {
- c = '\r';
- } else if (c == 't') {
- c = '\t';
- } else if (c == 'f') {
- c = '\f';
- } else if (c == '\b') {
- c = '\b';
- } else if (c == '\"') {
- c = '\"';
- } else if (c == '\'') {
- c = '\'';
- } else if (c == '\\') {
- c = '\\';
- }
- }
- sbuf.append(c);
- }
- return sbuf.toString();
- }
-
-
- /**
- * Very similar to <code>System.getProperty</code> except
- * that the {@link SecurityException} is hidden.
- *
- * @param key The key to search for.
- * @param def The default value to return.
- * @return the string value of the system property, or the default
- * value if there is no property with that key.
- */
- public static String getSystemProperty(String key, String def) {
- try {
- return System.getProperty(key, def);
- } catch (Throwable e) { // MS-Java throws com.ms.security.SecurityExceptionEx
- LOGGER.debug("Was not allowed to read system property \"" + key + "\".");
- return def;
- }
- }
-
-
- public static Object instantiateByKey(Properties props, String key, Class superClass,
- Object defaultValue) {
-
- // Get the value of the property in string form
- String className = findAndSubst(key, props);
- if (className == null) {
- LOGGER.error("Could not find value for key " + key);
- return defaultValue;
- }
- // Trim className to avoid trailing spaces that cause problems.
- return OptionConverter.instantiateByClassName(className.trim(), superClass,
- defaultValue);
- }
-
- /**
- * If <code>value</code> is "true", then <code>true</code> is
- * returned. If <code>value</code> is "false", then
- * <code>true</code> is returned. Otherwise, <code>default</code> is
- * returned.
- * <p/>
- * <p>Case of value is unimportant.
- * @param value The value to convert.
- * @param dEfault The default value.
- * @return true or false, depending on the value and/or default.
- */
- public static boolean toBoolean(String value, boolean dEfault) {
- if (value == null) {
- return dEfault;
- }
- String trimmedVal = value.trim();
- if ("true".equalsIgnoreCase(trimmedVal)) {
- return true;
- }
- if ("false".equalsIgnoreCase(trimmedVal)) {
- return false;
- }
- return dEfault;
- }
-
- /**
- * Convert the String value to an int.
- * @param value The value as a String.
- * @param dEfault The default value.
- * @return The value as an int.
- */
- public static int toInt(String value, int dEfault) {
- if (value != null) {
- String s = value.trim();
- try {
- return Integer.valueOf(s);
- } catch (NumberFormatException e) {
- LOGGER.error("[" + s + "] is not in proper int form.");
- e.printStackTrace();
- }
- }
- return dEfault;
- }
-
- /**
- *
- * @param value The size of the file as a String.
- * @param dEfault The default value.
- * @return The size of the file as a long.
- */
- public static long toFileSize(String value, long dEfault) {
- if (value == null) {
- return dEfault;
- }
-
- String s = value.trim().toUpperCase();
- long multiplier = 1;
- int index;
-
- if ((index = s.indexOf("KB")) != -1) {
- multiplier = ONE_K;
- s = s.substring(0, index);
- } else if ((index = s.indexOf("MB")) != -1) {
- multiplier = ONE_K * ONE_K;
- s = s.substring(0, index);
- } else if ((index = s.indexOf("GB")) != -1) {
- multiplier = ONE_K * ONE_K * ONE_K;
- s = s.substring(0, index);
- }
- if (s != null) {
- try {
- return Long.valueOf(s) * multiplier;
- } catch (NumberFormatException e) {
- LOGGER.error("[" + s + "] is not in proper int form.");
- LOGGER.error("[" + value + "] not in expected format.", e);
- }
- }
- return dEfault;
- }
-
- /**
- * Find the value corresponding to <code>key</code> in
- * <code>props</code>. Then perform variable substitution on the
- * found value.
- * @param key The key to locate.
- * @param props The properties.
- * @return The String after substitution.
- */
- public static String findAndSubst(String key, Properties props) {
- String value = props.getProperty(key);
- if (value == null) {
- return null;
- }
-
- try {
- return substVars(value, props);
- } catch (IllegalArgumentException e) {
- LOGGER.error("Bad option value [" + value + "].", e);
- return value;
- }
- }
-
- /**
- * Instantiate an object given a class name. Check that the
- * <code>className</code> is a subclass of
- * <code>superClass</code>. If that test fails or the object could
- * not be instantiated, then <code>defaultValue</code> is returned.
- *
- * @param className The fully qualified class name of the object to instantiate.
- * @param superClass The class to which the new object should belong.
- * @param defaultValue The object to return in case of non-fulfillment
- * @return The created object.
- */
- public static Object instantiateByClassName(String className, Class superClass,
- Object defaultValue) {
- if (className != null) {
- try {
- Class classObj = Loader.loadClass(className);
- if (!superClass.isAssignableFrom(classObj)) {
- LOGGER.error("A \"" + className + "\" object is not assignable to a \"" +
- superClass.getName() + "\" variable.");
- LOGGER.error("The class \"" + superClass.getName() + "\" was loaded by ");
- LOGGER.error("[" + superClass.getClassLoader() + "] whereas object of type ");
- LOGGER.error("\"" + classObj.getName() + "\" was loaded by ["
- + classObj.getClassLoader() + "].");
- return defaultValue;
- }
- return classObj.newInstance();
- } catch (ClassNotFoundException e) {
- LOGGER.error("Could not instantiate class [" + className + "].", e);
- } catch (IllegalAccessException e) {
- LOGGER.error("Could not instantiate class [" + className + "].", e);
- } catch (InstantiationException e) {
- LOGGER.error("Could not instantiate class [" + className + "].", e);
- } catch (RuntimeException e) {
- LOGGER.error("Could not instantiate class [" + className + "].", e);
- }
- }
- return defaultValue;
- }
-
-
- /**
- * Perform variable substitution in string <code>val</code> from the
- * values of keys found in the system propeties.
- * <p/>
- * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
- * <p/>
- * <p>For example, if the System properties contains "key=value", then
- * the call
- * <pre>
- * String s = OptionConverter.substituteVars("Value of key is ${key}.");
- * </pre>
- * <p/>
- * will set the variable <code>s</code> to "Value of key is value.".
- * <p/>
- * <p>If no value could be found for the specified key, then the
- * <code>props</code> parameter is searched, if the value could not
- * be found there, then substitution defaults to the empty string.
- * <p/>
- * <p>For example, if system propeties contains no value for the key
- * "inexistentKey", then the call
- * <p/>
- * <pre>
- * String s = OptionConverter.subsVars("Value of inexistentKey is [${inexistentKey}]");
- * </pre>
- * will set <code>s</code> to "Value of inexistentKey is []"
- * <p/>
- * <p>An {@link java.lang.IllegalArgumentException} is thrown if
- * <code>val</code> contains a start delimeter "${" which is not
- * balanced by a stop delimeter "}". </p>
- * <p/>
- * <p><b>Author</b> Avy Sharell</a></p>
- *
- * @param val The string on which variable substitution is performed.
- * @param props The properties to use for substitution.
- * @return The String after substitution.
- * @throws IllegalArgumentException if <code>val</code> is malformed.
- */
- public static String substVars(String val, Properties props) throws
- IllegalArgumentException {
-
- StringBuilder sbuf = new StringBuilder();
-
- int i = 0;
- int j;
- int k;
-
- while (true) {
- j = val.indexOf(DELIM_START, i);
- if (j == -1) {
- // no more variables
- if (i == 0) { // this is a simple string
- return val;
- } else { // add the tail string which contails no variables and return the result.
- sbuf.append(val.substring(i, val.length()));
- return sbuf.toString();
- }
- } else {
- sbuf.append(val.substring(i, j));
- k = val.indexOf(DELIM_STOP, j);
- if (k == -1) {
- throw new IllegalArgumentException('"' + val +
- "\" has no closing brace. Opening brace at position " + j
- + '.');
- } else {
- j += DELIM_START_LEN;
- String key = val.substring(j, k);
- // first try in System properties
- String replacement = getSystemProperty(key, null);
- // then try props parameter
- if (replacement == null && props != null) {
- replacement = props.getProperty(key);
- }
-
- if (replacement != null) {
- // Do variable substitution on the replacement string
- // such that we can solve "Hello ${x2}" as "Hello p1"
- // the where the properties are
- // x1=p1
- // x2=${x1}
- String recursiveReplacement = substVars(replacement, props);
- sbuf.append(recursiveReplacement);
- }
- i = k + DELIM_STOP_LEN;
- }
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Transform.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Transform.java
deleted file mode 100644
index 001ca41..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/Transform.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.helpers;
-
-
-/**
- * Utility class for transforming strings.
- */
-public final class Transform {
-
- private static final String CDATA_START = "<![CDATA[";
- private static final String CDATA_END = "]]>";
- 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();
-
- private Transform() {
- }
-
- /**
- * 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.
- */
- public static 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.
-
- StringBuilder buf = new StringBuilder(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 (<![CDATA[) and final CDEnd (]]>) 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.
- */
- public static void appendEscapingCDATA(final StringBuilder 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/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
deleted file mode 100644
index 97c7fc6..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.helpers;
-
-import java.lang.reflect.Method;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.nio.ByteBuffer;
-import java.security.SecureRandom;
-import java.util.Enumeration;
-import java.util.Random;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Generates a unique id. The generated UUID will be unique for approximately 8,925 years so long as
- * less than 4095 ids are generated per millisecond on the same device (as identified by its MAC adddress).
- */
-public final class UUIDUtil {
- /**
- * System property that may be used to seed the uuid generation with an integer value.
- */
- public static final String UUID_SEQUENCE = "org.apache.logging.log4j.uuidSequence";
-
- private static final String ASSIGNED_SEQUENCES = "org.apache.logging.log4j.assignedSequences";
-
- private static AtomicInteger count = new AtomicInteger(0);
-
- private static final long TYPE1 = 0x1000L;
-
- private static final byte VARIANT = (byte) 0x80;
-
- private static final int SEQUENCE_MASK = 0x3FFF;
-
- private static final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L;
-
- private static long uuidSequence = Long.getLong(UUID_SEQUENCE, 0);
-
- private static long least;
-
- private static final long LOW_MASK = 0xffffffffL;
- private static final long MID_MASK = 0xffff00000000L;
- private static final long HIGH_MASK = 0xfff000000000000L;
- private static final int NODE_SIZE = 8;
- private static final int SHIFT_2 = 16;
- private static final int SHIFT_4 = 32;
- private static final int SHIFT_6 = 48;
- private static final int HUNDRED_NANOS_PER_MILLI = 10000;
-
- static {
- byte[] mac = null;
- try {
- InetAddress address = InetAddress.getLocalHost();
- try {
- NetworkInterface ni = NetworkInterface.getByInetAddress(address);
- if (ni != null && !ni.isLoopback() && ni.isUp()) {
- Method method = ni.getClass().getMethod("getHardwareAddress");
- if (method != null) {
- mac = (byte[]) method.invoke(ni);
- }
- }
-
- if (mac == null) {
- Enumeration<NetworkInterface> enumeration = NetworkInterface.getNetworkInterfaces();
- while (enumeration.hasMoreElements() && mac == null) {
- ni = enumeration.nextElement();
- if (ni != null && ni.isUp() && !ni.isLoopback()) {
- Method method = ni.getClass().getMethod("getHardwareAddress");
- if (method != null) {
- mac = (byte[]) method.invoke(ni);
- }
- }
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- // Ignore exception
- }
- if (mac == null || mac.length == 0) {
- mac = address.getAddress();
- }
- } catch (UnknownHostException e) {
- // Ignore exception
- }
- Random randomGenerator = new SecureRandom();
- if (mac == null || mac.length == 0) {
- mac = new byte[6];
- randomGenerator.nextBytes(mac);
- }
- int length = mac.length >= 6 ? 6 : mac.length;
- int index = mac.length >= 6 ? mac.length - 6 : 0;
- byte[] node = new byte[NODE_SIZE];
- node[0] = VARIANT;
- node[1] = 0;
- for (int i = 2; i < NODE_SIZE; ++i) {
- node[i] = 0;
- }
- System.arraycopy(mac, index, node, index + 2, length);
- ByteBuffer buf = ByteBuffer.wrap(node);
- long rand = uuidSequence;
- Runtime runtime = Runtime.getRuntime();
- synchronized (runtime) {
- String assigned = System.getProperty(ASSIGNED_SEQUENCES);
- long[] sequences;
- if (assigned == null) {
- sequences = new long[0];
- } else {
- String[] array = assigned.split(",");
- sequences = new long[array.length];
- int i = 0;
- for (String value : array) {
- sequences[i] = Long.parseLong(value);
- ++i;
- }
- }
- if (rand == 0) {
- rand = randomGenerator.nextLong();
- }
- rand &= SEQUENCE_MASK;
- boolean duplicate;
- do {
- duplicate = false;
- for (long sequence : sequences) {
- if (sequence == rand) {
- duplicate = true;
- }
- }
- if (duplicate) {
- rand = (rand + 1) & SEQUENCE_MASK;
- }
- } while (duplicate);
- assigned = assigned == null ? Long.toString(rand) : assigned + "," + Long.toString(rand);
- System.setProperty(ASSIGNED_SEQUENCES, assigned);
- }
-
- least = buf.getLong() | rand << SHIFT_6;
- }
-
-
- /* This class cannot be instantiated */
- private UUIDUtil() {
- }
-
- /**
- * Generates Type 1 UUID. The time contains the number of 100NS intervals that have occurred
- * since 00:00:00.00 UTC, 10 October 1582. Each UUID on a particular machine is unique to the 100NS interval
- * until they rollover around 3400 A.D.
- * <ol>
- * <li>Digits 1-12 are the lower 48 bits of the number of 100 ns increments since the start of the UUID
- * epoch.</li>
- * <li>Digit 13 is the version (with a value of 1).</li>
- * <li>Digits 14-16 are a sequence number that is incremented each time a UUID is generated.</li>
- * <li>Digit 17 is the variant (with a value of binary 10) and 10 bits of the sequence number</li>
- * <li>Digit 18 is final 16 bits of the sequence number.</li>
- * <li>Digits 19-32 represent the system the application is running on.
- * </ol>
- *
- * @return universally unique identifiers (UUID)
- */
- public static UUID getTimeBasedUUID() {
-
- long time = ((System.currentTimeMillis() * HUNDRED_NANOS_PER_MILLI) + NUM_100NS_INTERVALS_SINCE_UUID_EPOCH) +
- (count.incrementAndGet() % HUNDRED_NANOS_PER_MILLI);
- long timeLow = (time & LOW_MASK) << SHIFT_4;
- long timeMid = (time & MID_MASK) >> SHIFT_2;
- long timeHi = (time & HIGH_MASK) >> SHIFT_6;
- long most = timeLow | timeMid | TYPE1 | timeHi;
- return new UUID(most, least);
- }
-}
-
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/package-info.java
deleted file mode 100644
index d33a392..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 helper classes.
- */
-package org.apache.logging.log4j.core.helpers;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
deleted file mode 100644
index 1fb463a..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.impl;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.helpers.Constants;
-import org.apache.logging.log4j.core.helpers.Loader;
-import org.apache.logging.log4j.core.selector.ClassLoaderContextSelector;
-import org.apache.logging.log4j.core.selector.ContextSelector;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.spi.LoggerContextFactory;
-
-/**
- * Factory to locate a ContextSelector and then load a LoggerContext.
- */
-public class Log4jContextFactory implements LoggerContextFactory {
-
- private ContextSelector selector;
-
- private StatusLogger logger = StatusLogger.getLogger();
-
- private ThreadLocal<Log4jContextFactory> recursive = new ThreadLocal<Log4jContextFactory>();
-
- /**
- * Constructor that initializes the ContextSelector.
- */
- public Log4jContextFactory() {
- String sel = System.getProperty(Constants.LOG4J_CONTEXT_SELECTOR);
- if (sel != null) {
- try {
- Class clazz = Loader.loadClass(sel);
- if (clazz != null && ContextSelector.class.isAssignableFrom(clazz)) {
- selector = (ContextSelector) clazz.newInstance();
- return;
- }
- } catch (Exception ex) {
- logger.error("Unable to create context " + sel, ex);
- }
-
- }
- selector = new ClassLoaderContextSelector();
- }
-
- /**
- * Return the ContextSelector.
- * @return The ContextSelector.
- */
- public ContextSelector getSelector() {
- return selector;
- }
-
- /**
- * Load the LoggerContext using the ContextSelector.
- * @param fqcn The fully qualified class name of the caller.
- * @param currentContext If true returns the current Context, if false returns the Context appropriate
- * for the caller if a more appropriate Context can be determined.
- * @return The LoggerContext.
- */
- public LoggerContext getContext(String fqcn, boolean currentContext) {
- LoggerContext ctx = selector.getContext(fqcn, currentContext);
- synchronized (ctx) {
- if (recursive.get() != null || ctx.isStarted()) {
- return ctx;
- }
- try {
- recursive.set(this);
- ctx.start();
- return ctx;
- } finally {
- recursive.remove();
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
deleted file mode 100644
index b2827e5..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.impl;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.message.LoggerNameAwareMessage;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.TimestampMessage;
-
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
-
-/**
- * Implementation of a LogEvent.
- */
-public class Log4jLogEvent implements LogEvent, Serializable {
-
- private static final long serialVersionUID = -1351367343806656055L;
- private static final String NOT_AVAIL = "?";
- private final String fqcnOfLogger;
- private final Marker marker;
- private final Level level;
- private final String name;
- private final Message message;
- private final long timestamp;
- private final ThrowableProxy throwable;
- private final Map<String, String> mdc;
- private final Stack<String> ndc;
- private String threadName = null;
- private StackTraceElement location;
-
- /**
- * Constructor.
- * @param loggerName The name of the Logger.
- * @param marker The Marker or null.
- * @param fqcn The fully qualified class name of the caller.
- * @param level The logging Level.
- * @param message The Message.
- * @param t A Throwable or null.
- */
- public Log4jLogEvent(String loggerName, Marker marker, String fqcn, Level level, Message message, Throwable t) {
- this(loggerName, marker, fqcn, level, message, t, ThreadContext.getContext(), ThreadContext.cloneStack(), null,
- null, System.currentTimeMillis());
- }
-
- /**
- * Constructor.
- * @param loggerName The name of the Logger.
- * @param marker The Marker or null.
- * @param fqcn The fully qualified class name of the caller.
- * @param level The logging Level.
- * @param message The Message.
- * @param t A Throwable or null.
- * @param mdc The mapped diagnostic context.
- * @param ndc the nested diagnostic context.
- * @param threadName The name of the thread.
- * @param location The locations of the caller.
- * @param timestamp The timestamp of the event.
- */
- public Log4jLogEvent(String loggerName, Marker marker, String fqcn, Level level, Message message, Throwable t,
- Map<String, String> mdc, Stack<String> ndc, String threadName, StackTraceElement location,
- long timestamp) {
- name = loggerName;
- this.marker = marker;
- this.fqcnOfLogger = fqcn;
- this.level = level;
- this.message = message;
- this.throwable = t == null ? null : new ThrowableProxy(t);
- this.mdc = mdc;
- this.ndc = ndc;
- this.timestamp = message instanceof TimestampMessage ? ((TimestampMessage) message).getTimestamp() : timestamp;
- this.threadName = threadName;
- this.location = location;
- if (message != null && message instanceof LoggerNameAwareMessage) {
- ((LoggerNameAwareMessage) message).setLoggerName(name);
- }
- }
-
- /**
- * Returns the logging Level.
- * @return the Level associated with this event.
- */
- public Level getLevel() {
- return level;
- }
-
- /**
- * Return the name of the Logger used to generate the event.
- * @return The Logger name.
- */
- public String getLoggerName() {
- return name;
- }
-
- /**
- * Return the Message associated with the event.
- * @return The Message.
- */
- public Message getMessage() {
- return message;
- }
-
- /**
- * Return the name of the Thread on which the event was generated.
- * @return The name of the Thread.
- */
- public String getThreadName() {
- if (threadName == null) {
- threadName = Thread.currentThread().getName();
- }
- return threadName;
- }
-
- /**
- * Return the time in milliseconds from the epoch when the event occurred.
- * @return The time the event occurred.
- */
- public long getMillis() {
- return timestamp;
- }
-
- /**
- * Return the Throwable associated with the event, or null.
- * @return The Throwable associated with the event.
- */
- public Throwable getThrown() {
- return throwable;
- }
-
- /**
- * Return the Marker associated with the event, or null.
- * @return the Marker associated with the event.
- */
- public Marker getMarker() {
- return marker;
- }
-
- /**
- * The fully qualified class name of the class that was called by the caller.
- * @return the fully qualified class name of the class that is performing logging.
- */
- public String getFQCN() {
- return fqcnOfLogger;
- }
-
- /**
- * @doubt Allows direct access to the map passed into the constructor, would allow appender
- * or layout to manipulate event as seen by other appenders.
- * @return The context Map.
- */
- public Map<String, String> getContextMap() {
- return mdc;
- }
-
- /**
- * @doubt Allows direct access to the map passed into the constructor, would allow appender
- * or layout to manipulate event as seen by other appenders.
- * @return The context Stack.
- */
- public Stack<String> getContextStack() {
- return ndc;
- }
-
- /**
- * Return the StackTraceElement for the caller. This will be the entry that occurs right
- * before the first occurrence of FQCN as a class name.
- * @return the StackTraceElement for the caller.
- */
- public StackTraceElement getSource() {
- if (fqcnOfLogger == null) {
- return null;
- }
- if (location == null) {
- StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
- boolean next = false;
- for (StackTraceElement element : stackTrace) {
- String className = element.getClassName();
- if (next) {
- if (fqcnOfLogger.equals(className)) {
- continue;
- }
- location = element;
- break;
- }
-
- if (fqcnOfLogger.equals(className)) {
- next = true;
- } else if (NOT_AVAIL.equals(className)) {
- break;
- }
- }
- }
-
- return location;
- }
-
- /**
- * Creates a LogEventProxy that can be serialized.
- * @return a LogEventProxy.
- */
- protected Object writeReplace() {
- return new LogEventProxy(this);
- }
-
- private void readObject(ObjectInputStream stream) throws InvalidObjectException {
- throw new InvalidObjectException("Proxy required");
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- String n = name.length() == 0 ? "root" : name;
- sb.append("Logger=").append(n);
- sb.append(" Level=").append(level.name());
- sb.append(" Message").append(message.getFormattedMessage());
- return sb.toString();
- }
-
- /**
- * Proxy pattern used to serialize the LogEvent.
- */
- private static class LogEventProxy implements Serializable {
-
- private static final long serialVersionUID = -7139032940312647146L;
- private final String fqcnOfLogger;
- private final Marker marker;
- private final Level level;
- private final String name;
- private final Message message;
- private final long timestamp;
- private final Throwable throwable;
- private final HashMap<String, String> mdc;
- private final Stack<String> ndc;
- private String threadName;
- private StackTraceElement location;
-
- public LogEventProxy(Log4jLogEvent event) {
- this.fqcnOfLogger = event.fqcnOfLogger;
- this.marker = event.marker;
- this.level = event.level;
- this.name = event.name;
- this.message = event.message;
- this.timestamp = event.timestamp;
- this.throwable = event.throwable;
- this.mdc = new HashMap<String, String>(event.mdc);
- this.ndc = event.ndc;
- this.location = event.getSource();
- this.threadName = event.getThreadName();
- }
-
- /**
- * Return a Log4jLogEvent using the data in the proxy.
- * @return Log4jLogEvent.
- */
- protected Object readResolve() {
- return new Log4jLogEvent(name, marker, fqcnOfLogger, level, message, throwable, mdc, ndc, threadName,
- location, timestamp);
- }
-
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/LogEventFactory.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/LogEventFactory.java
deleted file mode 100644
index 9a3ed49..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/LogEventFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.impl;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.message.Message;
-
-/**
- *
- */
-public interface LogEventFactory {
-
- LogEvent createEvent(String loggerName, Marker marker, String fqcn, Level level, Message data, Throwable t);
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
deleted file mode 100644
index 14e1994..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.impl;
-
-import java.io.Serializable;
-
-/**
- * Package data for a StackTraceElement.
- */
-public class StackTracePackageElement implements Serializable {
-
- private static final long serialVersionUID = -2171069569241280505L;
-
- private final String location;
-
- private final String version;
-
- private final boolean isExact;
-
- /**
- * Constructor that takes the location, version, and exact match flag.
- * @param location The location of the Class.
- * @param version The version of the component.
- * @param exact if true this is an exact package element.
- */
- public StackTracePackageElement(String location, String version, boolean exact) {
- this.location = location;
- this.version = version;
- this.isExact = exact;
- }
-
- /**
- * Return the location of the element.
- * @return The location of the element.
- */
- public String getLocation() {
- return location;
- }
-
- /**
- * Return the version of the element.
- * @return the version of the element.
- */
- public String getVersion() {
- return version;
- }
-
- /**
- * Return the indicator of whether this is an exact match.
- * @return true if the location was determined exactly.
- */
- public boolean isExact() {
- return isExact;
- }
-
- @Override
- public String toString() {
- String exact = isExact ? "" : "~";
- return exact + "[" + location + ":" + version + "]";
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
deleted file mode 100644
index ee447a8..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.impl;
-
-import org.apache.logging.log4j.core.helpers.Loader;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.net.URL;
-import java.security.CodeSource;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
-
-/**
- * Wraps a Throwable to add packaging information about each stack trace element.
- */
-public class ThrowableProxy extends Throwable {
-
- private static final long serialVersionUID = -2752771578252251910L;
-
- private static Method getCallerClass;
-
- private static PrivateSecurityManager securityManager;
-
- private static final org.apache.logging.log4j.Logger LOGGER = StatusLogger.getLogger();
-
- private static Method getSuppressed;
-
- private final Throwable throwable;
- private final ThrowableProxy cause;
- private final ThrowableProxy[] suppressed;
- private int commonElementCount;
-
- private final StackTracePackageElement[] callerPackageData;
-
-
- static {
- setupCallerCheck();
- versionCheck();
- }
-
- /**
- * Construct the wrapper for the Throwable that includes packaging data.
- * @param throwable The Throwable to wrap.
- */
- public ThrowableProxy(Throwable throwable) {
- this.throwable = throwable;
- Map<String, CacheEntry> map = new HashMap<String, CacheEntry>();
- Stack<Class> stack = getCurrentStack();
- callerPackageData = resolvePackageData(stack, map, null, throwable.getStackTrace());
- this.cause = (throwable.getCause() == null) ? null :
- new ThrowableProxy(throwable, stack, map, throwable.getCause());
- suppressed = getSuppressed(throwable);
- }
-
- /**
- * Constructs the wrapper for a Throwable that is referenced as the cause by another
- * Throwable.
- * @param parent The Throwable referencing this Throwable.
- * @param stack The Class stack.
- * @param map The cache containing the packaging data.
- * @param cause The Throwable to wrap.
- */
- private ThrowableProxy(Throwable parent, Stack<Class> stack, Map<String, CacheEntry> map, Throwable cause) {
- this.throwable = cause;
- callerPackageData = resolvePackageData(stack, map, parent.getStackTrace(), cause.getStackTrace());
- this.cause = (throwable.getCause() == null) ? null :
- new ThrowableProxy(parent, stack, map, throwable.getCause());
- suppressed = getSuppressed(throwable);
- }
-
-
- @Override
- public void setStackTrace(StackTraceElement[] stackTraceElements) {
- throw new UnsupportedOperationException("Cannot set the stack trace on a ThrowableProxy");
- }
-
- @Override
- public String getMessage() {
- return throwable.getMessage();
- }
-
- @Override
- public String getLocalizedMessage() {
- return throwable.getLocalizedMessage();
- }
-
- @Override
- public Throwable getCause() {
- return cause;
- }
-
- /**
- * Added in Java 7.
- * @param exception A Throwable that was suppressed.
- */
- public void addSuppressed(Throwable exception) {
- throw new UnsupportedOperationException("Cannot add suppressed exceptions to a ThrowableProxy");
- }
-
- /**
- * Added in Java 7.
- * @return Any suppressed exceptions.
- */
- public Throwable[] getSuppressed() {
- return suppressed;
- }
-
- @Override
- public Throwable initCause(Throwable throwable) {
- throw new IllegalStateException("Cannot set the cause on a ThrowableProxy");
- }
-
- @Override
- public String toString() {
- return throwable.toString();
- }
-
- @Override
- public void printStackTrace() {
- throwable.printStackTrace();
- }
-
- @Override
- public void printStackTrace(PrintStream printStream) {
- throwable.printStackTrace(printStream);
- }
-
- @Override
- public void printStackTrace(PrintWriter printWriter) {
- throwable.printStackTrace(printWriter);
- }
-
- @Override
- public Throwable fillInStackTrace() {
- return this;
- }
-
- @Override
- public StackTraceElement[] getStackTrace() {
- return throwable.getStackTrace();
- }
-
- /**
- * Format the Throwable that is the cause of this Throwable.
- * @return The formatted Throwable that caused this Throwable.
- */
- public String getRootCauseStackTrace() {
- StringBuilder sb = new StringBuilder();
- if (cause != null) {
- formatWrapper(sb, cause);
- sb.append("Wrapped by: ");
- }
- sb.append(throwable.toString());
- sb.append("\n");
- formatElements(sb, 0, throwable.getStackTrace(), callerPackageData);
- return sb.toString();
- }
-
- /**
- * Formats the specified Throwable.
- * @param sb StringBuilder to contain the formatted Throwable.
- * @param cause The Throwable to format.
- */
- public void formatWrapper(StringBuilder sb, ThrowableProxy cause) {
- Throwable caused = cause.getCause();
- if (caused != null) {
- formatWrapper(sb, cause.cause);
- sb.append("Wrapped by: ");
- }
- sb.append(cause).append("\n");
- formatElements(sb, cause.commonElementCount, cause.getStackTrace(), cause.callerPackageData);
- }
-
- /**
- * Format the stack trace including packaging information.
- * @return The formatted stack trace including packaging information.
- */
- public String getExtendedStackTrace() {
- StringBuilder sb = new StringBuilder(throwable.toString());
- sb.append("\n");
- formatElements(sb, 0, throwable.getStackTrace(), callerPackageData);
- if (cause != null) {
- formatCause(sb, cause);
- }
- return sb.toString();
- }
-
- /**
- * Format the suppressed Throwables.
- * @return The formatted suppressed Throwables.
- */
- public String getSuppressedStackTrace() {
- if (suppressed == null || suppressed.length == 0) {
- return "";
- }
- StringBuilder sb = new StringBuilder("Suppressed Stack Trace Elements:\n");
- for (ThrowableProxy proxy : suppressed) {
- sb.append(proxy.getExtendedStackTrace());
- }
- return sb.toString();
- }
-
- private void formatCause(StringBuilder sb, ThrowableProxy cause) {
- sb.append("Caused by: ").append(cause).append("\n");
- formatElements(sb, cause.commonElementCount, cause.getStackTrace(), cause.callerPackageData);
- if (cause.getCause() != null) {
- formatCause(sb, cause.cause);
- }
- }
-
- private void formatElements(StringBuilder sb, int commonCount, StackTraceElement[] causedTrace,
- StackTracePackageElement[] packageData) {
- for (int i = 0; i < packageData.length; ++i) {
- sb.append("\tat ");
- sb.append(causedTrace[i]);
- sb.append(" ");
- sb.append(packageData[i]);
- sb.append("\n");
- }
- if (commonCount != 0) {
- sb.append("\t... ").append(commonCount).append(" more").append("\n");
- }
- }
-
- /**
- * Initialize the cache by resolving everything in the current stack trace via Reflection.getCallerClass
- * or via the SecurityManager if either are available. These are the only Classes that can be trusted
- * to be accurate.
- * @return A Deque containing the current stack of Class objects.
- */
- private Stack<Class> getCurrentStack() {
- if (getCallerClass != null) {
- Stack<Class> classes = new Stack<Class>();
- int index = 2;
- Class clazz = getCallerClass(index);
- while (clazz != null) {
- classes.push(clazz);
- clazz = getCallerClass(++index);
- }
- return classes;
- } else if (securityManager != null) {
- Class[] array = securityManager.getClasses();
- Stack<Class> classes = new Stack<Class>();
- for (Class clazz : array) {
- classes.push(clazz);
- }
- return classes;
- }
- return new Stack<Class>();
- }
-
- /**
- * Resolve all the stack entries in this stack trace that are not common with the parent.
- * @param stack The callers Class stack.
- * @param map The cache of CacheEntry objects.
- * @param rootTrace The first stack trace resolve or null.
- * @param stackTrace The stack trace being resolved.
- * @return The StackTracePackageElement array.
- */
- private StackTracePackageElement[] resolvePackageData(Stack<Class> stack, Map<String, CacheEntry> map,
- StackTraceElement[] rootTrace,
- StackTraceElement[] stackTrace) {
- int stackLength;
- if (rootTrace != null) {
- int rootIndex = rootTrace.length - 1;
- int stackIndex = stackTrace.length - 1;
- while (rootIndex >= 0 && stackIndex >= 0 && rootTrace[rootIndex].equals(stackTrace[stackIndex])) {
- --rootIndex;
- --stackIndex;
- }
- commonElementCount = stackTrace.length - 1 - stackIndex;
- stackLength = stackIndex + 1;
- } else {
- commonElementCount = 0;
- stackLength = stackTrace.length;
- }
- StackTracePackageElement[] packageArray = new StackTracePackageElement[stackLength];
- Class clazz = stack.peek();
- ClassLoader lastLoader = null;
- for (int i = stackLength - 1; i >= 0; --i) {
- String className = stackTrace[i].getClassName();
- // The stack returned from getCurrentStack will be missing entries for java.lang.reflect.Method.invoke()
- // and its implementation. The Throwable might also contain stack entries that are no longer
- // present as those methods have returned.
- if (className.equals(clazz.getName())) {
- CacheEntry entry = resolvePackageElement(clazz, true);
- packageArray[i] = entry.element;
- lastLoader = entry.loader;
- stack.pop();
- clazz = stack.peek();
- } else {
- if (map.containsKey(className)) {
- CacheEntry entry = map.get(className);
- packageArray[i] = entry.element;
- if (entry.loader != null) {
- lastLoader = entry.loader;
- }
- } else {
- CacheEntry entry = resolvePackageElement(loadClass(lastLoader, className), false);
- packageArray[i] = entry.element;
- map.put(className, entry);
- if (entry.loader != null) {
- lastLoader = entry.loader;
- }
- }
- }
- }
- return packageArray;
- }
-
-
- /**
- * Construct the CacheEntry from the Class's information.
- * @param callerClass The Class.
- * @param exact True if the class was obtained via Reflection.getCallerClass.
- * @return The CacheEntry.
- */
- private CacheEntry resolvePackageElement(Class callerClass, boolean exact) {
- String location = "?";
- String version = "?";
- ClassLoader lastLoader = null;
- if (callerClass != null) {
- try {
- CodeSource source = callerClass.getProtectionDomain().getCodeSource();
- if (source != null) {
- URL locationURL = source.getLocation();
- if (locationURL != null) {
- String str = locationURL.toString().replace('\\', '/');
- int index = str.lastIndexOf("/");
- if (index >= 0 && index == str.length() - 1) {
- index = str.lastIndexOf("/", index - 1);
- location = str.substring(index + 1);
- } else {
- location = str.substring(index + 1);
- }
- }
- }
- } catch (Exception ex) {
- // Ignore the exception.
- }
- Package pkg = callerClass.getPackage();
- if (pkg != null) {
- String ver = pkg.getImplementationVersion();
- if (ver != null) {
- version = ver;
- }
- }
- lastLoader = callerClass.getClassLoader();
- }
- return new CacheEntry(new StackTracePackageElement(location, version, exact), lastLoader);
- }
-
- /**
- * Invoke Reflection.getCallerClass via reflection. This is slightly slower than calling the method
- * directly but removes any dependency on Sun's JDK being present at compile time. The difference
- * can be measured by running the ReflectionComparison test.
- * @param index The index into the stack trace.
- * @return The Class at the specified stack entry.
- */
- private Class getCallerClass(int index) {
- if (getCallerClass != null) {
- try {
- Object[] params = new Object[]{index};
- return (Class) getCallerClass.invoke(null, params);
- } catch (Exception ex) {
- // logger.debug("Unable to determine caller class via Sun Reflection", ex);
- }
- }
- return null;
- }
-
- /**
- * Loads classes not located via Reflection.getCallerClass.
- * @param lastLoader The ClassLoader that loaded the Class that called this Class.
- * @param className The name of the Class.
- * @return The Class object for the Class or null if it could not be located.
- */
- private Class loadClass(ClassLoader lastLoader, String className) {
- Class clazz;
- if (lastLoader != null) {
- try {
- clazz = lastLoader.loadClass(className);
- if (clazz != null) {
- return clazz;
- }
- } catch (Exception ex) {
- // Ignore exception.
- }
- }
- try {
- clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
- } catch (ClassNotFoundException e) {
- try {
- clazz = Class.forName(className);
- } catch (ClassNotFoundException e1) {
- try {
- clazz = getClass().getClassLoader().loadClass(className);
- } catch (ClassNotFoundException e2) {
- return null;
- }
- }
- }
- return clazz;
- }
-
- private static void versionCheck() {
- Method[] methods = Throwable.class.getMethods();
- for (Method method : methods) {
- if (method.getName().equals("getSuppressed")) {
- getSuppressed = method;
- }
- }
- }
-
- /**
- * Determine if Reflection.getCallerClass is available.
- */
- private static void setupCallerCheck() {
- try {
- ClassLoader loader = Loader.getClassLoader();
- Class clazz = loader.loadClass("sun.reflect.Reflection");
- Method[] methods = clazz.getMethods();
- for (Method method : methods) {
- int modifier = method.getModifiers();
- if (method.getName().equals("getCallerClass") && Modifier.isStatic(modifier)) {
- getCallerClass = method;
- return;
- }
- }
- } catch (ClassNotFoundException cnfe) {
- LOGGER.debug("sun.reflect.Reflection is not installed");
- }
-
- try {
- PrivateSecurityManager mgr = new PrivateSecurityManager();
- if (mgr.getClasses() != null) {
- securityManager = mgr;
- } else {
- // This shouldn't happen.
- LOGGER.error("Unable to obtain call stack from security manager");
- }
- } catch (Exception ex) {
- LOGGER.debug("Unable to install security manager", ex);
- }
- }
-
- private ThrowableProxy[] getSuppressed(Throwable throwable) {
- ThrowableProxy[] supp = null;
- if (getSuppressed != null) {
- try {
- Throwable[] array = (Throwable[]) getSuppressed.invoke(throwable, null);
- supp = new ThrowableProxy[array.length];
- int i = 0;
- for (Throwable t : array) {
- supp[i] = new ThrowableProxy(t);
- ++i;
- }
- } catch (Exception ex) {
- //
- }
- }
- return supp;
- }
-
- /**
- * Cached StackTracePackageElement and the ClassLoader.
- */
- private class CacheEntry {
- private StackTracePackageElement element;
- private ClassLoader loader;
-
- public CacheEntry(StackTracePackageElement element, ClassLoader loader) {
- this.element = element;
- this.loader = loader;
- }
- }
-
- /**
- * Security Manager for accessing the call stack.
- */
- private static class PrivateSecurityManager extends SecurityManager {
- public Class[] getClasses() {
- return getClassContext();
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java
deleted file mode 100644
index ff8c923..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 private implementation classes.
- */
-package org.apache.logging.log4j.core.impl;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextAnchor.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextAnchor.java
deleted file mode 100644
index ba94821..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextAnchor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.javaee;
-
-import org.apache.logging.log4j.core.LoggerContext;
-
-/**
- * Anchor for the ThreadContext.
- */
-public final class ContextAnchor {
-
- /**
- * Anchor for the LoggerContext for the current Thread.
- */
- public static final ThreadLocal<LoggerContext> THREAD_CONTEXT = new ThreadLocal<LoggerContext>();
-
- private ContextAnchor() {
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextListener.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextListener.java
deleted file mode 100644
index 09c35dd..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/ContextListener.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.javaee;
-
-import org.apache.logging.log4j.core.LoggerContext;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-/**
- * Saves the LoggerContext into the ServletContext as an attribute.
- */
-public class ContextListener implements ServletContextListener {
-
- /**
- * The name of the attribute to use to store the LoggerContext into the ServletContext.
- */
- public static final String LOG4J_CONTEXT_ATTRIBUTE = "Log4JContext";
-
- public void contextInitialized(ServletContextEvent event) {
- ServletContext context = event.getServletContext();
- LoggerContext ctx = new LoggerContext(context.getServletContextName(), context);
- context.setAttribute(LOG4J_CONTEXT_ATTRIBUTE, ctx);
- }
-
- public void contextDestroyed(ServletContextEvent event) {
- ServletContext context = event.getServletContext();
- LoggerContext ctx = (LoggerContext) context.getAttribute(LOG4J_CONTEXT_ATTRIBUTE);
- if (ctx != null) {
- context.removeAttribute(LOG4J_CONTEXT_ATTRIBUTE);
- ctx.stop();
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java
deleted file mode 100644
index 64dc857..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.javaee;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.impl.Log4jContextFactory;
-import org.apache.logging.log4j.core.selector.ContextSelector;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.selector.NamedContextSelector;
-import org.apache.logging.log4j.spi.LoggerContextFactory;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.UnavailableException;
-import java.io.IOException;
-
-/**
- * ServletFilter than may be used to set up a LoggerContext for each web application.
- */
-public class JNDIContextFilter implements Filter {
- /**
- * The Filter init parameter that defines the name of the LoggerContext.
- */
- public static final String CONTEXT_NAME = "context-name";
- /**
- * The Filter init parameter that defines the configuration location for the LoggerContext.
- */
- public static final String CONFIG_LOCATION = "config-location";
- private ServletContext context;
- private boolean created = false;
- private String name;
- private NamedContextSelector selector = null;
-
- public void init(FilterConfig filterConfig) throws ServletException {
- context = filterConfig.getServletContext();
- name = filterConfig.getInitParameter(CONTEXT_NAME);
- String configLocn = filterConfig.getInitParameter(CONFIG_LOCATION);
- if (name == null) {
- throw new UnavailableException("A context-name attribute is required");
- }
- if (context.getAttribute(ContextListener.LOG4J_CONTEXT_ATTRIBUTE) == null) {
- LoggerContext ctx;
- LoggerContextFactory factory = LogManager.getFactory();
- if (factory instanceof Log4jContextFactory) {
- ContextSelector sel = ((Log4jContextFactory) factory).getSelector();
- if (sel instanceof NamedContextSelector) {
- selector = (NamedContextSelector) sel;
- ctx = selector.locateContext(name, configLocn);
- } else {
- return;
- }
- } else {
- return;
- }
- context.setAttribute(ContextListener.LOG4J_CONTEXT_ATTRIBUTE, ctx);
- created = true;
- context.log("Created context for " + name + " using " + ctx.getClass().getClassLoader());
- }
- }
-
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
- throws IOException, ServletException {
- LoggerContext ctx = (LoggerContext) context.getAttribute(ContextListener.LOG4J_CONTEXT_ATTRIBUTE);
- if (ctx != null) {
- ContextAnchor.THREAD_CONTEXT.set(ctx);
- try {
- filterChain.doFilter(servletRequest, servletResponse);
- } finally {
- ContextAnchor.THREAD_CONTEXT.remove();
- }
- } else {
- filterChain.doFilter(servletRequest, servletResponse);
- }
- }
-
- public void destroy() {
- LoggerContext ctx = (LoggerContext) context.getAttribute(ContextListener.LOG4J_CONTEXT_ATTRIBUTE);
- if (ctx != null && created) {
- context.log("Removing context for " + name);
- context.removeAttribute(ContextListener.LOG4J_CONTEXT_ATTRIBUTE);
- if (selector != null) {
- selector.removeContext(name);
- }
- ctx.stop();
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/package-info.java
deleted file mode 100644
index 90da62e..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Classes to aid integration with Java EE.
- */
-package org.apache.logging.log4j.core.javaee;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java
deleted file mode 100644
index 4d44f2b..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.jmx;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.impl.Log4jContextFactory;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.selector.ContextSelector;
-import org.apache.logging.log4j.status.StatusData;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.util.List;
-
-/**
- * Preliminary implementation for testing with JBoss.
- */
-public class Log4jManager {
-
- private static final StatusLogger LOGGER = StatusLogger.getLogger();
-
- public List<LoggerContext> getLoggerContexts() {
- Log4jContextFactory factory = (Log4jContextFactory) LogManager.getFactory();
- ContextSelector selector = factory.getSelector();
- return selector.getLoggerContexts();
- }
-
- public List<StatusData> getStatusData() {
- return LOGGER.getStatusData();
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManagerMBean.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManagerMBean.java
deleted file mode 100644
index cb782b6..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManagerMBean.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.jmx;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.status.StatusData;
-
-import java.util.List;
-
-/**
- *
- */
-public interface Log4jManagerMBean {
-
- List<LoggerContext> getLoggerContexts();
-
- List<StatusData> getStatusData();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/package-info.java
deleted file mode 100644
index 9b5cd0b..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 JMX support.
- */
-package org.apache.logging.log4j.core.jmx;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
deleted file mode 100644
index 5f4b3b5..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.core.LogEvent;
-
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-
-/**
- * Base class for Layouts that result in a String.
- */
-public abstract class AbstractStringLayout extends LayoutBase<String> {
-
- /**
- * The charset of the formatted message.
- */
- private Charset charset;
-
- private final StringEncoder encoder;
-
- protected AbstractStringLayout(Charset charset) {
- this.charset = charset;
- boolean useClass = false;
- try {
- Class[] types = new Class[] {Charset.class};
- if (String.class.getMethod("getBytes", types) != null) {
- useClass = true;
- }
-
- } catch (NoSuchMethodException ex) {
- // Not JDK 6 or greater.
- }
- encoder = useClass ? new ClassEncoder() : new NameEncoder();
- }
-
- /**
- * Format the Log Event.
- * @param event The Log Event.
- * @return The formatted event as a byte array.
- */
- public byte[] format(LogEvent event) {
- return encoder.getBytes(formatAs(event));
- }
-
- protected Charset getCharset() {
- return charset;
- }
-
- /**
- * Encoder interface to support Java 5 and Java 6+.
- */
- private interface StringEncoder {
-
- byte[] getBytes(String str);
- }
-
- /**
- * JDK 6 or greater.
- */
- private class ClassEncoder implements StringEncoder {
- public byte[] getBytes(String str) {
- return str.getBytes(charset);
- }
- }
-
- /**
- * JDK 5.
- */
- private class NameEncoder implements StringEncoder {
- public byte[] getBytes(String str) {
- try {
- return str.getBytes(charset.name());
- } catch (UnsupportedEncodingException ex) {
- // This shouldn't ever happen since an invalid Charset would never have been created.
- return str.getBytes();
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
deleted file mode 100644
index 9dcdd41..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.helpers.Transform;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.io.LineNumberReader;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.lang.management.ManagementFactory;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-
-/**
- * This layout outputs events in a HTML table.
- * <p/>
- * 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.
- */
-@Plugin(name = "HTMLLayout", type = "Core", elementType = "layout", printObject = true)
-public final class HTMLLayout extends AbstractStringLayout {
-
- private static final int BUF_SIZE = 256;
-
- private static final String TRACE_PREFIX = "<br> ";
-
- private static final String LINE_SEP = System.getProperty("line.separator");
-
- private static final String DEFAULT_TITLE = "Log4J Log Messages";
-
- private static final String DEFAULT_CONTENT_TYPE = "text/html";
-
- private final long jvmStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
-
- // Print no location info by default
- private final boolean locationInfo;
-
- private final String title;
-
- private final String contentType;
-
- private HTMLLayout(boolean locationInfo, String title, String contentType, Charset charset) {
- super(charset);
- this.locationInfo = locationInfo;
- this.title = title;
- this.contentType = contentType;
- }
-
- /**
- * Format as a String.
- * @param event The Logging Event.
- * @return A String containging the LogEvent as HTML.
- */
- public String formatAs(LogEvent event) {
- StringBuilder sbuf = new StringBuilder(BUF_SIZE);
-
- sbuf.append(LINE_SEP).append("<tr>").append(LINE_SEP);
-
- sbuf.append("<td>");
- sbuf.append(event.getMillis() - jvmStartTime);
- sbuf.append("</td>").append(LINE_SEP);
-
- String escapedThread = Transform.escapeTags(event.getThreadName());
- sbuf.append("<td title=\"").append(escapedThread).append(" thread\">");
- sbuf.append(escapedThread);
- sbuf.append("</td>").append(LINE_SEP);
-
- sbuf.append("<td title=\"Level\">");
- if (event.getLevel().equals(Level.DEBUG)) {
- sbuf.append("<font color=\"#339933\">");
- sbuf.append(Transform.escapeTags(String.valueOf(event.getLevel())));
- sbuf.append("</font>");
- } else if (event.getLevel().isAtLeastAsSpecificAs(Level.WARN)) {
- sbuf.append("<font color=\"#993300\"><strong>");
- sbuf.append(Transform.escapeTags(String.valueOf(event.getLevel())));
- sbuf.append("</strong></font>");
- } else {
- sbuf.append(Transform.escapeTags(String.valueOf(event.getLevel())));
- }
- sbuf.append("</td>").append(LINE_SEP);
-
- String escapedLogger = Transform.escapeTags(event.getLoggerName());
- if (escapedLogger.length() == 0) {
- escapedLogger = "root";
- }
- sbuf.append("<td title=\"").append(escapedLogger).append(" logger\">");
- sbuf.append(escapedLogger);
- sbuf.append("</td>").append(LINE_SEP);
-
- if (locationInfo) {
- StackTraceElement element = event.getSource();
- sbuf.append("<td>");
- sbuf.append(Transform.escapeTags(element.getFileName()));
- sbuf.append(':');
- sbuf.append(element.getLineNumber());
- sbuf.append("</td>").append(LINE_SEP);
- }
-
- sbuf.append("<td title=\"Message\">");
- sbuf.append(Transform.escapeTags(event.getMessage().getFormattedMessage()));
- sbuf.append("</td>").append(LINE_SEP);
- sbuf.append("</tr>").append(LINE_SEP);
-
- if (event.getContextStack().size() > 0) {
- sbuf.append("<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" ");
- sbuf.append("title=\"Nested Diagnostic Context\">");
- sbuf.append("NDC: ").append(Transform.escapeTags(event.getContextStack().toString()));
- sbuf.append("</td></tr>").append(LINE_SEP);
- }
-
- if (event.getContextMap().size() > 0) {
- sbuf.append("<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" ");
- sbuf.append("title=\"Mapped Diagnostic Context\">");
- sbuf.append("MDC: ").append(Transform.escapeTags(event.getContextMap().toString()));
- sbuf.append("</td></tr>").append(LINE_SEP);
- }
-
- Throwable throwable = event.getThrown();
- if (throwable != null) {
- sbuf.append("<tr><td bgcolor=\"#993300\" style=\"color:White; font-size : xx-small;\" colspan=\"6\">");
- appendThrowableAsHTML(throwable, sbuf);
- sbuf.append("</td></tr>").append(LINE_SEP);
- }
-
- return sbuf.toString();
- }
-
- private void appendThrowableAsHTML(Throwable throwable, StringBuilder sbuf) {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- try {
- throwable.printStackTrace(pw);
- } catch (RuntimeException ex) {
- // Ignore the exception.
- }
- pw.flush();
- LineNumberReader reader = new LineNumberReader(new StringReader(sw.toString()));
- ArrayList<String> lines = new ArrayList<String>();
- try {
- String line = reader.readLine();
- while (line != null) {
- lines.add(line);
- line = reader.readLine();
- }
- } catch (IOException ex) {
- if (ex instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- lines.add(ex.toString());
- }
- boolean first = true;
- for (String line : lines) {
- if (!first) {
- sbuf.append(TRACE_PREFIX);
- } else {
- first = false;
- }
- sbuf.append(Transform.escapeTags(line));
- sbuf.append(LINE_SEP);
- }
- }
-
- /**
- * Returns appropriate HTML headers.
- * @return The header as a byte array.
- */
- @Override
- public byte[] getHeader() {
- StringBuilder sbuf = new StringBuilder();
- sbuf.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" ");
- sbuf.append("\"http://www.w3.org/TR/html4/loose.dtd\">");
- sbuf.append(LINE_SEP);
- sbuf.append("<html>").append(LINE_SEP);
- sbuf.append("<head>").append(LINE_SEP);
- sbuf.append("<title>").append(title).append("</title>").append(LINE_SEP);
- sbuf.append("<style type=\"text/css\">").append(LINE_SEP);
- sbuf.append("<!--").append(LINE_SEP);
- sbuf.append("body, table {font-family: arial,sans-serif; font-size: x-small;}").append(LINE_SEP);
- sbuf.append("th {background: #336699; color: #FFFFFF; text-align: left;}").append(LINE_SEP);
- sbuf.append("-->").append(LINE_SEP);
- sbuf.append("</style>").append(LINE_SEP);
- sbuf.append("</head>").append(LINE_SEP);
- sbuf.append("<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">").append(LINE_SEP);
- sbuf.append("<hr size=\"1\" noshade>").append(LINE_SEP);
- sbuf.append("Log session start time " + new java.util.Date() + "<br>").append(LINE_SEP);
- sbuf.append("<br>").append(LINE_SEP);
- sbuf.append(
- "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">");
- sbuf.append(LINE_SEP);
- sbuf.append("<tr>").append(LINE_SEP);
- sbuf.append("<th>Time</th>").append(LINE_SEP);
- sbuf.append("<th>Thread</th>").append(LINE_SEP);
- sbuf.append("<th>Level</th>").append(LINE_SEP);
- sbuf.append("<th>Logger</th>").append(LINE_SEP);
- if (locationInfo) {
- sbuf.append("<th>File:Line</th>").append(LINE_SEP);
- }
- sbuf.append("<th>Message</th>").append(LINE_SEP);
- sbuf.append("</tr>").append(LINE_SEP);
- return sbuf.toString().getBytes(getCharset());
- }
-
- /**
- * Returns the appropriate HTML footers.
- * @return the footer as a byet array.
- */
- @Override
- public byte[] getFooter() {
- StringBuilder sbuf = new StringBuilder();
- sbuf.append("</table>").append(LINE_SEP);
- sbuf.append("<br>").append(LINE_SEP);
- sbuf.append("</body></html>");
- return sbuf.toString().getBytes(getCharset());
- }
-
- /**
- * Create an HTML Layout.
- * @param locationInfo If "true", location information will be included. The default is false.
- * @param title The title to include in the file header. If none is specified the default title will be used.
- * @param contentType The content type. Defaults to "text/html".
- * @param charset The character set to use. If not specified, the default will be used.
- * @return An HTML Layout.
- */
- @PluginFactory
- public static HTMLLayout createLayout(@PluginAttr("locationInfo") String locationInfo,
- @PluginAttr("title") String title,
- @PluginAttr("contentType") String contentType,
- @PluginAttr("charset") String charset) {
- Charset c = Charset.isSupported("UTF-8") ? Charset.forName("UTF-8") : Charset.defaultCharset();
- if (charset != null) {
- if (Charset.isSupported(charset)) {
- c = Charset.forName(charset);
- } else {
- LOGGER.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
- }
- }
- boolean info = locationInfo == null ? false : Boolean.valueOf(locationInfo);
- if (title == null) {
- title = DEFAULT_TITLE;
- }
- if (contentType == null) {
- contentType = DEFAULT_CONTENT_TYPE;
- }
- return new HTMLLayout(info, title, contentType, c);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/LayoutBase.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/LayoutBase.java
deleted file mode 100644
index b6e2301..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/LayoutBase.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.io.Serializable;
-
-/**
- * Base class for Layouts.
- * @param <T> The Class that the Layout will format the LogEvent into.
- */
-public abstract class LayoutBase<T extends Serializable> implements Layout<T> {
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
- /**
- * The header to include when the stream is opened. May be null.
- */
- protected byte[] header;
- /**
- * The footer to add when the stream is closed. May be null.
- */
- protected byte[] footer;
-
- /**
- * Return the header, if one is available.
- * @return A byte array containing the header.
- */
- public byte[] getHeader() {
- return header;
- }
-
- /**
- * Set the header.
- * @param header The header.
- */
- public void setHeader(byte[] header) {
- this.header = header;
- }
-
- /**
- * Returns the footer, if one is available.
- * @return A byte array containing the footer.
- */
- public byte[] getFooter() {
- return footer;
- }
-
- /**
- * Set the footer.
- * @param footer The footer.
- */
- public void setFooter(byte[] footer) {
- this.footer = footer;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
deleted file mode 100644
index 74b1c28..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.helpers.OptionConverter;
-import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
-import org.apache.logging.log4j.core.pattern.PatternConverter;
-import org.apache.logging.log4j.core.pattern.PatternParser;
-import org.apache.logging.log4j.core.pattern.RegexReplacement;
-
-import java.nio.charset.Charset;
-import java.util.List;
-
-/**
- * <p>A flexible layout configurable with pattern string. The goal of this class
- * is to {@link #format format} a {@link LogEvent} and return the results.
- * The format of the result depends on the <em>conversion pattern</em>.
- * <p>
- * <p/>
- * <p>The conversion pattern is closely related to the conversion
- * pattern of the printf function in C. A conversion pattern is
- * composed of literal text and format control expressions called
- * <em>conversion specifiers</em>.
- *
- * See the Log4j Manual for details on the supported pattern converters.
- */
-@Plugin(name = "PatternLayout", type = "Core", elementType = "layout", printObject = true)
-public final class PatternLayout extends AbstractStringLayout {
- /**
- * Default pattern string for log output. Currently set to the
- * string <b>"%m%n"</b> which just prints the application supplied
- * message.
- */
- public static final String DEFAULT_CONVERSION_PATTERN = "%m%n";
-
- /**
- * A conversion pattern equivalent to the TTCCCLayout.
- * Current value is <b>%r [%t] %p %c %x - %m%n</b>.
- */
- public static final String TTCC_CONVERSION_PATTERN =
- "%r [%t] %p %c %x - %m%n";
-
- /**
- * A simple pattern.
- * Current value is <b>%d [%t] %p %c - %m%n</b>.
- */
- public static final String SIMPLE_CONVERSION_PATTERN =
- "%d [%t] %p %c - %m%n";
-
- private static final String KEY = "Converter";
-
- /**
- * Initial converter for pattern.
- */
- private List<PatternConverter> converters;
-
- /**
- * Conversion pattern.
- */
- private String conversionPattern;
-
- /**
- * True if any element in pattern formats information from exceptions.
- */
- private boolean handlesExceptions;
-
- /**
- * The current Configuration.
- */
- private final Configuration config;
-
- private final RegexReplacement replace;
-
- /**
- * Constructs a EnhancedPatternLayout using the supplied conversion pattern.
- *
- * @param config The Configuration.
- * @param replace The regular expression to match.
- * @param pattern conversion pattern.
- * @param charset The character set.
- */
- private PatternLayout(Configuration config, final RegexReplacement replace, final String pattern,
- final Charset charset) {
- super(charset);
- this.replace = replace;
- this.conversionPattern = pattern;
- this.config = config;
- PatternParser parser = createPatternParser(config);
- converters = parser.parse((pattern == null) ? DEFAULT_CONVERSION_PATTERN : pattern);
- handlesExceptions = parser.handlesExceptions();
-
- }
-
- /**
- * Set the <b>ConversionPattern</b> option. This is the string which
- * controls formatting and consists of a mix of literal content and
- * conversion specifiers.
- *
- * @param conversionPattern conversion pattern.
- */
- public void setConversionPattern(final String conversionPattern) {
- String pattern = OptionConverter.convertSpecialChars(conversionPattern);
- if (pattern == null) {
- return;
- }
- PatternParser parser = createPatternParser(this.config);
- converters = parser.parse(pattern);
- handlesExceptions = parser.handlesExceptions();
- }
-
- /**
- * Formats a logging event to a writer.
- *
- * @param event logging event to be formatted.
- * @return The event formatted as a String.
- */
- public String formatAs(final LogEvent event) {
- StringBuilder buf = new StringBuilder();
- for (PatternConverter c : converters) {
- c.format(event, buf);
- }
- String str = buf.toString();
- if (replace != null) {
- str = replace.format(str);
- }
- return config == null ? str : config.getSubst().replace(event, str);
- }
-
- /**
- * Create a PatternParser.
- * @param config The Configuration.
- * @return The PatternParser.
- */
- public static PatternParser createPatternParser(Configuration config) {
- if (config == null) {
- return new PatternParser(config, KEY, LogEventPatternConverter.class);
- }
- PatternParser parser = (PatternParser) config.getComponent(KEY);
- if (parser == null) {
- parser = new PatternParser(config, KEY, LogEventPatternConverter.class);
- config.addComponent(KEY, parser);
- parser = (PatternParser) config.getComponent(KEY);
- }
- return parser;
- }
-
- @Override
- public String toString() {
- return conversionPattern;
- }
-
- /**
- * Create a pattern layout.
- * @param pattern The pattern. If not specified, defaults to DEFAULT_CONVERSION_PATTERN.
- * @param config The Configuration. Some Converters require access to the Interpolator.
- * @param replace A Regex replacement String.
- * @param charset The character set.
- * @return The PatternLayout.
- */
- @PluginFactory
- public static PatternLayout createLayout(@PluginAttr("pattern") String pattern,
- @PluginConfiguration Configuration config,
- @PluginElement("replace") RegexReplacement replace,
- @PluginAttr("charset") String charset) {
- Charset c = Charset.isSupported("UTF-8") ? Charset.forName("UTF-8") : Charset.defaultCharset();
- if (charset != null) {
- if (Charset.isSupported(charset)) {
- c = Charset.forName(charset);
- } else {
- LOGGER.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
- }
- }
- return new PatternLayout(config, replace, pattern == null ? DEFAULT_CONVERSION_PATTERN : pattern, c);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java
deleted file mode 100644
index 6412717..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/RFC5424Layout.java
+++ /dev/null
@@ -1,459 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.net.Facility;
-import org.apache.logging.log4j.core.net.Priority;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.StructuredDataId;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-
-/**
- * Formats a log event in accordance with RFC 5424.
- */
-@Plugin(name = "RFC5424Layout", type = "Core", elementType = "layout", printObject = true)
-public final class RFC5424Layout extends AbstractStringLayout {
-
- /**
- * Not a very good default - it is the Apache Software Foundation's enterprise number.
- */
- public static final int DEFAULT_ENTERPRISE_NUMBER = 18060;
- /**
- * The default event id.
- */
- public static final String DEFAULT_ID = "Audit";
-
- private static final String DEFAULT_MDCID = "mdc";
- private static final int TWO_DIGITS = 10;
- private static final int THREE_DIGITS = 100;
- private static final int MILLIS_PER_MINUTE = 60000;
- private static final int MINUTES_PER_HOUR = 60;
-
- private final Facility facility;
- private final String defaultId;
- private final Integer enterpriseNumber;
- private final boolean includeMDC;
- private final String mdcId;
- private final String localHostName;
- private final String appName;
- private final String messageId;
- private final String configName;
- private final List<String> mdcExcludes;
- private final List<String> mdcIncludes;
- private final List<String> mdcRequired;
- private final ListChecker checker;
- private final ListChecker noopChecker = new NoopChecker();
- private final boolean includeNewLine;
-
- private long lastTimestamp = -1;
- private String timestamppStr = null;
-
-
- private RFC5424Layout(Configuration config, Facility facility, String id, int ein, boolean includeMDC,
- boolean includeNL, String mdcId, String appName, String messageId, String excludes,
- String includes, String required, Charset charset) {
- super(charset);
- this.facility = facility;
- this.defaultId = id == null ? DEFAULT_ID : id;
- this.enterpriseNumber = ein;
- this.includeMDC = includeMDC;
- this.includeNewLine = includeNL;
- this.mdcId = mdcId;
- this.appName = appName;
- this.messageId = messageId;
- this.localHostName = getLocalHostname();
- ListChecker c = null;
- if (excludes != null) {
- String[] array = excludes.split(",");
- if (array.length > 0) {
- c = new ExcludeChecker();
- mdcExcludes = new ArrayList<String>(array.length);
- for (String str : array) {
- mdcExcludes.add(str.trim());
- }
- } else {
- mdcExcludes = null;
- }
- } else {
- mdcExcludes = null;
- }
- if (includes != null) {
- String[] array = includes.split(",");
- if (array.length > 0) {
- c = new IncludeChecker();
- mdcIncludes = new ArrayList<String>(array.length);
- for (String str : array) {
- mdcIncludes.add(str.trim());
- }
- } else {
- mdcIncludes = null;
- }
- } else {
- mdcIncludes = null;
- }
- if (required != null) {
- String[] array = required.split(",");
- if (array.length > 0) {
- mdcRequired = new ArrayList<String>(array.length);
- for (String str : array) {
- mdcRequired.add(str.trim());
- }
- } else {
- mdcRequired = null;
- }
-
- } else {
- mdcRequired = null;
- }
- this.checker = c != null ? c : noopChecker;
- String name = config == null ? null : config.getName();
- configName = (name != null && name.length() > 0) ? name : null;
- }
-
- /**
- * Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the RFC 5424 Syslog specification.
- * @param event The LogEvent.
- * @return The RFC 5424 String representation of the LogEvent.
- */
- public String formatAs(final LogEvent event) {
- Message msg = event.getMessage();
- boolean isStructured = msg instanceof StructuredDataMessage;
- StringBuilder buf = new StringBuilder();
-
- buf.append("<");
- buf.append(Priority.getPriority(facility, event.getLevel()));
- buf.append(">1 ");
- buf.append(computeTimeStampString(event.getMillis()));
- buf.append(' ');
- buf.append(localHostName);
- buf.append(' ');
- if (appName != null) {
- buf.append(appName);
- } else if (configName != null) {
- buf.append(configName);
- } else {
- buf.append("-");
- }
- buf.append(" ");
- buf.append(getProcId());
- buf.append(" ");
- String type = isStructured ? ((StructuredDataMessage) msg).getType() : null;
- if (type != null) {
- buf.append(type);
- } else if (messageId != null) {
- buf.append(messageId);
- } else {
- buf.append("-");
- }
- buf.append(" ");
- if (isStructured || includeMDC) {
- StructuredDataId id = null;
- String text;
- if (isStructured) {
- StructuredDataMessage data = (StructuredDataMessage) msg;
- Map map = data.getData();
- id = data.getId();
- formatStructuredElement(id, map, buf, noopChecker);
- text = data.getMessageFormat();
- } else {
- text = msg.getFormattedMessage();
- }
- if (includeMDC) {
- if (mdcRequired != null) {
- checkRequired(event.getContextMap());
- }
- int ein = id == null || id.getEnterpriseNumber() < 0 ? enterpriseNumber : id.getEnterpriseNumber();
- StructuredDataId mdcSDID = new StructuredDataId(mdcId, ein, null, null);
- formatStructuredElement(mdcSDID, event.getContextMap(), buf, checker);
- }
- if (text != null && text.length() > 0) {
- buf.append(" ").append(text);
- }
- } else {
- buf.append("- ");
- buf.append(msg.getFormattedMessage());
- }
- if (includeNewLine) {
- buf.append("\n");
- }
- return buf.toString();
- }
-
- protected String getProcId() {
- return "-";
- }
-
- /**
- * This method gets the network name of the machine we are running on.
- * Returns "UNKNOWN_LOCALHOST" in the unlikely case where the host name
- * cannot be found.
- *
- * @return String the name of the local host
- */
- public String getLocalHostname() {
- try {
- InetAddress addr = InetAddress.getLocalHost();
- return addr.getHostName();
- } catch (UnknownHostException uhe) {
- LOGGER.error("Could not determine local host name", uhe);
- return "UNKNOWN_LOCALHOST";
- }
- }
-
- protected List<String> getMdcExcludes() {
- return mdcExcludes;
- }
-
- protected List<String> getMdcIncludes() {
- return mdcIncludes;
- }
-
- private String computeTimeStampString(long now) {
- long last;
- synchronized (this) {
- last = lastTimestamp;
- if (now == lastTimestamp) {
- return timestamppStr;
- }
- }
-
- StringBuilder buf = new StringBuilder();
- Calendar cal = new GregorianCalendar();
- cal.setTimeInMillis(now);
- buf.append(Integer.toString(cal.get(Calendar.YEAR)));
- buf.append("-");
- pad(cal.get(Calendar.MONTH) + 1, TWO_DIGITS, buf);
- buf.append("-");
- pad(cal.get(Calendar.DAY_OF_MONTH), TWO_DIGITS, buf);
- buf.append("T");
- pad(cal.get(Calendar.HOUR_OF_DAY), TWO_DIGITS, buf);
- buf.append(":");
- pad(cal.get(Calendar.MINUTE), TWO_DIGITS, buf);
- buf.append(":");
- pad(cal.get(Calendar.SECOND), TWO_DIGITS, buf);
-
- int millis = cal.get(Calendar.MILLISECOND);
- if (millis != 0) {
- buf.append(".");
- pad(millis, THREE_DIGITS, buf);
- }
-
- int tzmin = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / MILLIS_PER_MINUTE;
- if (tzmin == 0) {
- buf.append("Z");
- } else {
- if (tzmin < 0) {
- tzmin = -tzmin;
- buf.append("-");
- } else {
- buf.append("+");
- }
- int tzhour = tzmin / MINUTES_PER_HOUR;
- tzmin -= tzhour * MINUTES_PER_HOUR;
- pad(tzhour, TWO_DIGITS, buf);
- buf.append(":");
- pad(tzmin, TWO_DIGITS, buf);
- }
- synchronized (this) {
- if (last == lastTimestamp) {
- lastTimestamp = now;
- timestamppStr = buf.toString();
- }
- }
- return buf.toString();
- }
-
- private void pad(int val, int max, StringBuilder buf) {
- while (max > 1) {
- if (val < max) {
- buf.append("0");
- }
- max = max / TWO_DIGITS;
- }
- buf.append(Integer.toString(val));
- }
-
- private void formatStructuredElement(StructuredDataId id, Map<String, String> data, StringBuilder sb,
- ListChecker checker) {
- if (id == null && defaultId == null) {
- return;
- }
- sb.append("[");
- sb.append(getId(id));
- appendMap(data, sb, checker);
- sb.append("]");
- }
-
- private String getId(StructuredDataId id) {
- StringBuilder sb = new StringBuilder();
- if (id.getName() == null) {
- sb.append(defaultId);
- } else {
- sb.append(id.getName());
- }
- int ein = id.getEnterpriseNumber();
- if (ein < 0) {
- ein = enterpriseNumber;
- }
- if (ein >= 0) {
- sb.append("@").append(ein);
- }
- return sb.toString();
- }
-
- private void checkRequired(Map<String, String> map) {
- for (String key : mdcRequired) {
- String value = map.get(key);
- if (value == null) {
- throw new LoggingException("Required key " + key + " is missing from the " + mdcId);
- }
- }
- }
-
- private void appendMap(Map<String, String> map, StringBuilder sb, ListChecker checker)
- {
- SortedMap<String, String> sorted = new TreeMap<String, String>(map);
- for (Map.Entry<String, String> entry : sorted.entrySet()) {
- if (checker.check(entry.getKey())) {
- sb.append(" ");
- sb.append(entry.getKey()).append("=\"").append(entry.getValue()).append("\"");
- }
- }
- }
-
- /**
- * Interface used to check keys in a Map.
- */
- private interface ListChecker {
- boolean check(String key);
- }
-
- /**
- * Includes only the listed keys.
- */
- private class IncludeChecker implements ListChecker {
- public boolean check(String key) {
- return mdcIncludes.contains(key);
- }
- }
-
- /**
- * Excludes the listed keys.
- */
- private class ExcludeChecker implements ListChecker {
- public boolean check(String key) {
- return !mdcExcludes.contains(key);
- }
- }
-
- /**
- * Does nothing.
- */
- private class NoopChecker implements ListChecker {
- public boolean check(String key) {
- return true;
- }
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("facility=").append(facility.name());
- sb.append(" appName=").append(appName);
- sb.append(" defaultId=").append(defaultId);
- sb.append(" enterpriseNumber=").append(enterpriseNumber);
- sb.append(" newLine=").append(includeNewLine);
- sb.append(" includeMDC=").append(includeMDC);
- sb.append(" messageId=").append(messageId);
- return sb.toString();
- }
-
- /**
- * Create the RFC 5424 Layout.
- * @param facility The Facility is used to try to classify the message.
- * @param id The default structured data id to use when formatting according to RFC 5424.
- * @param ein The IANA enterprise number.
- * @param includeMDC Indicates whether data from the ThreadContextMap will be included in the RFC 5424 Syslog
- * record. Defaults to "true:.
- * @param mdcId The id to use for the MDC Structured Data Element.
- * @param includeNL If true, a newline will be appended to the end of the syslog record. The default is false.
- * @param appName The value to use as the APP-NAME in the RFC 5424 syslog record.
- * @param msgId The default value to be used in the MSGID field of RFC 5424 syslog records.
- * @param excludes A comma separated list of mdc keys that should be excluded from the LogEvent.
- * @param includes A comma separated list of mdc keys that should be included in the FlumeEvent.
- * @param required A comma separated list of mdc keys that must be present in the MDC.
- * @param charset The character set.
- * @param config The Configuration. Some Converters require access to the Interpolator.
- * @return An RFC5424Layout.
- */
- @PluginFactory
- public static RFC5424Layout createLayout(@PluginAttr("facility") String facility,
- @PluginAttr("id") String id,
- @PluginAttr("enterpriseNumber") String ein,
- @PluginAttr("includeMDC") String includeMDC,
- @PluginAttr("mdcId") String mdcId,
- @PluginAttr("newLine") String includeNL,
- @PluginAttr("appName") String appName,
- @PluginAttr("messageId") String msgId,
- @PluginAttr("mdcExcludes") String excludes,
- @PluginAttr("mdcIncludes") String includes,
- @PluginAttr("mdcRequired") String required,
- @PluginAttr("charset") String charset,
- @PluginConfiguration Configuration config) {
- Charset c = Charset.isSupported("UTF-8") ? Charset.forName("UTF-8") : Charset.defaultCharset();
- if (charset != null) {
- if (Charset.isSupported(charset)) {
- c = Charset.forName(charset);
- } else {
- LOGGER.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
- }
- }
- if (includes != null && excludes != null) {
- LOGGER.error("mdcIncludes and mdcExcludes are mutually exclusive. Includes wil be ignored");
- includes = null;
- }
- Facility f = facility != null ? Facility.valueOf(facility.toUpperCase()) : Facility.LOCAL0;
- int enterpriseNumber = ein == null ? DEFAULT_ENTERPRISE_NUMBER : Integer.parseInt(ein);
- boolean isMdc = includeMDC == null ? true : Boolean.valueOf(includeMDC);
- boolean includeNewLine = includeNL == null ? false : Boolean.valueOf(includeNL);
- if (mdcId == null) {
- mdcId = DEFAULT_MDCID;
- }
-
- return new RFC5424Layout(config, f, id, enterpriseNumber, isMdc, includeNewLine, mdcId, appName, msgId,
- excludes, includes, required, c);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java
deleted file mode 100644
index d76a8ed..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SerializedLayout.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-
-/**
- * Format a LogEvent in its serialized form.
- */
-@Plugin(name = "SerializedLayout", type = "Core", elementType = "layout", printObject = true)
-public final class SerializedLayout extends LayoutBase<LogEvent> {
-
- private static byte[] header;
-
- static {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.close();
- header = baos.toByteArray();
- } catch (Exception ex) {
- LOGGER.error("Unable to generate Object stream header", ex);
- }
- }
-
- private SerializedLayout() {
- }
-
- /**
- * Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the log4j.dtd.
- * @param event The LogEvent.
- * @return the formatted LogEvent.
- */
- public byte[] format(final LogEvent event) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- ObjectOutputStream oos = new PrivateObjectOutputStream(baos);
- oos.writeObject(event);
- } catch (IOException ioe) {
- LOGGER.error("Serialization of Logging Event failed.", ioe);
- }
- return baos.toByteArray();
- }
-
- /**
- * Returns the LogEvent.
- * @param event The Logging Event.
- * @return The LogEvent.
- */
- public LogEvent formatAs(final LogEvent event) {
- return event;
- }
-
- /**
- * Create a SerializedLayout.
- * @return A SerializedLayout.
- */
- @PluginFactory
- public static SerializedLayout createLayout() {
-
- return new SerializedLayout();
- }
-
- @Override
- public byte[] getHeader() {
- return header;
- }
-
- /**
- * The stream header will be written in the Manager so skip it here.
- */
- private class PrivateObjectOutputStream extends ObjectOutputStream {
-
- public PrivateObjectOutputStream() throws IOException {
- }
-
- public PrivateObjectOutputStream(OutputStream os) throws IOException {
- super(os);
- }
-
- @Override
- protected void writeStreamHeader() {
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java
deleted file mode 100644
index c920697..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.net.Facility;
-import org.apache.logging.log4j.core.net.Priority;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.charset.Charset;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-
-/**
- * Formats a log event as a BSD Log record.
- */
-@Plugin(name = "SyslogLayout", type = "Core", elementType = "layout", printObject = true)
-public class SyslogLayout extends AbstractStringLayout {
-
- private final Facility facility;
- private final boolean includeNewLine;
-
- /**
- * Date format used if header = true.
- */
- private final SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd HH:mm:ss ", Locale.ENGLISH);
- /**
- * Host name used to identify messages from this appender.
- */
- private final String localHostname = getLocalHostname();
-
-
- protected SyslogLayout(Facility facility, boolean includeNL, Charset c) {
- super(c);
- this.facility = facility;
- this.includeNewLine = includeNL;
- }
-
- /**
- * Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the log4j.dtd.
- * @param event The LogEvent
- * @return the event formatted as a String.
- */
- public String formatAs(final LogEvent event) {
- StringBuilder buf = new StringBuilder();
-
- buf.append("<");
- buf.append(Priority.getPriority(facility, event.getLevel()));
- buf.append(">");
- addDate(event.getMillis(), buf);
- buf.append(" ");
- buf.append(localHostname);
- buf.append(" ");
- buf.append(event.getMessage().getFormattedMessage());
- if (includeNewLine) {
- buf.append("\n");
- }
- return buf.toString();
- }
-
- /**
- * This method gets the network name of the machine we are running on.
- * Returns "UNKNOWN_LOCALHOST" in the unlikely case where the host name
- * cannot be found.
- *
- * @return String the name of the local host
- */
- private String getLocalHostname() {
- try {
- InetAddress addr = InetAddress.getLocalHost();
- return addr.getHostName();
- } catch (UnknownHostException uhe) {
- LOGGER.error("Could not determine local host name", uhe);
- return "UNKNOWN_LOCALHOST";
- }
- }
-
- private synchronized void addDate(final long timestamp, StringBuilder buf) {
- int index = buf.length() + 4;
- buf.append(dateFormat.format(new Date(timestamp)));
- // RFC 3164 says leading space, not leading zero on days 1-9
- if (buf.charAt(index) == '0') {
- buf.setCharAt(index, ' ');
- }
- }
-
- /**
- * Create a SyslogLayout.
- * @param facility The Facility is used to try to classify the message.
- * @param includeNL If true a newline will be appended to the result.
- * @param charset The character set.
- * @return A SyslogLayout.
- */
- @PluginFactory
- public static SyslogLayout createLayout(@PluginAttr("facility") String facility,
- @PluginAttr("newLine") String includeNL,
- @PluginAttr("charset") String charset) {
-
- Charset c = Charset.isSupported("UTF-8") ? Charset.forName("UTF-8") : Charset.defaultCharset();
- if (charset != null) {
- if (Charset.isSupported(charset)) {
- c = Charset.forName(charset);
- } else {
- LOGGER.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
- }
- }
- boolean includeNewLine = includeNL == null ? false : Boolean.valueOf(includeNL);
- Facility f = facility != null ? Facility.valueOf(facility.toUpperCase()) : Facility.LOCAL0;
- return new SyslogLayout(f, includeNewLine, c);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java
deleted file mode 100644
index 4cfce65..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/XMLLayout.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.io.LineNumberReader;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.helpers.Transform;
-import org.apache.logging.log4j.core.LogEvent;
-
-
-/**
- * The output of the XMLLayout consists of a series of log4j:event
- * elements as defined in the <a href="log4j.dtd">log4j.dtd</a>. If configured to do so it will
- * output a complete well-formed XML file. The output is designed to be
- * included as an <em>external entity</em> in a separate file to form
- * a correct XML file.
- * <p/>
- * <p>For example, if <code>abc</code> is the name of the file where
- * the XMLLayout ouput goes, then a well-formed XML file would be:
- * <p/>
- * <pre>
- * <?xml version="1.0" ?>
- *
- * <!DOCTYPE log4j:eventSet SYSTEM "log4j.dtd" [<!ENTITY data SYSTEM "abc">]>
- *
- * <log4j:eventSet version="1.2" xmlns:log4j="http://logging.apache.org/log4j/">
- * &data;
- * </log4j:eventSet>
- * </pre>
- * <p/>
- * <p>This approach enforces the independence of the XMLLayout and the
- * appender where it is embedded.
- * <p/>
- * <p>The <code>version</code> 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.
- * <p/>
- * 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.
- */
-@Plugin(name = "XMLLayout", type = "Core", elementType = "layout", printObject = true)
-public class XMLLayout extends AbstractStringLayout {
-
- private static final int DEFAULT_SIZE = 256;
-
- private final boolean locationInfo;
- private final boolean properties;
- private final boolean complete;
-
- protected XMLLayout(boolean locationInfo, boolean properties, boolean complete, Charset charset) {
- super(charset);
- this.locationInfo = locationInfo;
- this.properties = properties;
- this.complete = complete;
- }
-
- /**
- * Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the log4j.dtd.
- * @param event The LogEvent.
- * @return The XML representation of the LogEvent.
- */
- public String formatAs(final LogEvent event) {
- StringBuilder buf = new StringBuilder(DEFAULT_SIZE);
-
- // We yield to the \r\n heresy.
-
- buf.append("<log4j:event logger=\"");
- String name = event.getLoggerName();
- if (name.length() == 0) {
- name = "root";
- }
- buf.append(Transform.escapeTags(name));
- buf.append("\" timestamp=\"");
- buf.append(event.getMillis());
- buf.append("\" level=\"");
- buf.append(Transform.escapeTags(String.valueOf(event.getLevel())));
- buf.append("\" thread=\"");
- buf.append(Transform.escapeTags(event.getThreadName()));
- buf.append("\">\r\n");
-
- buf.append("<log4j:message><![CDATA[");
- // Append the rendered message. Also make sure to escape any
- // existing CDATA sections.
- Transform.appendEscapingCDATA(buf, event.getMessage().getFormattedMessage());
- buf.append("]]></log4j:message>\r\n");
-
- if (event.getContextStack().size() > 0) {
- buf.append("<log4j:NDC><![CDATA[");
- Transform.appendEscapingCDATA(buf, event.getContextStack().toString());
- buf.append("]]></log4j:NDC>\r\n");
- }
-
- Throwable throwable = event.getThrown();
- if (throwable != null) {
- List<String> s = getThrowableString(throwable);
- buf.append("<log4j:throwable><![CDATA[");
- for (String str : s) {
- Transform.appendEscapingCDATA(buf, str);
- buf.append("\r\n");
- }
- buf.append("]]></log4j:throwable>\r\n");
- }
-
- if (locationInfo) {
- StackTraceElement element = event.getSource();
- buf.append("<log4j:locationInfo class=\"");
- buf.append(Transform.escapeTags(element.getClassName()));
- buf.append("\" method=\"");
- buf.append(Transform.escapeTags(element.getMethodName()));
- buf.append("\" file=\"");
- buf.append(Transform.escapeTags(element.getFileName()));
- buf.append("\" line=\"");
- buf.append(element.getLineNumber());
- buf.append("\"/>\r\n");
- }
-
- if (properties && event.getContextMap().size() > 0) {
- buf.append("<log4j:properties>\r\n");
- for (Map.Entry<String, String> entry : event.getContextMap().entrySet()) {
- buf.append("<log4j:data name=\"");
- buf.append(Transform.escapeTags(entry.getKey()));
- buf.append("\" value=\"");
- buf.append(Transform.escapeTags(String.valueOf(entry.getValue())));
- buf.append("\"/>\r\n");
- }
- buf.append("</log4j:properties>\r\n");
- }
-
- buf.append("</log4j:event>\r\n\r\n");
-
- return buf.toString();
- }
-
- /**
- * Returns appropriate XML headers.
- * @return a byte array containing the header.
- */
- @Override
- public byte[] getHeader() {
- if (!complete) {
- return null;
- }
- StringBuilder sbuf = new StringBuilder();
- sbuf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
- sbuf.append("<log4j:eventSet xmlns:log4j=\"http://logging.apache.org/log4j/\">\r\n");
- return sbuf.toString().getBytes(getCharset());
- }
-
-
- /**
- * Returns appropriate XML headers.
- * @return a byte array containing the footer.
- */
- @Override
- public byte[] getFooter() {
- if (!complete) {
- return null;
- }
- StringBuilder sbuf = new StringBuilder();
- sbuf.append("</log4j:eventSet>\r\n");
- return sbuf.toString().getBytes(getCharset());
- }
-
- List<String> getThrowableString(Throwable throwable) {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- try {
- throwable.printStackTrace(pw);
- } catch (RuntimeException ex) {
- // Ignore any exceptions.
- }
- pw.flush();
- LineNumberReader reader = new LineNumberReader(new StringReader(sw.toString()));
- ArrayList<String> lines = new ArrayList<String>();
- try {
- String line = reader.readLine();
- while (line != null) {
- lines.add(line);
- line = reader.readLine();
- }
- } catch (IOException ex) {
- if (ex instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- lines.add(ex.toString());
- }
- return lines;
- }
-
- /**
- * Create an XML Layout.
- * @param locationInfo If "true" include the location information in the generated XML.
- * @param properties If "true" include the thread context in the generated XML.
- * @param complete If "true" include the XML header.
- * @param charset The character set to use.
- * @return An XML Layout.
- */
- @PluginFactory
- public static XMLLayout createLayout(@PluginAttr("locationInfo") String locationInfo,
- @PluginAttr("properties") String properties,
- @PluginAttr("complete") String complete,
- @PluginAttr("charset") String charset) {
- Charset c = Charset.isSupported("UTF-8") ? Charset.forName("UTF-8") : Charset.defaultCharset();
- if (charset != null) {
- if (Charset.isSupported(charset)) {
- c = Charset.forName(charset);
- } else {
- LOGGER.error("Charset " + charset + " is not supported for layout, using " + c.displayName());
- }
- }
- boolean info = locationInfo == null ? false : Boolean.valueOf(locationInfo);
- boolean props = properties == null ? false : Boolean.valueOf(properties);
- boolean comp = complete == null ? false : Boolean.valueOf(complete);
- return new XMLLayout(info, props, comp, c);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/package-info.java
deleted file mode 100644
index a4e9a38..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 Layout support.
- */
-package org.apache.logging.log4j.core.layout;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/ContextMapLookup.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/ContextMapLookup.java
deleted file mode 100644
index 9bc034d..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/ContextMapLookup.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-/**
- * Looks up keys from system properties.
- */
-@Plugin(name = "ctx", type = "Lookup")
-public class ContextMapLookup implements StrLookup {
-
- /**
- * Lookup the value from the ThreadContext Map.
- * @param key the key to be looked up, may be null
- * @return The value associated with the key.
- */
- public String lookup(String key) {
- return ThreadContext.get(key);
- }
-
- /**
- * Lookup the value from the ThreadContext Map.
- * @param event The current LogEvent.
- * @param key the key to be looked up, may be null
- * @return The value associated with the key.
- */
- public String lookup(LogEvent event, String key) {
- return event.getContextMap().get(key);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/DateLookup.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/DateLookup.java
deleted file mode 100644
index a7f518e..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/DateLookup.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Formats the current date or the date in the LogEvent. The "key" is used as the format String.
- */
-@Plugin(name = "date", type = "Lookup")
-public class DateLookup implements StrLookup {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
- /**
- * Get the value of the environment variable.
- * @param key the format to use. If null, the default DateFormat will be used.
- * @return The value of the environment variable.
- */
- public String lookup(String key) {
- return formatDate(System.currentTimeMillis(), key);
- }
-
- /**
- * Get the value of the environment variable.
- * @param event The current LogEvent (is ignored by this StrLookup).
- * @param key the format to use. If null, the default DateFormat will be used.
- * @return The value of the environment variable.
- */
- public String lookup(LogEvent event, String key) {
- return formatDate(event.getMillis(), key);
- }
-
- private String formatDate(long date, String format) {
- DateFormat dateFormat = null;
- if (format != null) {
- try {
- dateFormat = new SimpleDateFormat(format);
- } catch (Exception ex) {
- LOGGER.error("Invalid date format: \"" + format + "\", using default", ex);
- }
- }
- if (dateFormat == null) {
- dateFormat = DateFormat.getInstance();
- }
- return dateFormat.format(new Date(date));
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/EnvironmentLookup.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/EnvironmentLookup.java
deleted file mode 100644
index f94ff07..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/EnvironmentLookup.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-/**
- * Looks up keys from environment variables.
- */
-@Plugin(name = "env", type = "Lookup")
-public class EnvironmentLookup implements StrLookup {
-
- /**
- * Get the value of the environment variable.
- * @param key the key to be looked up, may be null
- * @return The value of the environment variable.
- */
- public String lookup(String key) {
- return System.getenv(key);
- }
-
- /**
- * Get the value of the environment variable.
- * @param event The current LogEvent (is ignored by this StrLookup).
- * @param key the key to be looked up, may be null
- * @return The value of the environment variable.
- */
- public String lookup(LogEvent event, String key) {
- return System.getenv(key);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
deleted file mode 100644
index bace0e8..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.PluginManager;
-import org.apache.logging.log4j.core.config.plugins.PluginType;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The Interpolator is a StrLookup that acts as a proxy for all the other StrLookups.
- */
-public class Interpolator implements StrLookup {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- /** Constant for the prefix separator. */
- private static final char PREFIX_SEPARATOR = ':';
-
- private final Map<String, StrLookup> lookups = new HashMap<String, StrLookup>();
-
- private final StrLookup defaultLookup;
-
- public Interpolator(StrLookup defaultLookup) {
- this.defaultLookup = defaultLookup == null ? new MapLookup(new HashMap<String, String>()) : defaultLookup;
- PluginManager manager = new PluginManager("Lookup");
- manager.collectPlugins();
- Map<String, PluginType> plugins = manager.getPlugins();
-
- for (Map.Entry<String, PluginType> entry : plugins.entrySet()) {
- Class<StrLookup> clazz = entry.getValue().getPluginClass();
- try {
- lookups.put(entry.getKey(), clazz.newInstance());
- } catch (Exception ex) {
- LOGGER.error("Unable to create Lookup for " + entry.getKey(), ex);
- }
- }
- }
-
- /**
- * Resolves the specified variable. This implementation will try to extract
- * a variable prefix from the given variable name (the first colon (':') is
- * used as prefix separator). It then passes the name of the variable with
- * the prefix stripped to the lookup object registered for this prefix. If
- * no prefix can be found or if the associated lookup object cannot resolve
- * this variable, the default lookup object will be used.
- *
- * @param var the name of the variable whose value is to be looked up
- * @return the value of this variable or <b>null</b> if it cannot be
- * resolved
- */
- public String lookup(String var) {
- return lookup(null, var);
- }
-
- /**
- * Resolves the specified variable. This implementation will try to extract
- * a variable prefix from the given variable name (the first colon (':') is
- * used as prefix separator). It then passes the name of the variable with
- * the prefix stripped to the lookup object registered for this prefix. If
- * no prefix can be found or if the associated lookup object cannot resolve
- * this variable, the default lookup object will be used.
- *
- * @param event The current LogEvent or null.
- * @param var the name of the variable whose value is to be looked up
- * @return the value of this variable or <b>null</b> if it cannot be
- * resolved
- */
- public String lookup(LogEvent event, String var) {
- if (var == null) {
- return null;
- }
-
- int prefixPos = var.indexOf(PREFIX_SEPARATOR);
- if (prefixPos >= 0) {
- String prefix = var.substring(0, prefixPos);
- String name = var.substring(prefixPos + 1);
- StrLookup lookup = lookups.get(prefix);
- String value = null;
- if (lookup != null) {
- value = event == null ? lookup.lookup(name) : lookup.lookup(event, name);
- }
-
- if (value != null) {
- return value;
- }
- var = var.substring(prefixPos);
- }
- if (defaultLookup != null) {
- return event == null ? defaultLookup.lookup(var) : defaultLookup.lookup(event, var);
- }
- return null;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- for (String name : lookups.keySet()) {
- if (sb.length() == 0) {
- sb.append("{");
- } else {
- sb.append(", ");
- }
-
- sb.append(name);
- }
- if (sb.length() > 0) {
- sb.append("}");
- }
- return sb.toString();
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java
deleted file mode 100644
index c87fe11..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.message.MapMessage;
-
-import java.util.Map;
-
-/**
- * The basis for a lookup based on a Map.
- * @param <V> The type of object contained in the Map.
- */
-@Plugin(name = "map", type = "Lookup")
-public class MapLookup<V> implements StrLookup<V> {
- /**
- * Map keys are variable names and value.
- */
- private final Map<String, V> map;
-
- /**
- * Creates a new instance backed by a Map. Used by the default lookup.
- *
- * @param map the map of keys to values, may be null
- */
- public MapLookup(Map<String, V> map) {
- this.map = map;
- }
-
- /**
- * Constructor when used directly as a plugin.
- */
- public MapLookup() {
- this.map = null;
- }
-
- /**
- * Looks up a String key to a String value using the map.
- * <p/>
- * If the map is null, then null is returned.
- * The map result object is converted to a string using toString().
- *
- * @param key the key to be looked up, may be null
- * @return the matching value, null if no match
- */
- public String lookup(String key) {
- if (map == null) {
- return null;
- }
- Object obj = map.get(key);
- if (obj == null) {
- return null;
- }
- return obj.toString();
- }
-
- public String lookup(LogEvent event, String key) {
- if (map == null && !(event.getMessage() instanceof MapMessage)) {
- return null;
- }
- if (map != null && map.containsKey(key)) {
- Object obj = map.get(key);
- if (obj != null) {
- return obj.toString();
- }
- }
- if (event.getMessage() instanceof MapMessage) {
- return ((MapMessage) event.getMessage()).get(key);
- }
- return null;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrLookup.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrLookup.java
deleted file mode 100644
index 74256a7..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrLookup.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.core.LogEvent;
-
-/**
- * Lookup a String key to a String value.
- * <p>
- * This class represents the simplest form of a string to string map.
- * It has a benefit over a map in that it can create the result on
- * demand based on the key.
- * <p>
- * This class comes complete with various factory methods.
- * If these do not suffice, you can subclass and implement your own matcher.
- * <p>
- * For example, it would be possible to implement a lookup that used the
- * key as a primary key, and looked up the value on demand from the database
- *
- * @author Apache Software Foundation
- * @version $Id$
- *
- * @param <V> The type of the value that is being queried.
- */
-public interface StrLookup<V> {
- /**
- * Looks up a String key to a String value.
- * <p>
- * The internal implementation may use any mechanism to return the value.
- * The simplest implementation is to use a Map. However, virtually any
- * implementation is possible.
- * <p>
- * For example, it would be possible to implement a lookup that used the
- * key as a primary key, and looked up the value on demand from the database
- * Or, a numeric based implementation could be created that treats the key
- * as an integer, increments the value and return the result as a string -
- * converting 1 to 2, 15 to 16 etc.
- * <p>
- * The {@link #lookup(String)} method always returns a String, regardless of
- * the underlying data, by converting it as necessary. For example:
- * <pre>
- * Map<String, Object> map = new HashMap<String, Object>();
- * map.put("number", new Integer(2));
- * assertEquals("2", StrLookup.mapLookup(map).lookup("number"));
- * </pre>
- * @param key the key to be looked up, may be null
- * @return the matching value, null if no match
- */
- String lookup(String key);
-
- /**
- * Looks up a String key to a String value possibly using the current LogEvent.
- * <p>
- * The internal implementation may use any mechanism to return the value.
- * The simplest implementation is to use a Map. However, virtually any
- * implementation is possible.
- * <p>
- * For example, it would be possible to implement a lookup that used the
- * key as a primary key, and looked up the value on demand from the database
- * Or, a numeric based implementation could be created that treats the key
- * as an integer, increments the value and return the result as a string -
- * converting 1 to 2, 15 to 16 etc.
- * <p>
- * The {@link #lookup(String)} method always returns a String, regardless of
- * the underlying data, by converting it as necessary. For example:
- * <pre>
- * Map<String, Object> map = new HashMap<String, Object>();
- * map.put("number", new Integer(2));
- * assertEquals("2", StrLookup.mapLookup(map).lookup("number"));
- * </pre>
- * @param event The current LogEvent.
- * @param key the key to be looked up, may be null
- * @return the matching value, null if no match
- */
- String lookup(LogEvent event, String key);
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrMatcher.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrMatcher.java
deleted file mode 100644
index 31e0d05..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrMatcher.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import java.util.Arrays;
-
-/**
- * A matcher class that can be queried to determine if a character array
- * portion matches.
- * <p>
- * This class comes complete with various factory methods.
- * If these do not suffice, you can subclass and implement your own matcher.
- */
-public abstract class StrMatcher {
-
- /**
- * Matches the comma character.
- */
- private static final StrMatcher COMMA_MATCHER = new CharMatcher(',');
- /**
- * Matches the tab character.
- */
- private static final StrMatcher TAB_MATCHER = new CharMatcher('\t');
- /**
- * Matches the space character.
- */
- private static final StrMatcher SPACE_MATCHER = new CharMatcher(' ');
- /**
- * Matches the same characters as StringTokenizer,
- * namely space, tab, newline, formfeed.
- */
- private static final StrMatcher SPLIT_MATCHER = new CharSetMatcher(" \t\n\r\f".toCharArray());
- /**
- * Matches the String trim() whitespace characters.
- */
- private static final StrMatcher TRIM_MATCHER = new TrimMatcher();
- /**
- * Matches the double quote character.
- */
- private static final StrMatcher SINGLE_QUOTE_MATCHER = new CharMatcher('\'');
- /**
- * Matches the double quote character.
- */
- private static final StrMatcher DOUBLE_QUOTE_MATCHER = new CharMatcher('"');
- /**
- * Matches the single or double quote character.
- */
- private static final StrMatcher QUOTE_MATCHER = new CharSetMatcher("'\"".toCharArray());
- /**
- * Matches no characters.
- */
- private static final StrMatcher NONE_MATCHER = new NoMatcher();
-
- /**
- * Constructor.
- */
- protected StrMatcher() {
- }
-
- /**
- * Returns a matcher which matches the comma character.
- *
- * @return a matcher for a comma
- */
- public static StrMatcher commaMatcher() {
- return COMMA_MATCHER;
- }
-
- /**
- * Returns a matcher which matches the tab character.
- *
- * @return a matcher for a tab
- */
- public static StrMatcher tabMatcher() {
- return TAB_MATCHER;
- }
-
- /**
- * Returns a matcher which matches the space character.
- *
- * @return a matcher for a space
- */
- public static StrMatcher spaceMatcher() {
- return SPACE_MATCHER;
- }
-
- /**
- * Matches the same characters as StringTokenizer,
- * namely space, tab, newline and formfeed.
- *
- * @return the split matcher
- */
- public static StrMatcher splitMatcher() {
- return SPLIT_MATCHER;
- }
-
- /**
- * Matches the String trim() whitespace characters.
- *
- * @return the trim matcher
- */
- public static StrMatcher trimMatcher() {
- return TRIM_MATCHER;
- }
-
- /**
- * Returns a matcher which matches the single quote character.
- *
- * @return a matcher for a single quote
- */
- public static StrMatcher singleQuoteMatcher() {
- return SINGLE_QUOTE_MATCHER;
- }
-
- /**
- * Returns a matcher which matches the double quote character.
- *
- * @return a matcher for a double quote
- */
- public static StrMatcher doubleQuoteMatcher() {
- return DOUBLE_QUOTE_MATCHER;
- }
-
- /**
- * Returns a matcher which matches the single or double quote character.
- *
- * @return a matcher for a single or double quote
- */
- public static StrMatcher quoteMatcher() {
- return QUOTE_MATCHER;
- }
-
- /**
- * Matches no characters.
- *
- * @return a matcher that matches nothing
- */
- public static StrMatcher noneMatcher() {
- return NONE_MATCHER;
- }
-
- /**
- * Constructor that creates a matcher from a character.
- *
- * @param ch the character to match, must not be null
- * @return a new Matcher for the given char
- */
- public static StrMatcher charMatcher(char ch) {
- return new CharMatcher(ch);
- }
-
- /**
- * Constructor that creates a matcher from a set of characters.
- *
- * @param chars the characters to match, null or empty matches nothing
- * @return a new matcher for the given char[]
- */
- public static StrMatcher charSetMatcher(char[] chars) {
- if (chars == null || chars.length == 0) {
- return NONE_MATCHER;
- }
- if (chars.length == 1) {
- return new CharMatcher(chars[0]);
- }
- return new CharSetMatcher(chars);
- }
-
- /**
- * Constructor that creates a matcher from a string representing a set of characters.
- *
- * @param chars the characters to match, null or empty matches nothing
- * @return a new Matcher for the given characters
- */
- public static StrMatcher charSetMatcher(String chars) {
- if (chars == null || chars.length() == 0) {
- return NONE_MATCHER;
- }
- if (chars.length() == 1) {
- return new CharMatcher(chars.charAt(0));
- }
- return new CharSetMatcher(chars.toCharArray());
- }
-
- /**
- * Constructor that creates a matcher from a string.
- *
- * @param str the string to match, null or empty matches nothing
- * @return a new Matcher for the given String
- */
- public static StrMatcher stringMatcher(String str) {
- if (str == null || str.length() == 0) {
- return NONE_MATCHER;
- }
- return new StringMatcher(str);
- }
-
- /**
- * Returns the number of matching characters, zero for no match.
- * <p>
- * This method is called to check for a match.
- * The parameter <code>pos</code> represents the current position to be
- * checked in the string <code>buffer</code> (a character array which must
- * not be changed).
- * The API guarantees that <code>pos</code> is a valid index for <code>buffer</code>.
- * <p>
- * The character array may be larger than the active area to be matched.
- * Only values in the buffer between the specifed indices may be accessed.
- * <p>
- * The matching code may check one character or many.
- * It may check characters preceeding <code>pos</code> as well as those
- * after, so long as no checks exceed the bounds specified.
- * <p>
- * It must return zero for no match, or a positive number if a match was found.
- * The number indicates the number of characters that matched.
- *
- * @param buffer the text content to match against, do not change
- * @param pos the starting position for the match, valid for buffer
- * @param bufferStart the first active index in the buffer, valid for buffer
- * @param bufferEnd the end index (exclusive) of the active buffer, valid for buffer
- * @return the number of matching characters, zero for no match
- */
- public abstract int isMatch(char[] buffer, int pos, int bufferStart, int bufferEnd);
-
- /**
- * Returns the number of matching characters, zero for no match.
- * <p>
- * This method is called to check for a match.
- * The parameter <code>pos</code> represents the current position to be
- * checked in the string <code>buffer</code> (a character array which must
- * not be changed).
- * The API guarantees that <code>pos</code> is a valid index for <code>buffer</code>.
- * <p>
- * The matching code may check one character or many.
- * It may check characters preceeding <code>pos</code> as well as those after.
- * <p>
- * It must return zero for no match, or a positive number if a match was found.
- * The number indicates the number of characters that matched.
- *
- * @param buffer the text content to match against, do not change
- * @param pos the starting position for the match, valid for buffer
- * @return the number of matching characters, zero for no match
- * @since 2.4
- */
- public int isMatch(char[] buffer, int pos) {
- return isMatch(buffer, pos, 0, buffer.length);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Class used to define a set of characters for matching purposes.
- */
- static final class CharSetMatcher extends StrMatcher {
- /** The set of characters to match. */
- private final char[] chars;
-
- /**
- * Constructor that creates a matcher from a character array.
- *
- * @param chars the characters to match, must not be null
- */
- CharSetMatcher(char[] chars) {
- super();
- this.chars = chars.clone();
- Arrays.sort(this.chars);
- }
-
- /**
- * Returns whether or not the given character matches.
- *
- * @param buffer the text content to match against, do not change
- * @param pos the starting position for the match, valid for buffer
- * @param bufferStart the first active index in the buffer, valid for buffer
- * @param bufferEnd the end index of the active buffer, valid for buffer
- * @return the number of matching characters, zero for no match
- */
- @Override
- public int isMatch(char[] buffer, int pos, int bufferStart, int bufferEnd) {
- return Arrays.binarySearch(chars, buffer[pos]) >= 0 ? 1 : 0;
- }
- }
-
- //-----------------------------------------------------------------------
- /**
- * Class used to define a character for matching purposes.
- */
- static final class CharMatcher extends StrMatcher {
- /** The character to match. */
- private final char ch;
-
- /**
- * Constructor that creates a matcher that matches a single character.
- *
- * @param ch the character to match
- */
- CharMatcher(char ch) {
- super();
- this.ch = ch;
- }
-
- /**
- * Returns whether or not the given character matches.
- *
- * @param buffer the text content to match against, do not change
- * @param pos the starting position for the match, valid for buffer
- * @param bufferStart the first active index in the buffer, valid for buffer
- * @param bufferEnd the end index of the active buffer, valid for buffer
- * @return the number of matching characters, zero for no match
- */
- @Override
- public int isMatch(char[] buffer, int pos, int bufferStart, int bufferEnd) {
- return ch == buffer[pos] ? 1 : 0;
- }
- }
-
- //-----------------------------------------------------------------------
- /**
- * Class used to define a set of characters for matching purposes.
- */
- static final class StringMatcher extends StrMatcher {
- /** The string to match, as a character array. */
- private final char[] chars;
-
- /**
- * Constructor that creates a matcher from a String.
- *
- * @param str the string to match, must not be null
- */
- StringMatcher(String str) {
- super();
- chars = str.toCharArray();
- }
-
- /**
- * Returns whether or not the given text matches the stored string.
- *
- * @param buffer the text content to match against, do not change
- * @param pos the starting position for the match, valid for buffer
- * @param bufferStart the first active index in the buffer, valid for buffer
- * @param bufferEnd the end index of the active buffer, valid for buffer
- * @return the number of matching characters, zero for no match
- */
- @Override
- public int isMatch(char[] buffer, int pos, int bufferStart, int bufferEnd) {
- int len = chars.length;
- if (pos + len > bufferEnd) {
- return 0;
- }
- for (int i = 0; i < chars.length; i++, pos++) {
- if (chars[i] != buffer[pos]) {
- return 0;
- }
- }
- return len;
- }
- }
-
- //-----------------------------------------------------------------------
- /**
- * Class used to match no characters.
- */
- static final class NoMatcher extends StrMatcher {
-
- /**
- * Constructs a new instance of <code>NoMatcher</code>.
- */
- NoMatcher() {
- super();
- }
-
- /**
- * Always returns <code>false</code>.
- *
- * @param buffer the text content to match against, do not change
- * @param pos the starting position for the match, valid for buffer
- * @param bufferStart the first active index in the buffer, valid for buffer
- * @param bufferEnd the end index of the active buffer, valid for buffer
- * @return the number of matching characters, zero for no match
- */
- @Override
- public int isMatch(char[] buffer, int pos, int bufferStart, int bufferEnd) {
- return 0;
- }
- }
-
- //-----------------------------------------------------------------------
- /**
- * Class used to match whitespace as per trim().
- */
- static final class TrimMatcher extends StrMatcher {
-
- /**
- * Constructs a new instance of <code>TrimMatcher</code>.
- */
- TrimMatcher() {
- super();
- }
-
- /**
- * Returns whether or not the given character matches.
- *
- * @param buffer the text content to match against, do not change
- * @param pos the starting position for the match, valid for buffer
- * @param bufferStart the first active index in the buffer, valid for buffer
- * @param bufferEnd the end index of the active buffer, valid for buffer
- * @return the number of matching characters, zero for no match
- */
- @Override
- public int isMatch(char[] buffer, int pos, int bufferStart, int bufferEnd) {
- return buffer[pos] <= ' ' ? 1 : 0;
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java
deleted file mode 100644
index 0c73fff..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java
+++ /dev/null
@@ -1,1134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.core.LogEvent;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Substitutes variables within a string by values.
- * <p>
- * This class takes a piece of text and substitutes all the variables within it.
- * The default definition of a variable is <code>${variableName}</code>.
- * The prefix and suffix can be changed via constructors and set methods.
- * <p>
- * Variable values are typically resolved from a map, but could also be resolved
- * from system properties, or by supplying a custom variable resolver.
- * <p>
- * The simplest example is to use this class to replace Java System properties. For example:
- * <pre>
- * StrSubstitutor.replaceSystemProperties(
- * "You are running with java.version = ${java.version} and os.name = ${os.name}.");
- * </pre>
- * <p>
- * Typical usage of this class follows the following pattern: First an instance is created
- * and initialized with the map that contains the values for the available variables.
- * If a prefix and/or suffix for variables should be used other than the default ones,
- * the appropriate settings can be performed. After that the <code>replace()</code>
- * method can be called passing in the source text for interpolation. In the returned
- * text all variable references (as long as their values are known) will be resolved.
- * The following example demonstrates this:
- * <pre>
- * Map valuesMap = HashMap();
- * valuesMap.put("animal", "quick brown fox");
- * valuesMap.put("target", "lazy dog");
- * String templateString = "The ${animal} jumped over the ${target}.";
- * StrSubstitutor sub = new StrSubstitutor(valuesMap);
- * String resolvedString = sub.replace(templateString);
- * </pre>
- * yielding:
- * <pre>
- * The quick brown fox jumped over the lazy dog.
- * </pre>
- * <p>
- * In addition to this usage pattern there are some static convenience methods that
- * cover the most common use cases. These methods can be used without the need of
- * manually creating an instance. However if multiple replace operations are to be
- * performed, creating and reusing an instance of this class will be more efficient.
- * <p>
- * Variable replacement works in a recursive way. Thus, if a variable value contains
- * a variable then that variable will also be replaced. Cyclic replacements are
- * detected and will cause an exception to be thrown.
- * <p>
- * Sometimes the interpolation's result must contain a variable prefix. As an example
- * take the following source text:
- * <pre>
- * The variable ${${name}} must be used.
- * </pre>
- * Here only the variable's name referred to in the text should be replaced resulting
- * in the text (assuming that the value of the <code>name</code> variable is <code>x</code>):
- * <pre>
- * The variable ${x} must be used.
- * </pre>
- * To achieve this effect there are two possibilities: Either set a different prefix
- * and suffix for variables which do not conflict with the result text you want to
- * produce. The other possibility is to use the escape character, by default '$'.
- * If this character is placed before a variable reference, this reference is ignored
- * and won't be replaced. For example:
- * <pre>
- * The variable $${${name}} must be used.
- * </pre>
- * <p>
- * In some complex scenarios you might even want to perform substitution in the
- * names of variables, for instance
- * <pre>
- * ${jre-${java.specification.version}}
- * </pre>
- * <code>StrSubstitutor</code> supports this recursive substitution in variable
- * names, but it has to be enabled explicitly by setting the
- * {@link #setEnableSubstitutionInVariables(boolean) enableSubstitutionInVariables}
- * property to <b>true</b>.
- *
- */
-public class StrSubstitutor {
-
- /**
- * Constant for the default escape character.
- */
- public static final char DEFAULT_ESCAPE = '$';
- /**
- * Constant for the default variable prefix.
- */
- public static final StrMatcher DEFAULT_PREFIX = StrMatcher.stringMatcher("${");
- /**
- * Constant for the default variable suffix.
- */
- public static final StrMatcher DEFAULT_SUFFIX = StrMatcher.stringMatcher("}");
-
- private static final int BUF_SIZE = 256;
-
- /**
- * Stores the escape character.
- */
- private char escapeChar;
- /**
- * Stores the variable prefix.
- */
- private StrMatcher prefixMatcher;
- /**
- * Stores the variable suffix.
- */
- private StrMatcher suffixMatcher;
- /**
- * Variable resolution is delegated to an implementor of VariableResolver.
- */
- private StrLookup<?> variableResolver;
- /**
- * The flag whether substitution in variable names is enabled.
- */
- private boolean enableSubstitutionInVariables;
-
- //-----------------------------------------------------------------------
- /**
- * Creates a new instance with defaults for variable prefix and suffix
- * and the escaping character.
- */
- public StrSubstitutor() {
- this(null, DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_ESCAPE);
- }
- /**
- * Creates a new instance and initializes it. Uses defaults for variable
- * prefix and suffix and the escaping character.
- *
- * @param <V> The type of object contained in the Map.
- * @param valueMap the map with the variables' values, may be null
- */
- public <V> StrSubstitutor(Map<String, V> valueMap) {
- this(new MapLookup(valueMap), DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_ESCAPE);
- }
-
- /**
- * Creates a new instance and initializes it. Uses a default escaping character.
- *
- * @param <V> The type of object contained in the Map.
- * @param valueMap the map with the variables' values, may be null
- * @param prefix the prefix for variables, not null
- * @param suffix the suffix for variables, not null
- * @throws IllegalArgumentException if the prefix or suffix is null
- */
- public <V> StrSubstitutor(Map<String, V> valueMap, String prefix, String suffix) {
- this(new MapLookup(valueMap), prefix, suffix, DEFAULT_ESCAPE);
- }
-
- /**
- * Creates a new instance and initializes it.
- *
- * @param <V> The type of object contained in the Map.
- * @param valueMap the map with the variables' values, may be null
- * @param prefix the prefix for variables, not null
- * @param suffix the suffix for variables, not null
- * @param escape the escape character
- * @throws IllegalArgumentException if the prefix or suffix is null
- */
- public <V> StrSubstitutor(Map<String, V> valueMap, String prefix, String suffix, char escape) {
- this(new MapLookup(valueMap), prefix, suffix, escape);
- }
-
- /**
- * Creates a new instance and initializes it.
- *
- * @param variableResolver the variable resolver, may be null
- */
- public StrSubstitutor(StrLookup<?> variableResolver) {
- this(variableResolver, DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_ESCAPE);
- }
-
- /**
- * Creates a new instance and initializes it.
- *
- * @param variableResolver the variable resolver, may be null
- * @param prefix the prefix for variables, not null
- * @param suffix the suffix for variables, not null
- * @param escape the escape character
- * @throws IllegalArgumentException if the prefix or suffix is null
- */
- public StrSubstitutor(StrLookup<?> variableResolver, String prefix, String suffix, char escape) {
- this.setVariableResolver(variableResolver);
- this.setVariablePrefix(prefix);
- this.setVariableSuffix(suffix);
- this.setEscapeChar(escape);
- }
-
- /**
- * Creates a new instance and initializes it.
- *
- * @param variableResolver the variable resolver, may be null
- * @param prefixMatcher the prefix for variables, not null
- * @param suffixMatcher the suffix for variables, not null
- * @param escape the escape character
- * @throws IllegalArgumentException if the prefix or suffix is null
- */
- public StrSubstitutor(StrLookup<?> variableResolver, StrMatcher prefixMatcher, StrMatcher suffixMatcher,
- char escape) {
- this.setVariableResolver(variableResolver);
- this.setVariablePrefixMatcher(prefixMatcher);
- this.setVariableSuffixMatcher(suffixMatcher);
- this.setEscapeChar(escape);
- }
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables in the given source object with
- * their matching values from the map.
- *
- * @param <V> The type of object contained in the Map.
- * @param source the source text containing the variables to substitute, null returns null
- * @param valueMap the map with the values, may be null
- * @return the result of the replace operation
- */
- public static <V> String replace(Object source, Map<String, V> valueMap) {
- return new StrSubstitutor(valueMap).replace(source);
- }
-
- /**
- * Replaces all the occurrences of variables in the given source object with
- * their matching values from the map. This method allows to specifiy a
- * custom variable prefix and suffix
- *
- * @param <V> The type of object contained in the Map.
- * @param source the source text containing the variables to substitute, null returns null
- * @param valueMap the map with the values, may be null
- * @param prefix the prefix of variables, not null
- * @param suffix the suffix of variables, not null
- * @return the result of the replace operation
- * @throws IllegalArgumentException if the prefix or suffix is null
- */
- public static <V> String replace(Object source, Map<String, V> valueMap, String prefix, String suffix) {
- return new StrSubstitutor(valueMap, prefix, suffix).replace(source);
- }
-
- /**
- * Replaces all the occurrences of variables in the given source object with their matching
- * values from the properties.
- *
- * @param source the source text containing the variables to substitute, null returns null
- * @param valueProperties the properties with values, may be null
- * @return the result of the replace operation
- */
- public static String replace(Object source, Properties valueProperties) {
- if (valueProperties == null) {
- return source.toString();
- }
- Map<String, String> valueMap = new HashMap<String, String>();
- Enumeration<?> propNames = valueProperties.propertyNames();
- while (propNames.hasMoreElements()) {
- String propName = (String) propNames.nextElement();
- String propValue = valueProperties.getProperty(propName);
- valueMap.put(propName, propValue);
- }
- return StrSubstitutor.replace(source, valueMap);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source string as a template.
- *
- * @param source the string to replace in, null returns null
- * @return the result of the replace operation
- */
- public String replace(String source) {
- return replace(null, source);
- }
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source string as a template.
- *
- * @param event The current LogEvent if there is one.
- * @param source the string to replace in, null returns null
- * @return the result of the replace operation
- */
- public String replace(LogEvent event, String source) {
- if (source == null) {
- return null;
- }
- StringBuilder buf = new StringBuilder(source);
- if (!substitute(event, buf, 0, source.length())) {
- return source;
- }
- return buf.toString();
- }
-
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source string as a template.
- * <p>
- * Only the specified portion of the string will be processed.
- * The rest of the string is not processed, and is not returned.
- *
- * @param source the string to replace in, null returns null
- * @param offset the start offset within the array, must be valid
- * @param length the length within the array to be processed, must be valid
- * @return the result of the replace operation
- */
- public String replace(String source, int offset, int length) {
- return replace(null, source, offset, length);
- }
-
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source string as a template.
- * <p>
- * Only the specified portion of the string will be processed.
- * The rest of the string is not processed, and is not returned.
- *
- * @param event the current LogEvent, if one exists.
- * @param source the string to replace in, null returns null
- * @param offset the start offset within the array, must be valid
- * @param length the length within the array to be processed, must be valid
- * @return the result of the replace operation
- */
- public String replace(LogEvent event, String source, int offset, int length) {
- if (source == null) {
- return null;
- }
- StringBuilder buf = new StringBuilder(length).append(source, offset, length);
- if (!substitute(event, buf, 0, length)) {
- return source.substring(offset, offset + length);
- }
- return buf.toString();
- }
-
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source array as a template.
- * The array is not altered by this method.
- *
- * @param source the character array to replace in, not altered, null returns null
- * @return the result of the replace operation
- */
- public String replace(char[] source) {
- return replace(null, source);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source array as a template.
- * The array is not altered by this method.
- *
- * @param event the current LogEvent, if one exists.
- * @param source the character array to replace in, not altered, null returns null
- * @return the result of the replace operation
- */
- public String replace(LogEvent event, char[] source) {
- if (source == null) {
- return null;
- }
- StringBuilder buf = new StringBuilder(source.length).append(source);
- substitute(event, buf, 0, source.length);
- return buf.toString();
- }
-
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source array as a template.
- * The array is not altered by this method.
- * <p>
- * Only the specified portion of the array will be processed.
- * The rest of the array is not processed, and is not returned.
- *
- * @param source the character array to replace in, not altered, null returns null
- * @param offset the start offset within the array, must be valid
- * @param length the length within the array to be processed, must be valid
- * @return the result of the replace operation
- */
- public String replace(char[] source, int offset, int length) {
- return replace(null, source, offset, length);
- }
-
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source array as a template.
- * The array is not altered by this method.
- * <p>
- * Only the specified portion of the array will be processed.
- * The rest of the array is not processed, and is not returned.
- *
- * @param event the current LogEvent, if one exists.
- * @param source the character array to replace in, not altered, null returns null
- * @param offset the start offset within the array, must be valid
- * @param length the length within the array to be processed, must be valid
- * @return the result of the replace operation
- */
- public String replace(LogEvent event, char[] source, int offset, int length) {
- if (source == null) {
- return null;
- }
- StringBuilder buf = new StringBuilder(length).append(source, offset, length);
- substitute(event, buf, 0, length);
- return buf.toString();
- }
-
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source buffer as a template.
- * The buffer is not altered by this method.
- *
- * @param source the buffer to use as a template, not changed, null returns null
- * @return the result of the replace operation
- */
- public String replace(StringBuffer source) {
- return replace(null, source);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source buffer as a template.
- * The buffer is not altered by this method.
- *
- * @param event the current LogEvent, if one exists.
- * @param source the buffer to use as a template, not changed, null returns null
- * @return the result of the replace operation
- */
- public String replace(LogEvent event, StringBuffer source) {
- if (source == null) {
- return null;
- }
- StringBuilder buf = new StringBuilder(source.length()).append(source);
- substitute(event, buf, 0, buf.length());
- return buf.toString();
- }
-
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source buffer as a template.
- * The buffer is not altered by this method.
- * <p>
- * Only the specified portion of the buffer will be processed.
- * The rest of the buffer is not processed, and is not returned.
- *
- * @param source the buffer to use as a template, not changed, null returns null
- * @param offset the start offset within the array, must be valid
- * @param length the length within the array to be processed, must be valid
- * @return the result of the replace operation
- */
- public String replace(StringBuffer source, int offset, int length) {
- return replace(null, source, offset, length);
- }
-
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source buffer as a template.
- * The buffer is not altered by this method.
- * <p>
- * Only the specified portion of the buffer will be processed.
- * The rest of the buffer is not processed, and is not returned.
- *
- * @param event the current LogEvent, if one exists.
- * @param source the buffer to use as a template, not changed, null returns null
- * @param offset the start offset within the array, must be valid
- * @param length the length within the array to be processed, must be valid
- * @return the result of the replace operation
- */
- public String replace(LogEvent event, StringBuffer source, int offset, int length) {
- if (source == null) {
- return null;
- }
- StringBuilder buf = new StringBuilder(length).append(source, offset, length);
- substitute(event, buf, 0, length);
- return buf.toString();
- }
-
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source builder as a template.
- * The builder is not altered by this method.
- *
- * @param source the builder to use as a template, not changed, null returns null
- * @return the result of the replace operation
- */
- public String replace(StringBuilder source) {
- return replace(null, source);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source builder as a template.
- * The builder is not altered by this method.
- *
- * @param event The LogEvent.
- * @param source the builder to use as a template, not changed, null returns null.
- * @return the result of the replace operation.
- */
- public String replace(LogEvent event, StringBuilder source) {
- if (source == null) {
- return null;
- }
- StringBuilder buf = new StringBuilder(source.length()).append(source);
- substitute(event, buf, 0, buf.length());
- return buf.toString();
- }
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source builder as a template.
- * The builder is not altered by this method.
- * <p>
- * Only the specified portion of the builder will be processed.
- * The rest of the builder is not processed, and is not returned.
- *
- * @param source the builder to use as a template, not changed, null returns null
- * @param offset the start offset within the array, must be valid
- * @param length the length within the array to be processed, must be valid
- * @return the result of the replace operation
- */
- public String replace(StringBuilder source, int offset, int length) {
- return replace(null, source, offset, length);
- }
-
- /**
- * Replaces all the occurrences of variables with their matching values
- * from the resolver using the given source builder as a template.
- * The builder is not altered by this method.
- * <p>
- * Only the specified portion of the builder will be processed.
- * The rest of the builder is not processed, and is not returned.
- *
- * @param event the current LogEvent, if one exists.
- * @param source the builder to use as a template, not changed, null returns null
- * @param offset the start offset within the array, must be valid
- * @param length the length within the array to be processed, must be valid
- * @return the result of the replace operation
- */
- public String replace(LogEvent event, StringBuilder source, int offset, int length) {
- if (source == null) {
- return null;
- }
- StringBuilder buf = new StringBuilder(length).append(source, offset, length);
- substitute(event, buf, 0, length);
- return buf.toString();
- }
-
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables in the given source object with
- * their matching values from the resolver. The input source object is
- * converted to a string using <code>toString</code> and is not altered.
- *
- * @param source the source to replace in, null returns null
- * @return the result of the replace operation
- */
- public String replace(Object source) {
- return replace(null, source);
- }
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables in the given source object with
- * their matching values from the resolver. The input source object is
- * converted to a string using <code>toString</code> and is not altered.
- *
- * @param event the current LogEvent, if one exists.
- * @param source the source to replace in, null returns null
- * @return the result of the replace operation
- */
- public String replace(LogEvent event, Object source) {
- if (source == null) {
- return null;
- }
- StringBuilder buf = new StringBuilder().append(source);
- substitute(event, buf, 0, buf.length());
- return buf.toString();
- }
-
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables within the given source buffer
- * with their matching values from the resolver.
- * The buffer is updated with the result.
- *
- * @param source the buffer to replace in, updated, null returns zero
- * @return true if altered
- */
- public boolean replaceIn(StringBuffer source) {
- if (source == null) {
- return false;
- }
- return replaceIn(source, 0, source.length());
- }
-
- /**
- * Replaces all the occurrences of variables within the given source buffer
- * with their matching values from the resolver.
- * The buffer is updated with the result.
- * <p>
- * Only the specified portion of the buffer will be processed.
- * The rest of the buffer is not processed, but it is not deleted.
- *
- * @param source the buffer to replace in, updated, null returns zero
- * @param offset the start offset within the array, must be valid
- * @param length the length within the buffer to be processed, must be valid
- * @return true if altered
- */
- public boolean replaceIn(StringBuffer source, int offset, int length) {
- return replaceIn(null, source, offset, length);
- }
-
- /**
- * Replaces all the occurrences of variables within the given source buffer
- * with their matching values from the resolver.
- * The buffer is updated with the result.
- * <p>
- * Only the specified portion of the buffer will be processed.
- * The rest of the buffer is not processed, but it is not deleted.
- *
- * @param event the current LogEvent, if one exists.
- * @param source the buffer to replace in, updated, null returns zero
- * @param offset the start offset within the array, must be valid
- * @param length the length within the buffer to be processed, must be valid
- * @return true if altered
- */
- public boolean replaceIn(LogEvent event, StringBuffer source, int offset, int length) {
- if (source == null) {
- return false;
- }
- StringBuilder buf = new StringBuilder(length).append(source, offset, length);
- if (!substitute(event, buf, 0, length)) {
- return false;
- }
- source.replace(offset, offset + length, buf.toString());
- return true;
- }
-
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables within the given source
- * builder with their matching values from the resolver.
- *
- * @param source the builder to replace in, updated, null returns zero
- * @return true if altered
- */
- public boolean replaceIn(StringBuilder source) {
- return replaceIn(null, source);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Replaces all the occurrences of variables within the given source
- * builder with their matching values from the resolver.
- *
- * @param event the current LogEvent, if one exists.
- * @param source the builder to replace in, updated, null returns zero
- * @return true if altered
- */
- public boolean replaceIn(LogEvent event, StringBuilder source) {
- if (source == null) {
- return false;
- }
- return substitute(event, source, 0, source.length());
- }
- /**
- * Replaces all the occurrences of variables within the given source
- * builder with their matching values from the resolver.
- * <p>
- * Only the specified portion of the builder will be processed.
- * The rest of the builder is not processed, but it is not deleted.
- *
- * @param source the builder to replace in, null returns zero
- * @param offset the start offset within the array, must be valid
- * @param length the length within the builder to be processed, must be valid
- * @return true if altered
- */
- public boolean replaceIn(StringBuilder source, int offset, int length) {
- return replaceIn(null, source, offset, length);
- }
-
- /**
- * Replaces all the occurrences of variables within the given source
- * builder with their matching values from the resolver.
- * <p>
- * Only the specified portion of the builder will be processed.
- * The rest of the builder is not processed, but it is not deleted.
- *
- * @param event the current LogEvent, if one is present.
- * @param source the builder to replace in, null returns zero
- * @param offset the start offset within the array, must be valid
- * @param length the length within the builder to be processed, must be valid
- * @return true if altered
- */
- public boolean replaceIn(LogEvent event, StringBuilder source, int offset, int length) {
- if (source == null) {
- return false;
- }
- return substitute(event, source, offset, length);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Internal method that substitutes the variables.
- * <p>
- * Most users of this class do not need to call this method. This method will
- * be called automatically by another (public) method.
- * <p>
- * Writers of subclasses can override this method if they need access to
- * the substitution process at the start or end.
- *
- * @param event The current LogEvent, if there is one.
- * @param buf the string builder to substitute into, not null
- * @param offset the start offset within the builder, must be valid
- * @param length the length within the builder to be processed, must be valid
- * @return true if altered
- */
- protected boolean substitute(LogEvent event, StringBuilder buf, int offset, int length) {
- return substitute(event, buf, offset, length, null) > 0;
- }
-
- /**
- * Recursive handler for multiple levels of interpolation. This is the main
- * interpolation method, which resolves the values of all variable references
- * contained in the passed in text.
- *
- * @param event The current LogEvent, if there is one.
- * @param buf the string builder to substitute into, not null
- * @param offset the start offset within the builder, must be valid
- * @param length the length within the builder to be processed, must be valid
- * @param priorVariables the stack keeping track of the replaced variables, may be null
- * @return the length change that occurs, unless priorVariables is null when the int
- * represents a boolean flag as to whether any change occurred.
- */
- private int substitute(LogEvent event, StringBuilder buf, int offset, int length, List<String> priorVariables) {
- StrMatcher prefixMatcher = getVariablePrefixMatcher();
- StrMatcher suffixMatcher = getVariableSuffixMatcher();
- char escape = getEscapeChar();
-
- boolean top = (priorVariables == null);
- boolean altered = false;
- int lengthChange = 0;
- char[] chars = getChars(buf);
- int bufEnd = offset + length;
- int pos = offset;
- while (pos < bufEnd) {
- int startMatchLen = prefixMatcher.isMatch(chars, pos, offset,
- bufEnd);
- if (startMatchLen == 0) {
- pos++;
- } else {
- // found variable start marker
- if (pos > offset && chars[pos - 1] == escape) {
- // escaped
- buf.deleteCharAt(pos - 1);
- chars = getChars(buf);
- lengthChange--;
- altered = true;
- bufEnd--;
- } else {
- // find suffix
- int startPos = pos;
- pos += startMatchLen;
- int endMatchLen = 0;
- int nestedVarCount = 0;
- while (pos < bufEnd) {
- if (isEnableSubstitutionInVariables()
- && (endMatchLen = prefixMatcher.isMatch(chars,
- pos, offset, bufEnd)) != 0) {
- // found a nested variable start
- nestedVarCount++;
- pos += endMatchLen;
- continue;
- }
-
- endMatchLen = suffixMatcher.isMatch(chars, pos, offset,
- bufEnd);
- if (endMatchLen == 0) {
- pos++;
- } else {
- // found variable end marker
- if (nestedVarCount == 0) {
- String varName = new String(chars, startPos
- + startMatchLen, pos - startPos
- - startMatchLen);
- if (isEnableSubstitutionInVariables()) {
- StringBuilder bufName = new StringBuilder(varName);
- substitute(event, bufName, 0, bufName.length());
- varName = bufName.toString();
- }
- pos += endMatchLen;
- int endPos = pos;
-
- // on the first call initialize priorVariables
- if (priorVariables == null) {
- priorVariables = new ArrayList<String>();
- priorVariables.add(new String(chars,
- offset, length));
- }
-
- // handle cyclic substitution
- checkCyclicSubstitution(varName, priorVariables);
- priorVariables.add(varName);
-
- // resolve the variable
- String varValue = resolveVariable(event, varName, buf,
- startPos, endPos);
- if (varValue != null) {
- // recursive replace
- int varLen = varValue.length();
- buf.replace(startPos, endPos, varValue);
- altered = true;
- int change = substitute(event, buf, startPos,
- varLen, priorVariables);
- change = change
- + (varLen - (endPos - startPos));
- pos += change;
- bufEnd += change;
- lengthChange += change;
- chars = getChars(buf); // in case buffer was
- // altered
- }
-
- // remove variable from the cyclic stack
- priorVariables
- .remove(priorVariables.size() - 1);
- break;
- } else {
- nestedVarCount--;
- pos += endMatchLen;
- }
- }
- }
- }
- }
- }
- if (top) {
- return (altered ? 1 : 0);
- }
- return lengthChange;
- }
-
- /**
- * Checks if the specified variable is already in the stack (list) of variables.
- *
- * @param varName the variable name to check
- * @param priorVariables the list of prior variables
- */
- private void checkCyclicSubstitution(String varName, List<String> priorVariables) {
- if (!priorVariables.contains(varName)) {
- return;
- }
- StringBuilder buf = new StringBuilder(BUF_SIZE);
- buf.append("Infinite loop in property interpolation of ");
- buf.append(priorVariables.remove(0));
- buf.append(": ");
- appendWithSeparators(buf, priorVariables, "->");
- throw new IllegalStateException(buf.toString());
- }
-
- /**
- * Internal method that resolves the value of a variable.
- * <p>
- * Most users of this class do not need to call this method. This method is
- * called automatically by the substitution process.
- * <p>
- * Writers of subclasses can override this method if they need to alter
- * how each substitution occurs. The method is passed the variable's name
- * and must return the corresponding value. This implementation uses the
- * {@link #getVariableResolver()} with the variable's name as the key.
- *
- * @param event The LogEvent, if there is one.
- * @param variableName the name of the variable, not null
- * @param buf the buffer where the substitution is occurring, not null
- * @param startPos the start position of the variable including the prefix, valid
- * @param endPos the end position of the variable including the suffix, valid
- * @return the variable's value or <b>null</b> if the variable is unknown
- */
- protected String resolveVariable(LogEvent event, String variableName, StringBuilder buf, int startPos,
- int endPos) {
- StrLookup<?> resolver = getVariableResolver();
- if (resolver == null) {
- return null;
- }
- return resolver.lookup(event, variableName);
- }
-
- // Escape
- //-----------------------------------------------------------------------
- /**
- * Returns the escape character.
- *
- * @return the character used for escaping variable references
- */
- public char getEscapeChar() {
- return this.escapeChar;
- }
-
- /**
- * Sets the escape character.
- * If this character is placed before a variable reference in the source
- * text, this variable will be ignored.
- *
- * @param escapeCharacter the escape character (0 for disabling escaping)
- */
- public void setEscapeChar(char escapeCharacter) {
- this.escapeChar = escapeCharacter;
- }
-
- // Prefix
- //-----------------------------------------------------------------------
- /**
- * Gets the variable prefix matcher currently in use.
- * <p>
- * The variable prefix is the characer or characters that identify the
- * start of a variable. This prefix is expressed in terms of a matcher
- * allowing advanced prefix matches.
- *
- * @return the prefix matcher in use
- */
- public StrMatcher getVariablePrefixMatcher() {
- return prefixMatcher;
- }
-
- /**
- * Sets the variable prefix matcher currently in use.
- * <p>
- * The variable prefix is the characer or characters that identify the
- * start of a variable. This prefix is expressed in terms of a matcher
- * allowing advanced prefix matches.
- *
- * @param prefixMatcher the prefix matcher to use, null ignored
- * @return this, to enable chaining
- * @throws IllegalArgumentException if the prefix matcher is null
- */
- public StrSubstitutor setVariablePrefixMatcher(StrMatcher prefixMatcher) {
- if (prefixMatcher == null) {
- throw new IllegalArgumentException("Variable prefix matcher must not be null!");
- }
- this.prefixMatcher = prefixMatcher;
- return this;
- }
-
- /**
- * Sets the variable prefix to use.
- * <p>
- * The variable prefix is the character or characters that identify the
- * start of a variable. This method allows a single character prefix to
- * be easily set.
- *
- * @param prefix the prefix character to use
- * @return this, to enable chaining
- */
- public StrSubstitutor setVariablePrefix(char prefix) {
- return setVariablePrefixMatcher(StrMatcher.charMatcher(prefix));
- }
-
- /**
- * Sets the variable prefix to use.
- * <p>
- * The variable prefix is the characer or characters that identify the
- * start of a variable. This method allows a string prefix to be easily set.
- *
- * @param prefix the prefix for variables, not null
- * @return this, to enable chaining
- * @throws IllegalArgumentException if the prefix is null
- */
- public StrSubstitutor setVariablePrefix(String prefix) {
- if (prefix == null) {
- throw new IllegalArgumentException("Variable prefix must not be null!");
- }
- return setVariablePrefixMatcher(StrMatcher.stringMatcher(prefix));
- }
-
- // Suffix
- //-----------------------------------------------------------------------
- /**
- * Gets the variable suffix matcher currently in use.
- * <p>
- * The variable suffix is the characer or characters that identify the
- * end of a variable. This suffix is expressed in terms of a matcher
- * allowing advanced suffix matches.
- *
- * @return the suffix matcher in use
- */
- public StrMatcher getVariableSuffixMatcher() {
- return suffixMatcher;
- }
-
- /**
- * Sets the variable suffix matcher currently in use.
- * <p>
- * The variable suffix is the characer or characters that identify the
- * end of a variable. This suffix is expressed in terms of a matcher
- * allowing advanced suffix matches.
- *
- * @param suffixMatcher the suffix matcher to use, null ignored
- * @return this, to enable chaining
- * @throws IllegalArgumentException if the suffix matcher is null
- */
- public StrSubstitutor setVariableSuffixMatcher(StrMatcher suffixMatcher) {
- if (suffixMatcher == null) {
- throw new IllegalArgumentException("Variable suffix matcher must not be null!");
- }
- this.suffixMatcher = suffixMatcher;
- return this;
- }
-
- /**
- * Sets the variable suffix to use.
- * <p>
- * The variable suffix is the characer or characters that identify the
- * end of a variable. This method allows a single character suffix to
- * be easily set.
- *
- * @param suffix the suffix character to use
- * @return this, to enable chaining
- */
- public StrSubstitutor setVariableSuffix(char suffix) {
- return setVariableSuffixMatcher(StrMatcher.charMatcher(suffix));
- }
-
- /**
- * Sets the variable suffix to use.
- * <p>
- * The variable suffix is the character or characters that identify the
- * end of a variable. This method allows a string suffix to be easily set.
- *
- * @param suffix the suffix for variables, not null
- * @return this, to enable chaining
- * @throws IllegalArgumentException if the suffix is null
- */
- public StrSubstitutor setVariableSuffix(String suffix) {
- if (suffix == null) {
- throw new IllegalArgumentException("Variable suffix must not be null!");
- }
- return setVariableSuffixMatcher(StrMatcher.stringMatcher(suffix));
- }
-
- // Resolver
- //-----------------------------------------------------------------------
- /**
- * Gets the VariableResolver that is used to lookup variables.
- *
- * @return the VariableResolver
- */
- public StrLookup<?> getVariableResolver() {
- return this.variableResolver;
- }
-
- /**
- * Sets the VariableResolver that is used to lookup variables.
- *
- * @param variableResolver the VariableResolver
- */
- public void setVariableResolver(StrLookup<?> variableResolver) {
- this.variableResolver = variableResolver;
- }
-
- // Substitution support in variable names
- //-----------------------------------------------------------------------
- /**
- * Returns a flag whether substitution is done in variable names.
- *
- * @return the substitution in variable names flag
- */
- public boolean isEnableSubstitutionInVariables() {
- return enableSubstitutionInVariables;
- }
-
- /**
- * Sets a flag whether substitution is done in variable names. If set to
- * <b>true</b>, the names of variables can contain other variables which are
- * processed first before the original variable is evaluated, e.g.
- * <code>${jre-${java.version}}</code>. The default value is <b>false</b>.
- *
- * @param enableSubstitutionInVariables the new value of the flag
- */
- public void setEnableSubstitutionInVariables(boolean enableSubstitutionInVariables) {
- this.enableSubstitutionInVariables = enableSubstitutionInVariables;
- }
-
- private char[] getChars(StringBuilder sb) {
- char[] chars = new char[sb.length()];
- sb.getChars(0, sb.length(), chars, 0);
- return chars;
- }
-
- /**
- * Appends a iterable placing separators between each value, but
- * not before the first or after the last.
- * Appending a null iterable will have no effect..
- *
- * @param sb StringBuilder that contains the String being constructed.
- * @param iterable the iterable to append
- * @param separator the separator to use, null means no separator
- */
- public void appendWithSeparators(StringBuilder sb, Iterable<?> iterable, String separator) {
- if (iterable != null) {
- separator = (separator == null ? "" : separator);
- Iterator<?> it = iterable.iterator();
- while (it.hasNext()) {
- sb.append(it.next());
- if (it.hasNext()) {
- sb.append(separator);
- }
- }
- }
- }
-
- @Override
- public String toString() {
- return "StrSubstitutor(" + variableResolver.toString() + ")";
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StructuredDataLookup.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StructuredDataLookup.java
deleted file mode 100644
index cc7ed90..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/StructuredDataLookup.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-
-/**
- * Looks up keys from system properties.
- */
-@Plugin(name = "sd", type = "Lookup")
-public class StructuredDataLookup implements StrLookup {
-
- /**
- * Lookup the value for the key.
- * @param key the key to be looked up, may be null
- * @return The value for the key.
- */
- public String lookup(String key) {
- return null;
- }
-
- /**
- * Lookup the value for the key using the data in the LogEvent.
- * @param event The current LogEvent.
- * @param key the key to be looked up, may be null
- * @return The value associated with the key.
- */
- public String lookup(LogEvent event, String key) {
- if (event == null || !(event.getMessage() instanceof StructuredDataMessage)) {
- return null;
- }
- StructuredDataMessage msg = (StructuredDataMessage) event.getMessage();
- if (key.equalsIgnoreCase("id")) {
- return msg.getId().getName();
- } else if (key.equalsIgnoreCase("type")) {
- return msg.getType();
- }
- return msg.get(key);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/SystemPropertiesLookup.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/SystemPropertiesLookup.java
deleted file mode 100644
index 970ccd6..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/SystemPropertiesLookup.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-/**
- * Looks up keys from system properties.
- */
-@Plugin(name = "sys", type = "Lookup")
-public class SystemPropertiesLookup implements StrLookup {
-
- /**
- * Lookup the value for the key.
- * @param key the key to be looked up, may be null
- * @return The value for the key.
- */
- public String lookup(String key) {
- return System.getProperty(key);
- }
-
- /**
- * Lookup the value for the key using the data in the LogEvent.
- * @param event The current LogEvent.
- * @param key the key to be looked up, may be null
- * @return The value associated with the key.
- */
- public String lookup(LogEvent event, String key) {
- return System.getProperty(key);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/package-info.java
deleted file mode 100644
index 1cec640..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/lookup/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 Lookups.
- */
-package org.apache.logging.log4j.core.lookup;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSManager.java
deleted file mode 100644
index 11b1867..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSManager.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.core.appender.AbstractManager;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import java.io.Serializable;
-import java.util.Properties;
-
-/**
- * Base Class for Managers of JMS connections.
- */
-public abstract class AbstractJMSManager extends AbstractManager {
-
- /**
- * The Constructor.
- * @param name The name of the Appender.
- */
- public AbstractJMSManager(String name) {
- super(name);
- }
-
- /**
- * Create the InitialContext.
- * @param factoryName The fully qualified class name of the InitialContextFactory.
- * @param providerURL The URL of the provider to use.
- * @param urlPkgPrefixes A colon-separated list of package prefixes for the class name of the factory class that
- * will create a URL context factory
- * @param securityPrincipalName The name of the identity of the Principal.
- * @param securityCredentials The security credentials of the Principal.
- * @return the InitialContext.
- * @throws NamingException if a naming error occurs.
- */
- protected static Context createContext(String factoryName, String providerURL, String urlPkgPrefixes,
- String securityPrincipalName, String securityCredentials)
- throws NamingException {
-
- Properties props = getEnvironment(factoryName, providerURL, urlPkgPrefixes, securityPrincipalName,
- securityCredentials);
- return new InitialContext(props);
- }
-
- /**
- * Looks up the name in the context.
- * @param ctx The Context.
- * @param name The name to locate.
- * @return The object to be located.
- * @throws NamingException If an error occurs locating the name.
- */
- 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;
- }
- }
-
- /**
- * Sets up the properties to pass to the InitialContext.
- * @param factoryName The fully qualified class name of the InitialContextFactory.
- * @param providerURL The URL of the provider to use.
- * @param urlPkgPrefixes A colon-separated list of package prefixes for the class name of the factory class that
- * will create a URL context factory
- * @param securityPrincipalName The name of the identity of the Principal.
- * @param securityCredentials The security credentials of the Principal.
- * @return The Properties.
- */
- protected static Properties getEnvironment(String factoryName, String providerURL, String urlPkgPrefixes,
- String securityPrincipalName, String securityCredentials) {
- Properties props = new Properties();
- if (factoryName != null) {
- props.put(Context.INITIAL_CONTEXT_FACTORY, factoryName);
- if (providerURL != null) {
- props.put(Context.PROVIDER_URL, providerURL);
- } else {
- LOGGER.warn("The InitalContext factory name has been provided without a ProviderURL. " +
- "This is likely to cause problems");
- }
- if (urlPkgPrefixes != null) {
- props.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes);
- }
- if (securityPrincipalName != null) {
- props.put(Context.SECURITY_PRINCIPAL, securityPrincipalName);
- if (securityCredentials != null) {
- props.put(Context.SECURITY_CREDENTIALS, securityCredentials);
- } else {
- LOGGER.warn("SecurityPrincipalName has been set without SecurityCredentials. " +
- "This is likely to cause problems.");
- }
- }
- return props;
- }
- return null;
- }
-
- /**
- * Send the message.
- * @param object The Object to sent.
- * @throws Exception if an error occurs.
- */
- public abstract void send(Serializable object) throws Exception;
-
- /**
- * Send the Object.
- * @param object The Object to send.
- * @param session The Session.
- * @param producer The MessageProducer.
- * @throws Exception if an error occurs.
- */
- public synchronized void send(Serializable object, Session session, MessageProducer producer) throws Exception {
- try {
- Message msg;
- if (object instanceof String) {
- msg = session.createTextMessage();
- ((TextMessage) msg).setText((String) object);
- } else {
- msg = session.createObjectMessage();
- ((ObjectMessage) msg).setObject(object);
- }
- producer.send(msg);
- } catch (JMSException ex) {
- LOGGER.error("Could not publish message via JMS " + getName());
- throw ex;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSReceiver.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSReceiver.java
deleted file mode 100644
index e0c6f45..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSReceiver.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.AbstractServer;
-import org.apache.logging.log4j.core.LogEvent;
-
-import javax.jms.JMSException;
-import javax.jms.ObjectMessage;
-import javax.naming.Context;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
-/**
- * Base class for receiving LogEvents over JMS. This class expects all messages to be serialized log events.
- */
-public abstract class AbstractJMSReceiver extends AbstractServer implements javax.jms.MessageListener {
-
- /**
- * Logger to capture diagnostics.
- */
- protected Logger logger = LogManager.getLogger(this.getClass().getName());
-
- /**
- * Listener that receives the event.
- * @param message The received message.
- */
- public void onMessage(javax.jms.Message message) {
-
- try {
- if (message instanceof ObjectMessage) {
- ObjectMessage objectMessage = (ObjectMessage) message;
- log((LogEvent) objectMessage.getObject());
- } 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);
- }
- }
-
- /**
- * Looks up an object from the Context.
- * @param ctx The Context.
- * @param name The name of the object to locate.
- * @return The object.
- * @throws NamingException if an error occurs.
- */
- protected 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;
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/AbstractSocketManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/AbstractSocketManager.java
deleted file mode 100644
index 1282788..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/AbstractSocketManager.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.core.appender.OutputStreamManager;
-
-import java.io.OutputStream;
-import java.net.InetAddress;
-
-/**
- * Base class for managing sockets.
- */
-public abstract class AbstractSocketManager extends OutputStreamManager {
-
- /**
- * The internet address of the host.
- */
- protected final InetAddress address;
- /**
- * The name of the host.
- */
- protected final String host;
- /**
- * The port on the host.
- */
- protected final int port;
-
- /**
- * The Constructor.
- * @param name The unique name of this connection.
- * @param os The OutputStream to manage.
- * @param addr The internet address.
- * @param host The target host name.
- * @param port The target port number.
- */
- public AbstractSocketManager(String name, OutputStream os, InetAddress addr, String host, int port) {
- super(os, name);
- this.address = addr;
- this.host = host;
- this.port = port;
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/DatagramOutputStream.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/DatagramOutputStream.java
deleted file mode 100644
index 47f0960..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/DatagramOutputStream.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.AppenderRuntimeException;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-
-/**
- * OutputStream for UDP connections.
- */
-public class DatagramOutputStream extends OutputStream {
-
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
-
- private static final int SHIFT_1 = 8;
- private static final int SHIFT_2 = 16;
- private static final int SHIFT_3 = 24;
-
- private DatagramSocket ds;
- private InetAddress address;
- private int port;
-
- private byte[] data;
-
- /**
- * The Constructor.
- * @param host The host to connect to.
- * @param port The port on the host.
- */
- public DatagramOutputStream(String host, int port) {
- this.port = port;
- try {
- address = InetAddress.getByName(host);
- } catch (UnknownHostException ex) {
- String msg = "Could not find host " + host;
- LOGGER.error(msg, ex);
- throw new AppenderRuntimeException(msg, ex);
- }
-
- try {
- ds = new DatagramSocket();
- } catch (SocketException ex) {
- String msg = "Could not instantiate DatagramSocket to " + host;
- LOGGER.error(msg, ex);
- throw new AppenderRuntimeException(msg, ex);
- }
- }
-
- @Override
- public synchronized void write(byte[] bytes, int offset, int length) throws IOException {
- copy(bytes, offset, length);
- }
-
- @Override
- public synchronized void write(int i) throws IOException {
- copy(new byte[] {(byte) (i >>> SHIFT_3), (byte) (i >>> SHIFT_2), (byte) (i >>> SHIFT_1), (byte) i}, 0, 4);
- }
-
- @Override
- public synchronized void write(byte[] bytes) throws IOException {
- copy(bytes, 0, bytes.length);
- }
-
- @Override
- public synchronized void flush() throws IOException {
- if (this.ds != null && this.address != null) {
- DatagramPacket packet = new DatagramPacket(data, data.length, address, port);
- ds.send(packet);
- }
- data = null;
- }
-
- @Override
- public synchronized void close() throws IOException {
- if (ds != null) {
- if (data != null) {
- flush();
- }
- ds.close();
- ds = null;
- }
- }
-
- private void copy(byte[] bytes, int offset, int length) {
- int index = data == null ? 0 : data.length;
- byte[] copy = new byte[length + index];
- if (data != null) {
- System.arraycopy(data, 0, copy, 0, index);
- }
- System.arraycopy(bytes, offset, copy, index, length);
- data = copy;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/DatagramSocketManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/DatagramSocketManager.java
deleted file mode 100644
index c672ada..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/DatagramSocketManager.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.core.appender.ManagerFactory;
-
-import java.io.OutputStream;
-
-/**
- * Socket Manager for UDP connections.
- */
-public class DatagramSocketManager extends AbstractSocketManager {
-
- private static ManagerFactory factory = new DatagramSocketManagerFactory();
-
- /**
- * The Constructor.
- * @param os The OutputStream.
- * @param name The unique name of the connection.
- * @param host The host to connect to.
- * @param port The port on the host.
- */
- protected DatagramSocketManager(OutputStream os, String name, String host, int port) {
- super(name, os, null, host, port);
- }
-
- /**
- * Obtain a SocketManager.
- * @param host The host to connect to.
- * @param port The port on the host.
- * @return A DatagramSocketManager.
- */
- public static DatagramSocketManager getSocketManager(String host, int port) {
- if (host == null || host.length() == 0) {
- throw new IllegalArgumentException("A host name is required");
- }
- if (port <= 0) {
- throw new IllegalArgumentException("A port value is required");
- }
- return (DatagramSocketManager) getManager("UDP:" + host + ":" + port, factory,
- new FactoryData(host, port));
- }
-
- /**
- * Data for the factory.
- */
- private static class FactoryData {
- private String host;
- private int port;
-
- public FactoryData(String host, int port) {
- this.host = host;
- this.port = port;
- }
- }
-
- /**
- * Factory to create the DatagramSocketManager.
- */
- private static class DatagramSocketManagerFactory implements ManagerFactory<DatagramSocketManager, FactoryData> {
-
- public DatagramSocketManager createManager(String name, FactoryData data) {
- OutputStream os = new DatagramOutputStream(data.host, data.port);
- return new DatagramSocketManager(os, name, data.host, data.port);
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Facility.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Facility.java
deleted file mode 100644
index 8f2c558..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Facility.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-/**
- * The facility codes used by the Syslog system.
- *
- * Numerical Facility<br>
- * Code<br>
- *
- * 0 kernel messages<br>
- * 1 user-level messages<br>
- * 2 mail system<br>
- * 3 system daemons<br>
- * 4 security/authorization messages<br>
- * 5 messages generated internally by syslogd<br>
- * 6 line printer subsystem<br>
- * 7 network news subsystem<br>
- * 8 UUCP subsystem<br>
- * 9 clock daemon<br>
- * 10 security/authorization messages<br>
- * 11 FTP daemon<br>
- * 12 NTP subsystem<br>
- * 13 log audit<br>
- * 14 log alert<br>
- * 15 clock daemon (note 2)<br>
- * 16 local use 0 (local0)<br>
- * 17 local use 1 (local1)<br>
- * 18 local use 2 (local2)<br>
- * 19 local use 3 (local3)<br>
- * 20 local use 4 (local4)<br>
- * 21 local use 5 (local5)<br>
- * 22 local use 6 (local6)<br>
- * 23 local use 7 (local7)<br>
- */
-public enum Facility {
- /** Kernel messages. */
- KERN(0),
- /** User level messages. */
- USER(1),
- /** Mail system. */
- MAIL(2),
- /** System daemons. */
- DAEMON(3),
- /** Security/Authorization messages. */
- AUTH(4),
- /** Messages generated by syslogd. */
- SYSLOG(5),
- /** Line printer subsystem. */
- LPR(6),
- /** Network news subsystem. */
- NEWS(7),
- /** UUCP subsystem. */
- UUCP(8),
- /** Clock daemon. */
- CRON(9),
- /** Security/Authorization messages. */
- AUTHPRIV(10),
- /** FTP daemon. */
- FTP(11),
- /** NTP subsystem. */
- NTP(12),
- /** Log audit. */
- LOG_AUDIT(13),
- /** Log alert. */
- LOG_ALERT(14),
- /** Clock daemon. */
- CLOCK(15),
- /** Local use 0. */
- LOCAL0(16),
- /** Local use 1. */
- LOCAL1(17),
- /** Local use 2. */
- LOCAL2(18),
- /** Local use 3. */
- LOCAL3(19),
- /** Local use 4. */
- LOCAL4(20),
- /** Local use 5. */
- LOCAL5(21),
- /** Local use 6. */
- LOCAL6(22),
- /** Local use 7. */
- LOCAL7(23);
-
- private final int code;
-
- private Facility(int code) {
- this.code = code;
- }
-
- /**
- * Retrieve the value of the enumeration.
- * @return The value associated with the enumeration.
- */
- public int getCode() {
- return this.code;
- }
-
- /**
- * Determine if this enumeration matches the specified name (ignoring case).
- * @param name The name to check.
- * @return true if the name matches this enumeration, ignoring case.
- */
- public boolean isEqual(String name) {
- return this.name().equalsIgnoreCase(name);
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSQueueManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSQueueManager.java
deleted file mode 100644
index 8a362a2..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSQueueManager.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.core.appender.ManagerFactory;
-
-import javax.jms.JMSException;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueSender;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import java.io.Serializable;
-
-/**
- * Manager for a JMS Queue.
- */
-public class JMSQueueManager extends AbstractJMSManager {
-
- private static ManagerFactory factory = new JMSQueueManagerFactory();
-
- private QueueConnection queueConnection;
- private QueueSession queueSession;
- private QueueSender queueSender;
-
- /**
- * The Constructor.
- * @param name The unique name of the connection.
- * @param conn The QueueConnection.
- * @param sess The QueueSession.
- * @param sender The QueueSender.
- */
- protected JMSQueueManager(String name, QueueConnection conn, QueueSession sess, QueueSender sender) {
- super(name);
- this.queueConnection = conn;
- this.queueSession = sess;
- this.queueSender = sender;
- }
-
- /**
- * Obtain a JMSQueueManager.
- * @param factoryName The fully qualified class name of the InitialContextFactory.
- * @param providerURL The URL of the provider to use.
- * @param urlPkgPrefixes A colon-separated list of package prefixes for the class name of the factory class that
- * will create a URL context factory
- * @param securityPrincipalName The name of the identity of the Principal.
- * @param securityCredentials The security credentials of the Principal.
- * @param factoryBindingName The name to locate in the Context that provides the QueueConnectionFactory.
- * @param queueBindingName The name to use to locate the Queue.
- * @param userName The userid to use to create the Queue Connection.
- * @param password The password to use to create the Queue Connection.
- * @return The JMSQueueManager.
- */
- public static JMSQueueManager getJMSQueueManager(String factoryName, String providerURL, String urlPkgPrefixes,
- String securityPrincipalName, String securityCredentials,
- String factoryBindingName, String queueBindingName,
- String userName, String password) {
-
- if (factoryBindingName == null) {
- LOGGER.error("No factory name provided for JMSQueueManager");
- return null;
- }
- if (queueBindingName == null) {
- LOGGER.error("No topic name provided for JMSQueueManager");
- return null;
- }
-
- String name = "JMSQueue:" + factoryBindingName + "." + queueBindingName;
- return (JMSQueueManager) getManager(name, factory, new FactoryData(factoryName, providerURL, urlPkgPrefixes,
- securityPrincipalName, securityCredentials, factoryBindingName, queueBindingName, userName, password));
- }
-
- @Override
- public void send(Serializable object) throws Exception {
- super.send(object, queueSession, queueSender);
- }
-
- @Override
- public void releaseSub() {
- try {
- if (queueSession != null) {
- queueSession.close();
- }
- if (queueConnection != null) {
- queueConnection.close();
- }
- } catch (JMSException ex) {
- LOGGER.error("Error closing " + getName(), ex);
- }
- }
-
- /**
- * Data for the factory.
- */
- private static class FactoryData {
- private String factoryName;
- private String providerURL;
- private String urlPkgPrefixes;
- private String securityPrincipalName;
- private String securityCredentials;
- private String factoryBindingName;
- private String queueBindingName;
- private String userName;
- private String password;
-
- public FactoryData(String factoryName, String providerURL, String urlPkgPrefixes, String securityPrincipalName,
- String securityCredentials, String factoryBindingName, String queueBindingName,
- String userName, String password) {
- this.factoryName = factoryName;
- this.providerURL = providerURL;
- this.urlPkgPrefixes = urlPkgPrefixes;
- this.securityPrincipalName = securityPrincipalName;
- this.securityCredentials = securityCredentials;
- this.factoryBindingName = factoryBindingName;
- this.queueBindingName = queueBindingName;
- this.userName = userName;
- this.password = password;
- }
- }
-
- /**
- * Factory to create the JMSQueueManager.
- */
- private static class JMSQueueManagerFactory implements ManagerFactory<JMSQueueManager, FactoryData> {
-
- public JMSQueueManager createManager(String name, FactoryData data) {
- try {
- Context ctx = createContext(data.factoryName, data.providerURL, data.urlPkgPrefixes,
- data.securityPrincipalName, data.securityCredentials);
- QueueConnectionFactory factory = (QueueConnectionFactory) lookup(ctx, data.factoryBindingName);
- QueueConnection conn;
- if (data.userName != null) {
- conn = factory.createQueueConnection(data.userName, data.password);
- } else {
- conn = factory.createQueueConnection();
- }
- QueueSession sess = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = (Queue) lookup(ctx, data.queueBindingName);
- QueueSender sender = sess.createSender(queue);
- conn.start();
- return new JMSQueueManager(name, conn, sess, sender);
-
- } catch (NamingException ex) {
- LOGGER.error("Unable to locate resource", ex);
- } catch (JMSException jmsex) {
- LOGGER.error("Unable to establish connection", jmsex);
- }
-
- return null;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSQueueReceiver.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSQueueReceiver.java
deleted file mode 100644
index 1d8eaa4..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSQueueReceiver.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import javax.jms.JMSException;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
-/**
- * Receives Log Events over a JMS Queue. This implementation expects that all messages will
- * contain a serialized LogEvent.
- */
-public class JMSQueueReceiver extends AbstractJMSReceiver {
-
- /**
- * Constructor.
- * @param qcfBindingName The QueueConnectionFactory binding name.
- * @param queueBindingName The Queue binding name.
- * @param username The userid to connect to the queue.
- * @param password The password to connect to the queue.
- */
- public JMSQueueReceiver(String qcfBindingName, String queueBindingName, String username, String password) {
-
- try {
- Context ctx = new InitialContext();
- QueueConnectionFactory queueConnectionFactory;
- queueConnectionFactory = (QueueConnectionFactory) lookup(ctx, qcfBindingName);
- QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(username, password);
- queueConnection.start();
- QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = (Queue) ctx.lookup(queueBindingName);
- QueueReceiver queueReceiver = queueSession.createReceiver(queue);
- queueReceiver.setMessageListener(this);
- } catch (JMSException e) {
- logger.error("Could not read JMS message.", e);
- } catch (NamingException e) {
- logger.error("Could not read JMS message.", e);
- } catch (RuntimeException e) {
- logger.error("Could not read JMS message.", e);
- }
- }
-
- /**
- * Main startup for the receiver.
- * @param args The command line arguments.
- * @throws Exception if an error occurs.
- */
- public static void main(String[] args) throws Exception {
- if (args.length != 4) {
- usage("Wrong number of arguments.");
- }
-
- String qcfBindingName = args[0];
- String queueBindingName = args[1];
- String username = args[2];
- String password = args[3];
-
- new JMSQueueReceiver(qcfBindingName, queueBindingName, username, password);
-
- BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
- // Loop until the word "exit" is typed
- System.out.println("Type \"exit\" to quit JMSQueueReceiver.");
- 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;
- }
- }
- }
-
-
- private static void usage(String msg) {
- System.err.println(msg);
- System.err.println("Usage: java " + JMSQueueReceiver.class.getName()
- + " QueueConnectionFactoryBindingName QueueBindingName username password");
- System.exit(1);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSTopicManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSTopicManager.java
deleted file mode 100644
index cfe15f0..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSTopicManager.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.core.appender.ManagerFactory;
-
-import javax.jms.JMSException;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicConnectionFactory;
-import javax.jms.TopicPublisher;
-import javax.jms.TopicSession;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import java.io.Serializable;
-
-/**
- * Manager for JMS Topic connections.
- */
-public class JMSTopicManager extends AbstractJMSManager {
-
- private static ManagerFactory factory = new JMSTopicManagerFactory();
-
- private TopicConnection topicConnection;
- private TopicSession topicSession;
- private TopicPublisher topicPublisher;
-
- /**
- * Constructor.
- * @param name The unique name of the connection.
- * @param conn The TopicConnection.
- * @param sess The TopicSession.
- * @param pub The TopicPublisher.
- */
- public JMSTopicManager(String name, TopicConnection conn, TopicSession sess, TopicPublisher pub) {
- super(name);
- this.topicConnection = conn;
- this.topicSession = sess;
- this.topicPublisher = pub;
- }
-
- /**
- * Obtain a JSMTopicManager.
- * @param factoryName The fully qualified class name of the InitialContextFactory.
- * @param providerURL The URL of the provider to use.
- * @param urlPkgPrefixes A colon-separated list of package prefixes for the class name of the factory class that
- * will create a URL context factory
- * @param securityPrincipalName The name of the identity of the Principal.
- * @param securityCredentials The security credentials of the Principal.
- * @param factoryBindingName The name to locate in the Context that provides the TopicConnectionFactory.
- * @param topicBindingName The name to use to locate the Topic.
- * @param userName The userid to use to create the Topic Connection.
- * @param password The password to use to create the Topic Connection.
- * @return A JMSTopicManager.
- */
- public static JMSTopicManager getJMSTopicManager(String factoryName, String providerURL, String urlPkgPrefixes,
- String securityPrincipalName, String securityCredentials,
- String factoryBindingName, String topicBindingName,
- String userName, String password) {
-
- if (factoryBindingName == null) {
- LOGGER.error("No factory name provided for JMSTopicManager");
- return null;
- }
- if (topicBindingName == null) {
- LOGGER.error("No topic name provided for JMSTopicManager");
- return null;
- }
-
- String name = "JMSTopic:" + factoryBindingName + "." + topicBindingName;
- return (JMSTopicManager) getManager(name, factory, new FactoryData(factoryName, providerURL, urlPkgPrefixes,
- securityPrincipalName, securityCredentials, factoryBindingName, topicBindingName, userName, password));
- }
-
-
- @Override
- public void send(Serializable object) throws Exception {
- super.send(object, topicSession, topicPublisher);
- }
-
- @Override
- public void releaseSub() {
- try {
- if (topicSession != null) {
- topicSession.close();
- }
- if (topicConnection != null) {
- topicConnection.close();
- }
- } catch (JMSException ex) {
- LOGGER.error("Error closing " + getName(), ex);
- }
- }
-
- /**
- * Data for the factory.
- */
- private static class FactoryData {
- private String factoryName;
- private String providerURL;
- private String urlPkgPrefixes;
- private String securityPrincipalName;
- private String securityCredentials;
- private String factoryBindingName;
- private String topicBindingName;
- private String userName;
- private String password;
-
- public FactoryData(String factoryName, String providerURL, String urlPkgPrefixes, String securityPrincipalName,
- String securityCredentials, String factoryBindingName, String topicBindingName,
- String userName, String password) {
- this.factoryName = factoryName;
- this.providerURL = providerURL;
- this.urlPkgPrefixes = urlPkgPrefixes;
- this.securityPrincipalName = securityPrincipalName;
- this.securityCredentials = securityCredentials;
- this.factoryBindingName = factoryBindingName;
- this.topicBindingName = topicBindingName;
- this.userName = userName;
- this.password = password;
- }
- }
-
- /**
- * Factory to create a JMSTopicManager.
- */
- private static class JMSTopicManagerFactory implements ManagerFactory<JMSTopicManager, FactoryData> {
-
- public JMSTopicManager createManager(String name, FactoryData data) {
- try {
- Context ctx = createContext(data.factoryName, data.providerURL, data.urlPkgPrefixes,
- data.securityPrincipalName, data.securityCredentials);
- TopicConnectionFactory factory = (TopicConnectionFactory) lookup(ctx, data.factoryBindingName);
- TopicConnection conn;
- if (data.userName != null) {
- conn = factory.createTopicConnection(data.userName, data.password);
- } else {
- conn = factory.createTopicConnection();
- }
- TopicSession sess = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
- Topic topic = (Topic) lookup(ctx, data.topicBindingName);
- TopicPublisher pub = sess.createPublisher(topic);
- conn.start();
- return new JMSTopicManager(name, conn, sess, pub);
- } catch (NamingException ex) {
- LOGGER.error("Bad Name " + data.topicBindingName, ex);
- } catch (JMSException jmsex) {
- LOGGER.error("Unable to create publisher ", jmsex);
- }
-
- return null;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSTopicReceiver.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSTopicReceiver.java
deleted file mode 100644
index 0dff346..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/JMSTopicReceiver.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import javax.jms.JMSException;
-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.NamingException;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
-/**
- * Receives Topic messages that contain LogEvents. This implementation expects that all messages
- * are serialized log events.
- */
-public class JMSTopicReceiver extends AbstractJMSReceiver {
-
- /**
- * Constructor.
- * @param tcfBindingName The TopicConnectionFactory binding name.
- * @param topicBindingName The Topic binding name.
- * @param username The userid to connect to the topic.
- * @param password The password to connect to the topic.
- */
- public JMSTopicReceiver(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 (JMSException e) {
- logger.error("Could not read JMS message.", e);
- } catch (NamingException e) {
- logger.error("Could not read JMS message.", e);
- } catch (RuntimeException e) {
- logger.error("Could not read JMS message.", e);
- }
- }
-
- /**
- * Main startup for the receiver.
- * @param args The command line arguments.
- * @throws Exception if an error occurs.
- */
- public static void main(String[] args) throws Exception {
- if (args.length != 4) {
- usage("Wrong number of arguments.");
- }
-
- String tcfBindingName = args[0];
- String topicBindingName = args[1];
- String username = args[2];
- String password = args[3];
-
- new JMSTopicReceiver(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 JMSTopicReceiver.");
- 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;
- }
- }
- }
-
- private static void usage(String msg) {
- System.err.println(msg);
- System.err.println("Usage: java " + JMSTopicReceiver.class.getName()
- + " TopicConnectionFactoryBindingName TopicBindingName username password");
- System.exit(1);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Priority.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Priority.java
deleted file mode 100644
index 37712b3..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Priority.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.Level;
-
-/**
- * The Priority used in the Syslog system. Calculated from the Facility and Severity values.
- */
-public class Priority {
-
- private final Facility facility;
- private final Severity severity;
-
- /**
- * The Constructor.
- * @param facility The Facility.
- * @param severity The Severity.
- */
- public Priority(Facility facility, Severity severity) {
- this.facility = facility;
- this.severity = severity;
- }
-
- /**
- * Return the priority value based on the Facility and Log Level.
- * @param facility The Facility.
- * @param level The Level.
- * @return The integer value of the priority.
- */
- public static int getPriority(Facility facility, Level level) {
- return facility.getCode() << 3 + Severity.getSeverity(level).getCode();
- }
-
- /**
- * Return the Facility.
- * @return the Facility.
- */
- public Facility getFacility() {
- return facility;
- }
-
- /**
- * Return the Severity.
- * @return the Severity.
- */
- public Severity getSeverity() {
- return severity;
- }
-
- /**
- * Return the value of this Priority.
- * @return the value of this Priority.
- */
- public int getValue() {
- return facility.getCode() << 3 + severity.getCode();
- }
-
- @Override
- public String toString() {
- return Integer.toString(getValue());
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Protocol.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Protocol.java
deleted file mode 100644
index 768463d..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Protocol.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-/**
- * Enumeration of the supported protocols.
- */
-public enum Protocol {
- /** TCP Protocol. */
- TCP,
- /** UDP Protocol. */
- UDP;
-
- /**
- * Determine if the String matches this enum.
- * @param name The enumeration name to check.
- * @return true if this enumeration has the specified name.
- */
- public boolean isEqual(String name) {
- return this.name().equalsIgnoreCase(name);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Severity.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Severity.java
deleted file mode 100644
index 3c3f9a6..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/Severity.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.Level;
-
-/**
- * Severity values used by the Syslog system.
- *
- * Numerical Severity<br>
- * Code<br>
- *
- * 0 Emergency: system is unusable<br>
- * 1 Alert: action must be taken immediately<br>
- * 2 Critical: critical conditions<br>
- * 3 Error: error conditions<br>
- * 4 Warning: warning conditions<br>
- * 5 Notice: normal but significant condition<br>
- * 6 Informational: informational messages<br>
- * 7 Debug: debug-level messages
- */
-public enum Severity {
- /** System is unusable. */
- EMERG(0),
- /** Action must be taken immediately. */
- ALERT(1),
- /** Critical conditions. */
- CRITICAL(2),
- /** Error conditions. */
- ERROR(3),
- /** Warning conditions. */
- WARNING(4),
- /** Normal but significant conditions. */
- NOTICE(5),
- /** Informational messages. */
- INFO(6),
- /** Debug level messages. */
- DEBUG(7);
-
- private final int code;
-
- private Severity(int code) {
- this.code = code;
- }
-
- /**
- * Returns the severity code.
- * @return The numeric value associated with the Severity.
- */
- public int getCode() {
- return this.code;
- }
-
- /**
- * Determine if the name matches this Severity.
- * @param name the name to match.
- * @return true if the name matches, false otherwise.
- */
- public boolean isEqual(String name) {
- return this.name().equalsIgnoreCase(name);
- }
-
- /**
- * Return the Severity for the specified Level.
- * @param level The Level.
- * @return The matching Severity, or DEBUG if there is no match.
- */
- public static Severity getSeverity(Level level) {
- switch (level) {
- case ALL:
- return DEBUG;
- case TRACE:
- return DEBUG;
- case DEBUG:
- return DEBUG;
- case INFO:
- return INFO;
- case WARN:
- return WARNING;
- case ERROR:
- return ERROR;
- case FATAL:
- return ALERT;
- case OFF:
- return EMERG;
- }
- return DEBUG;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/SocketServer.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/SocketServer.java
deleted file mode 100644
index 18c1949..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/SocketServer.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.AbstractServer;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.config.XMLConfiguration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.xml.sax.InputSource;
-
-import java.io.BufferedReader;
-import java.io.EOFException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.ObjectInputStream;
-import java.io.OptionalDataException;
-import java.net.MalformedURLException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.URI;
-import java.net.URL;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * Listens for events over a socket connection.
- */
-public class SocketServer extends AbstractServer implements Runnable {
-
- private static Logger logger;
-
- private static final int MAX_PORT = 65534;
-
- private boolean isActive = true;
-
- private ServerSocket server;
-
- private ConcurrentMap<Long, SocketHandler> handlers = new ConcurrentHashMap<Long, SocketHandler>();
-
- /**
- * Constructor.
- * @param port to listen on.
- * @throws IOException If an error occurs.
- */
- public SocketServer(int port) throws IOException {
- server = new ServerSocket(port);
- if (logger == null) {
- logger = LogManager.getLogger(getClass().getName());
- }
- }
- /**
- * Main startup for the server.
- * @param args The command line arguments.
- * @throws Exception if an error occurs.
- */
- public static void main(String[] args) throws Exception {
- if (args.length < 1 || args.length > 2) {
- System.err.println("Incorrect number of arguments");
- printUsage();
- return;
- }
- int port = Integer.parseInt(args[0]);
- if (port <= 0 || port >= MAX_PORT) {
- System.err.println("Invalid port number");
- printUsage();
- return;
- }
- if (args.length == 2 && args[1].length() > 0) {
- ConfigurationFactory.setConfigurationFactory(new ServerConfigurationFactory(args[1]));
- }
- logger = LogManager.getLogger(SocketServer.class.getName());
- SocketServer sserver = new SocketServer(port);
- Thread server = new Thread(sserver);
- server.start();
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- while (true) {
- String line = reader.readLine();
- if (line.equalsIgnoreCase("Quit") || line.equalsIgnoreCase("Stop") || line.equalsIgnoreCase("Exit")) {
- sserver.shutdown();
- server.join();
- break;
- }
- }
- }
-
- private static void printUsage() {
- System.out.println("Usage: ServerSocket port configFilePath");
- }
-
- /**
- * Shutdown the server.
- */
- public void shutdown() {
- this.isActive = false;
- Thread.currentThread().interrupt();
- }
-
- /**
- * Accept incoming events and processes them.
- */
- public void run() {
- while (isActive) {
- try {
- // Accept incoming connections.
- Socket clientSocket = server.accept();
-
- // accept() will block until a client connects to the server.
- // If execution reaches this point, then it means that a client
- // socket has been accepted.
-
- SocketHandler handler = new SocketHandler(clientSocket);
- handlers.put(handler.getId(), handler);
- handler.start();
- } catch (IOException ioe) {
- System.out.println("Exception encountered on accept. Ignoring. Stack Trace :");
- ioe.printStackTrace();
- }
- }
- for (Map.Entry<Long, SocketHandler> entry : handlers.entrySet()) {
- SocketHandler handler = entry.getValue();
- handler.shutdown();
- try {
- handler.join();
- } catch (InterruptedException ie) {
- // Ignore the exception
- }
- }
- }
-
- /**
- * Thread that processes the events.
- */
- private class SocketHandler extends Thread {
- private final ObjectInputStream ois;
-
- private boolean shutdown = false;
-
- public SocketHandler(Socket socket) throws IOException {
-
- ois = new ObjectInputStream(socket.getInputStream());
- }
-
- public void shutdown() {
- this.shutdown = true;
- interrupt();
- }
-
- public void run() {
- boolean closed = false;
- try {
- try {
- while (!shutdown) {
- LogEvent event = (LogEvent) ois.readObject();
- if (event != null) {
- log(event);
- }
- }
- } catch (EOFException eof) {
- closed = true;
- } catch (OptionalDataException opt) {
- logger.error("OptionalDataException eof=" + opt.eof + " length=" + opt.length, opt);
- } catch (ClassNotFoundException cnfe) {
- logger.error("Unable to locate LogEvent class", cnfe);
- } catch (IOException ioe) {
- logger.error("IOException encountered while reading from socket", ioe);
- }
- if (!closed) {
- try {
- ois.close();
- } catch (Exception ex) {
- // Ignore the exception;
- }
- }
- } finally {
- handlers.remove(getId());
- }
- }
- }
-
- /**
- * Factory that creates a Configuration for the server.
- */
- private static class ServerConfigurationFactory extends XMLConfigurationFactory {
-
- private final String path;
-
- public ServerConfigurationFactory(String path) {
- this.path = path;
- }
-
- @Override
- public Configuration getConfiguration(String name, URI configLocation) {
- if (path != null && path.length() > 0) {
- File file = null;
- InputSource source = null;
- try {
- file = new File(path);
- FileInputStream is = new FileInputStream(file);
- source = new InputSource(is);
- source.setSystemId(path);
- } catch (FileNotFoundException ex) {
- // Ignore this error
- }
- if (source == null) {
- try {
- URL url = new URL(path);
- source = new InputSource(url.openStream());
- source.setSystemId(path);
- } catch (MalformedURLException mue) {
- // Ignore this error
- } catch (IOException ioe) {
- // Ignore this error
- }
- }
-
- try {
- if (source != null) {
- return new XMLConfiguration(source, file);
- }
- } catch (Exception ex) {
- // Ignore this error.
- }
- System.err.println("Unable to process configuration at " + path + ", using default.");
- }
- return super.getConfiguration(name, configLocation);
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/TCPSocketManager.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/TCPSocketManager.java
deleted file mode 100644
index af975d7..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/TCPSocketManager.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.core.appender.AppenderRuntimeException;
-import org.apache.logging.log4j.core.appender.ManagerFactory;
-import org.apache.logging.log4j.core.appender.OutputStreamManager;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.ConnectException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-
-/**
- * Manager of TCP Socket connections.
- */
-public class TCPSocketManager extends AbstractSocketManager {
- /**
- The default reconnection delay (30000 milliseconds or 30 seconds).
- */
- public static final int DEFAULT_RECONNECTION_DELAY = 30000;
- /**
- The default port number of remote logging server (4560).
- */
- private static final int DEFAULT_PORT = 4560;
-
- private static ManagerFactory factory = new TCPSocketManagerFactory();
-
- private final int reconnectionDelay;
-
- private Reconnector connector = null;
-
- private Socket socket;
-
- private final boolean retry;
-
- /**
- * The Constructor.
- * @param name The unique name of this connection.
- * @param os The OutputStream.
- * @param sock The Socket.
- * @param addr The internet address of the host.
- * @param host The name of the host.
- * @param port The port number on the host.
- * @param delay Reconnection interval.
- */
- public TCPSocketManager(String name, OutputStream os, Socket sock, InetAddress addr, String host, int port,
- int delay) {
- super(name, os, addr, host, port);
- this.reconnectionDelay = delay;
- this.socket = sock;
- retry = delay > 0;
- }
-
- /**
- * Obtain a TCPSocketManager.
- * @param host The host to connect to.
- * @param port The port on the host.
- * @param delay The interval to pause between retries.
- * @return A TCPSocketManager.
- */
- public static TCPSocketManager getSocketManager(String host, int port, int delay) {
- if (host == null || host.length() == 0) {
- throw new IllegalArgumentException("A host name is required");
- }
- if (port <= 0) {
- port = DEFAULT_PORT;
- }
- if (delay == 0) {
- delay = DEFAULT_RECONNECTION_DELAY;
- }
- return (TCPSocketManager) getManager("TCP:" + host + ":" + port, factory, new FactoryData(host, port, delay));
- }
-
- @Override
- protected synchronized void write(byte[] bytes, int offset, int length) {
- try {
- getOutputStream().write(bytes, offset, length);
- socket.setSendBufferSize(length);
- } catch (IOException ex) {
- if (retry && connector == null) {
- connector = new Reconnector(this);
- connector.setDaemon(true);
- connector.setPriority(Thread.MIN_PRIORITY);
- connector.start();
- }
- String msg = "Error writing to " + getName();
- throw new AppenderRuntimeException(msg, ex);
- }
- }
-
- @Override
- protected synchronized void close() {
- super.close();
- if (connector != null) {
- connector.shutdown();
- connector.interrupt();
- connector = null;
- }
- }
-
- /**
- * Handles recoonecting to a Thread.
- */
- private class Reconnector extends Thread {
-
- private boolean shutdown = false;
-
- private final Object owner;
-
- public Reconnector(OutputStreamManager owner) {
- this.owner = owner;
- }
-
- public void shutdown() {
- shutdown = true;
- }
-
- public void run() {
- while (!shutdown) {
- try {
- sleep(reconnectionDelay);
- Socket sock = new Socket(address, port);
- OutputStream newOS = sock.getOutputStream();
- synchronized (owner) {
- try {
- getOutputStream().close();
- } catch (IOException ioe) {
- // Ignore this.
- }
-
- setOutputStream(newOS);
- socket = sock;
- connector = null;
- }
- LOGGER.debug("Connection to " + host + ":" + port + " reestablished.");
- } catch (InterruptedException ie) {
- LOGGER.debug("Reconnection interrupted.");
- } catch (ConnectException ex) {
- LOGGER.debug(host + ":" + port + " refused connection");
- } catch (IOException ioe) {
- LOGGER.debug("Unable to reconnect to " + host + ":" + port);
- }
- }
- }
- }
-
- /**
- * Data for the factory.
- */
- private static class FactoryData {
- private String host;
- private int port;
- private int delay;
-
- public FactoryData(String host, int port, int delay) {
- this.host = host;
- this.port = port;
- this.delay = delay;
- }
- }
-
- /**
- * Factory to create a TCPSocketManager.
- */
- private static class TCPSocketManagerFactory implements ManagerFactory<TCPSocketManager, FactoryData> {
-
- public TCPSocketManager createManager(String name, FactoryData data) {
- try {
- InetAddress address = InetAddress.getByName(data.host);
- Socket socket = new Socket(data.host, data.port);
- OutputStream os = socket.getOutputStream();
- return new TCPSocketManager(name, os, socket, address, data.host, data.port, data.delay);
- } catch (UnknownHostException ex) {
- LOGGER.error("Could not find address of " + data.host, ex);
- } catch (IOException ex) {
- LOGGER.error("TCPSocketManager (" + name + ") " + ex);
- }
- return null;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/package-info.java
deleted file mode 100644
index 9f101b5..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/net/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 network support.
- */
-package org.apache.logging.log4j.core.net;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/package-info.java
deleted file mode 100644
index efd3d11..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Implementation of Log4j 2.0.
- */
-package org.apache.logging.log4j.core;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/AbstractPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/AbstractPatternConverter.java
deleted file mode 100644
index 7b7551f..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/AbstractPatternConverter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-
-/**
- * <p>AbstractPatternConverter is an abstract class that provides the
- * formatting functionality that derived classes need.
- * <p/>
- * <p>Conversion specifiers in a conversion patterns are parsed to
- * individual PatternConverters. Each of which is responsible for
- * converting an object in a converter specific manner.
- */
-public abstract class AbstractPatternConverter implements PatternConverter {
- /**
- * Converter name.
- */
- private final String name;
-
- /**
- * Converter style name.
- */
- private final String style;
-
- /**
- * Create a new pattern converter.
- *
- * @param name name for pattern converter.
- * @param style CSS style for formatted output.
- */
- protected AbstractPatternConverter(final String name, final String style) {
- this.name = name;
- this.style = style;
- }
-
- /**
- * This method returns the name of the conversion pattern.
- * <p/>
- * The name can be useful to certain Layouts such as HTMLLayout.
- *
- * @return the name of the conversion pattern
- */
- public final String getName() {
- return name;
- }
-
- /**
- * This method returns the CSS style class that should be applied to
- * the LoggingEvent passed as parameter, which can be null.
- * <p/>
- * This information is currently used only by HTMLLayout.
- *
- * @param e null values are accepted
- * @return the name of the conversion pattern
- */
- public String getStyleClass(Object e) {
- return style;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ArrayPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ArrayPatternConverter.java
deleted file mode 100644
index 3867a89..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ArrayPatternConverter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-/**
- * Interface implemented by PatternConverters that accept an array of objects when formatting.
- */
-public interface ArrayPatternConverter extends PatternConverter {
-
- /**
- * Format an array of Objects.
- * @param objects The Object array.
- * @param toAppendTo The StringBuilder to add the content to.
- */
- void format(Object[] objects, final StringBuilder toAppendTo);
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/CachedDateFormat.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/CachedDateFormat.java
deleted file mode 100644
index 878405d..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/CachedDateFormat.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import java.text.DateFormat;
-import java.text.FieldPosition;
-import java.text.NumberFormat;
-import java.text.ParsePosition;
-import java.util.Date;
-import java.util.TimeZone;
-
-
-/**
- * CachedDateFormat optimizes the performance of a wrapped
- * DateFormat. The implementation is not thread-safe.
- * If the millisecond pattern is not recognized,
- * the class will only use the cache if the
- * same value is requested.
- */
-final class CachedDateFormat extends DateFormat {
- /**
- * Constant used to represent that there was no change
- * observed when changing the millisecond count.
- */
- public static final int NO_MILLISECONDS = -2;
-
- /**
- * Constant used to represent that there was an
- * observed change, but was an expected change.
- */
- public static final int UNRECOGNIZED_MILLISECONDS = -1;
-
- /**
- * Supported digit set. If the wrapped DateFormat uses
- * a different unit set, the millisecond pattern
- * will not be recognized and duplicate requests
- * will use the cache.
- */
- private static final String DIGITS = "0123456789";
-
- /**
- * First magic number used to detect the millisecond position.
- */
- private static final int MAGIC1 = 654;
-
- /**
- * Expected representation of first magic number.
- */
- private static final String MAGICSTRING1 = "654";
-
- /**
- * Second magic number used to detect the millisecond position.
- */
- private static final int MAGIC2 = 987;
-
- /**
- * Expected representation of second magic number.
- */
- private static final String MAGICSTRING2 = "987";
-
- /**
- * Expected representation of 0 milliseconds.
- */
- private static final String ZERO_STRING = "000";
-
- private static final int BUF_SIZE = 50;
-
- private static final int MILLIS_IN_SECONDS = 1000;
-
- private static final int DEFAULT_VALIDITY = 1000;
-
- private static final int THREE_DIGITS = 100;
-
- private static final int TWO_DIGITS = 10;
-
- private static final long SLOTS = 1000L;
-
- /**
- * Wrapped formatter.
- */
- private final DateFormat formatter;
-
- /**
- * Index of initial digit of millisecond pattern or
- * UNRECOGNIZED_MILLISECONDS or NO_MILLISECONDS.
- */
- private int millisecondStart;
-
- /**
- * Integral second preceding the previous convered Date.
- */
- private long slotBegin;
-
- /**
- * Cache of previous conversion.
- */
- private StringBuffer cache = new StringBuffer(BUF_SIZE);
-
- /**
- * Maximum validity period for the cache.
- * Typically 1, use cache for duplicate requests only, or
- * 1000, use cache for requests within the same integral second.
- */
- private final int expiration;
-
- /**
- * Date requested in previous conversion.
- */
- private long previousTime;
-
- /**
- * Scratch date object used to minimize date object creation.
- */
- private final Date tmpDate = new Date(0);
-
- /**
- * Creates a new CachedDateFormat object.
- *
- * @param dateFormat Date format, may not be null.
- * @param expiration maximum cached range in milliseconds.
- * If the dateFormat is known to be incompatible with the
- * caching algorithm, use a value of 0 to totally disable
- * caching or 1 to only use cache for duplicate requests.
- */
- public CachedDateFormat(final DateFormat dateFormat, final int expiration) {
- if (dateFormat == null) {
- throw new IllegalArgumentException("dateFormat cannot be null");
- }
-
- if (expiration < 0) {
- throw new IllegalArgumentException("expiration must be non-negative");
- }
-
- formatter = dateFormat;
- this.expiration = expiration;
- millisecondStart = 0;
-
- //
- // set the previousTime so the cache will be invalid
- // for the next request.
- previousTime = Long.MIN_VALUE;
- slotBegin = Long.MIN_VALUE;
- }
-
- /**
- * Finds start of millisecond field in formatted time.
- *
- * @param time long time, must be integral number of seconds
- * @param formatted String corresponding formatted string
- * @param formatter DateFormat date format
- * @return int position in string of first digit of milliseconds,
- * -1 indicates no millisecond field, -2 indicates unrecognized
- * field (likely RelativeTimeDateFormat)
- */
- public static int findMillisecondStart(final long time, final String formatted, final DateFormat formatter) {
- long slotBegin = (time / MILLIS_IN_SECONDS) * MILLIS_IN_SECONDS;
-
- if (slotBegin > time) {
- slotBegin -= MILLIS_IN_SECONDS;
- }
-
- int millis = (int) (time - slotBegin);
-
- int magic = MAGIC1;
- String magicString = MAGICSTRING1;
-
- if (millis == MAGIC1) {
- magic = MAGIC2;
- magicString = MAGICSTRING2;
- }
-
- String plusMagic = formatter.format(new Date(slotBegin + magic));
-
- /**
- * If the string lengths differ then
- * we can't use the cache except for duplicate requests.
- */
- if (plusMagic.length() != formatted.length()) {
- return UNRECOGNIZED_MILLISECONDS;
- } else {
- // find first difference between values
- for (int i = 0; i < formatted.length(); i++) {
- if (formatted.charAt(i) != plusMagic.charAt(i)) {
- //
- // determine the expected digits for the base time
- StringBuffer formattedMillis = new StringBuffer("ABC");
- millisecondFormat(millis, formattedMillis, 0);
-
- String plusZero = formatter.format(new Date(slotBegin));
-
- // If the next 3 characters match the magic
- // string and the expected string
- if (
- (plusZero.length() == formatted.length())
- && magicString.regionMatches(
- 0, plusMagic, i, magicString.length())
- && formattedMillis.toString().regionMatches(
- 0, formatted, i, magicString.length())
- && ZERO_STRING.regionMatches(
- 0, plusZero, i, ZERO_STRING.length())) {
- return i;
- } else {
- return UNRECOGNIZED_MILLISECONDS;
- }
- }
- }
- }
-
- return NO_MILLISECONDS;
- }
-
- /**
- * Formats a Date into a date/time string.
- *
- * @param date the date to format.
- * @param sbuf the string buffer to write to.
- * @param fieldPosition remains untouched.
- * @return the formatted time string.
- */
- public StringBuffer format(Date date, StringBuffer sbuf, FieldPosition fieldPosition) {
- format(date.getTime(), sbuf);
-
- return sbuf;
- }
-
- /**
- * Formats a millisecond count into a date/time string.
- *
- * @param now Number of milliseconds after midnight 1 Jan 1970 GMT.
- * @param buf the string buffer to write to.
- * @return the formatted time string.
- */
- public StringBuffer format(long now, StringBuffer buf) {
- //
- // If the current requested time is identical to the previously
- // requested time, then append the cache contents.
- //
- if (now == previousTime) {
- buf.append(cache);
-
- return buf;
- }
-
- //
- // If millisecond pattern was not unrecognized
- // (that is if it was found or milliseconds did not appear)
- //
- if (millisecondStart != UNRECOGNIZED_MILLISECONDS &&
- // Check if the cache is still valid.
- // If the requested time is within the same integral second
- // as the last request and a shorter expiration was not requested.
- (now < (slotBegin + expiration)) && (now >= slotBegin) && (now < (slotBegin + SLOTS))) {
- //
- // if there was a millisecond field then update it
- //
- if (millisecondStart >= 0) {
- millisecondFormat((int) (now - slotBegin), cache, millisecondStart);
- }
-
- //
- // update the previously requested time
- // (the slot begin should be unchanged)
- previousTime = now;
- buf.append(cache);
-
- return buf;
- }
-
- //
- // could not use previous value.
- // Call underlying formatter to format date.
- cache.setLength(0);
- tmpDate.setTime(now);
- cache.append(formatter.format(tmpDate));
- buf.append(cache);
- previousTime = now;
- slotBegin = (previousTime / MILLIS_IN_SECONDS) * MILLIS_IN_SECONDS;
-
- if (slotBegin > previousTime) {
- slotBegin -= MILLIS_IN_SECONDS;
- }
-
- //
- // if the milliseconds field was previous found
- // then reevaluate in case it moved.
- //
- if (millisecondStart >= 0) {
- millisecondStart =
- findMillisecondStart(now, cache.toString(), formatter);
- }
-
- return buf;
- }
-
- /**
- * Formats a count of milliseconds (0-999) into a numeric representation.
- *
- * @param millis Millisecond coun between 0 and 999.
- * @param buf String buffer, may not be null.
- * @param offset Starting position in buffer, the length of the
- * buffer must be at least offset + 3.
- */
- private static void millisecondFormat(
- final int millis, final StringBuffer buf, final int offset) {
- buf.setCharAt(offset, DIGITS.charAt(millis / THREE_DIGITS));
- buf.setCharAt(offset + 1, DIGITS.charAt((millis / TWO_DIGITS) % TWO_DIGITS));
- buf.setCharAt(offset + 2, DIGITS.charAt(millis % TWO_DIGITS));
- }
-
- /**
- * Set timezone.
- * <p/>
- * Setting the timezone using getCalendar().setTimeZone()
- * will likely cause caching to misbehave.
- *
- * @param timeZone TimeZone new timezone
- */
- public void setTimeZone(final TimeZone timeZone) {
- formatter.setTimeZone(timeZone);
- previousTime = Long.MIN_VALUE;
- slotBegin = Long.MIN_VALUE;
- }
-
- /**
- * This method is delegated to the formatter which most
- * likely returns null.
- *
- * @param s string representation of date.
- * @param pos field position, unused.
- * @return parsed date, likely null.
- */
- public Date parse(String s, ParsePosition pos) {
- return formatter.parse(s, pos);
- }
-
- /**
- * Gets number formatter.
- *
- * @return NumberFormat number formatter
- */
- public NumberFormat getNumberFormat() {
- return formatter.getNumberFormat();
- }
-
- /**
- * Gets maximum cache validity for the specified SimpleDateTime
- * conversion pattern.
- *
- * @param pattern conversion pattern, may not be null.
- * @return Duration in milliseconds from an integral second
- * that the cache will return consistent results.
- */
- public static int getMaximumCacheValidity(final String pattern) {
- //
- // If there are more "S" in the pattern than just one "SSS" then
- // (for example, "HH:mm:ss,SSS SSS"), then set the expiration to
- // one millisecond which should only perform duplicate request caching.
- //
- int firstS = pattern.indexOf('S');
-
- if ((firstS >= 0) && (firstS != pattern.lastIndexOf("SSS"))) {
- return 1;
- }
-
- return DEFAULT_VALIDITY;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ClassNamePatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ClassNamePatternConverter.java
deleted file mode 100644
index f4b01e3..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ClassNamePatternConverter.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-
-/**
- * Formats the class name of the site of the logging request.
- */
-@Plugin(name = "ClassNamePatternConverter", type = "Converter")
-@ConverterKeys({"C", "class" })
-public final class ClassNamePatternConverter extends NamePatternConverter {
-
- private static final String NA = "?";
- /**
- * Private constructor.
- *
- * @param options options, may be null.
- */
- private ClassNamePatternConverter(
- final String[] options) {
- super("Class Name", "class name", options);
- }
-
- /**
- * Gets an instance of ClassNamePatternConverter.
- *
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static ClassNamePatternConverter newInstance(final String[] options) {
- return new ClassNamePatternConverter(options);
- }
-
- /**
- * Format a logging event.
- *
- * @param event event to format.
- * @param toAppendTo string buffer to which class name will be appended.
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
-
- StackTraceElement element = event.getSource();
-
- if (element == null) {
- toAppendTo.append(NA);
- } else {
- toAppendTo.append(abbreviate(element.getClassName()));
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ConverterKeys.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ConverterKeys.java
deleted file mode 100644
index cce1081..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ConverterKeys.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Identifies the keys that are associated with a PatternConverter.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface ConverterKeys {
- String[] value();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
deleted file mode 100644
index 07ea820..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/DatePatternConverter.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-
-/**
- * Convert and format the event's date in a StringBuffer.
- */
-@Plugin(name = "DatePatternConverter", type = "Converter")
-@ConverterKeys({"d", "date" })
-public final class DatePatternConverter extends LogEventPatternConverter implements ArrayPatternConverter {
- /**
- * ABSOLUTE string literal.
- */
- private static final String ABSOLUTE_FORMAT = "ABSOLUTE";
- /**
- * SimpleTimePattern for ABSOLUTE.
- */
- private static final String ABSOLUTE_TIME_PATTERN = "HH:mm:ss,SSS";
-
-
- /**
- * DATE string literal.
- */
- private static final String DATE_AND_TIME_FORMAT = "DATE";
- /**
- * SimpleTimePattern for DATE.
- */
- private static final String DATE_AND_TIME_PATTERN = "dd MMM yyyy HH:mm:ss,SSS";
-
- /**
- * ISO8601 string literal.
- */
- private static final String ISO8601_FORMAT = "ISO8601";
- /**
- * SimpleTimePattern for ISO8601.
- */
- private static final String ISO8601_PATTERN = "yyyy-MM-dd HH:mm:ss,SSS";
- /**
- * Date format.
- */
- private String cachedDate;
-
- private long lastTimestamp;
-
- private SimpleDateFormat simpleFormat;
-
- /**
- * Private constructor.
- *
- * @param options options, may be null.
- */
- private DatePatternConverter(final String[] options) {
- super("Date", "date");
-
- String patternOption;
-
- if ((options == null) || (options.length == 0)) {
- // the branch could be optimized, but here we are making explicit
- // that null values for patternOption are allowed.
- patternOption = null;
- } else {
- patternOption = options[0];
- }
-
- String pattern;
-
- if (patternOption == null || patternOption.equalsIgnoreCase(ISO8601_FORMAT)) {
- pattern = ISO8601_PATTERN;
- } else if (patternOption.equalsIgnoreCase(ABSOLUTE_FORMAT)) {
- pattern = ABSOLUTE_TIME_PATTERN;
- } else if (patternOption.equalsIgnoreCase(DATE_AND_TIME_FORMAT)) {
- pattern = DATE_AND_TIME_PATTERN;
- } else {
- pattern = patternOption;
- }
-
- try {
- simpleFormat = new SimpleDateFormat(pattern);
- } catch (IllegalArgumentException e) {
- LOGGER.warn("Could not instantiate SimpleDateFormat with pattern " + patternOption, e);
-
- // default to the ISO8601 format
- simpleFormat = new SimpleDateFormat(ISO8601_PATTERN);
- }
-
- // if the option list contains a TZ option, then set it.
- if ((options != null) && (options.length > 1)) {
- TimeZone tz = TimeZone.getTimeZone(options[1]);
- simpleFormat.setTimeZone(tz);
- }
- }
-
- /**
- * Obtains an instance of pattern converter.
- *
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static DatePatternConverter newInstance(final String[] options) {
- return new DatePatternConverter(options);
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder output) {
- long timestamp = event.getMillis();
-
- synchronized (this) {
- if (timestamp != lastTimestamp) {
- lastTimestamp = timestamp;
- cachedDate = simpleFormat.format(timestamp);
- }
- }
- output.append(cachedDate);
- }
-
- public void format(Object[] objects, final StringBuilder toAppendTo) {
- for (Object obj : objects) {
- if (obj instanceof Date) {
- format(obj, toAppendTo);
- break;
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final Object obj, final StringBuilder output) {
- if (obj instanceof Date) {
- format((Date) obj, output);
- }
-
- super.format(obj, output);
- }
-
- /**
- * Append formatted date to string buffer.
- *
- * @param date date
- * @param toAppendTo buffer to which formatted date is appended.
- */
- public void format(final Date date, final StringBuilder toAppendTo) {
- synchronized (this) {
- toAppendTo.append(simpleFormat.format(date.getTime()));
- }
- }
-
- public String getPattern() {
- return simpleFormat.toPattern();
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java
deleted file mode 100644
index c0a1809..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.impl.ThrowableProxy;
-
-/**
- * Outputs the Throwable portion of the LoggingEvent as a full stacktrace
- * unless this converter's option is 'short', where it just outputs the first line of the trace, or if
- * the number of lines to print is explicitly specified.
- * <p>
- * The extended stack trace will also include the location of where the class was loaded from and the
- * version of the jar if available.
- */
-@Plugin(name = "ExtendedThrowablePatternConverter", type = "Converter")
-@ConverterKeys({"xEx", "xThrowable", "xException" })
-public final class ExtendedThrowablePatternConverter extends ThrowablePatternConverter {
- /**
- * Private constructor.
- *
- * @param options options, may be null.
- */
- private ExtendedThrowablePatternConverter(final String[] options) {
- super("ExtendedThrowable", "throwable", options);
- }
-
- /**
- * Gets an instance of the class.
- *
- * @param options pattern options, may be null. If first element is "short",
- * only the first line of the throwable will be formatted.
- * @return instance of class.
- */
- public static ExtendedThrowablePatternConverter newInstance(
- final String[] options) {
- return new ExtendedThrowablePatternConverter(options);
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- Throwable throwable = event.getThrown();
- if (throwable != null) {
- if (!(throwable instanceof ThrowableProxy)) {
- super.format(event, toAppendTo);
- return;
- }
- ThrowableProxy t = (ThrowableProxy) throwable;
- String trace = t.getExtendedStackTrace();
- int len = toAppendTo.length();
- if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
- toAppendTo.append(" ");
- }
- if (lines > 0) {
- StringBuilder sb = new StringBuilder();
- String[] array = trace.split("\n");
- for (int i = 0; i < lines; ++i) {
- sb.append(array[i]).append("\n");
- }
- toAppendTo.append(sb.toString());
-
- } else {
- toAppendTo.append(trace);
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FileDatePatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FileDatePatternConverter.java
deleted file mode 100644
index 2d48160..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FileDatePatternConverter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-/**
- * Formats an date by delegating to DatePatternConverter. The default
- * date pattern for a %d specifier in a file name is different than
- * the %d pattern in pattern layout.
- */
-@Plugin(name = "FileDatePatternConverter", type = "FileConverter")
-@ConverterKeys({"d", "date" })
-public final class FileDatePatternConverter {
- /**
- * Private constructor.
- */
- private FileDatePatternConverter() {
- }
-
- /**
- * Obtains an instance of pattern converter.
- *
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static PatternConverter newInstance(final String[] options) {
- if ((options == null) || (options.length == 0)) {
- return DatePatternConverter.newInstance(
- new String[]{
- "yyyy-MM-dd"
- });
- }
-
- return DatePatternConverter.newInstance(options);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FileLocationPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FileLocationPatternConverter.java
deleted file mode 100644
index ea1811a..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FileLocationPatternConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-
-/**
- * Return the event's line location information in a StringBuffer.
- */
-@Plugin(name = "FileLocationPatternConverter", type = "Converter")
-@ConverterKeys({"F", "file" })
-public final class FileLocationPatternConverter extends LogEventPatternConverter {
- /**
- * Singleton.
- */
- private static final FileLocationPatternConverter INSTANCE =
- new FileLocationPatternConverter();
-
- /**
- * Private constructor.
- */
- private FileLocationPatternConverter() {
- super("File Location", "file");
- }
-
- /**
- * Obtains an instance of pattern converter.
- *
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static FileLocationPatternConverter newInstance(final String[] options) {
- return INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder output) {
- StackTraceElement element = event.getSource();
-
- if (element != null) {
- output.append(element.getFileName());
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FormattingInfo.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FormattingInfo.java
deleted file mode 100644
index 0e2d4cb..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FormattingInfo.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-
-/**
- * Modifies the output of a pattern converter for a specified minimum
- * and maximum width and alignment.
- */
-public final class FormattingInfo {
- /**
- * Array of spaces.
- */
- private static final char[] SPACES =
- new char[]{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '};
-
- /**
- * Default instance.
- */
- private static final FormattingInfo DEFAULT =
- new FormattingInfo(false, 0, Integer.MAX_VALUE);
-
- /**
- * Minimum length.
- */
- private final int minLength;
-
- /**
- * Maximum length.
- */
- private final int maxLength;
-
- /**
- * Alignment.
- */
- private final boolean leftAlign;
-
- /**
- * Creates new instance.
- *
- * @param leftAlign left align if true.
- * @param minLength minimum length.
- * @param maxLength maximum length.
- */
- public FormattingInfo(final boolean leftAlign, final int minLength, final int maxLength) {
- this.leftAlign = leftAlign;
- this.minLength = minLength;
- this.maxLength = maxLength;
- }
-
- /**
- * Gets default instance.
- *
- * @return default instance.
- */
- public static FormattingInfo getDefault() {
- return DEFAULT;
- }
-
- /**
- * Determine if left aligned.
- *
- * @return true if left aligned.
- */
- public boolean isLeftAligned() {
- return leftAlign;
- }
-
- /**
- * Get minimum length.
- *
- * @return minimum length.
- */
- public int getMinLength() {
- return minLength;
- }
-
- /**
- * Get maximum length.
- *
- * @return maximum length.
- */
- public int getMaxLength() {
- return maxLength;
- }
-
- /**
- * Adjust the content of the buffer based on the specified lengths and alignment.
- *
- * @param fieldStart start of field in buffer.
- * @param buffer buffer to be modified.
- */
- public void format(final int fieldStart, final StringBuilder buffer) {
- final int rawLength = buffer.length() - fieldStart;
-
- if (rawLength > maxLength) {
- buffer.delete(fieldStart, buffer.length() - maxLength);
- } else if (rawLength < minLength) {
- if (leftAlign) {
- final int fieldEnd = buffer.length();
- buffer.setLength(fieldStart + minLength);
-
- for (int i = fieldEnd; i < buffer.length(); i++) {
- buffer.setCharAt(i, ' ');
- }
- } else {
- int padLength = minLength - rawLength;
-
- for (; padLength > SPACES.length; padLength -= SPACES.length) {
- buffer.insert(fieldStart, SPACES);
- }
-
- buffer.insert(fieldStart, SPACES, 0, padLength);
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FullLocationPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FullLocationPatternConverter.java
deleted file mode 100644
index a2649dd..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/FullLocationPatternConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-
-/**
- * Format the event's line location information.
- */
-@Plugin(name = "FullLocationPatternConverter", type = "Converter")
-@ConverterKeys({"l", "location" })
-public final class FullLocationPatternConverter extends LogEventPatternConverter {
- /**
- * Singleton.
- */
- private static final FullLocationPatternConverter INSTANCE =
- new FullLocationPatternConverter();
-
- /**
- * Private constructor.
- */
- private FullLocationPatternConverter() {
- super("Full Location", "fullLocation");
- }
-
- /**
- * Obtains an instance of pattern converter.
- *
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static FullLocationPatternConverter newInstance(final String[] options) {
- return INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder output) {
- StackTraceElement element = event.getSource();
-
- if (element != null) {
- output.append(element.toString());
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/IntegerPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/IntegerPatternConverter.java
deleted file mode 100644
index 73f1748..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/IntegerPatternConverter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-import java.util.Date;
-
-
-/**
- * Formats an integer.
- */
-@Plugin(name = "IntegerPatternConverter", type = "FileConverter")
-@ConverterKeys({"i", "index" })
-public final class IntegerPatternConverter extends AbstractPatternConverter implements ArrayPatternConverter {
- /**
- * Singleton.
- */
- private static final IntegerPatternConverter INSTANCE =
- new IntegerPatternConverter();
-
- /**
- * Private constructor.
- */
- private IntegerPatternConverter() {
- super("Integer", "integer");
- }
-
- /**
- * Obtains an instance of pattern converter.
- *
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static IntegerPatternConverter newInstance(
- final String[] options) {
- return INSTANCE;
- }
-
- public void format(Object[] objects, final StringBuilder toAppendTo) {
- for (Object obj : objects) {
- if (obj instanceof Integer) {
- format(obj, toAppendTo);
- break;
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(Object obj, final StringBuilder toAppendTo) {
- if (obj instanceof Integer) {
- toAppendTo.append(obj.toString());
- }
-
- if (obj instanceof Date) {
- toAppendTo.append(Long.toString(((Date) obj).getTime()));
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LevelPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LevelPatternConverter.java
deleted file mode 100644
index 2a14933..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LevelPatternConverter.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-
-/**
- * Return the event's level in a StringBuffer.
- */
-@Plugin(name = "LevelPatternConverter", type = "Converter")
-@ConverterKeys({"p", "level" })
-public final class LevelPatternConverter extends LogEventPatternConverter {
- /**
- * Singleton.
- */
- private static final LevelPatternConverter INSTANCE =
- new LevelPatternConverter();
-
- /**
- * Private constructor.
- */
- private LevelPatternConverter() {
- super("Level", "level");
- }
-
- /**
- * Obtains an instance of pattern converter.
- *
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static LevelPatternConverter newInstance(
- final String[] options) {
- return INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder output) {
- output.append(event.getLevel().toString());
- }
-
- /**
- * {@inheritDoc}
- */
- public String getStyleClass(Object e) {
- if (e instanceof LogEvent) {
- Level level = ((LogEvent) e).getLevel();
-
- switch (level) {
- case TRACE:
- return "level trace";
-
- case DEBUG:
- return "level debug";
-
- case INFO:
- return "level info";
-
- case WARN:
- return "level warn";
-
- case ERROR:
- return "level error";
-
- case FATAL:
- return "level fatal";
-
- default:
- return "level " + ((LogEvent) e).getLevel().toString();
- }
- }
-
- return "level";
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LineLocationPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LineLocationPatternConverter.java
deleted file mode 100644
index 19d4fd6..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LineLocationPatternConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-/**
- * Return the event's line location information in a StringBuffer.
- */
-@Plugin(name = "LineLocationPatternConverter", type = "Converter")
-@ConverterKeys({"L", "line" })
-public final class LineLocationPatternConverter extends LogEventPatternConverter {
- /**
- * Singleton.
- */
- private static final LineLocationPatternConverter INSTANCE =
- new LineLocationPatternConverter();
-
- /**
- * Private constructor.
- */
- private LineLocationPatternConverter() {
- super("Line", "line");
- }
-
- /**
- * Obtains an instance of pattern converter.
- *
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static LineLocationPatternConverter newInstance(
- final String[] options) {
- return INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder output) {
- StackTraceElement element = event.getSource();
-
- if (element != null) {
- output.append(element.getLineNumber());
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LineSeparatorPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LineSeparatorPatternConverter.java
deleted file mode 100644
index 925babe..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LineSeparatorPatternConverter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-/**
- * Formats a line separator.
- */
-@Plugin(name = "LineSeparatorPatternConverter", type = "Converter")
-@ConverterKeys({"n" })
-public final class LineSeparatorPatternConverter extends LogEventPatternConverter {
-
- private static final String LINE_SEP = System.getProperty("line.separator");
- /**
- * Singleton.
- */
- private static final LineSeparatorPatternConverter INSTANCE =
- new LineSeparatorPatternConverter();
-
- /**
- * Line separator.
- */
- private final String lineSep;
-
- /**
- * Private constructor.
- */
- private LineSeparatorPatternConverter() {
- super("Line Sep", "lineSep");
- lineSep = LINE_SEP;
- }
-
- /**
- * Obtains an instance of pattern converter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static LineSeparatorPatternConverter newInstance(final String[] options) {
- return INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(LogEvent event, final StringBuilder toAppendTo) {
- toAppendTo.append(lineSep);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LiteralPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LiteralPatternConverter.java
deleted file mode 100644
index 57695d6..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LiteralPatternConverter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-
-
-/**
- * Formats a string literal.
- */
-public final class LiteralPatternConverter extends LogEventPatternConverter implements ArrayPatternConverter {
- /**
- * String literal.
- */
- private final String literal;
-
- /**
- * Create a new instance.
- *
- * @param literal string literal.
- */
- public LiteralPatternConverter(final String literal) {
- super("Literal", "literal");
- this.literal = literal;
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- toAppendTo.append(literal);
- }
- /**
- * {@inheritDoc}
- */
- public void format(final Object obj, final StringBuilder output) {
- output.append(literal);
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(Object[] objects, final StringBuilder output) {
- output.append(literal);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LogEventPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LogEventPatternConverter.java
deleted file mode 100644
index 8e2708b..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LogEventPatternConverter.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * LoggingEventPatternConverter is a base class for pattern converters
- * that can format information from instances of LoggingEvent.
- */
-public abstract class LogEventPatternConverter extends AbstractPatternConverter {
- /**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
- /**
- * Constructs an instance of LoggingEventPatternConverter.
- *
- * @param name name of converter.
- * @param style CSS style for output.
- */
- protected LogEventPatternConverter(final String name, final String style) {
- super(name, style);
- }
-
- /**
- * Formats an event into a string buffer.
- *
- * @param event event to format, may not be null.
- * @param toAppendTo string buffer to which the formatted event will be appended. May not be null.
- */
- public abstract void format(final LogEvent event, final StringBuilder toAppendTo);
-
- /**
- * {@inheritDoc}
- */
- public void format(final Object obj, final StringBuilder output) {
- if (obj instanceof LogEvent) {
- format((LogEvent) obj, output);
- }
- }
-
- /**
- * Normally pattern converters are not meant to handle Exceptions although
- * few pattern converters might.
- * <p/>
- * By examining the return values for this method, the containing layout will
- * determine whether it handles throwables or not.
- *
- * @return true if this PatternConverter handles throwables
- */
- public boolean handlesThrowable() {
- return false;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LoggerPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LoggerPatternConverter.java
deleted file mode 100644
index 791ac3e..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LoggerPatternConverter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-
-/**
- * Formats a logger name.
- */
-@Plugin(name = "LoggerPatternConverter", type = "Converter")
-@ConverterKeys({"c", "logger" })
-public final class LoggerPatternConverter extends NamePatternConverter {
- /**
- * Singleton.
- */
- private static final LoggerPatternConverter INSTANCE =
- new LoggerPatternConverter(null);
-
- /**
- * Private constructor.
- *
- * @param options options, may be null.
- */
- private LoggerPatternConverter(final String[] options) {
- super("Logger", "logger", options);
- }
-
- /**
- * Obtains an instance of pattern converter.
- *
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static LoggerPatternConverter newInstance(
- final String[] options) {
- if ((options == null) || (options.length == 0)) {
- return INSTANCE;
- }
-
- return new LoggerPatternConverter(options);
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- toAppendTo.append(abbreviate(event.getLoggerName()));
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MDCPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MDCPatternConverter.java
deleted file mode 100644
index 44fa57b..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MDCPatternConverter.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Able to handle the contents of the LogEvent's MDC and either
- * output the entire contents of the properties in a similar format to the
- * java.util.Hashtable.toString(), or to output the value of a specific key
- * within the property bundle
- * when this pattern converter has the option set.
- */
- @Plugin(name = "MDCPatternConverter", type = "Converter")
-@ConverterKeys({"X", "mdc", "MDC" })
-public final class MDCPatternConverter extends LogEventPatternConverter {
- /**
- * Name of property to output.
- */
- private final String key;
-
- /**
- * Private constructor.
- *
- * @param options options, may be null.
- */
- private MDCPatternConverter(final String[] options) {
- super(((options != null) && (options.length > 0)) ? ("MDC{" + options[0] + "}") : "MDC", "mdc");
- key = (options != null && options.length > 0) ? options[0] : null;
- }
-
- /**
- * Obtains an instance of PropertiesPatternConverter.
- *
- * @param options options, may be null or first element contains name of property to format.
- * @return instance of PropertiesPatternConverter.
- */
- public static MDCPatternConverter newInstance(final String[] options) {
- return new MDCPatternConverter(options);
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- Map<String, String> contextMap = event.getContextMap();
- // if there is no additional options, we output every single
- // Key/Value pair for the MDC in a similar format to Hashtable.toString()
- if (key == null) {
-
-
- if (contextMap == null || contextMap.size() == 0) {
- toAppendTo.append("{}");
- return;
- }
- StringBuilder sb = new StringBuilder("{");
- Set<String> keys = new TreeSet<String>(contextMap.keySet());
- for (String key : keys) {
- if (sb.length() > 1) {
- sb.append(", ");
- }
- sb.append(key).append("=").append(contextMap.get(key));
-
- }
- sb.append("}");
- toAppendTo.append(sb);
- } else if (contextMap != null) {
- // otherwise they just want a single key output
- Object val = contextMap.get(key);
-
- if (val != null) {
- toAppendTo.append(val);
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MapPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MapPatternConverter.java
deleted file mode 100644
index a850951..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MapPatternConverter.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.message.MapMessage;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Able to handle the contents of the LogEvent's MapMessage and either
- * output the entire contents of the properties in a similar format to the
- * java.util.Hashtable.toString(), or to output the value of a specific key
- * within the Map.
- */
-@Plugin(name = "MapPatternConverter", type = "Converter")
-@ConverterKeys({"K", "map", "MAP" })
-public final class MapPatternConverter extends LogEventPatternConverter {
- /**
- * Name of property to output.
- */
- private final String key;
-
- /**
- * Private constructor.
- *
- * @param options options, may be null.
- */
- private MapPatternConverter(final String[] options) {
- super(((options != null) && (options.length > 0)) ? ("MAP{" + options[0] + "}") : "MAP", "map");
- key = (options != null && options.length > 0) ? options[0] : null;
- }
-
- /**
- * Obtains an instance of PropertiesPatternConverter.
- *
- * @param options options, may be null or first element contains name of property to format.
- * @return instance of PropertiesPatternConverter.
- */
- public static MapPatternConverter newInstance(final String[] options) {
- return new MapPatternConverter(options);
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- MapMessage msg;
- if (event.getMessage() instanceof MapMessage) {
- msg = (MapMessage) event.getMessage();
- } else {
- return;
- }
- Map<String, String> map = msg.getData();
- // if there is no additional options, we output every single
- // Key/Value pair for the Map in a similar format to Hashtable.toString()
- if (key == null) {
- if (map.size() == 0) {
- toAppendTo.append("{}");
- return;
- }
- StringBuilder sb = new StringBuilder("{");
- Set<String> keys = new TreeSet<String>(map.keySet());
- for (String key : keys) {
- if (sb.length() > 1) {
- sb.append(", ");
- }
- sb.append(key).append("=").append(map.get(key));
-
- }
- sb.append("}");
- toAppendTo.append(sb);
- } else {
- // otherwise they just want a single key output
- String val = map.get(key);
-
- if (val != null) {
- toAppendTo.append(val);
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MarkerPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MarkerPatternConverter.java
deleted file mode 100644
index c3a094c..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MarkerPatternConverter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-/**
- * Return the event's rendered message in a StringBuffer.
- */
-@Plugin(name = "MarkerPatternConverter", type = "Converter")
-@ConverterKeys({"marker" })
-public final class MarkerPatternConverter extends LogEventPatternConverter {
-
- /**
- * Private constructor.
- * @param options options, may be null.
- */
- private MarkerPatternConverter(final String[] options) {
- super("Marker", "marker");
- }
-
- /**
- * Obtains an instance of pattern converter.
- *
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static MarkerPatternConverter newInstance(final String[] options) {
- return new MarkerPatternConverter(options);
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- Marker marker = event.getMarker();
- if (marker != null) {
- toAppendTo.append(marker.toString());
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
deleted file mode 100644
index 8bae310..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.message.FormattedMessage;
-import org.apache.logging.log4j.message.Message;
-
-/**
- * Return the event's rendered message in a StringBuffer.
- */
-@Plugin(name = "MessagePatternConverter", type = "Converter")
-@ConverterKeys({"m", "msg", "message" })
-public final class MessagePatternConverter extends LogEventPatternConverter {
-
- private final String format;
-
- /**
- * Private constructor.
- * @param options options, may be null.
- */
- private MessagePatternConverter(final String[] options) {
- super("Message", "message");
- format = (options != null && options.length > 0) ? options[0] : null;
- }
-
- /**
- * Obtains an instance of pattern converter.
- *
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- public static MessagePatternConverter newInstance(final String[] options) {
- return new MessagePatternConverter(options);
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- Message msg = event.getMessage();
- if (msg != null && msg instanceof FormattedMessage) {
- ((FormattedMessage) msg).setFormat(format);
- }
- toAppendTo.append(msg.getFormattedMessage());
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MethodLocationPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MethodLocationPatternConverter.java
deleted file mode 100644
index 7583e73..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/MethodLocationPatternConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-
-/**
- * Return the event's line location information in a StringBuffer.
- */
-@Plugin(name = "MethodLocationPatternConverter", type = "Converter")
-@ConverterKeys({"M", "method" })
-public final class MethodLocationPatternConverter extends LogEventPatternConverter {
- /**
- * Singleton.
- */
- private static final MethodLocationPatternConverter INSTANCE =
- new MethodLocationPatternConverter();
-
- /**
- * Private constructor.
- */
- private MethodLocationPatternConverter() {
- super("Method", "method");
- }
-
- /**
- * Obtains an instance of MethodLocationPatternConverter.
- *
- * @param options options, may be null.
- * @return instance of MethodLocationPatternConverter.
- */
- public static MethodLocationPatternConverter newInstance(final String[] options) {
- return INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- StackTraceElement element = event.getSource();
-
- if (element != null) {
- toAppendTo.append(element.getMethodName());
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/NDCPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/NDCPatternConverter.java
deleted file mode 100644
index 4fdbf26..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/NDCPatternConverter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-
-/**
- * Return the event's NDC in a StringBuffer.
- */
-@Plugin(name = "NDCPatternConverter", type = "Converter")
-@ConverterKeys({"x", "NDC" })
-public final class NDCPatternConverter extends LogEventPatternConverter {
- /**
- * Singleton.
- */
- private static final NDCPatternConverter INSTANCE =
- new NDCPatternConverter();
-
- /**
- * Private constructor.
- */
- private NDCPatternConverter() {
- super("NDC", "ndc");
- }
-
- /**
- * Obtains an instance of NDCPatternConverter.
- * @param options options, may be null.
- * @return instance of NDCPatternConverter.
- */
- public static NDCPatternConverter newInstance(final String[] options) {
- return INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- toAppendTo.append(event.getContextStack());
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java
deleted file mode 100644
index e4809c2..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * NameAbbreviator generates abbreviated logger and class names.
- */
-public abstract class NameAbbreviator {
- /**
- * Default (no abbreviation) abbreviator.
- */
- private static final NameAbbreviator DEFAULT = new NOPAbbreviator();
-
- /**
- * Gets an abbreviator.
- * <p/>
- * For example, "%logger{2}" will output only 2 elements of the logger name,
- * "%logger{1.}" will output only the first character of the non-final elements in the name,
- * "%logger(1~.2~} will output the first character of the first element, two characters of
- * the second and subsequent elements and will use a tilde to indicate abbreviated characters.
- *
- * @param pattern abbreviation pattern.
- * @return abbreviator, will not be null.
- */
- public static NameAbbreviator getAbbreviator(final String pattern) {
- if (pattern.length() > 0) {
- // if pattern is just spaces and numbers then
- // use MaxElementAbbreviator
- String trimmed = pattern.trim();
-
- if (trimmed.length() == 0) {
- return DEFAULT;
- }
-
- int i = 0;
-
- while ((i < trimmed.length()) && (trimmed.charAt(i) >= '0')
- && (trimmed.charAt(i) <= '9')) {
- i++;
- }
-
- //
- // if all blanks and digits
- //
- if (i == trimmed.length()) {
- return new MaxElementAbbreviator(Integer.parseInt(trimmed));
- }
-
- ArrayList<PatternAbbreviatorFragment> fragments = new ArrayList<PatternAbbreviatorFragment>(5);
- char ellipsis;
- int charCount;
- int pos = 0;
-
- while ((pos < trimmed.length()) && (pos >= 0)) {
- int ellipsisPos = pos;
-
- if (trimmed.charAt(pos) == '*') {
- charCount = Integer.MAX_VALUE;
- ellipsisPos++;
- } else {
- if ((trimmed.charAt(pos) >= '0') && (trimmed.charAt(pos) <= '9')) {
- charCount = trimmed.charAt(pos) - '0';
- ellipsisPos++;
- } else {
- charCount = 0;
- }
- }
-
- ellipsis = '\0';
-
- if (ellipsisPos < trimmed.length()) {
- ellipsis = trimmed.charAt(ellipsisPos);
-
- if (ellipsis == '.') {
- ellipsis = '\0';
- }
- }
-
- fragments.add(new PatternAbbreviatorFragment(charCount, ellipsis));
- pos = trimmed.indexOf(".", pos);
-
- if (pos == -1) {
- break;
- }
-
- pos++;
- }
-
- return new PatternAbbreviator(fragments);
- }
-
- //
- // no matching abbreviation, return defaultAbbreviator
- //
- return DEFAULT;
- }
-
- /**
- * Gets default abbreviator.
- *
- * @return default abbreviator.
- */
- public static NameAbbreviator getDefaultAbbreviator() {
- return DEFAULT;
- }
-
- /**
- * Abbreviates a name in a String.
- *
- * @param buf buffer, may not be null.
- * @return The abbreviated String.
- */
- public abstract String abbreviate(final String buf);
-
- /**
- * Abbreviator that simply appends full name to buffer.
- */
- private static class NOPAbbreviator extends NameAbbreviator {
- /**
- * Constructor.
- */
- public NOPAbbreviator() {
- }
-
- /**
- * {@inheritDoc}
- */
- public String abbreviate(final String buf) {
- return buf;
- }
- }
-
- /**
- * Abbreviator that drops starting path elements.
- */
- private static class MaxElementAbbreviator extends NameAbbreviator {
- /**
- * Maximum number of path elements to output.
- */
- private final int count;
-
- /**
- * Create new instance.
- *
- * @param count maximum number of path elements to output.
- */
- public MaxElementAbbreviator(final int count) {
- this.count = count < 1 ? 1 : count;
- }
-
- /**
- * Abbreviate name.
- *
- * @param buf The String to abbreviate.
- * @return the abbreviated String.
- */
- public String abbreviate(final String buf) {
-
- // We substract 1 from 'len' when assigning to 'end' to avoid out of
- // bounds exception in return r.substring(end+1, len). This can happen if
- // precision is 1 and the category name ends with a dot.
- int end = buf.length() - 1;
-
- for (int i = count; i > 0; i--) {
- end = buf.lastIndexOf(".", end - 1);
- if (end == -1) {
- return buf;
- }
- }
-
- return buf.substring(end + 1);
- }
- }
-
- /**
- * Fragment of an pattern abbreviator.
- */
- private static class PatternAbbreviatorFragment {
- /**
- * Count of initial characters of element to output.
- */
- private final int charCount;
-
- /**
- * Character used to represent dropped characters.
- * '\0' indicates no representation of dropped characters.
- */
- private final char ellipsis;
-
- /**
- * Creates a PatternAbbreviatorFragment.
- *
- * @param charCount number of initial characters to preserve.
- * @param ellipsis character to represent elimination of characters,
- * '\0' if no ellipsis is desired.
- */
- public PatternAbbreviatorFragment(
- final int charCount, final char ellipsis) {
- this.charCount = charCount;
- this.ellipsis = ellipsis;
- }
-
- /**
- * Abbreviate element of name.
- *
- * @param buf buffer to receive element.
- * @param startPos starting index of name element.
- * @return starting index of next element.
- */
- public int abbreviate(final StringBuilder buf, final int startPos) {
- int nextDot = buf.toString().indexOf(".", startPos);
-
- if (nextDot != -1) {
- if ((nextDot - startPos) > charCount) {
- buf.delete(startPos + charCount, nextDot);
- nextDot = startPos + charCount;
-
- if (ellipsis != '\0') {
- buf.insert(nextDot, ellipsis);
- nextDot++;
- }
- }
-
- nextDot++;
- }
-
- return nextDot;
- }
- }
-
- /**
- * Pattern abbreviator.
- */
- private static class PatternAbbreviator extends NameAbbreviator {
- /**
- * Element abbreviation patterns.
- */
- private final PatternAbbreviatorFragment[] fragments;
-
- /**
- * Create PatternAbbreviator.
- *
- * @param fragments element abbreviation patterns.
- */
- public PatternAbbreviator(List fragments) {
- if (fragments.size() == 0) {
- throw new IllegalArgumentException(
- "fragments must have at least one element");
- }
-
- this.fragments = new PatternAbbreviatorFragment[fragments.size()];
- fragments.toArray(this.fragments);
- }
-
- /**
- * Abbreviate name.
- *
- * @param buf buffer that abbreviated name is appended.
- * @param nameStart start of name.
- */
- public String abbreviate(final String buf) {
- //
- // all non-terminal patterns are executed once
- //
- int pos = 0;
- StringBuilder sb = new StringBuilder(buf);
-
- for (int i = 0; (i < (fragments.length - 1)) && (pos < buf.length());
- i++) {
- pos = fragments[i].abbreviate(sb, pos);
- }
-
- //
- // last pattern in executed repeatedly
- //
- PatternAbbreviatorFragment terminalFragment = fragments[fragments.length - 1];
-
- while ((pos < buf.length()) && (pos >= 0)) {
- pos = terminalFragment.abbreviate(sb, pos);
- }
- return sb.toString();
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/NamePatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/NamePatternConverter.java
deleted file mode 100644
index 2696f4a..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/NamePatternConverter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-
-/**
- * Base class for other pattern converters which can return only parts of their name.
- */
-public abstract class NamePatternConverter extends LogEventPatternConverter {
- /**
- * Abbreviator.
- */
- private final NameAbbreviator abbreviator;
-
- /**
- * Constructor.
- *
- * @param name name of converter.
- * @param style style name for associated output.
- * @param options options, may be null, first element will be interpreted as an abbreviation pattern.
- */
- protected NamePatternConverter(final String name, final String style, final String[] options) {
- super(name, style);
-
- if ((options != null) && (options.length > 0)) {
- abbreviator = NameAbbreviator.getAbbreviator(options[0]);
- } else {
- abbreviator = NameAbbreviator.getDefaultAbbreviator();
- }
- }
-
- /**
- * Abbreviate name in string buffer.
- *
- * @param buf string buffer containing name.
- * @return The abbreviated name.
- */
- protected final String abbreviate(final String buf) {
- return abbreviator.abbreviate(buf);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/PatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/PatternConverter.java
deleted file mode 100644
index 9656ca8..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/PatternConverter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-/**
- * Interface that all PatternConverters must implement.
- */
-public interface PatternConverter {
- /**
- * Formats an object into a string buffer.
- *
- * @param obj event to format, may not be null.
- * @param toAppendTo string buffer to which the formatted event will be appended. May not be null.
- */
- void format(Object obj, StringBuilder toAppendTo);
-
- /**
- * Returns the name of the converter.
- * @return The name of the converter.
- */
- String getName();
-
- /**
- * This method returns the CSS style class that should be applied to
- * the LoggingEvent passed as parameter, which can be null.
- * <p/>
- *
- * @param e null values are accepted
- * @return the name of the conversion pattern
- */
- String getStyleClass(Object e);
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/PatternParser.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/PatternParser.java
deleted file mode 100644
index e53b718..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/PatternParser.java
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.PluginManager;
-import org.apache.logging.log4j.core.config.plugins.PluginType;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Most of the work of the {@link org.apache.logging.log4j.core.layout.PatternLayout} class
- * is delegated to the PatternParser class.
- * <p>It is this class that parses conversion patterns and creates
- * a chained list of {@link PatternConverter PatternConverters}.
- */
-public final class PatternParser {
- /**
- * Escape character for format specifier.
- */
- private static final char ESCAPE_CHAR = '%';
-
- /**
- * The states the parser can be in while parsing the pattern.
- */
- private enum ParserState {
- /**
- * Literal state.
- */
- LITERAL_STATE,
-
- /**
- * In converter name state.
- */
- CONVERTER_STATE,
-
- /**
- * Dot state.
- */
- DOT_STATE,
-
- /**
- * Min state.
- */
- MIN_STATE,
-
- /**
- * Max state.
- */
- MAX_STATE;
- }
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private static final int BUF_SIZE = 32;
-
- private static final int DECIMAL = 10;
-
- /**
- * Does pattern process exceptions.
- */
- private boolean handlesExceptions;
-
- private Configuration config;
-
- private final Map<String, Class<PatternConverter>> converterRules;
-
-
- /**
- * Constructor.
- * @param converterKey The type of converters that will be used.
- */
- public PatternParser(String converterKey) {
- this(null, converterKey, null);
- }
-
- /**
- * Constructor.
- * @param config The current Configuration.
- * @param converterKey The key to lookup the converters.
- * @param expected The expected base Class of each Converter.
- */
- public PatternParser(Configuration config, String converterKey, Class expected) {
- this.config = config;
- PluginManager manager = new PluginManager(converterKey, expected);
- manager.collectPlugins();
- Map<String, PluginType> plugins = manager.getPlugins();
- Map<String, Class<PatternConverter>> converters = new HashMap<String, Class<PatternConverter>>();
-
- for (PluginType type : plugins.values()) {
- try {
- Class<PatternConverter> clazz = type.getPluginClass();
- ConverterKeys keys = clazz.getAnnotation(ConverterKeys.class);
- if (keys != null) {
- for (String key : keys.value()) {
- converters.put(key, clazz);
- }
- }
- } catch (Exception ex) {
- LOGGER.error("Error processing plugin " + type.getElementName(), ex);
- }
- }
- converterRules = converters;
- }
-
-
- public List<PatternConverter> parse(String pattern) {
- List<PatternConverter> converters = new ArrayList<PatternConverter>();
- List<FormattingInfo> fields = new ArrayList<FormattingInfo>();
-
- parse(pattern, converters, fields);
-
- LogEventPatternConverter[] patternConverters = new LogEventPatternConverter[converters.size()];
- FormattingInfo[] patternFields = new FormattingInfo[converters.size()];
-
- int i = 0;
- Iterator fieldIter = fields.iterator();
-
- for (PatternConverter converter : converters) {
- if (converter instanceof LogEventPatternConverter) {
- patternConverters[i] = (LogEventPatternConverter) converter;
- handlesExceptions |= patternConverters[i].handlesThrowable();
- } else {
- patternConverters[i] = new LiteralPatternConverter("");
- }
-
- if (fieldIter.hasNext()) {
- patternFields[i] = (FormattingInfo) fieldIter.next();
- } else {
- patternFields[i] = FormattingInfo.getDefault();
- }
-
- i++;
- }
- return converters;
- }
-
- public boolean handlesExceptions() {
- return handlesExceptions;
- }
-
- /**
- * Extract the converter identifier found at position i.
- * <p/>
- * After this function returns, the variable i will point to the
- * first char after the end of the converter identifier.
- * <p/>
- * If i points to a char which is not a character acceptable at the
- * start of a unicode identifier, the value null is returned.
- *
- * @param lastChar last processed character.
- * @param pattern format string.
- * @param i current index into pattern format.
- * @param convBuf buffer to receive conversion specifier.
- * @param currentLiteral literal to be output in case format specifier in unrecognized.
- * @return position in pattern after converter.
- */
- private static int extractConverter(
- char lastChar, final String pattern, int i, final StringBuilder convBuf,
- final StringBuilder currentLiteral) {
- convBuf.setLength(0);
-
- // When this method is called, lastChar points to the first character of the
- // conversion word. For example:
- // For "%hello" lastChar = 'h'
- // For "%-5hello" lastChar = 'h'
- //System.out.println("lastchar is "+lastChar);
- if (!Character.isUnicodeIdentifierStart(lastChar)) {
- return i;
- }
-
- convBuf.append(lastChar);
-
- while ((i < pattern.length()) && Character.isUnicodeIdentifierPart(pattern.charAt(i))) {
- convBuf.append(pattern.charAt(i));
- currentLiteral.append(pattern.charAt(i));
- i++;
- }
-
- return i;
- }
-
- /**
- * Extract options.
- *
- * @param pattern conversion pattern.
- * @param i start of options.
- * @param options array to receive extracted options
- * @return position in pattern after options.
- */
- private static int extractOptions(String pattern, int i, List<String> options) {
- while ((i < pattern.length()) && (pattern.charAt(i) == '{')) {
- int end = pattern.indexOf('}', i);
-
- if (end == -1) {
- break;
- }
-
- String r = pattern.substring(i + 1, end);
- options.add(r);
- i = end + 1;
- }
-
- return i;
- }
-
- /**
- * Parse a format specifier.
- *
- * @param pattern pattern to parse.
- * @param patternConverters list to receive pattern converters.
- * @param formattingInfos list to receive field specifiers corresponding to pattern converters.
- */
- public void parse(final String pattern, final List<PatternConverter> patternConverters,
- final List<FormattingInfo> formattingInfos) {
- if (pattern == null) {
- throw new NullPointerException("pattern");
- }
-
- StringBuilder currentLiteral = new StringBuilder(BUF_SIZE);
-
- int patternLength = pattern.length();
- ParserState state = ParserState.LITERAL_STATE;
- char c;
- int i = 0;
- FormattingInfo formattingInfo = FormattingInfo.getDefault();
-
- while (i < patternLength) {
- c = pattern.charAt(i++);
-
- switch (state) {
- case LITERAL_STATE:
-
- // In literal state, the last char is always a literal.
- if (i == patternLength) {
- currentLiteral.append(c);
-
- continue;
- }
-
- if (c == ESCAPE_CHAR) {
- // peek at the next char.
- switch (pattern.charAt(i)) {
- case ESCAPE_CHAR:
- currentLiteral.append(c);
- i++; // move pointer
-
- break;
-
- default:
-
- if (currentLiteral.length() != 0) {
- patternConverters.add(new LiteralPatternConverter(currentLiteral.toString()));
- formattingInfos.add(FormattingInfo.getDefault());
- }
-
- currentLiteral.setLength(0);
- currentLiteral.append(c); // append %
- state = ParserState.CONVERTER_STATE;
- formattingInfo = FormattingInfo.getDefault();
- }
- } else {
- currentLiteral.append(c);
- }
-
- break;
-
- case CONVERTER_STATE:
- currentLiteral.append(c);
-
- switch (c) {
- case '-':
- formattingInfo =
- new FormattingInfo(true, formattingInfo.getMinLength(),
- formattingInfo.getMaxLength());
-
- break;
-
- case '.':
- state = ParserState.DOT_STATE;
-
- break;
-
- default:
-
- if ((c >= '0') && (c <= '9')) {
- formattingInfo = new FormattingInfo(formattingInfo.isLeftAligned(), c - '0',
- formattingInfo.getMaxLength());
- state = ParserState.MIN_STATE;
- } else {
- i = finalizeConverter(c, pattern, i, currentLiteral, formattingInfo,
- converterRules, patternConverters, formattingInfos);
-
- // Next pattern is assumed to be a literal.
- state = ParserState.LITERAL_STATE;
- formattingInfo = FormattingInfo.getDefault();
- currentLiteral.setLength(0);
- }
- } // switch
-
- break;
-
- case MIN_STATE:
- currentLiteral.append(c);
-
- if ((c >= '0') && (c <= '9')) {
- // Multiply the existing value and add the value of the number just encountered.
- formattingInfo = new FormattingInfo(formattingInfo.isLeftAligned(),
- (formattingInfo.getMinLength() * DECIMAL) + (c - '0'),
- formattingInfo.getMaxLength());
- } else if (c == '.') {
- state = ParserState.DOT_STATE;
- } else {
- i = finalizeConverter(c, pattern, i, currentLiteral, formattingInfo,
- converterRules, patternConverters, formattingInfos);
- state = ParserState.LITERAL_STATE;
- formattingInfo = FormattingInfo.getDefault();
- currentLiteral.setLength(0);
- }
-
- break;
-
- case DOT_STATE:
- currentLiteral.append(c);
-
- if ((c >= '0') && (c <= '9')) {
- formattingInfo = new FormattingInfo(formattingInfo.isLeftAligned(),
- formattingInfo.getMinLength(), c - '0');
- state = ParserState.MAX_STATE;
- } else {
- LOGGER.error("Error occurred in position " + i
- + ".\n Was expecting digit, instead got char \"" + c + "\".");
-
- state = ParserState.LITERAL_STATE;
- }
-
- break;
-
- case MAX_STATE:
- currentLiteral.append(c);
-
- if ((c >= '0') && (c <= '9')) {
- // Multiply the existing value and add the value of the number just encountered.
- formattingInfo = new FormattingInfo(
- formattingInfo.isLeftAligned(), formattingInfo.getMinLength(),
- (formattingInfo.getMaxLength() * DECIMAL) + (c - '0'));
- } else {
- i = finalizeConverter(c, pattern, i, currentLiteral, formattingInfo,
- converterRules, patternConverters, formattingInfos);
- state = ParserState.LITERAL_STATE;
- formattingInfo = FormattingInfo.getDefault();
- currentLiteral.setLength(0);
- }
-
- break;
- } // switch
- }
-
- // while
- if (currentLiteral.length() != 0) {
- patternConverters.add(new LiteralPatternConverter(currentLiteral.toString()));
- formattingInfos.add(FormattingInfo.getDefault());
- }
- }
-
- /**
- * Creates a new PatternConverter.
- *
- * @param converterId converterId.
- * @param currentLiteral literal to be used if converter is unrecognized or following converter
- * if converterId contains extra characters.
- * @param rules map of stock pattern converters keyed by format specifier.
- * @param options converter options.
- * @return converter or null.
- */
- private PatternConverter createConverter(final String converterId, final StringBuilder currentLiteral,
- final Map<String, Class<PatternConverter>> rules,
- final List<String> options) {
- String converterName = converterId;
- Class<PatternConverter> converterClass = null;
-
- for (int i = converterId.length(); (i > 0) && (converterClass == null); i--) {
- converterName = converterName.substring(0, i);
-
- if ((converterClass == null) && (rules != null)) {
- converterClass = rules.get(converterName);
- }
- }
-
- if (converterClass == null) {
- LOGGER.error("Unrecognized format specifier [" + converterId + "]");
-
- return null;
- }
-
- Method[] methods = converterClass.getDeclaredMethods();
- Method newInstance = null;
- for (Method method : methods) {
- if (method.getName().equals("newInstance")) {
- if (newInstance == null) {
- newInstance = method;
- } else {
- LOGGER.error("Class " + converterClass + " cannot contain multiple newInstance methods");
- return null;
- }
- }
- }
- if (newInstance == null) {
- LOGGER.error("Class " + converterClass + " does not contain a newInstance method");
- return null;
- }
-
- Class[] parmTypes = newInstance.getParameterTypes();
- Object [] parms = parmTypes.length > 0 ? new Object[parmTypes.length] : null;
-
- if (parms != null) {
- int i = 0;
- boolean errors = false;
- for (Class clazz : parmTypes) {
- if (clazz.isArray() && clazz.getName().equals("[Ljava.lang.String;")) {
- String[] optionsArray = options.toArray(new String[options.size()]);
- parms[i] = optionsArray;
- } else if (clazz.isAssignableFrom(Configuration.class)) {
- parms[i] = config;
- } else {
- LOGGER.error("Unknown parameter type " + clazz.getName() + " for newInstance method of " +
- converterClass.getName());
- errors = true;
- }
- ++i;
- }
- if (errors) {
- return null;
- }
- }
-
- try {
- Object newObj = newInstance.invoke(null, parms);
-
- if (newObj instanceof PatternConverter) {
- currentLiteral.delete(0, currentLiteral.length()
- - (converterId.length() - converterName.length()));
-
- return (PatternConverter) newObj;
- } else {
- LOGGER.warn("Class " + converterClass.getName() + " does not extend PatternConverter.");
- }
- } catch (Exception ex) {
- LOGGER.error("Error creating converter for " + converterId, ex);
- }
-
- return null;
- }
-
- /**
- * Processes a format specifier sequence.
- *
- * @param c initial character of format specifier.
- * @param pattern conversion pattern
- * @param i current position in conversion pattern.
- * @param currentLiteral current literal.
- * @param formattingInfo current field specifier.
- * @param rules map of stock pattern converters keyed by format specifier.
- * @param patternConverters list to receive parsed pattern converter.
- * @param formattingInfos list to receive corresponding field specifier.
- * @return position after format specifier sequence.
- */
- private int finalizeConverter(char c, String pattern, int i,
- final StringBuilder currentLiteral, final FormattingInfo formattingInfo,
- final Map<String, Class<PatternConverter>> rules,
- final List<PatternConverter> patternConverters, final List<FormattingInfo> formattingInfos) {
- StringBuilder convBuf = new StringBuilder();
- i = extractConverter(c, pattern, i, convBuf, currentLiteral);
-
- String converterId = convBuf.toString();
-
- List<String> options = new ArrayList<String>();
- i = extractOptions(pattern, i, options);
-
- PatternConverter pc = createConverter(converterId, currentLiteral, rules, options);
-
- if (pc == null) {
- StringBuilder msg;
-
- if ((converterId == null) || (converterId.length() == 0)) {
- msg =
- new StringBuilder("Empty conversion specifier starting at position ");
- } else {
- msg = new StringBuilder("Unrecognized conversion specifier [");
- msg.append(converterId);
- msg.append("] starting at position ");
- }
-
- msg.append(Integer.toString(i));
- msg.append(" in conversion pattern.");
-
- LOGGER.error(msg.toString());
-
- patternConverters.add(new LiteralPatternConverter(currentLiteral.toString()));
- formattingInfos.add(FormattingInfo.getDefault());
- } else {
- patternConverters.add(pc);
- formattingInfos.add(formattingInfo);
-
- if (currentLiteral.length() > 0) {
- patternConverters.add(new LiteralPatternConverter(currentLiteral.toString()));
- formattingInfos.add(FormattingInfo.getDefault());
- }
- }
-
- currentLiteral.setLength(0);
-
- return i;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RegexReplacement.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RegexReplacement.java
deleted file mode 100644
index 50e13e3..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RegexReplacement.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.util.regex.Pattern;
-
-/**
- * Replace tokens in the LogEvent message.
- */
-@Plugin(name = "replace", type = "Core", printObject = true)
-public final class RegexReplacement {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private final Pattern pattern;
-
- private final String substitution;
-
- /**
- * Private constructor.
- *
- * @param pattern The Pattern.
- * @param substitution The substitution String.
- */
- private RegexReplacement(Pattern pattern, String substitution) {
- this.pattern = pattern;
- this.substitution = substitution;
- }
-
- /**
- * Perform the replacement.
- * @param msg The String to match against.
- * @return the replacement String.
- */
- public String format(String msg) {
- return pattern.matcher(msg).replaceAll(substitution);
- }
-
- public String toString() {
- return "replace(regex=" + pattern.pattern() + ", replacement=" + substitution + ")";
- }
-
- /**
- * Create a RegexReplacement.
- * @param regex The regular expression to locate.
- * @param replacement The replacement value.
- * @return A RegexReplacement.
- */
- @PluginFactory
- public static RegexReplacement createRegexReplacement(@PluginAttr("regex") String regex,
- @PluginAttr("replacement") String replacement) {
- if (regex == null) {
- LOGGER.error("A regular expression is required for replacement");
- return null;
- }
- if (replacement == null) {
- LOGGER.error("A replacement string is required to perform replacement");
- }
- Pattern p = Pattern.compile(regex);
- return new RegexReplacement(p, replacement);
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RegexReplacementConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RegexReplacementConverter.java
deleted file mode 100644
index 1066b26..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RegexReplacementConverter.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-
-import java.util.List;
-import java.util.regex.Pattern;
-
-/**
- * Replacement pattern converter.
- */
-@Plugin(name = "replace", type = "Converter")
-@ConverterKeys({"replace" })
-public final class RegexReplacementConverter extends LogEventPatternConverter {
-
- private final Pattern pattern;
-
- private final String substitution;
-
- private List<PatternConverter> converters;
-
- /**
- * Construct the converter.
- * @param converters The PatternConverters to generate the text to manipulate.
- * @param pattern The regular expression Pattern.
- * @param substitution The substitution string.
- */
- private RegexReplacementConverter(List<PatternConverter> converters,
- Pattern pattern, String substitution) {
- super("replace", "replace");
- this.pattern = pattern;
- this.substitution = substitution;
- this.converters = converters;
- }
-
- /**
- * Gets an instance of the class.
- *
- * @param config The current Configuration.
- * @param options pattern options, may be null. If first element is "short",
- * only the first line of the throwable will be formatted.
- * @return instance of class.
- */
- public static RegexReplacementConverter newInstance(Configuration config, final String[] options) {
- if (options.length != 3) {
- LOGGER.error("Incorrect number of options on replace. Expected 3 received " + options.length);
- return null;
- }
- if (options[0] == null) {
- LOGGER.error("No pattern supplied on replace");
- return null;
- }
- if (options[1] == null) {
- LOGGER.error("No regular expression supplied on replace");
- return null;
- }
- if (options[2] == null) {
- LOGGER.error("No substitution supplied on replace");
- return null;
- }
- Pattern p = Pattern.compile(options[1]);
- PatternParser parser = PatternLayout.createPatternParser(config);
- List<PatternConverter> converters = parser.parse(options[0]);
- return new RegexReplacementConverter(converters, p, options[2]);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- StringBuilder buf = new StringBuilder();
- for (PatternConverter c : converters) {
- c.format(event, buf);
- }
- toAppendTo.append(pattern.matcher(buf.toString()).replaceAll(substitution));
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RelativeTimePatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RelativeTimePatternConverter.java
deleted file mode 100644
index f09a135..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RelativeTimePatternConverter.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-import java.lang.management.ManagementFactory;
-
-/**
- * Return the relative time in milliseconds since JVM Startup.
- */
-@Plugin(name = "RelativeTimePatternConverter", type = "Converter")
-@ConverterKeys({"r", "relative" })
-public class RelativeTimePatternConverter extends LogEventPatternConverter {
- /**
- * Cached formatted timestamp.
- */
- private long lastTimestamp = Long.MIN_VALUE;
- private long startTime = ManagementFactory.getRuntimeMXBean().getStartTime();
- private String relative;
-
- /**
- * Private constructor.
- */
- public RelativeTimePatternConverter() {
- super("Time", "time");
- }
-
- /**
- * Obtains an instance of RelativeTimePatternConverter.
- *
- * @param options options, currently ignored, may be null.
- * @return instance of RelativeTimePatternConverter.
- */
- public static RelativeTimePatternConverter newInstance(
- final String[] options) {
- return new RelativeTimePatternConverter();
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- long timestamp = event.getMillis();
-
- synchronized (this) {
- if (timestamp != lastTimestamp) {
- lastTimestamp = timestamp;
- relative = Long.toString(timestamp - startTime);
- }
- }
- toAppendTo.append(relative);
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverter.java
deleted file mode 100644
index 7849157..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverter.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.impl.ThrowableProxy;
-
-
-/**
- * Outputs the Throwable portion of the LoggingEvent as a full stacktrace
- * unless this converter's option is 'short', where it just outputs the first line of the trace, or if
- * the number of lines to print is explicitly specified.
- * <p>
- * The extended stack trace will also include the location of where the class was loaded from and the
- * version of the jar if available.
- */
-@Plugin(name = "RootThrowablePatternConverter", type = "Converter")
-@ConverterKeys({"rEx", "rThrowable", "rException" })
-public final class RootThrowablePatternConverter extends ThrowablePatternConverter {
- /**
- * Private constructor.
- *
- * @param options options, may be null.
- */
- private RootThrowablePatternConverter(final String[] options) {
- super("RootThrowable", "throwable", options);
- }
-
- /**
- * Gets an instance of the class.
- *
- * @param options pattern options, may be null. If first element is "short",
- * only the first line of the throwable will be formatted.
- * @return instance of class.
- */
- public static RootThrowablePatternConverter newInstance(
- final String[] options) {
- return new RootThrowablePatternConverter(options);
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- Throwable throwable = event.getThrown();
- if (throwable != null) {
- if (!(throwable instanceof ThrowableProxy)) {
- super.format(event, toAppendTo);
- return;
- }
- ThrowableProxy t = (ThrowableProxy) throwable;
- String trace = t.getRootCauseStackTrace();
- int len = toAppendTo.length();
- if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
- toAppendTo.append(" ");
- }
- if (lines > 0) {
- StringBuilder sb = new StringBuilder();
- String[] array = trace.split("\n");
- for (int i = 0; i < lines; ++i) {
- sb.append(array[i]).append("\n");
- }
- toAppendTo.append(sb.toString());
-
- } else {
- toAppendTo.append(trace);
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/SequenceNumberPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/SequenceNumberPatternConverter.java
deleted file mode 100644
index 9b0f45b..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/SequenceNumberPatternConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-
-/**
- * Formats the event sequence number.
- */
-@Plugin(name = "SequenceNumberPatternConverter", type = "Converter")
-@ConverterKeys({"sn", "sequenceNumber" })
-public final class SequenceNumberPatternConverter extends LogEventPatternConverter {
- private static AtomicLong sequence = new AtomicLong();
- /**
- * Singleton.
- */
- private static final SequenceNumberPatternConverter INSTANCE =
- new SequenceNumberPatternConverter();
-
- /**
- * Private constructor.
- */
- private SequenceNumberPatternConverter() {
- super("Sequence Number", "sn");
- }
-
- /**
- * Obtains an instance of SequencePatternConverter.
- *
- * @param options options, currently ignored, may be null.
- * @return instance of SequencePatternConverter.
- */
- public static SequenceNumberPatternConverter newInstance(
- final String[] options) {
- return INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- toAppendTo.append(Long.toString(sequence.incrementAndGet()));
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThreadPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThreadPatternConverter.java
deleted file mode 100644
index d6c8342..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThreadPatternConverter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-/**
- * Formats the event thread name.
- */
-@Plugin(name = "ThreadPatternConverter", type = "Converter")
-@ConverterKeys({"t", "thread" })
-public final class ThreadPatternConverter extends LogEventPatternConverter {
- /**
- * Singleton.
- */
- private static final ThreadPatternConverter INSTANCE =
- new ThreadPatternConverter();
-
- /**
- * Private constructor.
- */
- private ThreadPatternConverter() {
- super("Thread", "thread");
- }
-
- /**
- * Obtains an instance of ThreadPatternConverter.
- *
- * @param options options, currently ignored, may be null.
- * @return instance of ThreadPatternConverter.
- */
- public static ThreadPatternConverter newInstance(
- final String[] options) {
- return INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- toAppendTo.append(event.getThreadName());
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java
deleted file mode 100644
index b8538b5..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-
-/**
- * Outputs the Throwable portion of the LoggingEvent as a full stacktrace
- * unless this converter's option is 'short', where it just outputs the first line of the trace, or if
- * the number of lines to print is explicitly specified.
- */
-@Plugin(name = "ThrowablePatternConverter", type = "Converter")
-@ConverterKeys({"ex", "throwable", "exception" })
-public class ThrowablePatternConverter extends LogEventPatternConverter {
-
- /**
- * Format the whole stack trace.
- */
- protected static final String FULL = "full";
- /**
- * Format only the first line of the throwable.
- */
- protected static final String SHORT = "short";
- /**
- * If "short", only first line of throwable report will be formatted.<br>
- * If "full", the whole stack trace will be formatted.<br>
- * If "numeric" the output will be limited to the specified number of lines.
- */
- protected final String option;
-
- /**
- * The number of lines to write.
- */
- protected final int lines;
-
- /**
- * Constructor.
- * @param name Name of converter.
- * @param style CSS style for output.
- * @param options options, may be null.
- */
- protected ThrowablePatternConverter(String name, String style, final String[] options) {
- super(name, style);
- int count = 0;
- if ((options != null) && (options.length > 0)) {
- option = options[0];
- if (option.equalsIgnoreCase(SHORT)) {
- count = 2;
- } else if (!option.equalsIgnoreCase(FULL)) {
- count = Integer.parseInt(option);
- }
-
- } else {
- option = null;
- }
- lines = count;
- }
-
- /**
- * Gets an instance of the class.
- *
- * @param options pattern options, may be null. If first element is "short",
- * only the first line of the throwable will be formatted.
- * @return instance of class.
- */
- public static ThrowablePatternConverter newInstance(
- final String[] options) {
- return new ThrowablePatternConverter("Throwable", "throwable", options);
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- Throwable t = event.getThrown();
-
- if (t != null) {
- StringWriter w = new StringWriter();
- t.printStackTrace(new PrintWriter(w));
- int len = toAppendTo.length();
- if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
- toAppendTo.append(" ");
- }
- if (lines > 0) {
- StringBuilder sb = new StringBuilder();
- String[] array = w.toString().split("\n");
- for (int i = 0; i < lines; ++i) {
- sb.append(array[i]).append("\n");
- }
- toAppendTo.append(sb.toString());
-
- } else {
- toAppendTo.append(w.toString());
- }
- }
- }
-
- /**
- * This converter obviously handles throwables.
- *
- * @return true.
- */
- public boolean handlesThrowable() {
- return true;
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/UUIDPatternConverter.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/UUIDPatternConverter.java
deleted file mode 100644
index e237748..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/UUIDPatternConverter.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.helpers.UUIDUtil;
-
-import java.util.UUID;
-
-/**
- * Formats the event sequence number.
- */
-@Plugin(name = "UUIDPatternConverter", type = "Converter")
-@ConverterKeys({"u", "uuid" })
-public final class UUIDPatternConverter extends LogEventPatternConverter {
-
- private final boolean isRandom;
-
- /**
- * Private constructor.
- */
- private UUIDPatternConverter(boolean isRandom) {
- super("u", "uuid");
- this.isRandom = isRandom;
- }
-
- /**
- * Obtains an instance of SequencePatternConverter.
- *
- * @param options options, currently ignored, may be null.
- * @return instance of SequencePatternConverter.
- */
- public static UUIDPatternConverter newInstance(final String[] options) {
- if (options.length == 0) {
- return new UUIDPatternConverter(false);
- }
-
- if (options.length > 1 || (!options[0].equalsIgnoreCase("RANDOM") && !options[0].equalsIgnoreCase("Time"))) {
- LOGGER.error("UUID Pattern Converter only accepts a single option with the value \"RANDOM\" or \"TIME\"");
- }
- return new UUIDPatternConverter(options[0].equalsIgnoreCase("RANDOM"));
- }
-
- /**
- * {@inheritDoc}
- */
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- UUID uuid = isRandom ? UUID.randomUUID() : UUIDUtil.getTimeBasedUUID();
- toAppendTo.append(uuid.toString());
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/package-info.java
deleted file mode 100644
index 5b633ed..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Provides classes implementing format specifiers in conversion patterns.
- */
-package org.apache.logging.log4j.core.pattern;
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java
deleted file mode 100644
index 2d3b12b..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.selector;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.javaee.ContextAnchor;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Returns either this Thread's context or the default LoggerContext.
- */
-public class BasicContextSelector implements ContextSelector {
-
- private static LoggerContext context = new LoggerContext("Default");
-
- public LoggerContext getContext(String fqcn, boolean currentContext) {
-
- LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
- return ctx != null ? ctx : context;
- }
-
- public LoggerContext locateContext(String name, String configLocation) {
- return context;
- }
-
- public void removeContext(LoggerContext context) {
-
- }
-
- public List<LoggerContext> getLoggerContexts() {
- List<LoggerContext> list = new ArrayList<LoggerContext>();
- list.add(context);
- return Collections.unmodifiableList(list);
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
deleted file mode 100644
index feaa216..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.selector;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.helpers.Loader;
-import org.apache.logging.log4j.core.javaee.ContextAnchor;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * This ContextSelector chooses a LoggerContext based upon the ClassLoader of the caller. This allows Loggers
- * assigned to static variables to be released along with the classes that own then. Other ContextSelectors
- * will generally cause Loggers associated with classes loaded from different ClassLoaders to be co-mingled.
- * This is a problem if, for example, a web application is undeployed as some of the Loggers being released may be
- * associated with a Class in a parent ClassLoader, which will generally have negative consequences.
- *
- * The main downside to this ContextSelector is that Configuration is more challenging.
- *
- * This ContextSelector should not be used with a Servlet Filter such as the JNDIContextFilter.
- */
-public class ClassLoaderContextSelector implements ContextSelector {
-
- private static AtomicReference<LoggerContext> context = new AtomicReference<LoggerContext>();
-
- private static PrivateSecurityManager securityManager;
-
- private static Method getCallerClass;
-
- private static StatusLogger logger = StatusLogger.getLogger();
-
- private static ConcurrentMap<String, AtomicReference<WeakReference<LoggerContext>>> contextMap =
- new ConcurrentHashMap<String, AtomicReference<WeakReference<LoggerContext>>>();
-
-
- static {
- setupCallerCheck();
- }
-
- public LoggerContext getContext(String fqcn, boolean currentContext) {
-
- if (currentContext) {
- LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
- if (ctx != null) {
- return ctx;
- }
- return getDefault();
- } else {
- if (getCallerClass != null) {
- try {
- Class clazz = Class.class;
- boolean next = false;
- for (int index = 2; clazz != null; ++index) {
- Object[] params = new Object[] {index};
- clazz = (Class) getCallerClass.invoke(null, params);
- if (clazz == null) {
- break;
- }
- if (clazz.getName().equals(fqcn)) {
- next = true;
- continue;
- }
- if (next) {
- break;
- }
- }
- if (clazz != null) {
- return locateContext(clazz.getClassLoader(), null);
- }
- } catch (Exception ex) {
- // logger.debug("Unable to determine caller class via Sun Reflection", ex);
- }
- }
-
- if (securityManager != null) {
- Class clazz = securityManager.getCaller(fqcn);
- return locateContext(clazz.getClassLoader(), null);
- }
-
- Throwable t = new Throwable();
- boolean next = false;
- String name = null;
- for (StackTraceElement element : t.getStackTrace()) {
- if (element.getClassName().equals(fqcn)) {
- next = true;
- continue;
- }
- if (next) {
- name = element.getClassName();
- break;
- }
- }
- if (name != null) {
- try {
- return locateContext(Loader.loadClass(name).getClassLoader(), null);
- } catch (ClassNotFoundException ex) {
- //System.out.println("Could not load class " + name);
- }
- }
- LoggerContext lc = ContextAnchor.THREAD_CONTEXT.get();
- if (lc != null) {
- return lc;
- }
- return getDefault();
- }
- }
-
- public void removeContext(LoggerContext context) {
-
- for (Map.Entry<String, AtomicReference<WeakReference<LoggerContext>>> entry : contextMap.entrySet()) {
- LoggerContext ctx = entry.getValue().get().get();
- if (ctx == context) {
- contextMap.remove(entry.getKey());
- }
- }
- }
-
- public List<LoggerContext> getLoggerContexts() {
- List<LoggerContext> list = new ArrayList<LoggerContext>();
- Collection<AtomicReference<WeakReference<LoggerContext>>> coll = contextMap.values();
- for (AtomicReference<WeakReference<LoggerContext>> ref : coll) {
- LoggerContext ctx = ref.get().get();
- if (ctx != null) {
- list.add(ctx);
- }
- }
- return Collections.unmodifiableList(list);
- }
-
- private LoggerContext locateContext(ClassLoader loader, String configLocation) {
- String name = loader.toString();
- AtomicReference<WeakReference<LoggerContext>> ref = contextMap.get(name);
- if (ref == null) {
- LoggerContext ctx = new LoggerContext(name, null, configLocation);
- AtomicReference<WeakReference<LoggerContext>> r =
- new AtomicReference<WeakReference<LoggerContext>>();
- r.set(new WeakReference<LoggerContext>(ctx));
- contextMap.putIfAbsent(loader.toString(), r);
- ctx = contextMap.get(name).get().get();
- return ctx;
- } else {
- WeakReference<LoggerContext> r = ref.get();
- LoggerContext ctx = r.get();
- if (ctx != null) {
- return ctx;
- }
- ctx = new LoggerContext(name, null, configLocation);
- ref.compareAndSet(r, new WeakReference<LoggerContext>(ctx));
- return ctx;
- }
- }
-
- private static void setupCallerCheck() {
- try {
- ClassLoader loader = Loader.getClassLoader();
- Class clazz = loader.loadClass("sun.reflect.Reflection");
- Method[] methods = clazz.getMethods();
- for (Method method : methods) {
- int modifier = method.getModifiers();
- if (method.getName().equals("getCallerClass") && Modifier.isStatic(modifier)) {
- getCallerClass = method;
- break;
- }
- }
- } catch (ClassNotFoundException cnfe) {
- logger.debug("sun.reflect.Reflection is not installed");
- }
- try {
- securityManager = new PrivateSecurityManager();
- } catch (Exception ex) {
- ex.printStackTrace();
- logger.debug("Unable to install security manager", ex);
- }
- }
-
- private LoggerContext getDefault() {
- LoggerContext ctx = context.get();
- if (ctx != null) {
- return ctx;
- }
- context.compareAndSet(null, new LoggerContext("Default"));
- return context.get();
- }
-
- /**
- * SecurityManager that will locate the caller of the Log4j2 API.
- */
- private static class PrivateSecurityManager extends SecurityManager {
-
- public Class getCaller(String fqcn) {
- Class[] classes = getClassContext();
- boolean next = false;
- for (Class clazz : classes) {
- if (clazz.getName().equals(fqcn)) {
- next = true;
- continue;
- }
- if (next) {
- return clazz;
- }
- }
- return null;
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ContextSelector.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ContextSelector.java
deleted file mode 100644
index 31111ce..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ContextSelector.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.selector;
-
-import org.apache.logging.log4j.core.LoggerContext;
-
-import java.util.List;
-
-/**
- * Interface used to locate a LoggerContext.
- */
-public interface ContextSelector {
-
- /**
- * Return the LoggerContext.
- * @param fqcn The fully qualified class name of the caller.
- * @param currentContext If true returns the current Context, if false returns the Context appropriate
- * for the caller if a more appropriate Context can be determined.
- * @return The LoggerContext.
- */
- LoggerContext getContext(String fqcn, boolean currentContext);
-
- /**
- * Return a List of all the available LoggerContexts.
- * @return The List of LoggerContexts.
- */
- List<LoggerContext> getLoggerContexts();
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java
deleted file mode 100644
index 3a014af..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/JNDIContextSelector.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.selector;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.helpers.Constants;
-import org.apache.logging.log4j.core.javaee.ContextAnchor;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * This class can be used to define a
- * custom logger repository. It makes use of the fact that in J2EE
- * environments, each web-application is guaranteed to have its own JNDI
- * context relative to the <code>java:comp/env</code> context. In EJBs, each
- * enterprise bean (albeit not each application) has its own context relative
- * to the <code>java:comp/env</code> context. An <code>env-entry</code> in a
- * deployment descriptor provides the information to the JNDI context. Once the
- * <code>env-entry</code> is set, a repository selector can query the JNDI
- * application context to look up the value of the entry. The logging context of
- * the web-application will depend on the value the env-entry. The JNDI context
- * which is looked up by this class is
- * <code>java:comp/env/log4j/context-name</code>.
- *
- * <p>Here is an example of an <code>env-entry<code>:
- * <blockquote>
- * <pre>
- * <env-entry>
- * <description>JNDI logging context name for this app</description>
- * <env-entry-name>log4j/context-name</env-entry-name>
- * <env-entry-value>aDistinctiveLoggingContextName</env-entry-value>
- * <env-entry-type>java.lang.String</env-entry-type>
- * </env-entry>
- * </pre>
- * </blockquote>
- * </p>
- *
- * <p><em>If multiple applications use the same logging context name, then they
- * will share the same logging context.</em>
- * </p>
- *
- *<p>You can also specify the URL for this context's configuration resource.
- * This repository selector (ContextJNDISelector) will use this resource
- * to automatically configure the log4j repository.
- *</p>
- ** <blockquote>
- * <pre>
- * <env-entry>
- * <description>URL for configuring log4j context</description>
- * <env-entry-name>log4j/configuration-resource</env-entry-name>
- * <env-entry-value>urlOfConfigrationResource</env-entry-value>
- * <env-entry-type>java.lang.String</env-entry-type>
- * </env-entry>
- * </pre>
- * </blockquote>
- *
- * <p>It usually good practice for configuration resources of distinct
- * applications to have distinct names. However, if this is not possible
- * Naming
- * </p>
- *
- */
-public class JNDIContextSelector implements NamedContextSelector {
-
- private static LoggerContext context = new LoggerContext("Default");
-
- private static ConcurrentMap<String, LoggerContext> contextMap =
- new ConcurrentHashMap<String, LoggerContext>();
-
- private static final StatusLogger LOGGER = StatusLogger.getLogger();
-
- public LoggerContext getContext(String fqcn, boolean currentContext) {
-
- LoggerContext lc = ContextAnchor.THREAD_CONTEXT.get();
- if (lc != null) {
- return lc;
- }
-
- String loggingContextName = null;
-
- try {
- Context ctx = new InitialContext();
- loggingContextName = (String) lookup(ctx, Constants.JNDI_CONTEXT_NAME);
- } catch (NamingException ne) {
- LOGGER.error("Unable to lookup " + Constants.JNDI_CONTEXT_NAME, ne);
- }
-
- return loggingContextName == null ? context : locateContext(loggingContextName, null);
- }
-
- public LoggerContext locateContext(String name, String configLocation) {
- if (name == null) {
- LOGGER.error("A context name is required to locate a LoggerContext");
- return null;
- }
- if (!contextMap.containsKey(name)) {
- LoggerContext ctx = new LoggerContext(name, null, configLocation);
- contextMap.putIfAbsent(name, ctx);
- }
- return contextMap.get(name);
- }
-
- public void removeContext(LoggerContext context) {
-
- for (Map.Entry<String, LoggerContext> entry : contextMap.entrySet()) {
- if (entry.getValue().equals(context)) {
- contextMap.remove(entry.getKey());
- }
- }
- }
-
- public LoggerContext removeContext(String name) {
- return contextMap.remove(name);
- }
-
- public List<LoggerContext> getLoggerContexts() {
- List<LoggerContext> list = new ArrayList<LoggerContext>(contextMap.values());
- return Collections.unmodifiableList(list);
- }
-
-
- protected static Object lookup(Context ctx, String name) throws NamingException {
- if (ctx == null) {
- return null;
- }
- try {
- return ctx.lookup(name);
- } catch (NameNotFoundException e) {
- LOGGER.error("Could not find name [" + name + "].");
- throw e;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/NamedContextSelector.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/NamedContextSelector.java
deleted file mode 100644
index 587bcec..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/NamedContextSelector.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.selector;
-
-import org.apache.logging.log4j.core.LoggerContext;
-
-/**
- * ContextSelectors that have a name.
- */
-public interface NamedContextSelector extends ContextSelector {
-
- /**
- * Locate the LoggerContext with the specified name.
- * @param name The LoggerContext name.
- * @param configLocation The location of the configuration.
- * @return A LoggerContext.
- */
- LoggerContext locateContext(String name, String configLocation);
-
- /**
- * Locate the LoggerContext with the specified name using the default configuration.
- * @param name The LoggerContext name.
- * @return A LoggerContext.
- */
- LoggerContext removeContext(String name);
-}
diff --git a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/package-info.java b/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/package-info.java
deleted file mode 100644
index a22a6ca..0000000
--- a/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 Context Selectors.
- */
-package org.apache.logging.log4j.core.selector;
diff --git a/rgoers/log4j2-core/src/main/resources/Log4J-V2.0.xsd b/rgoers/log4j2-core/src/main/resources/Log4J-V2.0.xsd
deleted file mode 100644
index e8d5ace..0000000
--- a/rgoers/log4j2-core/src/main/resources/Log4J-V2.0.xsd
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="configuration" type="configurationType"/>
- <xs:complexType name="configurationType">
- <xs:sequence>
- <xs:element type="propertiesType" name="properties"/>
- <xs:choice minOccurs="0" maxOccurs="1">
- <xs:element type="filtersType" name="filters"/>
- <xs:element type="filterType" name="filter"/>
- </xs:choice>
- <xs:element type="appendersType" name="appenders"/>
- <xs:element type="loggersType" name="loggers"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="packages"/>
- <xs:attribute type="xs:string" name="status"/>
- <xs:attribute type="xs:string" name="strict"/>
- <xs:attribute type="xs:string" name="name"/>
- </xs:complexType>
- <xs:complexType name="propertiesType">
- <xs:sequence>
- <xs:element type="propertyType" name="property"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="appenderType">
- <xs:sequence>
- <xs:element type="layoutType" name="layout" minOccurs="0"/>
- <xs:choice minOccurs="0" maxOccurs="1">
- <xs:element type="filtersType" name="filters"/>
- <xs:element type="filterType" name="filter"/>
- </xs:choice>
- </xs:sequence>
- <xs:attribute type="xs:string" name="type" use="required"/>
- <xs:attribute type="xs:string" name="name" use="required"/>
- <xs:attribute type="xs:string" name="fileName" use="optional"/>
- </xs:complexType>
- <xs:complexType name="rootType">
- <xs:sequence>
- <xs:element type="appender-refType" name="appender-ref" maxOccurs="unbounded" minOccurs="1"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="level"/>
- </xs:complexType>
- <xs:complexType name="propertyType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="name"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="KeyValuePairType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="key"/>
- <xs:attribute type="xs:string" name="value"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="appendersType">
- <xs:sequence>
- <xs:element type="appenderType" name="appender" maxOccurs="unbounded" minOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="appender-refType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="ref" use="required"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="loggerType">
- <xs:sequence>
- <xs:choice minOccurs="0" maxOccurs="1">
- <xs:element type="filtersType" name="filters"/>
- <xs:element type="filterType" name="filter"/>
- </xs:choice>
- <xs:element type="appender-refType" name="appender-ref"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="name" use="required"/>
- <xs:attribute type="xs:string" name="level" use="optional"/>
- <xs:attribute type="xs:string" name="additivity" use="optional"/>
- </xs:complexType>
- <xs:complexType name="filterType" mixed="true">
- <xs:sequence>
- <xs:element type="KeyValuePairType" name="KeyValuePair" minOccurs="0"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="type" use="required"/>
- <xs:attribute type="xs:string" name="level" use="optional"/>
- <xs:attribute type="xs:string" name="marker" use="optional"/>
- <xs:attribute type="xs:string" name="onMatch" use="optional"/>
- <xs:attribute type="xs:string" name="onMismatch" use="optional"/>
- </xs:complexType>
- <xs:complexType name="filtersType">
- <xs:sequence>
- <xs:element type="filterType" name="filter" maxOccurs="unbounded" minOccurs="0"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="loggersType" mixed="true">
- <xs:sequence>
- <xs:element type="loggerType" name="logger" maxOccurs="unbounded" minOccurs="0"/>
- <xs:element type="rootType" name="root" maxOccurs="1" minOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="layoutType" mixed="true">
- <xs:sequence>
- <xs:element type="xs:string" name="pattern" minOccurs="0"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="type" use="required"/>
- <xs:attribute type="xs:string" name="pattern" use="optional"/>
- </xs:complexType>
-</xs:schema>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/main/resources/META-INF/LICENSE b/rgoers/log4j2-core/src/main/resources/META-INF/LICENSE
deleted file mode 100644
index 6279e52..0000000
--- a/rgoers/log4j2-core/src/main/resources/META-INF/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- 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/rgoers/log4j2-core/src/main/resources/META-INF/NOTICE b/rgoers/log4j2-core/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index 6233b56..0000000
--- a/rgoers/log4j2-core/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache log4j Enhanced PatternLayout for log4j 1.2.x
-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/rgoers/log4j2-core/src/main/resources/META-INF/log4j-provider.xml b/rgoers/log4j2-core/src/main/resources/META-INF/log4j-provider.xml
deleted file mode 100644
index b2c1275..0000000
--- a/rgoers/log4j2-core/src/main/resources/META-INF/log4j-provider.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
-<properties>
- <entry key="LoggerContextFactory">org.apache.logging.log4j.core.impl.Log4jContextFactory</entry>
- <entry key="Log4jAPIVersion">1.99.0</entry>
-</properties>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/site/resources/images/logo.jpg b/rgoers/log4j2-core/src/site/resources/images/logo.jpg
deleted file mode 100644
index 5b6ede8..0000000
--- a/rgoers/log4j2-core/src/site/resources/images/logo.jpg
+++ /dev/null
Binary files differ
diff --git a/rgoers/log4j2-core/src/site/resources/images/ls-logo.jpg b/rgoers/log4j2-core/src/site/resources/images/ls-logo.jpg
deleted file mode 100755
index 611c5c3..0000000
--- a/rgoers/log4j2-core/src/site/resources/images/ls-logo.jpg
+++ /dev/null
Binary files differ
diff --git a/rgoers/log4j2-core/src/site/site.xml b/rgoers/log4j2-core/src/site/site.xml
deleted file mode 100644
index 832d7b8..0000000
--- a/rgoers/log4j2-core/src/site/site.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project name="Component">
- <bannerLeft>
- <name>Logging Services</name>
- <src>../images/ls-logo.jpg</src>
- <href>../index.html</href>
- </bannerLeft>
- <bannerRight>
- <src>../images/logo.jpg</src>
- </bannerRight>
- <body>
- <links>
- <item name="Apache" href="http://www.apache.org/" />
- <item name="Logging Services" href="http://logging.apache.org/"/>
- <item name="Log4j" href="../index.html"/>
- </links>
- <menu ref="reports"/>
- </body>
-</project>
diff --git a/rgoers/log4j2-core/src/site/xdoc/index.xml b/rgoers/log4j2-core/src/site/xdoc/index.xml
deleted file mode 100644
index b36de16..0000000
--- a/rgoers/log4j2-core/src/site/xdoc/index.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4J 2.0 Implementation</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Log4j 2.0 Implementation">
-
- <p>
- The Log4Jj 2.0 implementation provides the functional components of the logging system. Users are
- free to create their own plugins and include them in the logging configuration.
- </p>
-
- </section>
-
- <section name="Requirements">
- <p>
- Log4j 2.0 requires Java 5 but has will take advantage of enhancements in Java 6 to improve performance.
- Some features may require optional dependencies. These dependencies are
- specified in the documentation for those features.
- </p>
- </section>
-
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/DebugDisabledPerformanceComparison.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/DebugDisabledPerformanceComparison.java
deleted file mode 100644
index 319d88b..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/DebugDisabledPerformanceComparison.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.core.util.Profiler;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-
-/**
- *
- */
-public class DebugDisabledPerformanceComparison {
-
- private Logger logger = LogManager.getLogger(DebugDisabledPerformanceComparison.class.getName());
- private org.slf4j.Logger logbacklogger = org.slf4j.LoggerFactory.getLogger(DebugDisabledPerformanceComparison.class);
- private org.apache.log4j.Logger log4jlogger = org.apache.log4j.Logger.getLogger(DebugDisabledPerformanceComparison.class);
-
-
- // How many times should we try to log:
- private static final int COUNT = 10000000;
- private static final int PROFILE_COUNT = 500000;
- private static final int WARMUP = 1000;
-
- private static final String CONFIG = "log4j2-perf2.xml";
- private static final String LOGBACK_CONFIG = "logback-perf2.xml";
- private static final String LOG4J_CONFIG = "log4j12-perf2.xml";
-
- private static final String LOGBACK_CONF = "logback.configurationFile";
- private static final String LOG4J_CONF = "log4j.configuration";
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- System.setProperty(LOGBACK_CONF, LOGBACK_CONFIG);
- System.setProperty(LOG4J_CONF, LOG4J_CONFIG);
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- System.clearProperty(LOGBACK_CONF);
- System.clearProperty(LOG4J_CONF);
- }
-
- @Test
- public void testPerformance() throws Exception {
-
- log4j(WARMUP);
- logback(WARMUP);
- log4j2(WARMUP);
-
- if (Profiler.isActive()) {
- System.out.println("Profiling Log4j 2.0");
- Profiler.start();
- long result = log4j2(PROFILE_COUNT);
- Profiler.stop();
- System.out.println("###############################################");
- System.out.println("Log4j 2.0: " + result);
- System.out.println("###############################################");
- } else {
- System.out.println("Starting isDebugEnabled tests");
- System.out.println("Starting Log4j 2.0");
- long result3 = log4j2IsDebug(COUNT);
- System.out.println("Starting Log4j");
- long result1 = log4j2IsDebug(COUNT);
- System.out.println("Starting Logback");
- long result2 = logbackIsDebug(COUNT );
-
- System.out.println("###############################################");
- System.out.println("Log4j: " + result1);
- System.out.println("Logback: " + result2);
- System.out.println("Log4j 2.0: " + result3);
- System.out.println("###############################################");
-
- System.out.println("Starting logger.debug tests with String concatenation");
- System.out.println("Starting Log4j 2.0");
- result3 = log4j2(COUNT);
- System.out.println("Starting Log4j");
- result1 = log4j(COUNT);
- System.out.println("Starting Logback");
- result2 = logback(COUNT);
-
- System.out.println("###############################################");
- System.out.println("Log4j: " + result1);
- System.out.println("Logback: " + result2);
- System.out.println("Log4j 2.0: " + result3);
- System.out.println("###############################################");
-
- System.out.println("Starting logger.debug tests without String concatenation");
- System.out.println("Starting Log4j 2.0");
- result3 = log4j2Debug(COUNT);
- System.out.println("Starting Logback");
- result2 = logbackDebug(COUNT);
-
- System.out.println("###############################################");
- System.out.println("Log4j: Not supported");
- System.out.println("Logback: " + result2);
- System.out.println("Log4j 2.0: " + result3);
- System.out.println("###############################################");
- }
- }
-
- //@Test
- public void testRawPerformance() throws Exception {
- OutputStream os = new FileOutputStream("target/testos.log", true);
- long result1 = writeToStream(COUNT, os);
- os.close();
- OutputStream bos = new BufferedOutputStream(new FileOutputStream("target/testbuffer.log", true));
- long result2 = writeToStream(COUNT, bos);
- bos.close();
- Writer w = new FileWriter("target/testwriter.log", true);
- long result3 = writeToWriter(COUNT, w);
- w.close();
- FileOutputStream cos = new FileOutputStream("target/testchannel.log", true);
- FileChannel channel = cos.getChannel();
- long result4 = writeToChannel(COUNT, channel);
- cos.close();
- System.out.println("###############################################");
- System.out.println("FileOutputStream: " + result1);
- System.out.println("BufferedOutputStream: " + result2);
- System.out.println("FileWriter: " + result3);
- System.out.println("FileChannel: " + result4);
- System.out.println("###############################################");
- }
-
-
- private long log4jIsDebug(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- log4jlogger.isDebugEnabled();
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private long logbackIsDebug(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- logbacklogger.isDebugEnabled();
- }
- return (System.nanoTime() - start) / loop;
- }
-
-
- private long log4j2IsDebug(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- logger.isDebugEnabled();
- }
- return (System.nanoTime() - start) / loop;
- }
-
-
-
- private long log4j(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- log4jlogger.debug("SEE IF THIS IS LOGGED " + j + ".");
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private long logback(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- logbacklogger.debug("SEE IF THIS IS LOGGED " + j + ".");
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private long logbackDebug(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- logbacklogger.debug("SEE IF THIS IS LOGGED {} .", j);
- }
- return (System.nanoTime() - start) / loop;
- }
-
-
- private long log4j2(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- logger.debug("SEE IF THIS IS LOGGED " + j + ".");
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private long log4j2Debug(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- logger.debug("SEE IF THIS IS LOGGED {} .", j);
- }
- return (System.nanoTime() - start) / loop;
- }
-
-
- private long writeToWriter(int loop, Writer w) throws Exception {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- w.write("SEE IF THIS IS LOGGED " + j + ".");
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private long writeToStream(int loop, OutputStream os) throws Exception {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- os.write(getBytes("SEE IF THIS IS LOGGED " + j + "."));
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private long writeToChannel(int loop, FileChannel channel) throws Exception {
- Integer j = new Integer(2);
- ByteBuffer buf = ByteBuffer.allocateDirect(8*1024);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- channel.write(getByteBuffer(buf, "SEE IF THIS IS LOGGED " + j + "."));
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private ByteBuffer getByteBuffer(ByteBuffer buf, String s) {
- buf.clear();
- buf.put(s.getBytes());
- buf.flip();
- return buf;
- }
-
- private byte[] getBytes(String s) {
- return s.getBytes();
- }
-
-}
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/FilterPerformanceComparison.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/FilterPerformanceComparison.java
deleted file mode 100644
index 1747d80..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/FilterPerformanceComparison.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.core.util.Profiler;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-
-/**
- *
- */
-public class FilterPerformanceComparison {
-
- private Logger logger = LogManager.getLogger(FilterPerformanceComparison.class.getName());
- private org.slf4j.Logger logbacklogger = org.slf4j.LoggerFactory.getLogger(FilterPerformanceComparison.class);
-
-
- // How many times should we try to log:
- private static final int COUNT = 10000000;
- private static final int THREADED_COUNT = 100000;
- private static final int WARMUP = 1000;
-
- private static final String CONFIG = "log4j2-perf-filter.xml";
- private static final String LOGBACK_CONFIG = "logback-perf-filter.xml";
-
- private static final String LOGBACK_CONF = "logback.configurationFile";
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- System.setProperty(LOGBACK_CONF, LOGBACK_CONFIG);
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- System.clearProperty(LOGBACK_CONF);
- }
-
- @Test
- public void testPerformance() throws Exception {
- logback(WARMUP);
- log4j2(WARMUP);
-
- System.out.println("Starting Log4j 2.0");
- long result3 = log4j2(COUNT);
- System.out.println("Starting Logback");
- long result2 = logback(COUNT);
-
- System.out.println("###############################################");
- System.out.println("Logback: " + result2);
- System.out.println("Log4j 2.0: " + result3);
- System.out.println("###############################################");
- }
-
- @Test
- public void testThreads() throws Exception {
- System.out.println("Testing multithreading");
- int threadedCount = COUNT; // THREADED_COUNT * threadCount < COUNT ? COUNT / threadCount : THREADED_COUNT;
- int[] threadCounts = new int[] {1, 2, 5, 10, 20, 50};
- for (int threadCount : threadCounts) {
- System.out.println("Testing " + threadCount + " threads");
- Worker[] workers = new Worker[threadCount];
- long[] results = new long[threadCount];
- for (int i=0; i < threadCount; ++i) {
- workers[i] = new Worker(true, threadedCount, results, i);
- }
- for (int i=0; i < threadCount; ++i) {
- workers[i].start();
- }
- long total = 0;
- for (int i=0; i < threadCount; ++i) {
- workers[i].join();
- total += results[i];
- }
- long result3 = total / threadCount;
- total = 0;
- for (int i=0; i < threadCount; ++i) {
- workers[i] = new Worker(false, threadedCount, results, i);
- }
- for (int i=0; i < threadCount; ++i) {
- workers[i].start();
- }
- for (int i=0; i < threadCount; ++i) {
- workers[i].join();
- total += results[i];
- }
- long result2 = total / threadCount;
- System.out.println("###############################################");
- System.out.println("Logback: " + result2);
- System.out.println("Log4j 2.0: " + result3 );
- System.out.println("###############################################");
- }
-
- }
-
- private long logback(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- logbacklogger.debug("SEE IF THIS IS LOGGED {}.", j);
- }
- return (System.nanoTime() - start) / loop;
- }
-
-
- private long log4j2(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- logger.debug("SEE IF THIS IS LOGGED {}.", j);
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private class Worker extends Thread {
-
- private boolean isLog4j;
- private int count;
- private long[] results;
- private int index;
-
- public Worker(boolean isLog4j, int count, long[] results, int index) {
- this.isLog4j = isLog4j;
- this.count = count;
- this.results = results;
- this.index = index;
- }
-
- public void run() {
- results[index] = isLog4j ? log4j2(count) : logback(count);
- }
- }
-
-}
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/LogbackSubstitution.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/LogbackSubstitution.java
deleted file mode 100644
index 14f0e75..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/LogbackSubstitution.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- *
- */
-public class LogbackSubstitution {
-
- private static final String LOGBACK_CONF = "logback.configurationFile";
- private static final String LOGBACK_CONFIG = "logback-subst.xml";
- private XLogger xLogger = XLoggerFactory.getXLogger(LogbackSubstitution.class);
-
-
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(LOGBACK_CONF, LOGBACK_CONFIG);
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(LOGBACK_CONF);
- }
-
- @Test
- public void testSubst() {
- xLogger.debug("Hello, {}", "Log4j {}");
- xLogger.debug("Hello, {}");
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/PerformanceComparison.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/PerformanceComparison.java
deleted file mode 100644
index f54f910..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/PerformanceComparison.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.core.util.Profiler;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.charset.Charset;
-
-/**
- *
- */
-public class PerformanceComparison {
-
- private Logger logger = LogManager.getLogger(PerformanceComparison.class.getName());
- private org.slf4j.Logger logbacklogger = org.slf4j.LoggerFactory.getLogger(PerformanceComparison.class);
- private org.apache.log4j.Logger log4jlogger = org.apache.log4j.Logger.getLogger(PerformanceComparison.class);
-
-
- // How many times should we try to log:
- private static final int COUNT = 1000000;
- private static final int PROFILE_COUNT = 500000;
- private static final int WARMUP = 1000;
-
- private static final String CONFIG = "log4j2-perf.xml";
- private static final String LOGBACK_CONFIG = "logback-perf.xml";
- private static final String LOG4J_CONFIG = "log4j12-perf.xml";
-
- private static final String LOGBACK_CONF = "logback.configurationFile";
- private static final String LOG4J_CONF = "log4j.configuration";
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- System.setProperty(LOGBACK_CONF, LOGBACK_CONFIG);
- System.setProperty(LOG4J_CONF, LOG4J_CONFIG);
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- System.clearProperty(LOGBACK_CONF);
- System.clearProperty(LOG4J_CONF);
- }
-
- @Test
- public void testPerformance() throws Exception {
-
- log4j(WARMUP);
- logback(WARMUP);
- log4j2(WARMUP);
-
- if (Profiler.isActive()) {
- System.out.println("Profiling Log4j 2.0");
- Profiler.start();
- long result = log4j2(PROFILE_COUNT);
- Profiler.stop();
- System.out.println("###############################################");
- System.out.println("Log4j 2.0: " + result);
- System.out.println("###############################################");
- } else {
- System.out.println("Starting Log4j 2.0");
- long result3 = log4j2(COUNT);
- System.out.println("Starting Log4j");
- long result1 = log4j(COUNT);
- System.out.println("Starting Logback");
- long result2 = logback(COUNT);
-
- System.out.println("###############################################");
- System.out.println("Log4j: " + result1);
- System.out.println("Logback: " + result2);
- System.out.println("Log4j 2.0: " + result3);
- System.out.println("###############################################");
- }
- }
-
- //@Test
- public void testRawPerformance() throws Exception {
- OutputStream os = new FileOutputStream("target/testos.log", true);
- long result1 = writeToStream(COUNT, os);
- os.close();
- OutputStream bos = new BufferedOutputStream(new FileOutputStream("target/testbuffer.log", true));
- long result2 = writeToStream(COUNT, bos);
- bos.close();
- Writer w = new FileWriter("target/testwriter.log", true);
- long result3 = writeToWriter(COUNT, w);
- w.close();
- FileOutputStream cos = new FileOutputStream("target/testchannel.log", true);
- FileChannel channel = cos.getChannel();
- long result4 = writeToChannel(COUNT, channel);
- cos.close();
- System.out.println("###############################################");
- System.out.println("FileOutputStream: " + result1);
- System.out.println("BufferedOutputStream: " + result2);
- System.out.println("FileWriter: " + result3);
- System.out.println("FileChannel: " + result4);
- System.out.println("###############################################");
- }
-
- private long log4j(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- log4jlogger.debug("SEE IF THIS IS LOGGED " + j + ".");
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private long logback(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- logbacklogger.debug("SEE IF THIS IS LOGGED " + j + ".");
- }
- return (System.nanoTime() - start) / loop;
- }
-
-
- private long log4j2(int loop) {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- logger.debug("SEE IF THIS IS LOGGED " + j + ".");
- }
- return (System.nanoTime() - start) / loop;
- }
-
-
- private long writeToWriter(int loop, Writer w) throws Exception {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- w.write("SEE IF THIS IS LOGGED " + j + ".");
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private long writeToStream(int loop, OutputStream os) throws Exception {
- Integer j = new Integer(2);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- os.write(getBytes("SEE IF THIS IS LOGGED " + j + "."));
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private long writeToChannel(int loop, FileChannel channel) throws Exception {
- Integer j = new Integer(2);
- ByteBuffer buf = ByteBuffer.allocateDirect(8*1024);
- long start = System.nanoTime();
- for (int i = 0; i < loop; i++) {
- channel.write(getByteBuffer(buf, "SEE IF THIS IS LOGGED " + j + "."));
- }
- return (System.nanoTime() - start) / loop;
- }
-
- private ByteBuffer getByteBuffer(ByteBuffer buf, String s) {
- buf.clear();
- buf.put(s.getBytes());
- buf.flip();
- return buf;
- }
-
- private byte[] getBytes(String s) {
- return s.getBytes();
- }
-
-}
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/ReflectionComparison.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/ReflectionComparison.java
deleted file mode 100644
index 571237b..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/ReflectionComparison.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j;
-
-import org.apache.logging.log4j.core.Timer;
-import org.apache.logging.log4j.core.helpers.Loader;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import sun.reflect.Reflection;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Tests the cost of invoking Reflection.getCallerClass via reflection vs calling it directly.
- */
-public class ReflectionComparison {
-
- private static Method getCallerClass;
-
- private static final int COUNT = 1000000;
-
- @BeforeClass
- public static void setupCallerCheck() {
- try {
- ClassLoader loader = Loader.getClassLoader();
- Class clazz = loader.loadClass("sun.reflect.Reflection");
- Method[] methods = clazz.getMethods();
- for (Method method : methods) {
- int modifier = method.getModifiers();
- if (method.getName().equals("getCallerClass") && Modifier.isStatic(modifier)) {
- getCallerClass = method;
- break;
- }
- }
- } catch (ClassNotFoundException cnfe) {
- cnfe.printStackTrace();
- throw new RuntimeException(cnfe);
- }
- }
-
- @Test
- public void test1() {
- Timer timer = new Timer("Reflection", COUNT);
- timer.start();
- Object[] arr = new Object[1];
- arr[0] = 3;
- for (int i= 0; i < COUNT; ++i) {
- getCallerClass(arr);
- }
- timer.stop();
- System.out.println(timer.toString());
- }
-
-
- @Test
- public void test2() {
- Timer timer = new Timer("Reflection", COUNT);
- timer.start();
- for (int i= 0; i < COUNT; ++i) {
-
- Reflection.getCallerClass(3);
- }
- timer.stop();
- System.out.println(timer.toString());
- }
-
- private Class getCallerClass(Object[] array) {
- if (getCallerClass != null) {
- try {
- /*Object[] params = new Object[]{index}; */
- return (Class) getCallerClass.invoke(null, array);
- } catch (Exception ex) {
- fail(ex.getMessage());
- // logger.debug("Unable to determine caller class via Sun Reflection", ex);
- }
- }
- return null;
- }
-
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
deleted file mode 100644
index e24f94d..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/BasicConfigurationFactory.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.config.BaseConfiguration;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.xml.sax.InputSource;
-
-import java.net.URI;
-
-/**
- *
- */
-public class BasicConfigurationFactory extends ConfigurationFactory {
-
- public Configuration getConfiguration(String name, URI configLocation) {
- return new BasicConfiguration();
- }
-
- @Override
- public String[] getSupportedTypes() {
- return null;
- }
-
- @Override
- public Configuration getConfiguration(InputSource source) {
- return null;
- }
-
- public class BasicConfiguration extends BaseConfiguration {
-
- private static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";
-
- public BasicConfiguration() {
-
- LoggerConfig root = getRootLogger();
- String l = System.getProperty(DEFAULT_LEVEL);
- Level level = (l != null && Level.valueOf(l) != null) ? Level.valueOf(l) : Level.ERROR;
- root.setLevel(level);
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/BasicLoggingTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/BasicLoggingTest.java
deleted file mode 100644
index 4c0ebe4..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/BasicLoggingTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.junit.Test;
-
-/**
- *
- */
-public class BasicLoggingTest {
-
- @Test
- public void test1() {
- Logger logger = LogManager.getLogger(BasicLoggingTest.class.getName());
- logger.debug("debug not set");
- logger.error("Test message");
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
deleted file mode 100644
index abb0349..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class LoggerTest {
-
- private static final String CONFIG = "log4j-test2.xml";
- private static Configuration config;
- private static ListAppender app;
- private static LoggerContext ctx;
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- ctx = (LoggerContext) LogManager.getContext(false);
- config = ctx.getConfiguration();
- for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) {
- if (entry.getKey().equals("List")) {
- app = (ListAppender) entry.getValue();
- break;
- }
- }
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- }
-
- org.apache.logging.log4j.Logger logger = LogManager.getLogger("LoggerTest");
-
- @Test
- public void basicFlow() {
- logger.entry();
- logger.exit();
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 2, actual " + events.size(), events.size() == 2);
- app.clear();
- }
-
- @Test
- public void simpleFlow() {
- logger.entry(CONFIG);
- logger.exit(0);
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 2, actual " + events.size(), events.size() == 2);
- app.clear();
- }
-
- @Test
- public void throwing() {
- logger.throwing(new IllegalArgumentException("Test Exception"));
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-
- @Test
- public void catching() {
- try {
- throw new NullPointerException();
- } catch (Exception e) {
- logger.catching(e);
- }
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-
- @Test
- public void debug() {
- logger.debug("Debug message");
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-
- @Test
- public void debugObject() {
- logger.debug(new Date());
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-
- @Test
- public void debugWithParms() {
- logger.debug("Hello, {}", "World");
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-
- @Test
- public void mdc() {
-
- ThreadContext.put("TestYear", new Integer(2010).toString());
- logger.debug("Debug message");
- ThreadContext.clear();
- logger.debug("Debug message");
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 2, actual " + events.size(), events.size() == 2);
- app.clear();
- }
-
- @Test
- public void structuredData() {
- ThreadContext.put("loginId", "JohnDoe");
- ThreadContext.put("ipAddress", "192.168.0.120");
- ThreadContext.put("locale", Locale.US.getDisplayName());
- StructuredDataMessage msg = new StructuredDataMessage("Audit@18060", "Transfer Complete", "Transfer");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "123457");
- msg.put("Amount", "200.00");
- logger.info(MarkerManager.getMarker("EVENT"), msg);
- ThreadContext.clear();
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-}
-
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/SimplePerfTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/SimplePerfTest.java
deleted file mode 100644
index 2c17751..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/SimplePerfTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.DefaultConfiguration;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.Assert;
-
-import java.util.Random;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class SimplePerfTest {
-
- private static org.apache.logging.log4j.Logger logger = LogManager.getLogger(SimplePerfTest.class.getName());
- private volatile Level lvl = Level.DEBUG;
- private static final int LOOP_CNT = 10000000;
- private static final int WARMUP = 1000;
- private static long maxTime;
- private static Random rand = new SimpleRandom();
- private static int RAND_SIZE = 250;
- private static int[] values = new int[RAND_SIZE];
-
- @BeforeClass
- public static void setupClass() {
-
- Configuration config = ((LoggerContext)LogManager.getContext()).getConfiguration();
- if (!DefaultConfiguration.DEFAULT_NAME.equals(config.getName())) {
- System.out.println("Configuration was " + config.getName());
- ((LoggerContext)LogManager.getContext()).setConfiguration(new DefaultConfiguration());
- }
-
- for (int i=0; i < WARMUP; ++i) {
- overhead();
- }
- System.gc();
- Timer timer = new Timer("Setup", LOOP_CNT);
- timer.start();
- for (int i=0; i < (LOOP_CNT / 150); ++i) {
- overhead();
- }
- timer.stop();
- maxTime = timer.getElapsedNanoTime();
- System.gc();
- System.out.println(timer.toString());
- }
-
- @Test
- public void debugDisabled() {
- System.gc();
- Timer timer = new Timer("DebugDisabled", LOOP_CNT);
- timer.start();
- for (int i=0; i < LOOP_CNT; ++i) {
- logger.isDebugEnabled();
- }
- timer.stop();
- System.out.println(timer.toString());
- assertTrue("Timer exceeded max time of " + maxTime, maxTime > timer.getElapsedNanoTime());
- }
-
- @Test
- public void debugLogger() {
- System.gc();
- Timer timer = new Timer("DebugLogger", LOOP_CNT);
- String msg = "This is a test";
- timer.start();
- for (int i=0; i < LOOP_CNT; ++i) {
- logger.debug(msg);
- }
- timer.stop();
- System.out.println(timer.toString());
- assertTrue("Timer exceeded max time of " + maxTime, maxTime > timer.getElapsedNanoTime());
- }
- /*
- @Test
- public void errorLogger() {
- Timer timer = new Timer("ErrorLogger", 10);
- timer.start();
- for (int i=0; i < 10; ++i) {
- logger.error("This is a test");
- }
- timer.stop();
- System.out.println(timer.toString());
- } */
-
- /*
- * Try to generate some overhead that can't be optimized well. Not sure how accurate this is,
- * but the point is simply to insure that changes made don't suddenly cause performance issues.
- */
- private static void overhead() {
- int values[] = new int[RAND_SIZE];
- Random rand = new SimpleRandom();
-
- for (int i = 0; i < RAND_SIZE; ++i) {
- values[i] = rand.nextInt();
- }
- bubbleSort(values);
- }
-
- private static class SimpleRandom extends Random {
- private int low = 5;
- private int high = 55;
-
- public int nextInt() {
- high = 36969 * (high & 65535) + (high >> 16);
- low = 18000 * (low & 65535) + (low >> 16);
- return (high << 16) + low;
- }
- }
-
- /**
- * Standard BubbleSort algorithm.
- * @param array The array to sort.
- */
- private static void bubbleSort(int array[]) {
- int length = array.length;
- for (int i = 0; i < length; i++) {
- for (int j = 1; j > length - i; j++) {
- if (array[j-1] > array[j]) {
- int temp = array[j-1];
- array[j-1] = array[j];
- array[j] = temp;
- }
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/StrictXMLConfigTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/StrictXMLConfigTest.java
deleted file mode 100644
index d2114bf..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/StrictXMLConfigTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class StrictXMLConfigTest {
-
- private static final String CONFIG = "log4j-strict1.xml";
- private static Configuration config;
- private static ListAppender app;
- private static LoggerContext ctx;
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- ctx = (LoggerContext) LogManager.getContext(false);
- config = ctx.getConfiguration();
- for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) {
- if (entry.getKey().equals("List")) {
- app = (ListAppender) entry.getValue();
- break;
- }
- }
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- }
-
- org.apache.logging.log4j.Logger logger = LogManager.getLogger("LoggerTest");
-
- @Test
- public void basicFlow() {
- logger.entry();
- logger.exit();
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 2, actual " + events.size(), events.size() == 2);
- app.clear();
- }
-
- @Test
- public void simpleFlow() {
- logger.entry(CONFIG);
- logger.exit(0);
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 2, actual " + events.size(), events.size() == 2);
- app.clear();
- }
-
- @Test
- public void throwing() {
- logger.throwing(new IllegalArgumentException("Test Exception"));
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-
- @Test
- public void catching() {
- try {
- throw new NullPointerException();
- } catch (Exception e) {
- logger.catching(e);
- }
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-
- @Test
- public void debug() {
- logger.debug("Debug message");
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-
- @Test
- public void debugObject() {
- logger.debug(new Date());
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-
- @Test
- public void debugWithParms() {
- logger.debug("Hello, {}", "World");
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-
- @Test
- public void mdc() {
-
- ThreadContext.put("TestYear", new Integer(2010).toString());
- logger.debug("Debug message");
- ThreadContext.clear();
- logger.debug("Debug message");
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 2, actual " + events.size(), events.size() == 2);
- app.clear();
- }
-
- @Test
- public void structuredData() {
- ThreadContext.put("loginId", "JohnDoe");
- ThreadContext.put("ipAddress", "192.168.0.120");
- ThreadContext.put("locale", Locale.US.getDisplayName());
- StructuredDataMessage msg = new StructuredDataMessage("Audit@18060", "Transfer Complete", "Transfer");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "123457");
- msg.put("Amount", "200.00");
- logger.info(MarkerManager.getMarker("EVENT"), msg);
- ThreadContext.clear();
- List<LogEvent> events = app.getEvents();
- assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size() == 1);
- app.clear();
- }
-}
-
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/ThreadedPerfTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/ThreadedPerfTest.java
deleted file mode 100644
index e6e3f76..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/ThreadedPerfTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.Test;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- *
- */
-public class ThreadedPerfTest {
-
- private static org.apache.logging.log4j.Logger logger = LogManager.getLogger(ThreadedPerfTest.class.getName());
- private volatile Level lvl = Level.DEBUG;
- private static final int LOOP_CNT = 10000000;
- private static final int THREADS = 10;
-
- @Test
- public void debugDisabled() {
- Timer timer = new Timer("DebugDisabled", LOOP_CNT * THREADS);
- Runnable runnable = new DebugDisabledRunnable();
- ExecutorService pool = Executors.newFixedThreadPool(THREADS);
- timer.start();
- for (int i=0; i < THREADS; ++i) {
- pool.execute(runnable);
- }
- pool.shutdown();
- timer.stop();
- System.out.println(timer.toString());
- }
-
- @Test
- public void debugLogger() {
- Timer timer = new Timer("DebugLogger", LOOP_CNT * THREADS);
- Runnable runnable = new DebugLoggerRunnable();
- ExecutorService pool = Executors.newFixedThreadPool(THREADS);
- timer.start();
- for (int i=0; i < THREADS; ++i) {
- pool.execute(runnable);
- }
- pool.shutdown();
- timer.stop();
- System.out.println(timer.toString());
- }
-
- public class DebugDisabledRunnable implements Runnable {
- public void run() {
- for (int i=0; i < LOOP_CNT; ++i) {
- logger.isDebugEnabled();
- }
- }
- }
-
- public class DebugLoggerRunnable implements Runnable {
- public void run() {
- for (int i=0; i < LOOP_CNT; ++i) {
- logger.debug("This is a test");
- }
- }
- }
-}
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/Timer.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/Timer.java
deleted file mode 100644
index 508dc16..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/Timer.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core;
-
-import java.io.Serializable;
-import java.text.DecimalFormat;
-
-/**
- *
- */
-public class Timer implements Serializable
-{
- private String m_name; // The timer's name
- private String m_status; // The timer's status
- private long m_startTime; // The start time
- private long m_elapsedTime; // The elapsed time
- private int m_iterations;
- private static long NANO_PER_SECOND = 1000000000L;
- private static long NANO_PER_MINUTE = NANO_PER_SECOND * 60;
- private static long NANO_PER_HOUR = NANO_PER_MINUTE * 60;
-
-
- /**
- * Constructor.
- * @param name the timer name.
- */
- public Timer(String name)
- {
- this(name, 0);
- }
-
- /**
- * Constructor.
- *
- * @param name the timer name.
- */
- public Timer(String name, int iterations)
- {
- m_name = name;
- m_startTime = 0;
- m_status = "Stopped";
- m_iterations = (iterations > 0) ? iterations : 0;
- }
-
- /**
- * Start the timer.
- */
- public void start()
- {
- m_startTime = System.nanoTime();
- m_elapsedTime = 0;
- m_status = "Start";
- }
-
- /**
- * Stop the timer.
- */
- public void stop()
- {
- m_elapsedTime += System.nanoTime() - m_startTime;
- m_startTime = 0;
- m_status = "Stop";
- }
-
- /**
- * Pause the timer.
- */
- public void pause()
- {
- m_elapsedTime += System.nanoTime() - m_startTime;
- m_startTime = 0;
- m_status = "Pause";
- }
-
- /**
- * Resume the timer.
- */
- public void resume()
- {
- m_startTime = System.nanoTime();
- m_status = "Resume";
- }
-
- /**
- * Accessor for the name.
- * @return the timer's name.
- */
- public String getName()
- {
- return m_name;
- }
-
- /**
- * Access the elapsed time.
- *
- * @return the elapsed time.
- */
- public long getElapsedTime()
- {
- return m_elapsedTime / 1000000;
- }
-
- /**
- * Access the elapsed time.
- *
- * @return the elapsed time.
- */
- public long getElapsedNanoTime()
- {
- return m_elapsedTime;
- }
-
- /**
- * Return the name of the last operation performed on this timer (Start, Stop, Pause or
- * Resume).
- * @return the string representing the last operation performed.
- */
- public String getStatus()
- {
- return m_status;
- }
-
- /**
- * Return the String representation of the timer based upon its current state
- */
- public String toString()
- {
- StringBuilder result = new StringBuilder("Timer ").append(m_name);
- if (m_status.equals("Start"))
- {
- result.append(" started");
- }
- else if (m_status.equals("Pause"))
- {
- result.append(" paused");
- }
- else if (m_status.equals("Resume"))
- {
- result.append(" resumed");
- }
- else if (m_status.equals("Stop"))
- {
- long nanoseconds = m_elapsedTime;
- // Get elapsed hours
- long hours = nanoseconds / NANO_PER_HOUR;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_HOUR;
- // Get minutes
- long minutes = nanoseconds / NANO_PER_MINUTE;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_MINUTE;
- // Get seconds
- long seconds = nanoseconds / NANO_PER_SECOND;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_SECOND;
-
- String elapsed = "";
-
- if (hours > 0)
- {
- elapsed += hours + " hours ";
- }
- if (minutes > 0 || hours > 0)
- {
- elapsed += minutes + " minutes ";
- }
-
- DecimalFormat numFormat = null;
- numFormat = new DecimalFormat("#0");
- elapsed += numFormat.format(seconds) + ".";
- numFormat = new DecimalFormat("000000000");
- elapsed += numFormat.format(nanoseconds) + " seconds";
- result.append(" stopped. Elapsed time: ").append(elapsed);
- if (m_iterations > 0)
- {
- nanoseconds = m_elapsedTime / m_iterations;
- // Get elapsed hours
- hours = nanoseconds / NANO_PER_HOUR;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_HOUR;
- // Get minutes
- minutes = nanoseconds / NANO_PER_MINUTE;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_MINUTE;
- // Get seconds
- seconds = nanoseconds / NANO_PER_SECOND;
- // Get remaining nanoseconds
- nanoseconds = nanoseconds % NANO_PER_SECOND;
-
- elapsed = "";
-
- if (hours > 0)
- {
- elapsed += hours + " hours ";
- }
- if (minutes > 0 || hours > 0)
- {
- elapsed += minutes + " minutes ";
- }
-
- numFormat = new DecimalFormat("#0");
- elapsed += numFormat.format(seconds) + ".";
- numFormat = new DecimalFormat("000000000");
- elapsed += numFormat.format(nanoseconds) + " seconds";
- result.append(" Average per iteration: ").append(elapsed);
- }
- }
- else
- {
- result.append(" ").append(m_status);
- }
- return result.toString();
- }
-
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof Timer)) return false;
-
- final Timer timer = (Timer) o;
-
- if (m_elapsedTime != timer.m_elapsedTime) return false;
- if (m_startTime != timer.m_startTime) return false;
- if (m_name != null ? !m_name.equals(timer.m_name) : timer.m_name != null) return false;
- if (m_status != null ? !m_status.equals(timer.m_status) : timer.m_status != null) return false;
-
- return true;
- }
-
- public int hashCode() {
- int result;
- result = (m_name != null ? m_name.hashCode() : 0);
- result = 29 * result + (m_status != null ? m_status.hashCode() : 0);
- result = 29 * result + (int) (m_startTime ^ (m_startTime >>> 32));
- result = 29 * result + (int) (m_elapsedTime ^ (m_elapsedTime >>> 32));
- return result;
- }
-
-}
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
deleted file mode 100644
index 7aedb3f..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-
-/**
- *
- */
-public class FailoverAppenderTest {
- private static final String CONFIG = "log4j-failover.xml";
- private static Configuration config;
- private static ListAppender app;
- private static LoggerContext ctx;
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- ctx = (LoggerContext) LogManager.getContext(false);
- config = ctx.getConfiguration();
- for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) {
- if (entry.getKey().equals("List")) {
- app = (ListAppender) entry.getValue();
- break;
- }
- }
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- }
-
- org.apache.logging.log4j.Logger logger = LogManager.getLogger("LoggerTest");
-
- @Test
- public void testFailover() {
- logger.error("This is a test");
- List<LogEvent> events = app.getEvents();
- assertNotNull(events);
- assertTrue("Incorrect number of events. Should be 1 is " + events.size(), events.size() == 1);
- app.clear();
- logger.error("This is a test");
- events = app.getEvents();
- assertNotNull(events);
- assertTrue("Incorrect number of events. Should be 1 is " + events.size(), events.size() == 1);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
deleted file mode 100644
index 7f12899..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class FileAppenderTest {
-
- private static final String FILENAME = "target/fileAppenderTest.log";
- private static final int THREADS = 2;
-
- @BeforeClass
- public static void setupClass() {
- deleteFile();
- }
-
- @AfterClass
- public static void cleanupClass() {
- deleteFile();
- assertTrue("Manager for " + FILENAME + " not removed", !OutputStreamManager.hasManager(FILENAME));
- }
-
- @After
- public void teardown() {
- deleteFile();
- }
-
- @Test
- public void testAppender() throws Exception {
- writer(false, 1, "test");
- verifyFile(1);
- }
-
- @Test
- public void testLockingAppender() throws Exception {
- writer(true, 1, "test");
- verifyFile(1);
- }
-
- @Test
- public void testMultipleAppenders() throws Exception {
- ExecutorService pool = Executors.newFixedThreadPool(THREADS);
- int count = 10;
- Runnable runnable = new FileWriterRunnable(false, count);
- for (int i=0; i < THREADS; ++i) {
- pool.execute(runnable);
- }
- pool.shutdown();
- pool.awaitTermination(10, TimeUnit.SECONDS);
- verifyFile(THREADS * count);
- }
-
-
- @Test
- public void testMultipleLockedAppenders() throws Exception {
- ExecutorService pool = Executors.newFixedThreadPool(THREADS);
- int count = 10;
- Runnable runnable = new FileWriterRunnable(true, count);
- for (int i=0; i < THREADS; ++i) {
- pool.execute(runnable);
- }
- pool.shutdown();
- pool.awaitTermination(10, TimeUnit.SECONDS);
- verifyFile(THREADS * count);
- }
-
-
- //@Test
- public void testMultipleVMs() throws Exception {
-
- String classPath = System.getProperty("java.class.path");
- Integer count = 10;
- int processes = 3;
- Process[] process = new Process[processes];
- ProcessBuilder[] builders = new ProcessBuilder[processes];
- for (int index=0; index < processes; ++index) {
- builders[index] = new ProcessBuilder("java","-cp", classPath, ProcessTest.class.getName(),
- "Process " + index, count.toString(), "true");
- }
- for (int index=0; index < processes; ++index) {
- process[index] = builders[index].start();
- }
- for (int index=0; index < processes; ++index) {
- Process p = process[index];
- //System.out.println("Process " + index + " exited with " + p.waitFor());
- InputStream is = p.getInputStream();
- InputStreamReader isr = new InputStreamReader(is);
- BufferedReader br = new BufferedReader(isr);
- String line;
- while ((line = br.readLine()) != null) {
- System.out.println(line);
- }
-
- p.destroy();
- }
- verifyFile(count * processes);
- }
-
- private static void writer(boolean lock, int count, String name) throws Exception {
- Layout layout = PatternLayout.createLayout(PatternLayout.SIMPLE_CONVERSION_PATTERN, null, null, null);
- FileAppender app = FileAppender.createAppender(FILENAME, "true", Boolean.toString(lock), "test", "false",
- "false", "false", layout, null);
- Thread t = Thread.currentThread();
- app.start();
- assertTrue("Appender did not start", app.isStarted());
- for (int i=0; i < count; ++i) {
- LogEvent event = new Log4jLogEvent("TestLogger", null, FileAppenderTest.class.getName(), Level.INFO,
- new SimpleMessage("Test"), null, null, null, name, null, System.currentTimeMillis());
- try {
- app.append(event);
- t.sleep(25); // Give up control long enough for another thread/process to occasionally do something.
- } catch (Exception ex) {
- throw ex;
- }
- }
- app.stop();
- assertFalse("Appender did not stop", app.isStarted());
- }
-
- private void verifyFile(int count) throws Exception {
- //String expected = "[\\w]* \\[\\s*\\] INFO TestLogger - Test$";
- String expected = "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3} \\[[^\\]]*\\] INFO TestLogger - Test";
- Pattern pattern = Pattern.compile(expected);
- DataInputStream is = new DataInputStream(new BufferedInputStream(new FileInputStream(FILENAME)));
- int counter = 0;
- String str = "";
- while (is.available() != 0) {
- str = is.readLine();
- //System.out.println(str);
- ++counter;
- Matcher matcher = pattern.matcher(str);
- assertTrue("Bad data: " + str, matcher.matches());
- }
- assertTrue("Incorrect count: was " + counter + " should be " + count, count == counter);
-
- }
-
-
- private static void deleteFile() {
- File file = new File(FILENAME);
- if (file.exists()) {
- file.delete();
- }
- }
-
- public class FileWriterRunnable implements Runnable {
- private final boolean lock;
- private final int count;
-
- public FileWriterRunnable(boolean lock, int count) {
- this.lock = lock;
- this.count = count;
- }
- public void run() {
- Thread thread = Thread.currentThread();
-
- try {
- writer(lock, count, thread.getName());
-
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
- }
-
- public static class ProcessTest {
-
- public static void main(String[] args) {
-
- if (args.length != 3) {
- System.out.println("Required arguments 'id', 'count' and 'lock' not provided");
- System.exit(-1);
- }
- String id = args[0];
-
- int count = Integer.parseInt(args[1]);
-
- if (count <= 0) {
- System.out.println("Invalid count value: " + args[1]);
- System.exit(-1);
- }
- boolean lock = Boolean.parseBoolean(args[2]);
-
- //System.out.println("Got arguments " + id + ", " + count + ", " + lock);
-
- try {
- writer(lock, count, id);
- //thread.sleep(50);
-
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
-
-
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamAppenderTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamAppenderTest.java
deleted file mode 100644
index 11e89f0..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamAppenderTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.message.SimpleMessage;
-
-import org.apache.logging.log4j.test.appender.InMemoryAppender;
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class OutputStreamAppenderTest {
-
-
- @Test
- public void testAppender() {
- Layout layout = PatternLayout.createLayout(null, null, null, null);
- InMemoryAppender app = new InMemoryAppender("test", layout, null, false);
- LogEvent event = new Log4jLogEvent("TestLogger", null, OutputStreamAppenderTest.class.getName(), Level.INFO,
- new SimpleMessage("Test"), null);
- app.start();
- assertTrue("Appender did not start", app.isStarted());
- app.append(event);
- String msg = app.toString();
- assertNotNull("No message", msg);
- assertTrue("Incorrect message: " + msg , msg.endsWith("Test\n"));
- app.stop();
- assertFalse("Appender did not stop", app.isStarted());
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java
deleted file mode 100644
index b433800..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderTest.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-
-/**
- *
- */
-public class SocketAppenderTest {
-
- private static final String HOST = "localhost";
- private static final String PORT = "8199";
- private static final int PORTNUM = Integer.parseInt(PORT);
-
- private static BlockingQueue<LogEvent> list = new ArrayBlockingQueue<LogEvent>(10);
-
- private static TCPSocketServer tcp;
- private static UDPSocketServer udp;
-
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("SocketAppenderTest");
-
- private static int tcpCount = 0;
- private static int udpCount = 0;
-
- @BeforeClass
- public static void setupClass() throws Exception {
- tcp = new TCPSocketServer();
- tcp.start();
- udp = new UDPSocketServer();
- udp.start();
- ((LoggerContext) LogManager.getContext()).reconfigure();
- }
-
- @AfterClass
- public static void cleanupClass() {
- tcp.shutdown();
- udp.shutdown();
- }
-
- @After
- public void teardown() {
- Map<String,Appender> map = root.getAppenders();
- for (Map.Entry<String, Appender> entry : map.entrySet()) {
- Appender app = entry.getValue();
- root.removeAppender(app);
- app.stop();
- }
- tcpCount = 0;
- udpCount = 0;
- }
-
- @Test
- public void testTCPAppender() throws Exception {
-
- SocketAppender appender = SocketAppender.createAppender("localhost", PORT, "tcp", "-1",
- "Test", null, null, null, null);
- appender.start();
-
- // set appender on root and set level to debug
- root.addAppender(appender);
- root.setAdditive(false);
- root.setLevel(Level.DEBUG);
- root.debug("This is a test message");
- LogEvent event = list.poll(3, TimeUnit.SECONDS);
- assertNotNull("No event retrieved", event);
- assertTrue("Incorrect event", event.getMessage().getFormattedMessage().equals("This is a test message"));
- assertTrue("Message not delivered via TCP", tcpCount > 0);
- }
-
-
- @Test
- public void testUDPAppender() throws Exception {
-
- SocketAppender appender = SocketAppender.createAppender("localhost", PORT, "udp", "-1",
- "Test", null, null, null, null);
- appender.start();
-
- // set appender on root and set level to debug
- root.addAppender(appender);
- root.setAdditive(false);
- root.setLevel(Level.DEBUG);
- root.debug("This is a test message");
- LogEvent event = list.poll(3, TimeUnit.SECONDS);
- assertNotNull("No event retrieved", event);
- assertTrue("Incorrect event", event.getMessage().getFormattedMessage().equals("This is a test message"));
- assertTrue("Message not delivered via UDP", udpCount > 0);
- }
-
- public static class UDPSocketServer extends Thread {
- private final DatagramSocket sock;
- private boolean shutdown = false;
- private Thread thread;
-
- public UDPSocketServer() throws IOException {
- this.sock = new DatagramSocket(PORTNUM);
- }
-
- public void shutdown() {
- this.shutdown = true;
- thread.interrupt();
- }
-
- public void run() {
- this.thread = Thread.currentThread();
- byte[] bytes = new byte[4096];
- DatagramPacket packet = new DatagramPacket(bytes, bytes.length);
- try {
- while (!shutdown) {
- sock.receive(packet);
- ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(packet.getData()));
- ++udpCount;
- list.add((LogEvent) ois.readObject());
- }
- } catch (Exception ex) {
- if (!shutdown) {
- throw new RuntimeException(ex);
- }
- }
- }
- }
-
- public static class TCPSocketServer extends Thread {
-
- private final ServerSocket sock;
- private boolean shutdown = false;
-
- public TCPSocketServer() throws IOException {
- this.sock = new ServerSocket(PORTNUM);
- }
-
- public void shutdown() {
- this.shutdown = true;
- interrupt();
- }
-
- public void run() {
- try {
- Socket socket = sock.accept();
- if (socket != null) {
- ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
- while (!shutdown) {
- list.add((LogEvent) ois.readObject());
- ++tcpCount;
- }
- }
- } catch (EOFException eof) {
- // Socket is closed.
- } catch (Exception ex) {
- if (!shutdown) {
- throw new RuntimeException(ex);
- }
- }
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/SyslogAppenderTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/SyslogAppenderTest.java
deleted file mode 100644
index aed434d..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/SyslogAppenderTest.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class SyslogAppenderTest {
-
- private static final String HOST = "localhost";
- private static final String PORT = "8199";
- private static final int PORTNUM = Integer.parseInt(PORT);
-
- private static BlockingQueue<String> list = new ArrayBlockingQueue<String>(10);
-
- private static TCPSocketServer tcp;
- private static UDPSocketServer udp;
-
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("SyslogAppenderTest");
-
- private static int tcpCount = 0;
- private static int udpCount = 0;
-
- private static final String line1 =
- "TestApp - Audit [Transfer@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"]" +
- "[RequestContext@18060 ipAddress=\"192.168.0.120\" loginId=\"JohnDoe\"] Transfer Complete\n";
-
- @BeforeClass
- public static void setupClass() throws Exception {
- tcp = new TCPSocketServer();
- tcp.start();
- udp = new UDPSocketServer();
- udp.start();
- ((LoggerContext) LogManager.getContext()).reconfigure();
- }
-
- @AfterClass
- public static void cleanupClass() {
- tcp.shutdown();
- udp.shutdown();
- }
-
- @After
- public void teardown() {
- Map<String,Appender> map = root.getAppenders();
- for (Map.Entry<String, Appender> entry : map.entrySet()) {
- Appender app = entry.getValue();
- root.removeAppender(app);
- app.stop();
- }
- tcpCount = 0;
- udpCount = 0;
- }
-
- @Test
- public void testTCPAppender() throws Exception {
- SyslogAppender appender = createAppender("tcp", "bsd");
- appender.start();
-
- // set appender on root and set level to debug
- root.addAppender(appender);
- root.setAdditive(false);
- root.setLevel(Level.DEBUG);
- root.debug("This is a test message");
- String msg = list.poll(3, TimeUnit.SECONDS);
- assertNotNull("No event retrieved", msg);
- assertTrue("Incorrect msg: " + msg, msg.endsWith("This is a test message\n"));
- assertTrue("Message not delivered via TCP", tcpCount > 0);
- root.debug("This is test message 2");
- msg = list.poll(3, TimeUnit.SECONDS);
- assertNotNull("No event retrieved", msg);
- assertTrue("Incorrect msg: " + msg, msg.endsWith("This is test message 2\n"));
- assertTrue("Message not delivered via TCP", tcpCount > 1);
- }
-
-
- @Test
- public void testTCPStructuredAppender() throws Exception {
- SyslogAppender appender = createAppender("tcp", "RFC5424");
- appender.start();
-
- // set appender on root and set level to debug
- root.addAppender(appender);
- root.setLevel(Level.DEBUG);
- root.setAdditive(false);
- ThreadContext.put("loginId", "JohnDoe");
- ThreadContext.put("ipAddress", "192.168.0.120");
- ThreadContext.put("locale", Locale.US.getDisplayName());
- StructuredDataMessage msg = new StructuredDataMessage("Transfer@18060", "Transfer Complete", "Audit");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "123457");
- msg.put("Amount", "200.00");
- root.info(MarkerManager.getMarker("EVENT"), msg);
- String str = list.poll(3, TimeUnit.SECONDS);
- assertNotNull("No event retrieved", str);
- assertTrue("Incorrect msg: " + str, str.endsWith(line1));
- assertTrue("Message not delivered via TCP", tcpCount > 0);
- }
-
-
- @Test
- public void testUDPAppender() throws Exception {
-
- SyslogAppender appender = createAppender("udp", "bsd");
- appender.start();
-
- // set appender on root and set level to debug
- root.addAppender(appender);
- root.setLevel(Level.DEBUG);
- root.setAdditive(false);
- root.debug("This is a test message");
- String str = list.poll(3, TimeUnit.SECONDS);
- assertNotNull("No event retrieved", str);
- assertTrue("Incorrect msg: " + str, str.endsWith("This is a test message\n"));
- assertTrue("Message not delivered via UDP", udpCount > 0);
- root.removeAppender(appender);
- appender.stop();
- }
-
-
- @Test
- public void testUDPStructuredAppender() throws Exception {
- SyslogAppender appender = createAppender("udp", "RFC5424");
- appender.start();
-
- // set appender on root and set level to debug
- root.addAppender(appender);
- root.setLevel(Level.DEBUG);
- root.setAdditive(false);
- ThreadContext.put("loginId", "JohnDoe");
- ThreadContext.put("ipAddress", "192.168.0.120");
- ThreadContext.put("locale", Locale.US.getDisplayName());
- StructuredDataMessage msg = new StructuredDataMessage("Transfer@18060", "Transfer Complete", "Audit");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "123457");
- msg.put("Amount", "200.00");
- root.info(MarkerManager.getMarker("EVENT"), msg);
- String str = list.poll(3, TimeUnit.SECONDS);
- assertNotNull("No event retrieved", str);
- assertTrue("Incorrect msg: " + str, str.endsWith(line1));
- assertTrue("Message not delivered via TCP", udpCount > 0);
- root.removeAppender(appender);
- appender.stop();
- }
-
- private SyslogAppender createAppender(String protocol, String format) {
- return SyslogAppender.createAppender("localhost", PORT, protocol, "-1", "Test", "true", "false", "LOCAL0", "Audit",
- "18060", "true", "RequestContext", "true", "TestApp", "Test", null, "ipAddress,loginId", null, format, null,
- null, null);
- }
-
- public static class UDPSocketServer extends Thread {
- private final DatagramSocket sock;
- private boolean shutdown = false;
- private Thread thread;
-
- public UDPSocketServer() throws IOException {
- this.sock = new DatagramSocket(PORTNUM);
- }
-
- public void shutdown() {
- this.shutdown = true;
- thread.interrupt();
- }
-
- public void run() {
- this.thread = Thread.currentThread();
- byte[] bytes = new byte[4096];
- DatagramPacket packet = new DatagramPacket(bytes, bytes.length);
- try {
- while (!shutdown) {
- sock.receive(packet);
- String str = new String(packet.getData(), 0, packet.getLength());
- ++udpCount;
- list.add(str);
- }
- } catch (Exception ex) {
- if (!shutdown) {
- throw new RuntimeException(ex);
- }
- }
- }
- }
-
- public static class TCPSocketServer extends Thread {
-
- private final ServerSocket sock;
- private boolean shutdown = false;
- private Thread thread;
-
- public TCPSocketServer() throws IOException {
- this.sock = new ServerSocket(PORTNUM);
- }
-
- public void shutdown() {
- this.shutdown = true;
- thread.interrupt();
- }
-
- public void run() {
- this.thread = Thread.currentThread();
- try {
- byte[] buffer = new byte[4096];
- while (!shutdown) {
- Socket socket = sock.accept();
- StringBuilder sb = new StringBuilder();
- if (socket != null) {
- InputStream in = socket.getInputStream();
- int i = in.read(buffer, 0, buffer.length);
- while (i != -1) {
- if (i < buffer.length) {
- String line = new String(buffer, 0, i);
- ++tcpCount;
- list.add(line);
- i = in.read(buffer, 0, buffer.length);
- } else if (i == 0) {
- System.out.println("No data received");
- } else {
- System.out.println("Message too long");
- }
- }
-
- socket.close();
- }
- }
- } catch (Exception ex) {
- if (!shutdown) {
- throw new RuntimeException(ex);
- }
- }
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
deleted file mode 100644
index 24c14d2..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rewrite;
-
-import org.apache.logging.log4j.EventLogger;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.message.MapMessage;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class RewriteAppenderTest {
- private static final String CONFIG = "log4j-rewrite.xml";
- private static Configuration config;
- private static ListAppender app;
- private static LoggerContext ctx;
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- ctx = (LoggerContext) LogManager.getContext(false);
- config = ctx.getConfiguration();
- for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) {
- if (entry.getKey().equals("List")) {
- app = (ListAppender) entry.getValue();
- break;
- }
- }
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- }
-
- @Test
- public void rewriteTest() {
- StructuredDataMessage msg = new StructuredDataMessage("Test", "This is a test", "Service");
- msg.put("Key1", "Value1");
- msg.put("Key2", "Value2");
- EventLogger.logEvent(msg);
- List<LogEvent> list = app.getEvents();
- assertNotNull("No events generated", list);
- assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
- LogEvent event = list.get(0);
- Message m = event.getMessage();
- assertTrue("Message is not a MapMessage", m instanceof MapMessage);
- MapMessage message = (MapMessage) m;
- Map<String, String> map = message.getData();
- assertNotNull("No Map", map);
- assertTrue("Incorrect number of map entries, expected 3 got " + map.size(), map.size() == 3);
- String value = map.get("Key1");
- assertEquals("Apache", value);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/TestRewritePolicy.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/TestRewritePolicy.java
deleted file mode 100644
index cbc2fd6..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/TestRewritePolicy.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rewrite;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.Message;
-
-import java.util.Map;
-
-/**
- *
- */
-@Plugin(name = "TestRewritePolicy", type = "Core", elementType = "rewritePolicy", printObject = true)
-public class TestRewritePolicy implements RewritePolicy {
-
- public LogEvent rewrite(LogEvent source) {
-
- return new Log4jLogEvent(source.getLoggerName(), source.getMarker(), source.getFQCN(), source.getLevel(),
- source.getMessage(), source.getThrown(), source.getContextMap(), source.getContextStack(),
- source.getThreadName(), source.getSource(), source.getMillis());
- }
-
- @PluginFactory
- public static TestRewritePolicy createPolicy() {
- return new TestRewritePolicy();
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
deleted file mode 100644
index 9477877..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.Test;
-
-import java.io.ByteArrayOutputStream;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class OnStartupTriggeringPolicyTest {
-
- @Test
- public void testPolicy() {
- MyRollingManager manager = new MyRollingManager();
- manager.setFileTime(System.currentTimeMillis() - 36000000);
- OnStartupTriggeringPolicy policy = OnStartupTriggeringPolicy.createPolicy();
- policy.initialize(manager);
- LogEvent event = new Log4jLogEvent(null, null, null, Level.ERROR, new SimpleMessage("Test"), null);
- assertTrue("Expected trigger to succeed", policy.isTriggeringEvent(event));
- assertTrue("Expected trigger not to fire", !policy.isTriggeringEvent(event));
- policy = OnStartupTriggeringPolicy.createPolicy();
- policy.initialize(manager);
- manager.setFileTime(System.currentTimeMillis());
- assertTrue("Expected trigger not to fire", !policy.isTriggeringEvent(event));
-
- }
-
- private class MyRollingManager extends RollingFileManager {
-
- private long timestamp;
-
- public MyRollingManager() {
- super("testfile", "target/rolling1/test1-%i.log.gz", new ByteArrayOutputStream(),
- false, 0, System.currentTimeMillis());
- }
-
- public void setFileTime(long timestamp) {
- this.timestamp = timestamp;
- }
-
- public long getFileTime() {
- return timestamp;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
deleted file mode 100644
index 0c4426a..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.Test;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-import java.io.File;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class RollingAppenderSizeTest {
-
- private static final String CONFIG = "log4j-rolling1.xml";
- private static final String DIR = "target/rolling1";
-
- org.apache.logging.log4j.Logger logger = LogManager.getLogger(RollingAppenderSizeTest.class.getName());
-
- @BeforeClass
- public static void setupClass() {
- deleteDir();
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Configuration config = ctx.getConfiguration();
- }
-
- @AfterClass
- public static void cleanupClass() {
- deleteDir();
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- }
-
- @Test
- public void testAppender() throws Exception {
- for (int i=0; i < 100; ++i) {
- logger.debug("This is test message number " + i);
- }
- File dir = new File(DIR);
- assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
- File[] files = dir.listFiles();
- assertTrue("No files created", files.length > 0);
- boolean found = false;
- for (File file : files) {
- if (file.getName().endsWith(".gz")) {
- found = true;
- }
- }
- assertTrue("No compressed files found", found);
- }
-
- private static void deleteDir() {
- File dir = new File(DIR);
- if (dir.exists()) {
- File[] files = dir.listFiles();
- for (File file : files) {
- file.delete();
- }
- dir.delete();
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
deleted file mode 100644
index bf46857..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.File;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class RollingAppenderTimeAndSizeTest {
-
- private static final String CONFIG = "log4j-rolling3.xml";
- private static final String DIR = "target/rolling3";
-
- org.apache.logging.log4j.Logger logger = LogManager.getLogger(RollingAppenderTimeAndSizeTest.class.getName());
-
- @BeforeClass
- public static void setupClass() {
- deleteDir();
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Configuration config = ctx.getConfiguration();
- }
-
- @AfterClass
- public static void cleanupClass() {
- deleteDir();
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- }
-
- @Test
- public void testAppender() throws Exception {
- for (int i=0; i < 100; ++i) {
- if (i % 11 == 0) {
- Thread.sleep(1000);
- }
- logger.debug("This is test message number " + i);
- }
- File dir = new File(DIR);
- assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
- File[] files = dir.listFiles();
- assertTrue("No files created", files.length > 0);
- boolean found = false;
- for (File file : files) {
- if (file.getName().endsWith(".gz")) {
- found = true;
- }
- }
- assertTrue("No compressed files found", found);
- }
-
- private static void deleteDir() {
- File dir = new File(DIR);
- if (dir.exists()) {
- File[] files = dir.listFiles();
- for (File file : files) {
- file.delete();
- }
- dir.delete();
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
deleted file mode 100644
index f9fc5c4..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.rolling;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.File;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class RollingAppenderTimeTest {
-
- private static final String CONFIG = "log4j-rolling2.xml";
- private static final String DIR = "target/rolling2";
-
- org.apache.logging.log4j.Logger logger = LogManager.getLogger(RollingAppenderTimeTest.class.getName());
-
- @BeforeClass
- public static void setupClass() {
- deleteDir();
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Configuration config = ctx.getConfiguration();
- }
-
- @AfterClass
- public static void cleanupClass() {
- deleteDir();
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- }
-
- @Test
- public void testAppender() throws Exception {
- for (int i=0; i < 100; ++i) {
- if (i % 11 == 0) {
- Thread.sleep(1000);
- }
- logger.debug("This is test message number " + i);
- }
- File dir = new File(DIR);
- assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
- File[] files = dir.listFiles();
- assertTrue("No files created", files.length > 0);
- boolean found = false;
- for (File file : files) {
- if (file.getName().endsWith(".gz")) {
- found = true;
- }
- }
- assertTrue("No compressed files found", found);
- }
-
- private static void deleteDir() {
- File dir = new File(DIR);
- if (dir.exists()) {
- File[] files = dir.listFiles();
- for (File file : files) {
- file.delete();
- }
- dir.delete();
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JSONRoutingAppender2Test.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JSONRoutingAppender2Test.java
deleted file mode 100644
index 7eb05b6..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JSONRoutingAppender2Test.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.routing;
-
-import org.apache.logging.log4j.EventLogger;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class JSONRoutingAppender2Test {
- private static final String CONFIG = "log4j-routing2.json";
- private static Configuration config;
- private static ListAppender app;
- private static LoggerContext ctx;
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- ctx = (LoggerContext) LogManager.getContext(false);
- config = ctx.getConfiguration();
- for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) {
- if (entry.getKey().equals("List")) {
- app = (ListAppender) entry.getValue();
- break;
- }
- }
- File file = new File("target/rolling1/rollingtest-Unknown.log");
- file.delete();
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- File file = new File("target/rolling1/rollingtest-Unknown.log");
- file.delete();
- }
-
- @Test
- public void routingTest() {
- StructuredDataMessage msg = new StructuredDataMessage("Test", "This is a test", "Service");
- EventLogger.logEvent(msg);
- List<LogEvent> list = app.getEvents();
- assertNotNull("No events generated", list);
- assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
- msg = new StructuredDataMessage("Test", "This is a test", "Unknown");
- EventLogger.logEvent(msg);
- File file = new File("target/rolling1/rollingtest-Unknown.log");
- assertTrue("File was not created", file.exists());
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JSONRoutingAppenderTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JSONRoutingAppenderTest.java
deleted file mode 100644
index 628a79e..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JSONRoutingAppenderTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.routing;
-
-import org.apache.logging.log4j.EventLogger;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class JSONRoutingAppenderTest {
- private static final String CONFIG = "log4j-routing.json";
- private static Configuration config;
- private static ListAppender app;
- private static LoggerContext ctx;
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- ctx = (LoggerContext) LogManager.getContext(false);
- config = ctx.getConfiguration();
- for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) {
- if (entry.getKey().equals("List")) {
- app = (ListAppender) entry.getValue();
- break;
- }
- }
- File file = new File("target/rolling1/rollingtest-Unknown.log");
- file.delete();
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- File file = new File("target/rolling1/rollingtest-Unknown.log");
- file.delete();
- }
-
- @Test
- public void routingTest() {
- StructuredDataMessage msg = new StructuredDataMessage("Test", "This is a test", "Service");
- EventLogger.logEvent(msg);
- List<LogEvent> list = app.getEvents();
- assertNotNull("No events generated", list);
- assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
- msg = new StructuredDataMessage("Test", "This is a test", "Unknown");
- EventLogger.logEvent(msg);
- File file = new File("target/rolling1/rollingtest-Unknown.log");
- assertTrue("File was not created", file.exists());
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java
deleted file mode 100644
index 5a6cc4b..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.appender.routing;
-
-import org.apache.logging.log4j.EventLogger;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class RoutingAppenderTest {
- private static final String CONFIG = "log4j-routing.xml";
- private static Configuration config;
- private static ListAppender app;
- private static LoggerContext ctx;
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- ctx = (LoggerContext) LogManager.getContext(false);
- config = ctx.getConfiguration();
- for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) {
- if (entry.getKey().equals("List")) {
- app = (ListAppender) entry.getValue();
- break;
- }
- }
- File file = new File("target/rolling1/rollingtest-Unknown.log");
- file.delete();
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- File file = new File("target/rolling1/rollingtest-Unknown.log");
- file.delete();
- }
-
- @Test
- public void routingTest() {
- StructuredDataMessage msg = new StructuredDataMessage("Test", "This is a test", "Service");
- EventLogger.logEvent(msg);
- List<LogEvent> list = app.getEvents();
- assertNotNull("No events generated", list);
- assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
- msg = new StructuredDataMessage("Test", "This is a test", "Unknown");
- EventLogger.logEvent(msg);
- File file = new File("target/rolling1/rollingtest-Unknown.log");
- assertTrue("File was not created", file.exists());
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/config/XMLConfigurationTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/config/XMLConfigurationTest.java
deleted file mode 100644
index cf513ba..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/config/XMLConfigurationTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.config;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.filter.ThreadContextMapFilter;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.BufferedInputStream;
-import java.io.DataInputStream;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.util.Iterator;
-import java.util.Map;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class XMLConfigurationTest {
-
- private static final String CONFIG = "log4j-test1.xml";
- private static final String LOGFILE = "target/test.log";
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Configuration config = ctx.getConfiguration();
- if (config instanceof XMLConfiguration) {
- String name = ((XMLConfiguration) config).getName();
- if (name == null || !name.equals("XMLConfigTest")) {
- ctx.reconfigure();
- }
- } else {
- ctx.reconfigure();
- }
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- }
-
- @Test
- public void testLogger() {
- Logger logger = LogManager.getLogger("org.apache.logging.log4j.test1.Test");
- assertTrue(logger instanceof org.apache.logging.log4j.core.Logger);
- org.apache.logging.log4j.core.Logger l = (org.apache.logging.log4j.core.Logger) logger;
- assertEquals(Level.DEBUG, l.getLevel());
- int filterCount = l.filterCount();
- assertTrue("number of filters - " + filterCount, filterCount == 1);
- Iterator<Filter> iter = l.getFilters();
- Filter filter = iter.next();
- assertTrue(filter instanceof ThreadContextMapFilter);
- Map<String, Appender> appenders = l.getAppenders();
- assertNotNull(appenders);
- assertTrue("number of appenders = " + appenders.size(), appenders.size() == 1);
- Appender a = appenders.get("STDOUT");
- assertNotNull(a);
- assertEquals(a.getName(), "STDOUT");
- }
-
- public void testConfiguredAppenders() {
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Configuration c = ctx.getConfiguration();
- Map<String, Appender> apps = c.getAppenders();
- assertNotNull(apps);
- assertEquals(apps.size(), 3);
- }
-
- @Test
- public void logToFile() throws Exception {
- FileOutputStream fos = new FileOutputStream(LOGFILE, false);
- fos.flush();
- fos.close();
- Logger logger = LogManager.getLogger("org.apache.logging.log4j.test2.Test");
- logger.debug("This is a test");
- DataInputStream is = new DataInputStream(new BufferedInputStream(new FileInputStream(LOGFILE)));
- int count = 0;
- String str = "";
- while (is.available() != 0) {
- str = is.readLine();
- ++count;
- }
- assertTrue("Incorrect count " + count, count == 1);
- assertTrue("Bad data", str.endsWith("This is a test"));
- }
-
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java
deleted file mode 100644
index 7451890..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/BurstFilterTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-/**
- * Unit test for <code>BurstFilter</code>.
- */
-public class BurstFilterTest {
-
- private static final String CONFIG = "log4j-burst.xml";
-
- private static Configuration config;
- private static ListAppender app;
- private static BurstFilter filter;
- private static LoggerContext ctx;
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- ctx = (LoggerContext) LogManager.getContext(false);
- config = ctx.getConfiguration();
- for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) {
- if (entry.getKey().equals("ListAppender")) {
- app = (ListAppender) entry.getValue();
- filter = (BurstFilter) app.getFilter();
- break;
- }
- }
- }
-
- private Logger logger = LogManager.getLogger(BurstFilterTest.class.getName());
-
- /**
- * Test BurstFilter by surpassing maximum number of log messages allowed by filter and
- * making sure only the maximum number are indeed logged, then wait for while and make
- * sure the filter allows the appropriate number of messages to be logged.
- */
- @Test
- public void test() throws Exception {
- assertNotNull("No ListAppender", app);
- assertNotNull("No BurstFilter", filter);
- // exceed the burst limit and make sure no more than 100 errors get logged
- long start = System.nanoTime();
- for (int i = 0; i < 110; i++) {
- if (i % 10 == 0) {
- Thread.sleep(200);
- }
- logger.info("Logging 110 messages, should only see 100 logs # " + (i + 1));
- assertTrue("Incorrect number of available slots", filter.getAvailable() < 100);
- }
- List<String> msgs = app.getMessages();
- assertTrue("Incorrect message count. Should be 100, actual " + msgs.size(), msgs.size() == 100);
- app.clear();
-
- assertTrue("Incorrect number of available slots", filter.getAvailable() < 100);
- // Allow some of the events to clear
- Thread.sleep(1500);
-
- for (int i = 0; i < 110; i++) {
- logger.info("Waited 1.5 seconds and trying to log again, should see more than 0 and less than 100" + (i + 1));
- }
-
- msgs = app.getMessages();
- assertTrue("Incorrect message count. Should be > 0 and < 100, actual " + msgs.size(),
- msgs.size() > 0 && msgs.size() < 100);
- app.clear();
-
- filter.clear();
-
- for (int i = 0; i < 110; i++) {
- logger.info("Waited 1.5 seconds and trying to log again, should see more than 0 and less than 100" + (i + 1));
- }
- assertTrue("", filter.getAvailable() == 0);
- app.clear();
-
-
- // now log 100 debugs, they shouldn't get through because there are no available slots.
- for (int i = 0; i < 110; i++) {
- logger.debug(
- "TEST FAILED! Logging 110 debug messages, shouldn't see any of them because they are debugs #" + (i + 1));
- }
-
- msgs = app.getMessages();
- assertTrue("Incorrect message count. Should be 0, actual " + msgs.size(), msgs.size() == 0);
- app.clear();
-
- // now log 100 warns, they should all get through because the filter's level is set at info
- for (int i = 0; i < 110; i++) {
- logger.warn("Logging 110 warn messages, should see all of them because they are warns #" + (i + 1));
- }
-
- msgs = app.getMessages();
- assertTrue("Incorrect message count. Should be 110, actual " + msgs.size(), msgs.size() == 110);
- app.clear();
-
- // now log 100 errors, they should all get through because the filter level is set at info
- for (int i = 0; i < 110; i++) {
- logger.error("Logging 110 error messages, should see all of them because they are errors #" + (i + 1));
- }
-
- msgs = app.getMessages();
- assertTrue("Incorrect message count. Should be 110, actual " + msgs.size(), msgs.size() == 110);
- app.clear();
-
- // now log 100 fatals, they should all get through because the filter level is set at info
- for (int i = 0; i < 110; i++) {
- logger.fatal("Logging 110 fatal messages, should see all of them because they are fatals #" + (i + 1));
- }
-
- msgs = app.getMessages();
- assertTrue("Incorrect message count. Should be 110, actual " + msgs.size(), msgs.size() == 110);
- app.clear();
-
- // wait and make sure we can log messages again despite the fact we just logged a bunch of warns, errors, fatals
- Thread.sleep(3100);
-
- for (int i = 0; i < 110; i++) {
- logger.debug("Waited 3+ seconds, should see 100 logs #" + (i + 1));
- }
- msgs = app.getMessages();
- assertTrue("Incorrect message count. Should be 100, actual " + msgs.size(), msgs.size() == 100);
- app.clear();
-
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java
deleted file mode 100644
index eea0b09..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class DynamicThresholdFilterTest {
-
- @Test
- public void testFilter() {
- ThreadContext.put("userid", "testuser");
- ThreadContext.put("organization", "apache");
- ValueLevelPair[] pairs = new ValueLevelPair[] { new ValueLevelPair("testuser", Level.DEBUG),
- new ValueLevelPair("JohnDoe", Level.WARN)};
- DynamicThresholdFilter filter = DynamicThresholdFilter.createFilter("userid", pairs, "ERROR", null, null);
- filter.start();
- assertTrue(filter.isStarted());
- assertTrue(filter.filter(null, Level.DEBUG, null, null, (Throwable)null) == Filter.Result.NEUTRAL);
- assertTrue(filter.filter(null, Level.ERROR, null, null, (Throwable)null) == Filter.Result.NEUTRAL);
- ThreadContext.clear();
- ThreadContext.put("userid", "JohnDoe");
- ThreadContext.put("organization", "apache");
- LogEvent event = new Log4jLogEvent(null, null, null, Level.DEBUG, new SimpleMessage("Test"), null);
- assertTrue(filter.filter(event) == Filter.Result.DENY);
- event = new Log4jLogEvent(null, null, null, Level.ERROR, new SimpleMessage("Test"), null);
- assertTrue(filter.filter(event) == Filter.Result.NEUTRAL);
- ThreadContext.clear();
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java
deleted file mode 100644
index dce55f9..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.helpers.KeyValuePair;
-import org.apache.logging.log4j.message.MapMessage;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class MapFilterTest {
-
-
- @Test
- public void testFilter() {
- KeyValuePair[] pairs = new KeyValuePair[] { new KeyValuePair("FromAccount", "211000"),
- new KeyValuePair("ToAccount", "123456")};
- MapFilter filter = MapFilter.createFilter(pairs, "and", null, null);
- filter.start();
- MapMessage msg = new MapMessage();
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "211000");
- msg.put("Amount", "1000.00");
- assertTrue(filter.isStarted());
- assertTrue(filter.filter(null, Level.DEBUG, null, msg, (Throwable)null) == Filter.Result.NEUTRAL);
- msg.put("ToAccount", "111111");
- assertTrue(filter.filter(null, Level.ERROR, null, msg, (Throwable)null) == Filter.Result.DENY);
- filter = MapFilter.createFilter(pairs, "or", null, null);
- filter.start();
- msg = new MapMessage();
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "211000");
- msg.put("Amount", "1000.00");
- assertTrue(filter.isStarted());
- assertTrue(filter.filter(null, Level.DEBUG, null, msg, (Throwable)null) == Filter.Result.NEUTRAL);
- msg.put("ToAccount", "111111");
- assertTrue(filter.filter(null, Level.ERROR, null, msg, (Throwable)null) == Filter.Result.NEUTRAL);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java
deleted file mode 100644
index dd5aeb0..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class MarkerFilterTest {
-
- @Test
- public void testMarkers() {
- Marker parent = MarkerManager.getMarker("Parent");
- Marker child = MarkerManager.getMarker("Child", parent);
- Marker grandChild = MarkerManager.getMarker("GrandChild", child);
- Marker sibling = MarkerManager.getMarker("Sibling", parent);
- Marker stranger = MarkerManager.getMarker("Stranger");
- MarkerFilter filter = MarkerFilter.createFilter("Parent", null, null);
- filter.start();
- assertTrue(filter.isStarted());
- assertTrue(filter.filter(null, null, stranger, null, (Throwable)null) == Filter.Result.DENY);
- assertTrue(filter.filter(null, null, child, null, (Throwable)null) == Filter.Result.NEUTRAL);
- LogEvent event = new Log4jLogEvent(null, grandChild, null, Level.DEBUG, new SimpleMessage("Test"), null);
- filter = MarkerFilter.createFilter("Child", null, null);
- assertTrue(filter.filter(event) == Filter.Result.NEUTRAL);
- event = new Log4jLogEvent(null, sibling, null, Level.DEBUG, new SimpleMessage("Test"), null);
- assertTrue(filter.filter(event) == Filter.Result.DENY);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java
deleted file mode 100644
index 5c760c7..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNull;
-
-/**
- *
- */
-public class RegexFilterTest {
-
- @Test
- public void testThresholds() {
- RegexFilter filter = RegexFilter.createFilter(".* test .*", null, null, null);
- filter.start();
- assertTrue(filter.isStarted());
- assertTrue(filter.filter(null, Level.DEBUG, null, "This is a test message", (Throwable)null) == Filter.Result.NEUTRAL);
- assertTrue(filter.filter(null, Level.ERROR, null, "This is not a test", (Throwable)null) == Filter.Result.DENY);
- LogEvent event = new Log4jLogEvent(null, null, null, Level.DEBUG, new SimpleMessage("Another test message"), null);
- assertTrue(filter.filter(event) == Filter.Result.NEUTRAL);
- event = new Log4jLogEvent(null, null, null, Level.ERROR, new SimpleMessage("test"), null);
- assertTrue(filter.filter(event) == Filter.Result.DENY);
- filter = RegexFilter.createFilter("* test *", null, null, null);
- assertNull(filter);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/StructuredDataFilterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/StructuredDataFilterTest.java
deleted file mode 100644
index 7ffc861..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/StructuredDataFilterTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.helpers.KeyValuePair;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class StructuredDataFilterTest {
-
-
- @Test
- public void testFilter() {
- KeyValuePair[] pairs = new KeyValuePair[] { new KeyValuePair("id.name", "AccountTransfer"),
- new KeyValuePair("ToAccount", "123456")};
- StructuredDataFilter filter = StructuredDataFilter.createFilter(pairs, "and", null, null);
- filter.start();
- StructuredDataMessage msg = new StructuredDataMessage("AccountTransfer@18060", "Transfer Successful", "Audit");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "211000");
- msg.put("Amount", "1000.00");
- assertTrue(filter.isStarted());
- assertTrue(filter.filter(null, Level.DEBUG, null, msg, (Throwable)null) == Filter.Result.NEUTRAL);
- msg.put("ToAccount", "111111");
- assertTrue(filter.filter(null, Level.ERROR, null, msg, (Throwable)null) == Filter.Result.DENY);
- filter = StructuredDataFilter.createFilter(pairs, "or", null, null);
- filter.start();
- msg = new StructuredDataMessage("AccountTransfer@18060", "Transfer Successful", "Audit");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "211000");
- msg.put("Amount", "1000.00");
- assertTrue(filter.isStarted());
- assertTrue(filter.filter(null, Level.DEBUG, null, msg, (Throwable)null) == Filter.Result.NEUTRAL);
- msg.put("ToAccount", "111111");
- assertTrue(filter.filter(null, Level.ERROR, null, msg, (Throwable)null) == Filter.Result.NEUTRAL);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java
deleted file mode 100644
index 10b8e6f..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/ThreadContextMapFilterTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.helpers.KeyValuePair;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-
-/**
- *
- */
-public class ThreadContextMapFilterTest {
-
- @Test
- public void testFilter() {
- ThreadContext.put("userid", "testuser");
- ThreadContext.put("organization", "Apache");
- KeyValuePair[] pairs = new KeyValuePair[] { new KeyValuePair("userid", "JohnDoe"),
- new KeyValuePair("organization", "Apache")};
- ThreadContextMapFilter filter = ThreadContextMapFilter.createFilter(pairs, "and", null, null);
- filter.start();
- assertTrue(filter.isStarted());
- assertTrue(filter.filter(null, Level.DEBUG, null, null, (Throwable)null) == Filter.Result.DENY);
- ThreadContext.remove("userid");
- assertTrue(filter.filter(null, Level.DEBUG, null, null, (Throwable)null) == Filter.Result.DENY);
- ThreadContext.put("userid", "JohnDoe");
- assertTrue(filter.filter(null, Level.ERROR, null, null, (Throwable)null) == Filter.Result.NEUTRAL);
- ThreadContext.put("organization", "ASF");
- assertTrue(filter.filter(null, Level.DEBUG, null, null, (Throwable)null) == Filter.Result.DENY);
- ThreadContext.clear();
- filter = ThreadContextMapFilter.createFilter(pairs, "or", null, null);
- filter.start();
- assertTrue(filter.isStarted());
- ThreadContext.put("userid", "testuser");
- ThreadContext.put("organization", "Apache");
- assertTrue(filter.filter(null, Level.DEBUG, null, null, (Throwable)null) == Filter.Result.NEUTRAL);
- ThreadContext.put("organization", "ASF");
- assertTrue(filter.filter(null, Level.DEBUG, null, null, (Throwable)null) == Filter.Result.DENY);
- ThreadContext.remove("organization");
- assertTrue(filter.filter(null, Level.DEBUG, null, null, (Throwable)null) == Filter.Result.DENY);
- ThreadContext.clear();
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/ThresholdFilterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/ThresholdFilterTest.java
deleted file mode 100644
index 9665027..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/ThresholdFilterTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class ThresholdFilterTest {
-
- @Test
- public void testThresholds() {
- ThresholdFilter filter = ThresholdFilter.createFilter("ERROR", null, null);
- filter.start();
- assertTrue(filter.isStarted());
- assertTrue(filter.filter(null, Level.DEBUG, null, null, (Throwable)null) == Filter.Result.DENY);
- assertTrue(filter.filter(null, Level.ERROR, null, null, (Throwable)null) == Filter.Result.NEUTRAL);
- LogEvent event = new Log4jLogEvent(null, null, null, Level.DEBUG, new SimpleMessage("Test"), null);
- assertTrue(filter.filter(event) == Filter.Result.DENY);
- event = new Log4jLogEvent(null, null, null, Level.ERROR, new SimpleMessage("Test"), null);
- assertTrue(filter.filter(event) == Filter.Result.NEUTRAL);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/TimeFilterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/TimeFilterTest.java
deleted file mode 100644
index 9e00582..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/TimeFilterTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.filter;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.junit.Test;
-
-import java.util.Calendar;
-import java.util.TimeZone;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class TimeFilterTest {
-
- @Test
- public void testTime() {
- TimeFilter filter = TimeFilter.createFilter("02:00:00", "03:00:00", "America/LosAngeles", null, null);
- filter.start();
- assertTrue(filter.isStarted());
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("America/LosAngeles"));
- cal.set(Calendar.HOUR_OF_DAY, 02);
- long tod = cal.getTimeInMillis();
- LogEvent event = new Log4jLogEvent(null, null, null, null, null, null, null, null, null, null, tod);
- assertTrue(filter.filter(null, Level.ERROR, null, null, (Throwable)null) == Filter.Result.NEUTRAL);
- assertTrue(filter.filter(event) == Filter.Result.NEUTRAL);
- cal.roll(Calendar.DAY_OF_MONTH, true);
- tod = cal.getTimeInMillis();
- event = new Log4jLogEvent(null, null, null, null, null, null, null, null, null, null, tod);
- assertTrue(filter.filter(event) == Filter.Result.NEUTRAL);
- cal.set(Calendar.HOUR_OF_DAY, 04);
- tod = cal.getTimeInMillis();
- event = new Log4jLogEvent(null, null, null, null, null, null, null, null, null, null, tod);
- assertTrue(filter.filter(event) == Filter.Result.DENY);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/helpers/UUIDTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/helpers/UUIDTest.java
deleted file mode 100644
index cf2330a..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/helpers/UUIDTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.helpers;
-
-import org.apache.logging.log4j.core.helpers.UUIDUtil;
-import org.junit.Test;
-
-import java.util.UUID;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-/**
- *
- */
-public class UUIDTest {
-
- private static final int COUNT = 200;
- private static final int THREADS = 10;
-
- private static final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L;
-
- @Test
- public void testTimeBaseUUID() {
- UUID uuid = UUIDUtil.getTimeBasedUUID();
- UUID uuid2 = UUIDUtil.getTimeBasedUUID();
- long current = (System.currentTimeMillis() * 10000) + NUM_100NS_INTERVALS_SINCE_UUID_EPOCH;
- long time = uuid.timestamp();
- assertTrue("Incorrect time", current + 10000 - time > 0);
- UUID[] uuids = new UUID[COUNT];
- long start = System.nanoTime();
- for (int i=0; i < COUNT; ++i) {
- uuids[i] = UUIDUtil.getTimeBasedUUID();
- }
- long elapsed = System.nanoTime() - start;
- System.out.println("Elapsed for " + COUNT + " UUIDS = " + elapsed + " Average = " + elapsed / COUNT + " ns");
- int errors = 0;
- for (int i=0; i < COUNT; ++i) {
- for (int j=i+1; j < COUNT; ++j) {
- if (uuids[i].equals(uuids[j])) {
- ++errors;
- System.out.println("UUID " + i + " equals UUID " + j);
- }
- }
- }
- assertTrue(errors + " duplicate UUIDS", errors == 0);
- int variant = uuid.variant();
- assertTrue("Incorrect variant. Expected 2 got " + variant, variant == 2);
- int version = uuid.version();
- assertTrue("Incorrect version. Expected 1 got " + version, version == 1);
- long node = uuid.node();
- assertTrue("Invalid node", node != 0);
- }
-
- @Test
- public void testThreads() throws Exception {
- Thread[] threads = new Thread[THREADS];
- UUID[] uuids = new UUID[COUNT * THREADS];
- long[] elapsed = new long[THREADS];
- for (int i=0; i < THREADS; ++i) {
- threads[i] = new Worker(uuids, elapsed, i, COUNT);
- }
- for (int i=0; i < THREADS; ++i) {
- threads[i].start();
- }
- long elapsedTime = 0;
- for (int i=0; i < THREADS; ++i) {
- threads[i].join();
- elapsedTime += elapsed[i];
- }
- System.out.println("Elapsed for " + COUNT * THREADS + " UUIDS = " + elapsedTime + " Average = " +
- elapsedTime / (COUNT * THREADS) + " ns");
- int errors = 0;
- for (int i=0; i < COUNT * THREADS; ++i) {
- for (int j=i+1; j < COUNT * THREADS; ++j) {
- if (uuids[i].equals(uuids[j])) {
- ++errors;
- System.out.println("UUID " + i + " equals UUID " + j);
- }
- }
- }
- assertTrue(errors + " duplicate UUIDS", errors == 0);
- }
-
-
-
- private class Worker extends Thread {
-
- private UUID[] uuids;
- private long[] elapsed;
- private int index;
- private int count;
-
- public Worker(UUID[] uuids, long[] elapsed, int index, int count) {
- this.uuids = uuids;
- this.index = index;
- this.count = count;
- this.elapsed = elapsed;
- }
-
- public void run() {
- int pos = index * count;
- long start = System.nanoTime();
- for (int i=pos; i < pos + count; ++i) {
- uuids[i] = UUIDUtil.getTimeBasedUUID();
- }
- elapsed[index] = System.nanoTime() - start;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
deleted file mode 100644
index 6c81e9b..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.BasicConfigurationFactory;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class HTMLLayoutTest {
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("");
-
- static ConfigurationFactory cf = new BasicConfigurationFactory();
-
- @BeforeClass
- public static void setupClass() {
- ConfigurationFactory.setConfigurationFactory(cf);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- ctx.reconfigure();
- }
-
- @AfterClass
- public static void cleanupClass() {
- ConfigurationFactory.removeConfigurationFactory(cf);
- }
-
- private static final String body =
- "<tr><td bgcolor=\"#993300\" style=\"color:White; font-size : xx-small;\" colspan=\"6\">java.lang.NullPointerException: test";
-
-
- /**
- * Test case for MDC conversion pattern.
- */
- @Test
- public void testLayout() throws Exception {
-
- // set up appender
- HTMLLayout layout = HTMLLayout.createLayout("true", null, null, null);
- ListAppender appender = new ListAppender("List", null, layout, true, false);
- appender.start();
-
- // 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");
-
- root.debug("empty mdc");
-
- ThreadContext.put("key1", "value1");
- ThreadContext.put("key2", "value2");
-
- root.debug("filled mdc");
-
- ThreadContext.remove("key1");
- ThreadContext.remove("key2");
-
- root.error("finished mdc pattern test", new NullPointerException("test"));
-
- appender.stop();
-
- List<String> list = appender.getMessages();
-
- assertTrue("Incorrect number of lines. Require at least 85 " + list.size(), list.size() > 85);
- assertTrue("Incorrect header", list.get(3).equals("<title>Log4J Log Messages</title>"));
- assertTrue("Incorrect footer", list.get(list.size() - 1).equals("</body></html>"));
- assertTrue("Incorrect body", list.get(61).equals(body));
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
deleted file mode 100644
index 45e87d0..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.BasicConfigurationFactory;
-import org.apache.logging.log4j.core.appender.FileAppender;
-import org.apache.logging.log4j.core.appender.FileManager;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.core.util.Compare;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.FileOutputStream;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class PatternLayoutTest {
- static String OUTPUT_FILE = "target/output/PatternParser";
- static String WITNESS_FILE = "witness/PatternParser";
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("");
-
- static String msgPattern = "%m%n";
- static final String regexPattern = "%replace{%logger %msg}{\\.}{/}";
- static ConfigurationFactory cf = new BasicConfigurationFactory();
-
- @BeforeClass
- public static void setupClass() {
- ConfigurationFactory.setConfigurationFactory(cf);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- ctx.reconfigure();
- }
-
- @AfterClass
- public static void cleanupClass() {
- ConfigurationFactory.removeConfigurationFactory(cf);
- }
-
-
- /**
- * Test case for MDC conversion pattern.
- */
- @Test
- 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 = PatternLayout.createLayout(msgPattern, ctx.getConfiguration(), null, null);
- //FileOutputStream fos = new FileOutputStream(OUTPUT_FILE + "_mdc");
- FileAppender appender = FileAppender.createAppender(OUTPUT_FILE + "_mdc", "false", "false", "File", "false",
- "true", "false", layout, null);
- appender.start();
-
- // 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");
-
- ThreadContext.put("key1", "value1");
- ThreadContext.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");
-
- ThreadContext.remove("key1");
- ThreadContext.remove("key2");
-
- layout.setConversionPattern(msgPattern);
- root.debug("finished mdc pattern test");
-
- assertTrue(Compare.compare(this.getClass(), OUTPUT_FILE + "_mdc", WITNESS_FILE + "_mdc"));
-
- root.removeAppender(appender);
-
- appender.stop();
- }
-
- @Test
- public void testRegex() throws Exception {
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- PatternLayout layout = PatternLayout.createLayout(regexPattern, ctx.getConfiguration(),
- null, null);
- LogEvent event = new Log4jLogEvent(this.getClass().getName(), null, "org.apache.logging.log4j.core.Logger",
- Level.INFO, new SimpleMessage("Hello, world!"), null);
- byte[] result = layout.format(event);
- assertEquals("org/apache/logging/log4j/core/layout/PatternLayoutTest Hello, world!", new String(result));
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/RFC5424LayoutTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/RFC5424LayoutTest.java
deleted file mode 100644
index 1b94691..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/RFC5424LayoutTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.BasicConfigurationFactory;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Locale;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class RFC5424LayoutTest {
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("");
-
-
- private static final String line1 = "ATM - - [RequestContext@3692 loginId=\"JohnDoe\"] starting mdc pattern test";
- private static final String line2 = "ATM - - [RequestContext@3692 loginId=\"JohnDoe\"] empty mdc";
- private static final String line3 = "ATM - - [RequestContext@3692 loginId=\"JohnDoe\"] filled mdc";
- private static final String line4 =
- "ATM - Audit [Transfer@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"]" +
- "[RequestContext@18060 ipAddress=\"192.168.0.120\" loginId=\"JohnDoe\"] Transfer Complete";
-
- static ConfigurationFactory cf = new BasicConfigurationFactory();
-
- @BeforeClass
- public static void setupClass() {
- ConfigurationFactory.setConfigurationFactory(cf);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- ctx.reconfigure();
- }
-
- @AfterClass
- public static void cleanupClass() {
- ConfigurationFactory.removeConfigurationFactory(cf);
- }
-
-
-
-
- /**
- * Test case for MDC conversion pattern.
- */
- @Test
- public void testLayout() throws Exception {
-
- // set up appender
- RFC5424Layout layout = RFC5424Layout.createLayout("Local0", "Event", "3692", "true", "RequestContext",
- "true", "ATM", null, "key1, key2, locale", null, "loginId", null, null);
- ListAppender appender = new ListAppender("List", null, layout, true, false);
- appender.start();
-
- // set appender on root and set level to debug
- root.addAppender(appender);
- root.setLevel(Level.DEBUG);
-
- ThreadContext.put("loginId", "JohnDoe");
-
- // output starting message
- root.debug("starting mdc pattern test");
-
- root.debug("empty mdc");
-
- ThreadContext.put("key1", "value1");
- ThreadContext.put("key2", "value2");
-
- root.debug("filled mdc");
-
- ThreadContext.put("ipAddress", "192.168.0.120");
- ThreadContext.put("locale", Locale.US.getDisplayName());
- try {
- StructuredDataMessage msg = new StructuredDataMessage("Transfer@18060", "Transfer Complete", "Audit");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "123457");
- msg.put("Amount", "200.00");
- root.info(MarkerManager.getMarker("EVENT"), msg);
-
- List<String> list = appender.getMessages();
-
- assertTrue("Expected line 1 to end with: " + line1 + " Actual " + list.get(0), list.get(0).endsWith(line1));
- assertTrue("Expected line 2 to end with: " + line2 + " Actual " + list.get(1), list.get(1).endsWith(line2));
- assertTrue("Expected line 3 to end with: " + line3 + " Actual " + list.get(2), list.get(2).endsWith(line3));
- assertTrue("Expected line 4 to end with: " + line4 + " Actual " + list.get(3), list.get(3).endsWith(line4));
-
- appender.clear();
-
- ThreadContext.remove("loginId");
-
- root.debug("This is a test");
-
- list = appender.getMessages();
- assertTrue("No messages expected, found " + list.size(), list.size() == 0);
- } finally {
-
- ThreadContext.clear();
-
- appender.stop();
- }
-
- }
-
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java
deleted file mode 100644
index fe57a33..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.BasicConfigurationFactory;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.List;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class SerializedLayoutTest {
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("");
-
- static ConfigurationFactory cf = new BasicConfigurationFactory();
-
- @BeforeClass
- public static void setupClass() {
- ConfigurationFactory.setConfigurationFactory(cf);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- ctx.reconfigure();
- }
-
- @AfterClass
- public static void cleanupClass() {
- ConfigurationFactory.removeConfigurationFactory(cf);
- }
-
- private static final String body =
- "<log4j:message><![CDATA[empty mdc]]></log4j:message>\r";
-
- private static final String[] expected = {
- "Logger=root Level=DEBUG Messagestarting mdc pattern test",
- "Logger=root Level=DEBUG Messageempty mdc",
- "Logger=root Level=DEBUG Messagefilled mdc",
- "Logger=root Level=ERROR Messagefinished mdc pattern test"
- };
-
-
- /**
- * Test case for MDC conversion pattern.
- */
- @Test
- public void testLayout() throws Exception {
-
- // set up appender
- SerializedLayout layout = SerializedLayout.createLayout();
- ListAppender appender = new ListAppender("List", null, layout, false, true);
- appender.start();
-
- // 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");
-
- root.debug("empty mdc");
-
- ThreadContext.put("key1", "value1");
- ThreadContext.put("key2", "value2");
-
- root.debug("filled mdc");
-
- ThreadContext.remove("key1");
- ThreadContext.remove("key2");
-
- root.error("finished mdc pattern test", new NullPointerException("test"));
-
- appender.stop();
-
- List<byte[]> data = appender.getData();
- assertTrue(data.size() > 0);
- int i = 0;
- for (byte[] item : data) {
- ByteArrayInputStream bais = new ByteArrayInputStream(item);
- ObjectInputStream ois = new ObjectInputStream(bais);
- LogEvent event;
- try {
- event = (LogEvent) ois.readObject();
- } catch (IOException ioe) {
- System.err.println("Exception processing item " + i);
- throw ioe;
- }
- assertTrue("Incorrect event", event.toString().equals(expected[i]));
- ++i;
- }
-
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/SyslogLayoutTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/SyslogLayoutTest.java
deleted file mode 100644
index a4e1299..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/SyslogLayoutTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.BasicConfigurationFactory;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Locale;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class SyslogLayoutTest {
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("");
-
-
- private static final String line1 = "starting mdc pattern test";
- private static final String line2 = "empty mdc";
- private static final String line3 = "filled mdc";
- private static final String line4 =
- "Audit [Transfer@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete";
-
- static ConfigurationFactory cf = new BasicConfigurationFactory();
-
- @BeforeClass
- public static void setupClass() {
- ConfigurationFactory.setConfigurationFactory(cf);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- ctx.reconfigure();
- }
-
- @AfterClass
- public static void cleanupClass() {
- ConfigurationFactory.removeConfigurationFactory(cf);
- }
-
-
-
-
- /**
- * Test case for MDC conversion pattern.
- */
- @Test
- public void testLayout() throws Exception {
-
- // set up appender
- SyslogLayout layout = SyslogLayout.createLayout("Local0", "true", null);
- //ConsoleAppender appender = new ConsoleAppender("Console", layout);
- ListAppender appender = new ListAppender("List", null, layout, true, false);
- appender.start();
-
- // 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");
-
- root.debug("empty mdc");
-
- ThreadContext.put("key1", "value1");
- ThreadContext.put("key2", "value2");
-
- root.debug("filled mdc");
-
- ThreadContext.put("loginId", "JohnDoe");
- ThreadContext.put("ipAddress", "192.168.0.120");
- ThreadContext.put("locale", Locale.US.getDisplayName());
- StructuredDataMessage msg = new StructuredDataMessage("Transfer@18060", "Transfer Complete", "Audit");
- msg.put("ToAccount", "123456");
- msg.put("FromAccount", "123457");
- msg.put("Amount", "200.00");
- root.info(MarkerManager.getMarker("EVENT"), msg);
-
- ThreadContext.clear();
-
- appender.stop();
-
- List<String> list = appender.getMessages();
-
- assertTrue("Expected line 1 to end with: " + line1 + " Actual " + list.get(0), list.get(0).endsWith(line1));
- assertTrue("Expected line 2 to end with: " + line2 + " Actual " + list.get(1), list.get(1).endsWith(line2));
- assertTrue("Expected line 3 to end with: " + line3 + " Actual " + list.get(2), list.get(2).endsWith(line3));
- assertTrue("Expected line 4 to end with: " + line4 + " Actual " + list.get(3), list.get(3).endsWith(line4));
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/XMLLayoutTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/XMLLayoutTest.java
deleted file mode 100644
index f8dc230..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/layout/XMLLayoutTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.layout;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.BasicConfigurationFactory;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class XMLLayoutTest {
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("");
-
- static ConfigurationFactory cf = new BasicConfigurationFactory();
-
- @BeforeClass
- public static void setupClass() {
- ConfigurationFactory.setConfigurationFactory(cf);
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- ctx.reconfigure();
- }
-
- @AfterClass
- public static void cleanupClass() {
- ConfigurationFactory.removeConfigurationFactory(cf);
- }
-
- private static final String body =
- "<log4j:message><![CDATA[empty mdc]]></log4j:message>\r";
-
-
- /**
- * Test case for MDC conversion pattern.
- */
- @Test
- public void testLayout() throws Exception {
-
- // set up appender
- XMLLayout layout = XMLLayout.createLayout("true", "true", "true", null);
- ListAppender appender = new ListAppender("List", null, layout, true, false);
- appender.start();
-
- // 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");
-
- root.debug("empty mdc");
-
- ThreadContext.put("key1", "value1");
- ThreadContext.put("key2", "value2");
-
- root.debug("filled mdc");
-
- ThreadContext.remove("key1");
- ThreadContext.remove("key2");
-
- root.error("finished mdc pattern test", new NullPointerException("test"));
-
- appender.stop();
-
- List<String> list = appender.getMessages();
-
- assertTrue("Incorrect number of lines. Require at least 50 " + list.size(), list.size() > 50);
- assertTrue("Incorrect header", list.get(0).equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r"));
- assertTrue("Incorrect footer", list.get(list.size() - 1).equals("</log4j:eventSet>\r"));
- assertTrue("Incorrect body. Expected " + body + " Actual: " + list.get(8), list.get(8).equals(body));
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/ContextMapLookupTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/ContextMapLookupTest.java
deleted file mode 100644
index e638698..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/ContextMapLookupTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.ThreadContext;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- *
- */
-public class ContextMapLookupTest {
-
- private static final String TESTKEY = "TestKey";
- private static final String TESTVAL = "TestValue";
-
- @Test
- public void testLookup() {
- ThreadContext.put(TESTKEY, TESTVAL);
- StrLookup lookup = new ContextMapLookup();
- String value = lookup.lookup(TESTKEY);
- assertEquals(TESTVAL, value);
- value = lookup.lookup("BadKey");
- assertNull(value);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/DateLookupTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/DateLookupTest.java
deleted file mode 100644
index e82666a..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/DateLookupTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.message.Message;
-import org.junit.Test;
-
-import java.util.Calendar;
-import java.util.Map;
-import java.util.Stack;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class DateLookupTest {
-
-
- @Test
- public void testLookup() {
- StrLookup lookup = new DateLookup();
- LogEvent event = new MyLogEvent();
- String value = lookup.lookup(event, "MM/dd/yyyy");
- assertNotNull(value);
- assertEquals("12/30/2011", value);
- }
-
- private class MyLogEvent implements LogEvent {
- public Level getLevel() {
- return null;
- }
-
- public String getLoggerName() {
- return null;
- }
-
- public StackTraceElement getSource() {
- return null;
- }
-
- public Message getMessage() {
- return null;
- }
-
- public Marker getMarker() {
- return null;
- }
-
- public String getThreadName() {
- return null;
- }
-
- public long getMillis() {
- Calendar cal = Calendar.getInstance();
- cal.set(2011, 11, 30, 10, 56, 35);
- return cal.getTimeInMillis();
- }
-
- public Throwable getThrown() {
- return null;
- }
-
- public Map<String, String> getContextMap() {
- return null;
- }
-
- public Stack<String> getContextStack() {
- return null;
- }
-
- public String getFQCN() {
- return null;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/EnvironmentLookupTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/EnvironmentLookupTest.java
deleted file mode 100644
index f13caca..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/EnvironmentLookupTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-/**
- *
- */
-public class EnvironmentLookupTest {
-
-
- @Test
- public void testLookup() {
- StrLookup lookup = new EnvironmentLookup();
- String value = lookup.lookup("PATH");
- assertNotNull(value);
- value = lookup.lookup("BadKey");
- assertNull(value);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/InterpolatorTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/InterpolatorTest.java
deleted file mode 100644
index 9a0542a..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/InterpolatorTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.ThreadContext;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- *
- */
-public class InterpolatorTest {
-
- private static final String TESTKEY = "TestKey";
- private static final String TESTVAL = "TestValue";
-
-
- @BeforeClass
- public static void before() {
- System.setProperty(TESTKEY, TESTVAL);
- }
-
- @AfterClass
- public static void after() {
- System.clearProperty(TESTKEY);
- }
-
-
- @Test
- public void testLookup() {
- Map<String, String> map = new HashMap<String, String>();
- map.put(TESTKEY, TESTVAL);
- StrLookup lookup = new Interpolator(new MapLookup<String>(map));
- ThreadContext.put(TESTKEY, TESTVAL);
- String value = lookup.lookup(TESTKEY);
- assertEquals(TESTVAL, value);
- value = lookup.lookup("ctx:" + TESTKEY);
- assertEquals(TESTVAL, value);
- value = lookup.lookup("sys:" + TESTKEY);
- assertEquals(TESTVAL, value);
- value = lookup.lookup("BadKey");
- assertNull(value);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/StrSubstitutorTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/StrSubstitutorTest.java
deleted file mode 100644
index c0af98b..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/StrSubstitutorTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.ThreadContext;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- *
- */
-public class StrSubstitutorTest {
-
- private static final String TESTKEY = "TestKey";
- private static final String TESTVAL = "TestValue";
-
-
- @BeforeClass
- public static void before() {
- System.setProperty(TESTKEY, TESTVAL);
- }
-
- @AfterClass
- public static void after() {
- System.clearProperty(TESTKEY);
- }
-
-
- @Test
- public void testLookup() {
- Map<String, String> map = new HashMap<String, String>();
- map.put(TESTKEY, TESTVAL);
- StrLookup lookup = new Interpolator(new MapLookup<String>(map));
- StrSubstitutor subst = new StrSubstitutor(lookup);
- ThreadContext.put(TESTKEY, TESTVAL);
- String value = subst.replace("${TestKey}-${ctx:TestKey}-${sys:TestKey}");
- assertEquals("TestValue-TestValue-TestValue", value);
- value = subst.replace("${BadKey}");
- assertEquals("${BadKey}", value);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/StructuredDataLookupTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/StructuredDataLookupTest.java
deleted file mode 100644
index 5b21d43..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/StructuredDataLookupTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- *
- */
-public class StructuredDataLookupTest {
-
- private static final String TESTKEY = "type";
- private static final String TESTVAL = "Audit";
-
- @Test
- public void testLookup() {
- Message msg = new StructuredDataMessage("Test", "This is a test", "Audit");
- LogEvent event = new Log4jLogEvent(null, null, null, Level.DEBUG, msg, null);
- StrLookup lookup = new StructuredDataLookup();
- String value = lookup.lookup(event, TESTKEY);
- assertEquals(TESTVAL, value);
- value = lookup.lookup("BadKey");
- assertNull(value);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/SystemPropertiesLookupTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/SystemPropertiesLookupTest.java
deleted file mode 100644
index 6a924eb..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/lookup/SystemPropertiesLookupTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.lookup;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- *
- */
-public class SystemPropertiesLookupTest {
-
-
- private static final String TESTKEY = "TestKey";
- private static final String TESTVAL = "TestValue";
-
- @BeforeClass
- public static void before() {
- System.setProperty(TESTKEY, TESTVAL);
- }
-
- @AfterClass
- public static void after() {
- System.clearProperty(TESTKEY);
- }
-
- @Test
- public void testLookup() {
- StrLookup lookup = new SystemPropertiesLookup();
- String value = lookup.lookup(TESTKEY);
- assertEquals(TESTVAL, value);
- value = lookup.lookup("BadKey");
- assertNull(value);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSQueueTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSQueueTest.java
deleted file mode 100644
index 4f2a937..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSQueueTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.core.appender.JMSQueueAppender;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.filter.CompositeFilter;
-import org.apache.logging.log4j.core.filter.FilterBase;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.status.StatusConsoleListener;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.mockejb.jms.MockQueue;
-import org.mockejb.jms.QueueConnectionFactoryImpl;
-import org.mockejb.jndi.MockContextFactory;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class JMSQueueTest {
-
- private static final String FACTORY_NAME = "TestQueueConnectionFactory";
- private static final String QUEUE_NAME = "TestQueue";
-
- private static Context context;
- private static AbstractJMSReceiver receiver;
-
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("JMSQueueTest");
-
- @BeforeClass
- public static void setupClass() throws Exception {
- // MockContextFactory becomes the primary JNDI provider
- StatusConsoleListener l = new StatusConsoleListener(Level.ERROR);
- StatusLogger.getLogger().registerListener(l);
- MockContextFactory.setAsInitial();
- context = new InitialContext();
- context.rebind(FACTORY_NAME, new QueueConnectionFactoryImpl() );
- context.rebind(QUEUE_NAME, new MockQueue(QUEUE_NAME));
- ((LoggerContext) LogManager.getContext()).reconfigure();
- receiver = new JMSQueueReceiver(FACTORY_NAME, QUEUE_NAME, null, null);
- }
-
- @AfterClass
- public static void cleanupClass() {
- StatusLogger.getLogger().reset();
- }
-
- @After
- public void teardown() {
- Map<String,Appender> map = root.getAppenders();
- for (Map.Entry<String, Appender> entry : map.entrySet()) {
- Appender app = entry.getValue();
- root.removeAppender(app);
- app.stop();
- }
- }
-
- @Test
- public void testServer() throws Exception {
- Filter clientFilter = new MessageFilter(Filter.Result.NEUTRAL, Filter.Result.DENY);
- Filter serverFilter = new MessageFilter(Filter.Result.DENY, Filter.Result.NEUTRAL);
- CompositeFilter clientFilters = CompositeFilter.createFilters(new Filter[]{clientFilter});
- JMSQueueAppender appender = JMSQueueAppender.createAppender(null, null, null, null, null, FACTORY_NAME,
- QUEUE_NAME, null, null, null, clientFilters, "true");
- appender.start();
- CompositeFilter serverFilters = CompositeFilter.createFilters(new Filter[]{serverFilter});
- ListAppender listApp = new ListAppender("Events", serverFilters, null, false, false);
- listApp.start();
- PatternLayout layout = PatternLayout.createLayout("%m %ex%n", null, null, null);
- ConsoleAppender console = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT", "Console", "true");
- console.start();
- Logger serverLogger = ctx.getLogger(JMSTopicReceiver.class.getName());
- serverLogger.addAppender(console);
- serverLogger.setAdditive(false);
-
-
- // set appender on root and set level to debug
- root.addAppender(listApp);
- root.addAppender(appender);
- root.setAdditive(false);
- root.setLevel(Level.DEBUG);
- root.debug("This is a test message");
- Thread.sleep(100);
- List<LogEvent> events = listApp.getEvents();
- assertNotNull("No event retrieved", events);
- assertTrue("No events retrieved", events.size() > 0);
- assertTrue("Incorrect event", events.get(0).getMessage().getFormattedMessage().equals("This is a test message"));
- }
-
- private class MessageFilter extends FilterBase {
- public MessageFilter(Result onMatch, Result onMismatch) {
- super(onMatch, onMismatch);
- }
-
- public Result filter(LogEvent event) {
- StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
- for (StackTraceElement element : stackTrace) {
- if (element.getMethodName().equals("onMessage")) {
- return onMatch;
- } else if (element.getMethodName().equals("testServer")) {
- return onMismatch;
- }
- }
- return onMismatch;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSTopicTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSTopicTest.java
deleted file mode 100644
index dc06913..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/JMSTopicTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.core.appender.JMSTopicAppender;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.filter.CompositeFilter;
-import org.apache.logging.log4j.core.filter.FilterBase;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.status.StatusConsoleListener;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.mockejb.jms.MockTopic;
-import org.mockejb.jms.TopicConnectionFactoryImpl;
-import org.mockejb.jndi.MockContextFactory;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class JMSTopicTest {
-
- private static final String FACTORY_NAME = "TestTopicConnectionFactory";
- private static final String TOPIC_NAME = "TestTopic";
-
- private static Context context;
- private static AbstractJMSReceiver receiver;
-
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("JMSTopicTest");
-
- @BeforeClass
- public static void setupClass() throws Exception {
- // MockContextFactory becomes the primary JNDI provider
- StatusConsoleListener l = new StatusConsoleListener(Level.ERROR);
- StatusLogger.getLogger().registerListener(l);
- MockContextFactory.setAsInitial();
- context = new InitialContext();
- context.rebind(FACTORY_NAME, new TopicConnectionFactoryImpl() );
- context.rebind(TOPIC_NAME, new MockTopic(TOPIC_NAME) );
- ((LoggerContext) LogManager.getContext()).reconfigure();
- receiver = new JMSTopicReceiver(FACTORY_NAME, TOPIC_NAME, null, null);
- }
-
- @AfterClass
- public static void cleanupClass() {
- StatusLogger.getLogger().reset();
- }
-
- @After
- public void teardown() {
- Map<String,Appender> map = root.getAppenders();
- for (Map.Entry<String, Appender> entry : map.entrySet()) {
- Appender app = entry.getValue();
- root.removeAppender(app);
- app.stop();
- }
- }
-
- @Test
- public void testServer() throws Exception {
- Filter clientFilter = new MessageFilter(Filter.Result.NEUTRAL, Filter.Result.DENY);
- Filter serverFilter = new MessageFilter(Filter.Result.DENY, Filter.Result.NEUTRAL);
- CompositeFilter clientFilters = CompositeFilter.createFilters(new Filter[]{clientFilter});
- JMSTopicAppender appender = JMSTopicAppender.createAppender(null, null, null, null, null, FACTORY_NAME,
- TOPIC_NAME, null, null, null, clientFilters, "true");
- appender.start();
- CompositeFilter serverFilters = CompositeFilter.createFilters(new Filter[]{serverFilter});
- ListAppender listApp = new ListAppender("Events", serverFilters, null, false, false);
- listApp.start();
- PatternLayout layout = PatternLayout.createLayout("%m %ex%n", null, null, null);
- ConsoleAppender console = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT", "Console", "true");
- console.start();
- Logger serverLogger = ctx.getLogger(JMSTopicReceiver.class.getName());
- serverLogger.addAppender(console);
- serverLogger.setAdditive(false);
-
-
- // set appender on root and set level to debug
- root.addAppender(listApp);
- root.addAppender(appender);
- root.setAdditive(false);
- root.setLevel(Level.DEBUG);
- root.debug("This is a test message");
- Thread.sleep(100);
- List<LogEvent> events = listApp.getEvents();
- assertNotNull("No event retrieved", events);
- assertTrue("No events retrieved", events.size() > 0);
- assertTrue("Incorrect event", events.get(0).getMessage().getFormattedMessage().equals("This is a test message"));
- }
-
- private class MessageFilter extends FilterBase {
- public MessageFilter(Result onMatch, Result onMismatch) {
- super(onMatch, onMismatch);
- }
-
- public Result filter(LogEvent event) {
- StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
- for (StackTraceElement element : stackTrace) {
- if (element.getMethodName().equals("onMessage")) {
- return onMatch;
- } else if (element.getMethodName().equals("testServer")) {
- return onMismatch;
- }
- }
- return onMismatch;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java
deleted file mode 100644
index 304073c..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.net;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.appender.SocketAppender;
-import org.apache.logging.log4j.core.filter.CompositeFilter;
-import org.apache.logging.log4j.core.filter.FilterBase;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class SocketServerTest {
-
- private static final String HOST = "localhost";
- private static final String PORT = "8199";
- private static final int PORTNUM = Integer.parseInt(PORT);
-
- private static BlockingQueue<LogEvent> list = new ArrayBlockingQueue<LogEvent>(10);
-
- private static SocketServer tcp;
- private static Thread thread;
-
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("SocketServerTest");
-
- @BeforeClass
- public static void setupClass() throws Exception {
- ((LoggerContext) LogManager.getContext()).reconfigure();
- tcp = new SocketServer(PORTNUM);
- thread = new Thread(tcp);
- thread.start();
-
- }
-
- @AfterClass
- public static void cleanupClass() {
- tcp.shutdown();
- try {
- thread.join();
- } catch (InterruptedException iex) {
-
- }
- }
-
- @After
- public void teardown() {
- Map<String,Appender> map = root.getAppenders();
- for (Map.Entry<String, Appender> entry : map.entrySet()) {
- Appender app = entry.getValue();
- root.removeAppender(app);
- app.stop();
- }
- }
-
- @Test
- public void testServer() throws Exception {
- Filter socketFilter = new ThreadFilter(Filter.Result.NEUTRAL, Filter.Result.DENY);
- Filter serverFilter = new ThreadFilter(Filter.Result.DENY, Filter.Result.NEUTRAL);
- CompositeFilter socketFilters = CompositeFilter.createFilters(new Filter[]{socketFilter});
- SocketAppender appender = SocketAppender.createAppender("localhost", PORT, "tcp", "-1",
- "Test", null, null, null, socketFilters);
- appender.start();
- CompositeFilter serverFilters = CompositeFilter.createFilters(new Filter[]{serverFilter});
- ListAppender listApp = new ListAppender("Events", serverFilters, null, false, false);
- appender.start();
- PatternLayout layout = PatternLayout.createLayout("%m %ex%n", null, null, null);
- ConsoleAppender console = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT", "Console", "true");
- Logger serverLogger = ctx.getLogger(SocketServer.class.getName());
- serverLogger.addAppender(console);
- serverLogger.setAdditive(false);
-
- // set appender on root and set level to debug
- root.addAppender(appender);
- root.addAppender(listApp);
- root.setAdditive(false);
- root.setLevel(Level.DEBUG);
- root.debug("This is a test message");
- Thread.sleep(100);
- List<LogEvent> events = listApp.getEvents();
- assertNotNull("No event retrieved", events);
- assertTrue("No events retrieved", events.size() > 0);
- assertTrue("Incorrect event", events.get(0).getMessage().getFormattedMessage().equals("This is a test message"));
- }
-
- private class ThreadFilter extends FilterBase {
-
- public ThreadFilter(Result onMatch, Result onMismatch) {
- super(onMatch, onMismatch);
- }
-
- public Filter.Result filter(LogEvent event) {
- return event.getThreadName().equals(Thread.currentThread().getName()) ? onMatch : onMismatch;
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverterTest.java
deleted file mode 100644
index bf4850e..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverterTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class ExtendedThrowablePatternConverterTest {
-
-
-
- @Before
- public void setup() {
-
- }
-
- @Test
- public void testFull() {
- ExtendedThrowablePatternConverter converter = ExtendedThrowablePatternConverter.newInstance(null);
- Throwable cause = new NullPointerException("null pointer");
- Throwable parent = new IllegalArgumentException("IllegalArgument", cause);
- LogEvent event = new Log4jLogEvent("testLogger", null, this.getClass().getName(), Level.DEBUG,
- new SimpleMessage("test exception"), parent);
- StringBuilder sb = new StringBuilder();
- converter.format(event, sb);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- parent.printStackTrace(pw);
- String result = sb.toString();
- //System.out.print(result);
- result = result.replaceAll(" ~?\\[.*\\]", "");
- assertEquals(sw.toString(), result);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/MapPatternConverterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/MapPatternConverterTest.java
deleted file mode 100644
index 54e8214..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/MapPatternConverterTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.MapMessage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class MapPatternConverterTest {
-
- @Test
- public void testConverter() {
-
- MapMessage msg = new MapMessage();
- msg.put("subject", "I");
- msg.put("verb", "love");
- msg.put("object", "Log4j");
- MapPatternConverter converter = MapPatternConverter.newInstance(null);
- LogEvent event = new Log4jLogEvent("MyLogger", null, null, Level.DEBUG, msg, null);
- StringBuilder sb = new StringBuilder();
- converter.format(event, sb);
- String str = sb.toString();
- String expected = "subject=I";
- assertTrue("Missing or incorrect subject. Expected " + expected + ", actual " + str, str.contains(expected));
- expected = "verb=love";
- assertTrue("Missing or incorrect verb", str.contains(expected));
- expected = "object=Log4j";
- assertTrue("Missing or incorrect object", str.contains(expected));
- }
-
- @Test
- public void testConverterWithKey() {
-
- MapMessage msg = new MapMessage();
- msg.put("subject", "I");
- msg.put("verb", "love");
- msg.put("object", "Log4j");
- MapPatternConverter converter = MapPatternConverter.newInstance(new String[] {"object"});
- LogEvent event = new Log4jLogEvent("MyLogger", null, null, Level.DEBUG, msg, null);
- StringBuilder sb = new StringBuilder();
- converter.format(event, sb);
- String str = sb.toString();
- String expected = "Log4j";
- assertEquals(expected, str);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/MarkerPatternConverterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/MarkerPatternConverterTest.java
deleted file mode 100644
index 9220d88..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/MarkerPatternConverterTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- *
- */
-public class MarkerPatternConverterTest {
-
-
- @Test
- public void testLookup() {
- Message msg = new StructuredDataMessage("Test", "This is a test", "Audit");
- Marker eventMarker = MarkerManager.getMarker("EVENT");
- Marker auditMarker = MarkerManager.getMarker("AUDIT", eventMarker);
- LogEvent event = new Log4jLogEvent("MyLogger", auditMarker, null, Level.DEBUG, msg, null);
- StringBuilder sb = new StringBuilder();
- MarkerPatternConverter converter = MarkerPatternConverter.newInstance(null);
- converter.format(event, sb);
- assertEquals(auditMarker.toString(), sb.toString());
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/NameAbbreviatorTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/NameAbbreviatorTest.java
deleted file mode 100644
index 6769dba..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/NameAbbreviatorTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- *
- */
-public class NameAbbreviatorTest {
-
- @Test
- public void testZero() {
- String str = this.getClass().getName();
- NameAbbreviator a = NameAbbreviator.getAbbreviator("0");
- String result = a.abbreviate(str);
- assertEquals("NameAbbreviatorTest", result);
- }
-
- @Test
- public void testNameAbbreviation() {
- String str = this.getClass().getName();
- NameAbbreviator a = NameAbbreviator.getAbbreviator("1");
- String result = a.abbreviate(str);
- assertEquals("NameAbbreviatorTest", result);
- }
-
- @Test
- public void testTwo() {
- String str = this.getClass().getName();
- NameAbbreviator a = NameAbbreviator.getAbbreviator("2");
- String result = a.abbreviate(str);
- assertEquals("pattern.NameAbbreviatorTest", result);
-
- }
-
- @Test
- public void testShortName() {
- String str = this.getClass().getName();
- NameAbbreviator a = NameAbbreviator.getAbbreviator("1.");
- String result = a.abbreviate(str);
- assertEquals("o.a.l.l.c.p.NameAbbreviatorTest", result);
-
- }
-
- @Test
- public void testSkipNames() {
- String str = this.getClass().getName();
- NameAbbreviator a = NameAbbreviator.getAbbreviator("1.1.~");
- String result = a.abbreviate(str);
- assertEquals("o.a.~.~.~.~.NameAbbreviatorTest", result);
-
- }
-
- @Test
- public void testZeroDot() {
- String str = this.getClass().getName();
- NameAbbreviator a = NameAbbreviator.getAbbreviator(".");
- String result = a.abbreviate(str);
- assertEquals("......NameAbbreviatorTest", result);
-
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java
deleted file mode 100644
index 539ba95..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.Logger;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-/**
- *
- */
-public class PatternParserTest {
-
- static String OUTPUT_FILE = "output/PatternParser";
- static String WITNESS_FILE = "witness/PatternParser";
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- Logger root = ctx.getLogger("");
-
- private static String msgPattern = "%m%n";
- private String mdcMsgPattern1 = "%m : %X%n";
- private String mdcMsgPattern2 = "%m : %X{key1}%n";
- private String mdcMsgPattern3 = "%m : %X{key2}%n";
- private String mdcMsgPattern4 = "%m : %X{key3}%n";
- private String mdcMsgPattern5 = "%m : %X{key1},%X{key2},%X{key3}%n";
-
-
- private static final String KEY = "Converter";
- private PatternParser parser;
-
- @Before
- public void setup() {
- parser = new PatternParser(KEY);
- }
-
- private void validateConverter(List<PatternConverter> converters, int index, String name) {
- PatternConverter pc = converters.get(index);
- assertEquals("Incorrect converter " + pc.getName() + " at index " + index + " expected " + name,
- pc.getName(), name);
- }
-
- /**
- * Test the default pattern
- */
- @Test
- public void defaultPattern() {
- List<PatternConverter> converters = parser.parse(msgPattern);
- assertNotNull(converters);
- assertTrue(converters.size() == 2);
- validateConverter(converters, 0, "Message");
- validateConverter(converters, 1, "Line Sep");
- }
-
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementConverterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementConverterTest.java
deleted file mode 100644
index 23a121b..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementConverterTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class RegexReplacementConverterTest {
-
-
- @Test
- public void testReplacement() {
- ThreadContext.put("MyKey", "Apache");
- LogEvent event = new Log4jLogEvent(RegexReplacementConverterTest.class.getName(), null, null,
- Level.DEBUG, new SimpleMessage("This is a test"), null);
- StringBuilder sb = new StringBuilder();
- LoggerContext ctx = (LoggerContext) LogManager.getContext();
- String[] options = new String[] {
- "%logger %msg%n", "\\.", "/"
- };
- RegexReplacementConverter converter = RegexReplacementConverter.newInstance(ctx.getConfiguration(),
- options);
- converter.format(event, sb);
- assertEquals("org/apache/logging/log4j/core/pattern/RegexReplacementConverterTest This is a test\n",
- sb.toString());
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java
deleted file mode 100644
index 7ccbe47..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class RegexReplacementTest {
- private static final String CONFIG = "log4j-replace.xml";
- private static Configuration config;
- private static ListAppender app;
- private static ListAppender app2;
- private static LoggerContext ctx;
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- ctx = (LoggerContext) LogManager.getContext(false);
- config = ctx.getConfiguration();
- for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) {
- if (entry.getKey().equals("List")) {
- app = (ListAppender) entry.getValue();
- }
- if (entry.getKey().equals("List2")) {
- app2 = (ListAppender) entry.getValue();
- }
- }
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- ThreadContext.clear();
- }
-
- org.apache.logging.log4j.Logger logger = LogManager.getLogger("LoggerTest");
- org.apache.logging.log4j.Logger logger2 = LogManager.getLogger("ReplacementTest");
-
- @Test
- public void testReplacement() {
- logger.error(this.getClass().getName());
- List<String> msgs = app.getMessages();
- assertNotNull(msgs);
- assertTrue("Incorrect number of messages. Should be 1 is " + msgs.size(), msgs.size() == 1);
- assertTrue("Replacement failed", msgs.get(0).endsWith("/RegexReplacementTest\n"));
- app.clear();
- ThreadContext.put("MyKey", "Apache");
- logger.error("This is a test for ${ctx:MyKey}");
- msgs = app.getMessages();
- assertNotNull(msgs);
- assertTrue("Incorrect number of messages. Should be 1 is " + msgs.size(), msgs.size() == 1);
- assertEquals("LoggerTest This is a test for Apache\n", msgs.get(0));
- app.clear();
-
- }
- @Test
- public void testConverter() {
- logger2.error(this.getClass().getName());
- List<String> msgs = app2.getMessages();
- assertNotNull(msgs);
- assertTrue("Incorrect number of messages. Should be 1 is " + msgs.size(), msgs.size() == 1);
- assertTrue("Replacement failed", msgs.get(0).endsWith("/RegexReplacementTest\n"));
- app2.clear();
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverterTest.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverterTest.java
deleted file mode 100644
index f975c57..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/RootThrowablePatternConverterTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.pattern;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class RootThrowablePatternConverterTest {
-
-
-
- @Before
- public void setup() {
-
- }
-
- @Test
- public void testFull() {
- RootThrowablePatternConverter converter = RootThrowablePatternConverter.newInstance(null);
- Throwable cause = new NullPointerException("null pointer");
- Throwable parent = new IllegalArgumentException("IllegalArgument", cause);
- LogEvent event = new Log4jLogEvent("testLogger", null, this.getClass().getName(), Level.DEBUG,
- new SimpleMessage("test exception"), parent);
- StringBuilder sb = new StringBuilder();
- converter.format(event, sb);
- String result = sb.toString();
- //System.out.print(result);
- assertTrue("Missing Exception",
- result.contains("Wrapped by: java.lang.IllegalArgumentException: IllegalArgument"));
- assertTrue("Incorrect start of msg", result.startsWith("java.lang.NullPointerException: null pointer"));
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/AbsoluteDateAndTimeFilter.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/AbsoluteDateAndTimeFilter.java
deleted file mode 100644
index b27bf42..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/AbsoluteDateAndTimeFilter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-
-public class AbsoluteDateAndTimeFilter implements Filter {
- Perl5Util util = new Perl5Util();
-
- public String filter(String in) {
- String pat = "/" + Filter.ABSOLUTE_DATE_AND_TIME_PAT + "/";
-
- if (util.match(pat, in)) {
- return util.substitute(
- "s/" + Filter.ABSOLUTE_DATE_AND_TIME_PAT + "//", in);
- } else {
- return in;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/AbsoluteTimeFilter.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/AbsoluteTimeFilter.java
deleted file mode 100644
index 03e446e..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/AbsoluteTimeFilter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class AbsoluteTimeFilter implements Filter {
- Perl5Util util = new Perl5Util();
-
- public String filter(String in) {
- String pat = "/" + Filter.ABSOLUTE_TIME_PAT + "/";
-
- if (util.match(pat, in)) {
- return util.substitute("s/" + Filter.ABSOLUTE_TIME_PAT + "//", in);
- } else {
- return in;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Compare.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Compare.java
deleted file mode 100644
index b6423cb..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Compare.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.*;
-import java.net.URL;
-
-
-public class Compare {
- static final int B1_NULL = -1;
- static final int B2_NULL = -2;
-
- private static final InputStream open(
- final Class testClass,
- final String fileName) throws IOException {
- String resourceName = fileName;
- /* if (fileName.startsWith("witness/")) {
- resourceName = fileName.substring(fileName.lastIndexOf('/') + 1);
- } */
- InputStream is = testClass.getResourceAsStream(resourceName);
- if (is == null) {
- is = testClass.getClassLoader().getResourceAsStream(resourceName);
- }
- if (is == null) {
- File file = new File(fileName);
- if (file.exists()) {
- is = new FileInputStream(file);
- } else {
- throw new FileNotFoundException("Resource "
- + resourceName + " not found");
- }
- }
- return is;
- }
-
- public static boolean compare(Class testClass,
- final String file1,
- final String file2)
- throws IOException {
- BufferedReader in1 = new BufferedReader(new FileReader(file1));
- BufferedReader in2 = new BufferedReader(new InputStreamReader(
- open(testClass, file2)));
- try {
- return compare(testClass, file1, file2, in1, in2);
- } finally {
- in1.close();
- in2.close();
- }
- }
-
- public static boolean compare(
- Class testClass, String file1, String file2, BufferedReader in1, BufferedReader in2) throws IOException {
-
- String s1;
- int lineCounter = 0;
-
- while ((s1 = in1.readLine()) != null) {
- lineCounter++;
-
- String s2 = in2.readLine();
-
- if (!s1.equals(s2)) {
- System.out.println(
- "Files [" + file1 + "] and [" + file2 + "] differ on line "
- + lineCounter);
- System.out.println("One reads: [" + s1 + "].");
- System.out.println("Other reads:[" + s2 + "].");
- outputFile(testClass, file1);
- outputFile(testClass, file2);
-
- return false;
- }
- }
-
- // the second file is longer
- if (in2.read() != -1) {
- System.out.println(
- "File [" + file2 + "] longer than file [" + file1 + "].");
- outputFile(testClass, file1);
- outputFile(testClass, file2);
-
- return false;
- }
-
- return true;
- }
-
- /**
- * Prints file on the console.
- */
- private static void outputFile(Class testClass, String file)
- throws IOException {
- InputStream is = open(testClass, file);
- BufferedReader in1 = new BufferedReader(new InputStreamReader(is));
-
- String s1;
- int lineCounter = 0;
- System.out.println("--------------------------------");
- System.out.println("Contents of " + file + ":");
-
- while ((s1 = in1.readLine()) != null) {
- lineCounter++;
- System.out.print(lineCounter);
-
- if (lineCounter < 10) {
- System.out.print(" : ");
- } else if (lineCounter < 100) {
- System.out.print(" : ");
- } else if (lineCounter < 1000) {
- System.out.print(" : ");
- } else {
- System.out.print(": ");
- }
-
- System.out.println(s1);
- }
- in1.close();
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/ControlFilter.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/ControlFilter.java
deleted file mode 100644
index 9a09fc3..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/ControlFilter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-
-public class ControlFilter implements Filter {
- Perl5Util util = new Perl5Util();
- String[] allowedPatterns;
-
- public ControlFilter(String[] allowedPatterns) {
- this.allowedPatterns = allowedPatterns;
- }
-
- public String filter(String in) throws UnexpectedFormatException {
- int len = allowedPatterns.length;
-
- for (int i = 0; i < len; i++) {
- //System.out.println("["+allowedPatterns[i]+"]");
- if (util.match("/" + allowedPatterns[i] + "/", in)) {
- //System.out.println("["+in+"] matched ["+allowedPatterns[i]);
- return in;
- }
- }
-
- throw new UnexpectedFormatException("[" + in + "]");
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Filter.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Filter.java
deleted file mode 100644
index 91d8cc1..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Filter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-public interface Filter {
- // 06 avr. 2002 18:36:32,036
- // 18 fevr. 2002 20:05:36,222
- public static final String ABSOLUTE_DATE_AND_TIME_PAT =
- "^\\d{1,2} .{2,6}\\.? 200\\d \\d{2}:\\d{2}:\\d{2},\\d{3}";
-
- // 18:54:19,201
- public static final String ABSOLUTE_TIME_PAT =
- "^\\d{2}:\\d{2}:\\d{2},\\d{3}";
- public static final String RELATIVE_TIME_PAT = "^\\d{1,10}";
- final String BASIC_PAT = "\\[main\\] (FATAL|ERROR|WARN|INFO|DEBUG)";
- final String ISO8601_PAT =
- "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3}";
-
- /**
- * This filter transforms the input string and returns the results as
- * output. If the input should be ignored, this method returns null.
- *
- */
- String filter(String in) throws UnexpectedFormatException;
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/ISO8601Filter.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/ISO8601Filter.java
deleted file mode 100644
index 3896f13..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/ISO8601Filter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-
-public class ISO8601Filter implements Filter {
- Perl5Util util = new Perl5Util();
-
- public String filter(String in) {
- String pat = "/" + ISO8601_PAT + "/";
-
- if (util.match(pat, in)) {
- return util.substitute("s/" + ISO8601_PAT + "//", in);
- } else {
- return in;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/JunitTestRunnerFilter.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/JunitTestRunnerFilter.java
deleted file mode 100644
index 47f653d..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/JunitTestRunnerFilter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-
-public class JunitTestRunnerFilter implements Filter {
- Perl5Util util = new Perl5Util();
-
- private static final String[] patterns = {
- "/at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner/",
- "/at org.apache.tools.ant/",
- "/at junit.textui.TestRunner/",
- "/at com.intellij.rt.execution.junit/",
- "/at java.lang.reflect.Method.invoke/",
- "/at org.apache.maven.surefire./"
- };
-
- /**
- * Filter out stack trace lines coming from the various JUnit TestRunners.
- */
- public String filter(String in) {
- if (in == null) {
- return null;
- }
-
- //
- // restore the one instance of Method.invoke that we actually want
- //
- if (util.match("/at junit.framework.TestCase.runTest/", in)) {
- return "\tat java.lang.reflect.Method.invoke(X)\n" + in;
- }
-
- for (int i = 0; i < patterns.length; i++) {
- if(util.match(patterns[i], in)) {
- return null;
- }
- }
- return in;
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/LineNumberFilter.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/LineNumberFilter.java
deleted file mode 100644
index 3632265..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/LineNumberFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-
-public class LineNumberFilter implements Filter {
- Perl5Util util = new Perl5Util();
-
- public String filter(String in) {
- if (util.match("/\\(.*:\\d{1,4}\\)/", in)) {
- return util.substitute("s/\\(.*:\\d{1,4}\\)/\\(X\\)/", in);
- } else if (util.match("/\\(Native Method\\)/", in)) {
- return util.substitute("s/\\(Native Method\\)/\\(X\\)/", in);
- } else {
- return in;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/MDCOrderFilter.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/MDCOrderFilter.java
deleted file mode 100644
index 87339a5..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/MDCOrderFilter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-/**
- * This class switches MDC values into the order
- * (unreasonably) expected by the witness files.
- */
-public class MDCOrderFilter implements Filter {
-
- /**
- * Unexpected orders of keys.
- * Note expected values are "va-one-one" and "va-one-two".
- */
- private static final String[] patterns =
- new String[] {
- "{key2,va12}{key1,va11}",
- "{key2,value2}{key1,value1}"
- };
-
- /**
- * Replacement values.
- */
- private static final String[] replacements =
- new String[] {
- "{key1,va11}{key2,va12}",
- "{key1,value1}{key2,value2}"
- };
-
- /**
- * Switch order of MDC keys when not in expected order.
- */
- public String filter(final String in) {
- if (in == null) {
- return null;
- }
-
- for(int i = 0; i < patterns.length; i++) {
- int ipos = in.indexOf(patterns[i]);
- if (ipos >= 1) {
- return in.substring(0, ipos)
- + replacements[i]
- + in.substring(ipos + patterns[i].length());
- }
- }
- return in;
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Profiler.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Profiler.java
deleted file mode 100644
index b0d21ea..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Profiler.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-import java.lang.reflect.Field;
-
-/**
- *
- */
-public class Profiler {
- private static Object profiler;
- private static Class profilingModes;
- private static Class controllerClazz;
-
- static {
- try {
- controllerClazz = Class.forName("com.yourkit.api.Controller");
- profilingModes = Class.forName("com.yourkit.api.ProfilingModes");
- try {
- profiler = controllerClazz.newInstance();
- } catch (Exception e) {
- e.printStackTrace();
- System.out.println("Profiler was active, but failed due: " + e.getMessage());
- }
- }
- catch (Exception e) {
- // Ignore
- }
-
- }
-
- public static boolean isActive() {
- return profiler != null;
- }
-
- public static void start() {
-
- if (profiler != null) {
- try {
- Field f = profilingModes.getDeclaredField("CPU_SAMPLING");
- Object[] args = new Object[2];
- args[0] = f.getLong(profilingModes);
- args[1] = "";
- Class[] parms = new Class[] {long.class, String.class};
- controllerClazz.getMethod("startCPUProfiling", parms).invoke(profiler, args);
- }
- catch (Exception e) {
- e.printStackTrace();
- System.out.println("Profiler was active, but failed due: " + e.getMessage());
- }
- }
- }
-
- public static void stop() {
- if (profiler != null) {
- try {
- Field f = profilingModes.getDeclaredField("SNAPSHOT_WITHOUT_HEAP");
- Object[] args = new Object[1];
- args[0] = f.getLong(profilingModes);
- Class[] parms = new Class[] {long.class};
- profiler.getClass().getMethod("captureSnapshot", parms).invoke(profiler, args);
- profiler.getClass().getMethod("stopCPUProfiling").invoke(profiler);
- }
- catch (Exception e) {
- e.printStackTrace();
- System.out.println("Profiler was active, but failed due: " + e.getMessage());
- }
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/RelativeTimeFilter.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/RelativeTimeFilter.java
deleted file mode 100644
index 4fb235c..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/RelativeTimeFilter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-
-public class RelativeTimeFilter implements Filter {
- Perl5Util util = new Perl5Util();
-
- public String filter(String in) {
- String pat = "/" + Filter.RELATIVE_TIME_PAT + "/";
-
- if (util.match(pat, in)) {
- //System.out.println("Removing relative time from line ["+in+"]");
- return util.substitute("s/" + Filter.RELATIVE_TIME_PAT + "//", in);
- } else {
- return in;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/SunReflectFilter.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/SunReflectFilter.java
deleted file mode 100644
index a32fb60..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/SunReflectFilter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-/**
- * The sun.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;
- } else {
- return in;
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Transformer.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Transformer.java
deleted file mode 100644
index 380bf9a..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/Transformer.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-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,
- UnexpectedFormatException {
-
- String line;
- BufferedReader input = new BufferedReader(new FileReader(in));
- PrintStream output = new PrintStream(new FileOutputStream(out, false));
-
- try {
- // Initialization of input and output omitted
- while ((line = input.readLine()) != null) {
- // apply all filters
- for (int i = 0; i < filters.length; i++) {
- line = filters[i].filter(line);
- }
- if (line != null) {
- output.println(line);
- }
- }
- } finally {
- input.close();
- output.close();
- }
- }
-
-
-
- public
- static
- void transform(String in, String out, Filter filter) throws FileNotFoundException,
- IOException,
- UnexpectedFormatException {
-
- String line;
- BufferedReader input = new BufferedReader(new FileReader(in));
- PrintStream output = new PrintStream(new FileOutputStream(out));
-
- try {
- // Initialization of input and output omitted
- while((line = input.readLine()) != null) {
- line = filter.filter(line);
- output.println(line);
- }
- } finally {
- input.close();
- output.close();
- }
- }
-
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/UnexpectedFormatException.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/UnexpectedFormatException.java
deleted file mode 100644
index b65cef4..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/util/UnexpectedFormatException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.core.util;
-
-public class UnexpectedFormatException extends Exception {
-
- public UnexpectedFormatException(String msg) {
- super(msg);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/test/appender/AlwaysFailAppender.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/test/appender/AlwaysFailAppender.java
deleted file mode 100644
index 1d89343..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/test/appender/AlwaysFailAppender.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.test.appender;
-
-import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.AppenderBase;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-
-/**
- *
- */
-@Plugin(name="AlwaysFail",type="Core",elementType="appender",printObject=true)
-public class AlwaysFailAppender extends AppenderBase {
-
- private AlwaysFailAppender(String name) {
- super(name, null, null, false);
- }
-
- public void append(LogEvent event) {
- throw new LoggingException("Always fail");
- }
-
- @PluginFactory
- public static AlwaysFailAppender createAppender(@PluginAttr("name") String name) {
- if (name == null) {
- LOGGER.error("A name for the Appender must be specified");
- return null;
- }
-
- return new AlwaysFailAppender(name);
- }
-
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/test/appender/InMemoryAppender.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/test/appender/InMemoryAppender.java
deleted file mode 100644
index c948f31..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/test/appender/InMemoryAppender.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.test.appender;
-
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.appender.OutputStreamAppender;
-import org.apache.logging.log4j.core.appender.OutputStreamManager;
-import org.apache.logging.log4j.core.filter.CompositeFilter;
-
-import java.io.ByteArrayOutputStream;
-
-/**
- *
- */
-public class InMemoryAppender extends OutputStreamAppender {
-
- public InMemoryAppender(String name, Layout layout, CompositeFilter filters, boolean handleException) {
- super(name, layout, filters, handleException, true, new InMemoryManager(name));
- }
-
- public String toString() {
- return getManager().toString();
- }
-
- private static class InMemoryManager extends OutputStreamManager {
-
- public InMemoryManager(String name) {
- super(new ByteArrayOutputStream(), name);
- }
-
- public String toString() {
- return getOutputStream().toString();
- }
- }
-}
diff --git a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java b/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
deleted file mode 100644
index 739c6a7..0000000
--- a/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.test.appender;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.AppenderBase;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.SerializedLayout;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * This appender is primarily used for testing. Use in a real environment is discouraged as the
- * List could eventually grow to cause an OutOfMemoryError.
- */
-@Plugin(name = "List", type = "Core", elementType = "appender", printObject = true)
-public class ListAppender extends AppenderBase {
-
- private List<LogEvent> events = new ArrayList<LogEvent>();
-
- private List<String> messages = new ArrayList<String>();
-
- private List<byte[]> data = new ArrayList<byte[]>();
-
- private final boolean newLine;
-
- private final boolean raw;
-
- public ListAppender(String name) {
- super(name, null, null);
- newLine = false;
- raw = false;
- }
-
- public ListAppender(String name, Filter filter, Layout layout, boolean newline, boolean raw) {
- super(name, filter, layout);
- this.newLine = newline;
- this.raw = raw;
- if (layout != null && !(layout instanceof SerializedLayout)) {
- byte[] bytes = layout.getHeader();
- if (bytes != null) {
- write(bytes);
- }
- }
- }
-
- public synchronized void append(LogEvent event) {
- Layout layout = getLayout();
- if (layout == null) {
- events.add(event);
- } else if (layout instanceof SerializedLayout) {
- byte[] header = layout.getHeader();
- byte[] content = layout.format(event);
- byte[] record = new byte[header.length + content.length];
- System.arraycopy(header, 0, record, 0, header.length);
- System.arraycopy(content, 0, record, header.length, content.length);
- data.add(record);
- } else {
- write(layout.format(event));
- }
- }
-
- private void write(byte[] bytes) {
- if (raw) {
- data.add(bytes);
- return;
- }
- String str = new String(bytes);
- if (newLine) {
- int index = 0;
- while (index < str.length()) {
- int end = str.indexOf("\n", index);
- if (index == end) {
- if (!messages.get(messages.size() - 1).equals("")) {
- messages.add("");
- }
- } else if (end >= 0) {
- messages.add(str.substring(index, end));
- } else {
- messages.add(str.substring(index));
- break;
- }
- index = end + 1;
- }
- } else {
- messages.add(str);
- }
- }
-
- public void stop() {
- super.stop();
- Layout layout = getLayout();
- if (layout != null) {
- byte[] bytes = layout.getFooter();
- if (bytes != null) {
- write(bytes);
- }
- }
- }
-
- public synchronized void clear() {
- events.clear();
- messages.clear();
- data.clear();
- }
-
- public synchronized List<LogEvent> getEvents() {
- return Collections.unmodifiableList(events);
- }
-
- public synchronized List<String> getMessages() {
- return Collections.unmodifiableList(messages);
- }
-
- public synchronized List<byte[]> getData() {
- return Collections.unmodifiableList(data);
- }
-
- @PluginFactory
- public static ListAppender createAppender(@PluginAttr("name") String name,
- @PluginAttr("entryPerNewLine") String newLine,
- @PluginAttr("raw") String raw,
- @PluginElement("layout") Layout layout,
- @PluginElement("filters") Filter filter) {
-
- if (name == null) {
- LOGGER.error("No name provided for ListAppender");
- return null;
- }
-
- boolean nl = (newLine == null) ? false : Boolean.parseBoolean(newLine);
- boolean r = (raw == null) ? false : Boolean.parseBoolean(raw);
-
- return new ListAppender(name, filter, layout, nl, r);
- }
-}
diff --git a/rgoers/log4j2-core/src/test/resources/FlumeFuncTest.xml b/rgoers/log4j2-core/src/test/resources/FlumeFuncTest.xml
deleted file mode 100644
index 1ffe849..0000000
--- a/rgoers/log4j2-core/src/test/resources/FlumeFuncTest.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration packages="" status="error" name="Flume">
- <MarkerFilter marker="EVENT" onMatch="ACCEPT" onMisMatch="NEUTRAL"/>
- <Appenders>
- <Flume name="eventLogger" suppressExceptions="false" mdcPrefix="." compress="true">
- <Agent host="192.168.10.101" port="8800"/>
- <RFC5424Layout enterpriseNumber="18060" includeMDC="true" mdcId="RequestContext" appName="MyApp"/>
- </Flume>
- <Console name="console">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36}:%L %M - %msg%n"/>
- </Console>
- </Appenders>
-
- <loggers>
- <logger name="EventLogger" level="info" additivity="false">
- <appender-ref ref="eventLogger"/>
- </logger>
- <root level="error">
- <appender-ref ref="console"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-burst.xml b/rgoers/log4j2-core/src/test/resources/log4j-burst.xml
deleted file mode 100644
index eefbb90..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-burst.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration status="warn" name="BurstTest" packages="org.apache.logging.log4j.test">
- <appenders>
- <List name="ListAppender">
- <PatternLayout pattern="%-5p %d{dd-MMM-yyyy HH:mm:ss} %t %m%n"/>
- <BurstFilter level="INFO" rate="33" maxBurst="100"/>
- </List>
- </appenders>
-
- <loggers>
- <root level="TRACE">
- <appender-ref ref="ListAppender"/>
- </root>
- </loggers>
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-failover.xml b/rgoers/log4j2-core/src/test/resources/log4j-failover.xml
deleted file mode 100644
index 9107c4a..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-failover.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration status="error" name="FailoverTest" packages="org.apache.logging.log4j.test">
- <Appenders>
- <AlwaysFail name="Fail" />
- <List name="List" />
- <Failover name="Failover" primary="Fail" suppressExceptions="false">
- <Failovers>
- <appender-ref ref="List"/>
- </Failovers>
- </Failover>
- </Appenders>
-
- <loggers>
- <root level="error">
- <appender-ref ref="Failover"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-replace.xml b/rgoers/log4j2-core/src/test/resources/log4j-replace.xml
deleted file mode 100644
index 73a59c0..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-replace.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration status="error" name="RegexReplacementTest" packages="org.apache.logging.log4j.test">
- <Appenders>
- <List name="List">
- <PatternLayout>
- <replace regex="\." replacement="/"/>
- <pattern>%logger %msg%n</pattern>
- </PatternLayout>
- </List>
- <List name="List2">
- <PatternLayout>
- <pattern>%replace{%logger %msg%n}{\.}{/}</pattern>
- </PatternLayout>
- </List>
- </Appenders>
-
- <loggers>
- <logger level="trace" name="ReplacementTest" additivity="false">
- <appender-ref ref="List2"/>
- </logger>
- <root level="trace">
- <appender-ref ref="List"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-rewrite.xml b/rgoers/log4j2-core/src/test/resources/log4j-rewrite.xml
deleted file mode 100644
index 5b4a23f..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-rewrite.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration status="error" name="RoutingTest" packages="org.apache.logging.log4j.test">
-
- <appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- <List name="List">
- <ThresholdFilter level="debug"/>
- </List>
- <Rewrite name="Rewrite">
- <MapRewritePolicy>
- <KeyValuePair key="Key1" Value="Apache"/>
- <KeyValuePair key="Key3" Value="Log4j"/>
- </MapRewritePolicy>
- <appender-ref ref="List"/>
-
- </Rewrite>
- </appenders>
-
- <loggers>
- <logger name="EventLogger" level="trace" additivity="false">
- <appender-ref ref="Rewrite"/>
- </logger>
-
- <root level="error">
- <appender-ref ref="STDOUT"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml b/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml
deleted file mode 100644
index 0cecccb..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration status="warn" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
- <properties>
- <property name="filename">target/rolling1/rollingtest.log</property>
- </properties>
- <ThresholdFilter level="debug"/>
-
- <appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- <RollingFile name="RollingFile" fileName="${filename}"
- filePattern="target/rolling1/test1-$${date:MM-dd-yyyy}-%i.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <SizeBasedTriggeringPolicy size="500" />
- </RollingFile>
- <List name="List">
- <ThresholdFilter level="error"/>
- </List>
- </appenders>
-
- <loggers>
- <logger name="org.apache.logging.log4j.test1" level="debug" additivity="false">
- <ThreadContextMapFilter>
- <KeyValuePair key="test" value="123"/>
- </ThreadContextMapFilter>
- <appender-ref ref="STDOUT"/>
- </logger>>
-
- <logger name="org.apache.logging.log4j.core.appender.rolling" level="debug" additivity="false">
- <appender-ref ref="RollingFile"/>
- </logger>>
-
- <root level="error">
- <appender-ref ref="STDOUT"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-rolling2.xml b/rgoers/log4j2-core/src/test/resources/log4j-rolling2.xml
deleted file mode 100644
index 500f131..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-rolling2.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration status="warn" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
- <properties>
- <property name="filename">target/rolling2/rollingtest.log</property>
- </properties>
- <filters>
- <ThresholdFilter level="debug"/>
- </filters>
-
- <appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- <RollingFile name="RollingFile" fileName="${filename}" filePattern="target/rolling2/test1-%d{MM-dd-yy-HH-mm-ss}.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- <List name="List">
- <filters>
- <ThresholdFilter level="error"/>
- </filters>
- </List>
- </appenders>
-
- <loggers>
- <logger name="org.apache.logging.log4j.core.appender.rolling" level="debug" additivity="false">
- <appender-ref ref="RollingFile"/>
- </logger>>
-
- <root level="error">
- <appender-ref ref="STDOUT"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-rolling3.xml b/rgoers/log4j2-core/src/test/resources/log4j-rolling3.xml
deleted file mode 100644
index 938563d..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-rolling3.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration status="warn" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
- <properties>
- <property name="filename">target/rolling3/rollingtest.log</property>
- </properties>
- <ThresholdFilter level="debug"/>
-
- <appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- <RollingFile name="RollingFile" fileName="${filename}" filePattern="target/rolling3/test1-%d{MM-dd-yy-HH-mm}-%i.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <Policies>
- <TimeBasedTriggeringPolicy />
- <SizeBasedTriggeringPolicy size="500" />
- </Policies>
- </RollingFile>
- <List name="List">
- <ThresholdFilter level="error"/>
- </List>
- </appenders>
-
- <loggers>
- <logger name="org.apache.logging.log4j.core.appender.rolling" level="debug" additivity="false">
- <appender-ref ref="RollingFile"/>
- </logger>>
-
- <root level="error">
- <appender-ref ref="STDOUT"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-routing.json b/rgoers/log4j2-core/src/test/resources/log4j-routing.json
deleted file mode 100644
index 362a0de..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-routing.json
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-{ "configuration": { "status": "error", "name": "RoutingTest", "packages": "org.apache.logging.log4j.test",
- "properties": {
- "property": { "name": "filename", "value" : "target/rolling1/rollingtest-$${sd:type}.log" }
- },
- "ThresholdFilter": { "level": "debug" },
- "appenders": {
- "Console": { "name": "STDOUT",
- "PatternLayout": { "pattern": "%m%n" }
- },
- "List": { "name": "List",
- "ThresholdFilter": { "level": "debug" }
- },
- "Routing": { "name": "Routing",
- "Routes": { "pattern": "$${sd:type}",
- "Route": [
- {
- "RollingFile": {
- "name": "Rolling-${sd:type}", "fileName": "${filename}",
- "filePattern": "target/rolling1/test1-${sd:type}.%i.log.gz",
- "PatternLayout": {"pattern": "%d %p %C{1.} [%t] %m%n"},
- "SizeBasedTriggeringPolicy": { "size": "500" }
- }
- },
- { "appender-ref": "STDOUT", "key": "Audit"},
- { "appender-ref": "List", "key": "Service"}
- ]
- }
- }
- },
- "loggers": {
- "logger": { "name": "EventLogger", "level": "info", "additivity": "false", "appender-ref": { "ref": "Routing" }},
- "root": { "level": "error", "appender-ref": { "ref": "STDOUT" }}
- }
- }
-}
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-routing.xml b/rgoers/log4j2-core/src/test/resources/log4j-routing.xml
deleted file mode 100644
index 2acfed5..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-routing.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration status="debug" name="RoutingTest" packages="org.apache.logging.log4j.test">
- <properties>
- <property name="filename">target/rolling1/rollingtest-$${sd:type}.log</property>
- </properties>
- <ThresholdFilter level="debug"/>
-
- <appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- <List name="List">
- <ThresholdFilter level="debug"/>
- </List>
- <Routing name="Routing">
- <Routes pattern="$${sd:type}">
- <Route>
- <RollingFile name="Rolling-${sd:type}" fileName="${filename}"
- filePattern="target/rolling1/test1-${sd:type}.%i.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <SizeBasedTriggeringPolicy size="500" />
- </RollingFile>
- </Route>
- <Route appender-ref="STDOUT" key="Audit"/>
- <Route appender-ref="List" key="Service"/>
- </Routes>
- </Routing>
- </appenders>
-
- <loggers>
- <logger name="EventLogger" level="info" additivity="false">
- <appender-ref ref="Routing"/>
- </logger>
-
- <root level="error">
- <appender-ref ref="STDOUT"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-routing2.json b/rgoers/log4j2-core/src/test/resources/log4j-routing2.json
deleted file mode 100644
index 9e0ed98..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-routing2.json
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-{ "configuration": { "status": "error", "name": "RoutingTest", "packages": "org.apache.logging.log4j.test",
- "properties": {
- "property": { "name": "filename", "value" : "target/rolling1/rollingtest-$${sd:type}.log" }
- },
- "ThresholdFilter": { "level": "debug" },
- "appenders": {
- "appender": [
- { "type": "Console", "name": "STDOUT", "PatternLayout": { "pattern": "%m%n" }},
- { "type": "List", "name": "List", "ThresholdFilter": { "level": "debug" }},
- { "type": "Routing", "name": "Routing",
- "Routes": { "pattern": "$${sd:type}",
- "Route": [
- {
- "RollingFile": {
- "name": "Rolling-${sd:type}", "fileName": "${filename}",
- "filePattern": "target/rolling1/test1-${sd:type}.%i.log.gz",
- "PatternLayout": {"pattern": "%d %p %C{1.} [%t] %m%n"},
- "SizeBasedTriggeringPolicy": { "size": "500" }
- }
- },
- { "appender-ref": "STDOUT", "key": "Audit"},
- { "appender-ref": "List", "key": "Service"}
- ]
- }
- }
- ]
- },
- "loggers": {
- "logger": [
- { "name": "EventLogger", "level": "info", "additivity": "false", "appender-ref": { "ref": "Routing" }},
- { "name": "com.foo.bar", "level": "error", "additivity": "false", "appender-ref": { "ref": "STDOUT" }}
- ],
- "root": { "level": "error", "appender-ref": { "ref": "STDOUT" }}
- }
- }
-}
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-strict1.xml b/rgoers/log4j2-core/src/test/resources/log4j-strict1.xml
deleted file mode 100644
index a63af85..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-strict1.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration status="debug" strict="true" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
- <properties>
- <property name="filename">target/test.log</property>
- </properties>
- <filter type="ThresholdFilter" level="trace"/>
-
- <appenders>
- <appender type="Console" name="STDOUT">
- <layout type="PatternLayout" pattern="%m MDC%X%n"/>
- <filters>
- <filter type="MarkerFilter" marker="FLOW" onMatch="DENY" onMismatch="NEUTRAL"/>
- <filter type="MarkerFilter" marker="EXCEPTION" onMatch="DENY" onMismatch="ACCEPT"/>
- </filters>
- </appender>
- <appender type="Console" name="FLOW">
- <layout type="PatternLayout" pattern="%C{1}.%M %m %ex%n"/>
- <filters>
- <filter type="MarkerFilter" marker="FLOW" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
- <filter type="MarkerFilter" marker="EXCEPTION" onMatch="ACCEPT" onMismatch="DENY"/>
- </filters>
- </appender>
- <appender type="File" name="File" fileName="${filename}">
- <layout type="PatternLayout">
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </layout>
- </appender>
- <appender type="List" name="List">
- </appender>
- </appenders>
-
- <loggers>
- <logger name="org.apache.logging.log4j.test1" level="debug" additivity="false">
- <filter type="ThreadContextMapFilter">
- <KeyValuePair key="test" value="123"/>
- </filter>
- <appender-ref ref="STDOUT"/>
- </logger>>
-
- <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
- <appender-ref ref="File"/>
- </logger>>
-
- <root level="trace">
- <appender-ref ref="List"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-test1.xml b/rgoers/log4j2-core/src/test/resources/log4j-test1.xml
deleted file mode 100644
index df6e324..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-test1.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration status="warn" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
- <properties>
- <property name="filename">target/test.log</property>
- </properties>
- <ThresholdFilter level="debug"/>
-
- <appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- <File name="File" fileName="${filename}" bufferedIO="false">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- </File>
- <List name="List">
- <filters>
- <ThresholdFilter level="error"/>
- </filters>
- </List>
- </appenders>
-
- <loggers>
- <logger name="org.apache.logging.log4j.test1" level="debug" additivity="false">
- <ThreadContextMapFilter>
- <KeyValuePair key="test" value="123"/>
- </ThreadContextMapFilter>
- <appender-ref ref="STDOUT"/>
- </logger>>
-
- <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
- <appender-ref ref="File"/>
- </logger>>
-
- <root level="error">
- <appender-ref ref="STDOUT"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j-test2.xml b/rgoers/log4j2-core/src/test/resources/log4j-test2.xml
deleted file mode 100644
index 2bc4942..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j-test2.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration status="debug" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
- <properties>
- <property name="filename">target/test.log</property>
- </properties>
- <ThresholdFilter level="trace"/>
-
- <appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m MDC%X%n"/>
- <filters>
- <MarkerFilter marker="FLOW" onMatch="DENY" onMismatch="NEUTRAL"/>
- <MarkerFilter marker="EXCEPTION" onMatch="DENY" onMismatch="ACCEPT"/>
- </filters>
- </Console>
- <Console name="FLOW">
- <PatternLayout pattern="%C{1}.%M %m %ex%n"/>
- <filters>
- <MarkerFilter marker="FLOW" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
- <MarkerFilter marker="EXCEPTION" onMatch="ACCEPT" onMismatch="DENY"/>
- </filters>
- </Console>
- <File name="File" fileName="${filename}">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- </File>
- <List name="List">
- </List>
- </appenders>
-
- <loggers>
- <logger name="org.apache.logging.log4j.test1" level="debug" additivity="false">
- <ThreadContextMapFilter>
- <KeyValuePair key="test" value="123"/>
- </ThreadContextMapFilter>
- <appender-ref ref="STDOUT"/>
- </logger>>
-
- <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
- <appender-ref ref="File"/>
- </logger>>
-
- <root level="trace">
- <appender-ref ref="List"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j12-perf.xml b/rgoers/log4j2-core/src/test/resources/log4j12-perf.xml
deleted file mode 100644
index 49d0d65..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j12-perf.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
- <appender name="TestLogfile" class="org.apache.log4j.FileAppender">
- <param name="File" value="target/testlog4j.log"/>
- <param name="immediateFlush" value="false"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{ISO8601} %5p [%t] %c{1} %X{transactionId} - %m%n"/>
- </layout>
- </appender>
- <root>
- <level value="debug"/>
- <appender-ref ref="TestLogfile"/>
- </root>
-</log4j:configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j12-perf2.xml b/rgoers/log4j2-core/src/test/resources/log4j12-perf2.xml
deleted file mode 100644
index f321a8b..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j12-perf2.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
- <appender name="TestLogfile" class="org.apache.log4j.FileAppender">
- <param name="File" value="target/testlog4j.log"/>
- <param name="immediateFlush" value="false"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{ISO8601} %5p [%t] %c{1} %X{transactionId} - %m%n"/>
- </layout>
- </appender>
- <root>
- <level value="error"/>
- <appender-ref ref="TestLogfile"/>
- </root>
-</log4j:configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j2-perf-filter.xml b/rgoers/log4j2-core/src/test/resources/log4j2-perf-filter.xml
deleted file mode 100644
index 52add53..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j2-perf-filter.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration packages="" name="XMLPerfTest" status="error">
- <!-- <MarkerFilter marker="LOG4J" onMismatch="NEUTRAL"/> -->
- <ThreadContextMapFilter onMismatch="NEUTRAL">
- <KeyValuePair key="LOG4J" value="test"/>
- </ThreadContextMapFilter>
- <appenders>
- <File name="TestLogfile" fileName="target/testlog4j2.log" immediateFlush="false">
- <PatternLayout>
- <pattern>%d{ISO8601} %5p [%t] %c{1} %X{transactionId} - %m%n</pattern>
- </PatternLayout>
- </File>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="TestLogfile"/>
- </root>
- </loggers>
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j2-perf.xml b/rgoers/log4j2-core/src/test/resources/log4j2-perf.xml
deleted file mode 100644
index 81625c3..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j2-perf.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration packages="" name="XMLPerfTest" status="error">
- <appenders>
- <File name="TestLogfile" fileName="target/testlog4j2.log" immediateFlush="false">
- <PatternLayout>
- <pattern>%d{ISO8601} %5p [%t] %c{1} %X{transactionId} - %m%n</pattern>
- </PatternLayout>
- </File>
- </appenders>
- <loggers>
- <root level="debug">
- <appender-ref ref="TestLogfile"/>
- </root>
- </loggers>
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/log4j2-perf2.xml b/rgoers/log4j2-core/src/test/resources/log4j2-perf2.xml
deleted file mode 100644
index 2b1a7f2..0000000
--- a/rgoers/log4j2-core/src/test/resources/log4j2-perf2.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration packages="" name="XMLPerfTest" status="error">
- <appenders>
- <File name="TestLogfile" fileName="target/testlog4j2.log" immediateFlush="false">
- <PatternLayout>
- <pattern>%d{ISO8601} %5p [%t] %c{1} %X{transactionId} - %m%n</pattern>
- </PatternLayout>
- </File>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="TestLogfile"/>
- </root>
- </loggers>
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/logback-flume.xml b/rgoers/log4j2-core/src/test/resources/logback-flume.xml
deleted file mode 100644
index ccc055b..0000000
--- a/rgoers/log4j2-core/src/test/resources/logback-flume.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration>
- <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>%d{ISO8601} %5p [%t] %c{0} %X{transactionId} - %m%n</Pattern>
- </encoder>
- </appender>
-
- <root level="error">
- <appender-ref ref="Console" />
- </root>
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/logback-perf-filter.xml b/rgoers/log4j2-core/src/test/resources/logback-perf-filter.xml
deleted file mode 100644
index 4fbb0a5..0000000
--- a/rgoers/log4j2-core/src/test/resources/logback-perf-filter.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration>
- <!--<turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
- <Marker>LOG4J</Marker>
- </turboFilter> -->
- <turboFilter class="ch.qos.logback.classic.turbo.MDCFilter">
- <MDCKey>LOG4J</MDCKey>
- <value>test</value>
- </turboFilter>
- <appender name="TestLogfile" class="ch.qos.logback.core.FileAppender">
- <file>target/testlogback.log</file>
- <encoder>
- <Pattern>%d{ISO8601} %5p [%t] %c{0} %X{transactionId} - %m%n</Pattern>
- </encoder>
- </appender>
-
- <root level="error">
- <appender-ref ref="TestLogfile" />
- </root>
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/logback-perf.xml b/rgoers/log4j2-core/src/test/resources/logback-perf.xml
deleted file mode 100644
index f5d50fb..0000000
--- a/rgoers/log4j2-core/src/test/resources/logback-perf.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration>
- <appender name="TestLogfile" class="ch.qos.logback.core.FileAppender">
- <file>target/testlogback.log</file>
- <encoder>
- <Pattern>%d{ISO8601} %5p [%t] %c{0} %X{transactionId} - %m%n</Pattern>
- </encoder>
- </appender>
-
- <root level="debug">
- <appender-ref ref="TestLogfile" />
- </root>
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/logback-perf2.xml b/rgoers/log4j2-core/src/test/resources/logback-perf2.xml
deleted file mode 100644
index a172db4..0000000
--- a/rgoers/log4j2-core/src/test/resources/logback-perf2.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration>
- <appender name="TestLogfile" class="ch.qos.logback.core.FileAppender">
- <file>target/testlogback.log</file>
- <encoder>
- <Pattern>%d{ISO8601} %5p [%t] %c{0} %X{transactionId} - %m%n</Pattern>
- </encoder>
- </appender>
-
- <root level="error">
- <appender-ref ref="TestLogfile" />
- </root>
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/logback-subst.xml b/rgoers/log4j2-core/src/test/resources/logback-subst.xml
deleted file mode 100644
index 68a346b..0000000
--- a/rgoers/log4j2-core/src/test/resources/logback-subst.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<configuration>
- <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>%d{ISO8601} %5p [%t] %c{0} - %m%n</Pattern>
- </encoder>
- </appender>
-
- <root level="debug">
- <appender-ref ref="stdout" />
- </root>
-</configuration>
\ No newline at end of file
diff --git a/rgoers/log4j2-core/src/test/resources/witness/PatternParser_mdc b/rgoers/log4j2-core/src/test/resources/witness/PatternParser_mdc
deleted file mode 100644
index 5c64114..0000000
--- a/rgoers/log4j2-core/src/test/resources/witness/PatternParser_mdc
+++ /dev/null
@@ -1,12 +0,0 @@
-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 : {key1=value1, key2=value2}
-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/rgoers/log4j2-flume-ng/pom.xml b/rgoers/log4j2-flume-ng/pom.xml
deleted file mode 100644
index f24c752..0000000
--- a/rgoers/log4j2-flume-ng/pom.xml
+++ /dev/null
@@ -1,203 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2</artifactId>
- <version>1.99.0-SNAPSHOT</version>
- </parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-flume-ng</artifactId>
- <packaging>jar</packaging>
- <name>Log4J2 Flume NG</name>
- <description>Log4j 2.0 Flume Appender</description>
- <properties>
- <log4j.parent.dir>${basedir}/..</log4j.parent.dir>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>slf4j-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.7</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.flume</groupId>
- <artifactId>flume-ng-core</artifactId>
- <version>1.0.0-incubating</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <forkMode>always</forkMode>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <version>2.6</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>changes-report</report>
- </reports>
- </reportSet>
- </reportSets>
- <configuration>
- <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.7</version>
- <configuration>
- <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
- <configLocation>${log4j.parent.dir}/checkstyle.xml</configLocation>
- <suppressionsLocation>${log4j.parent.dir}/checkstyle-suppressions.xml</suppressionsLocation>
- <enableRulesSummary>false</enableRulesSummary>
- <propertyExpansion>basedir=${basedir}</propertyExpansion>
- <propertyExpansion>licensedir=${log4j.parent.dir}/checkstyle-header.txt</propertyExpansion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8</version>
- <configuration>
- <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
- project -->
- <detectOfflineLinks>false</detectOfflineLinks>
- <linksource>true</linksource>
- <tags>
- <tag>
- <name>issue</name>
- <placement>a</placement>
- <head>JIRA issue:</head>
- </tag>
- <tag>
- <name>doubt</name>
- <placement>a</placement>
- <head>Troublesome:</head>
- </tag>
- <tag>
- <name>compare</name>
- <placement>a</placement>
- <head>Compare with:</head>
- </tag>
- </tags>
- </configuration>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <threshold>Normal</threshold>
- <effort>Default</effort>
- <excludeFilterFile>findbugs-exclude-filter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.3</version>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>jxr</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <targetJdk>1.5</targetJdk>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.2</version>
- <reportSets>
- <reportSet>
- <!-- Disabled at it kills the site generation via a NoClassDefFoundError -->
- <reports/>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
-</project>
-
diff --git a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/Agent.java b/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/Agent.java
deleted file mode 100644
index f6e123b..0000000
--- a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/Agent.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flume.appender;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Agent Specification for FlumeAvroAppender.
- */
-@Plugin(name = "Agent", type = "Core", printObject = true)
-public final class Agent {
-
- private static final String DEFAULT_HOST = "localhost";
-
- private static final int DEFAULT_PORT = 35853;
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private final String host;
-
- private final int port;
-
- private Agent(String host, int port) {
- this.host = host;
- this.port = port;
- }
-
- /**
- * Retrieve the host name.
- * @return The name of the host.
- */
- public String getHost() {
- return host;
- }
-
- /**
- * Retrieve the port number.
- * @return The port number.
- */
- public int getPort() {
- return port;
- }
-
- @Override
- public String toString() {
- return "host=" + host + " port=" + port;
- }
-
- /**
- * Create an Agent.
- * @param host The host name.
- * @param port The port number.
- * @return The Agent.
- */
- @PluginFactory
- public static Agent createAgent(@PluginAttr("host") String host,
- @PluginAttr("port") String port) {
- if (host == null) {
- host = DEFAULT_HOST;
- }
-
- int portNum;
- if (port != null) {
- try {
- portNum = Integer.parseInt(port);
- } catch (Exception ex) {
- LOGGER.error("Error parsing port number " + port, ex);
- return null;
- }
- } else {
- portNum = DEFAULT_PORT;
- }
- return new Agent(host, portNum);
- }
-}
diff --git a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAvroAppender.java b/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAvroAppender.java
deleted file mode 100644
index 5434da7..0000000
--- a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAvroAppender.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flume.appender;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.AppenderBase;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.RFC5424Layout;
-
-import java.net.InetAddress;
-
-/**
- * An Appender that uses the Avro protocol to route events to Flume.
- */
-@Plugin(name = "Flume", type = "Core", elementType = "appender", printObject = true)
-public final class FlumeAvroAppender extends AppenderBase implements FlumeEventFactory {
-
- private FlumeAvroManager manager;
-
- private final String mdcIncludes;
- private final String mdcExcludes;
- private final String mdcRequired;
-
- private final String eventPrefix;
-
- private final String mdcPrefix;
-
- private final boolean compressBody;
-
- private final String hostname;
-
- private final int reconnectDelay;
-
- private final int retries;
-
- private final FlumeEventFactory factory;
-
- private FlumeAvroAppender(String name, Filter filter, Layout layout, boolean handleException,
- String hostname, String includes, String excludes, String required, String mdcPrefix,
- String eventPrefix, boolean compress, int delay, int retries,
- FlumeEventFactory factory, FlumeAvroManager manager) {
- super(name, filter, layout, handleException);
- this.manager = manager;
- this.mdcIncludes = includes;
- this.mdcExcludes = excludes;
- this.mdcRequired = required;
- this.eventPrefix = eventPrefix;
- this.mdcPrefix = mdcPrefix;
- this.compressBody = compress;
- this.hostname = hostname;
- this.reconnectDelay = delay;
- this.retries = retries;
- this.factory = factory == null ? this : factory;
- }
-
- /**
- * Publish the event.
- * @param event The LogEvent.
- */
- public void append(LogEvent event) {
-
- FlumeEvent flumeEvent = factory.createEvent(event, mdcIncludes, mdcExcludes, mdcRequired, mdcPrefix,
- eventPrefix, compressBody);
- flumeEvent.setBody(getLayout().format(flumeEvent));
- manager.send(flumeEvent, reconnectDelay, retries);
- }
-
- @Override
- public void stop() {
- super.stop();
- manager.release();
- }
-
- /**
- * Create a Flume event.
- * @param event The Log4j LogEvent.
- * @param includes comma separated list of mdc elements to include.
- * @param excludes comma separated list of mdc elements to exclude.
- * @param required comma separated list of mdc elements that must be present with a value.
- * @param mdcPrefix The prefix to add to MDC key names.
- * @param eventPrefix The prefix to add to event fields.
- * @param compress If true the body will be compressed.
- * @return A Flume Event.
- */
- public FlumeEvent createEvent(LogEvent event, String includes, String excludes, String required,
- String mdcPrefix, String eventPrefix, boolean compress) {
- return new FlumeEvent(event, mdcIncludes, mdcExcludes, mdcRequired, mdcPrefix,
- eventPrefix, compressBody);
- }
-
- /**
- * Create a Flume Avro Appender.
- * @param agents An array of Agents.
- * @param delay The amount of time in milliseconds to wait between retries.
- * @param agentRetries The number of times to retry an agent before failing to the next agent.
- * @param name The name of the Appender.
- * @param suppress If true exceptions will be handled in the appender.
- * @param excludes A comma separated list of MDC elements to exclude.
- * @param includes A comma separated list of MDC elements to include.
- * @param required A comma separated list of MDC elements that are required.
- * @param mdcPrefix The prefix to add to MDC key names.
- * @param eventPrefix The prefix to add to event key names.
- * @param compressBody If true the event body will be compressed.
- * @param batchSize Number of events to include in a batch. Defaults to 1.
- * @param factory The factory to use to create Flume events.
- * @param layout The layout to format the event.
- * @param filter A Filter to filter events.
- * @return A Flume Avro Appender.
- */
- @PluginFactory
- public static FlumeAvroAppender createAppender(@PluginElement("agents") Agent[] agents,
- @PluginAttr("reconnectionDelay") String delay,
- @PluginAttr("agentRetries") String agentRetries,
- @PluginAttr("name") String name,
- @PluginAttr("suppressExceptions") String suppress,
- @PluginAttr("mdcExcludes") String excludes,
- @PluginAttr("mdcIncludes") String includes,
- @PluginAttr("mdcRequired") String required,
- @PluginAttr("mdcPrefix") String mdcPrefix,
- @PluginAttr("eventPrefix") String eventPrefix,
- @PluginAttr("compress") String compressBody,
- @PluginAttr("batchSize") String batchSize,
- @PluginElement("flumeEventFactory") FlumeEventFactory factory,
- @PluginElement("layout") Layout layout,
- @PluginElement("filters") Filter filter) {
-
- String hostname;
- try {
- hostname = InetAddress.getLocalHost().getHostName();
- } catch (Exception ex) {
- LOGGER.error("Unable to determine local hostname", ex);
- return null;
- }
- if (agents == null || agents.length == 0) {
- LOGGER.debug("No agents provided, using defaults");
- agents = new Agent[] {Agent.createAgent(null, null)};
- }
-
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
- boolean compress = compressBody == null ? true : Boolean.valueOf(compressBody);
-
- int batchCount = batchSize == null ? 1 : Integer.parseInt(batchSize);
- int reconnectDelay = delay == null ? 0 : Integer.parseInt(delay);
- int retries = agentRetries == null ? 0 : Integer.parseInt(agentRetries);
-
- if (layout == null) {
- layout = RFC5424Layout.createLayout(null, null, null, "True", null, null, null, null, excludes,
- includes, required, null, null);
- }
-
- if (name == null) {
- LOGGER.error("No name provided for Appender");
- return null;
- }
-
- FlumeAvroManager manager = FlumeAvroManager.getManager(agents, batchCount);
- if (manager == null) {
- return null;
- }
-
- return new FlumeAvroAppender(name, filter, layout, handleExceptions, hostname, includes,
- excludes, required, mdcPrefix, eventPrefix, compress, reconnectDelay, retries, factory, manager);
- }
-}
diff --git a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAvroManager.java b/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAvroManager.java
deleted file mode 100644
index 283ce6c..0000000
--- a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAvroManager.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flume.appender;
-
-import org.apache.avro.AvroRemoteException;
-import org.apache.avro.ipc.NettyTransceiver;
-import org.apache.avro.ipc.Transceiver;
-import org.apache.avro.ipc.specific.SpecificRequestor;
-import org.apache.flume.source.avro.AvroFlumeEvent;
-import org.apache.flume.source.avro.AvroSourceProtocol;
-import org.apache.flume.source.avro.Status;
-import org.apache.logging.log4j.core.appender.AbstractManager;
-import org.apache.logging.log4j.core.appender.AppenderRuntimeException;
-import org.apache.logging.log4j.core.appender.ManagerFactory;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Manager for FlumeAvroAppenders.
- */
-public class FlumeAvroManager extends AbstractManager {
-
- /**
- The default reconnection delay (500 milliseconds or .5 seconds).
- */
- public static final int DEFAULT_RECONNECTION_DELAY = 500;
-
- private static final int DEFAULT_RECONNECTS = 3;
-
- private static ManagerFactory factory = new AvroManagerFactory();
-
- private AvroSourceProtocol client;
-
- private final Agent[] agents;
-
- private final int batchSize;
-
- private final EventList events = new EventList();
-
- private int current = 0;
-
- private Transceiver transceiver;
-
- /**
- * Constructor
- * @param name The unique name of this manager.
- * @param agents An array of Agents.
- * @param batchSize The number of evetns to include in a batch.
- */
- protected FlumeAvroManager(String name, Agent[] agents, int batchSize) {
- super(name);
- this.agents = agents;
- this.batchSize = batchSize;
- this.client = connect(agents);
- }
-
- /**
- * Return a FlumeAvroManager.
- * @param agents The agents to use.
- * @param batchSize The number of events to include in a batch.
- * @return A FlumeAvroManager.
- */
- public static FlumeAvroManager getManager(Agent[] agents, int batchSize) {
- if (agents == null || agents.length == 0) {
- throw new IllegalArgumentException("At least one agent is required");
- }
-
- if (batchSize <= 0) {
- batchSize = 1;
- }
-
- StringBuilder sb = new StringBuilder("FlumeAvro[");
- boolean first = true;
- for (Agent agent : agents) {
- if (!first) {
- sb.append(",");
- }
- sb.append(agent.getHost()).append(":").append(agent.getPort());
- first = false;
- }
- sb.append("]");
- return (FlumeAvroManager) getManager(sb.toString(), factory, new FactoryData(agents, batchSize));
- }
-
- /**
- * Return the agents.
- * @return The agent array.
- */
- public Agent[] getAgents() {
- return agents;
- }
-
- /**
- * Returns the index of the current agent.
- * @return The index for the current agent.
- */
- public int getCurrent() {
- return current;
- }
-
- protected synchronized void send(FlumeEvent event, int delay, int retries) {
- if (delay == 0) {
- delay = DEFAULT_RECONNECTION_DELAY;
- }
- if (retries == 0) {
- retries = DEFAULT_RECONNECTS;
- }
- AvroFlumeEvent avroEvent = new AvroFlumeEvent();
- avroEvent.body = ByteBuffer.wrap(event.getBody());
- avroEvent.headers = new HashMap<CharSequence, CharSequence>();
-
- for (Map.Entry<String, String> entry : event.getHeaders().entrySet()) {
- avroEvent.headers.put(entry.getKey(), entry.getValue());
- }
-
- List<AvroFlumeEvent> batch = batchSize > 1 ? events.addAndGet(avroEvent, batchSize) : null;
- if (batch == null && batchSize > 1) {
- return;
- }
-
- int i = 0;
-
- String msg = "Error writing to " + getName();
-
- do {
- try {
- Status status = (batch == null) ? client.append(avroEvent) : client.appendBatch(batch);
- if (!status.equals(Status.OK)) {
- throw new AvroRemoteException("RPC communication failed to " + agents[current].getHost() +
- ":" + agents[current].getPort());
- }
- return;
- } catch (Exception ex) {
- if (i == retries - 1) {
- msg = "Error writing to " + getName() + " at " + agents[current].getHost() + ":" +
- agents[current].getPort();
- LOGGER.warn(msg, ex);
- break;
- }
- sleep(delay);
- }
- } while (++i < retries);
-
- for (int index = 0; index < agents.length; ++index) {
- if (index == current) {
- continue;
- }
- Agent agent = agents[index];
- i = 0;
- do {
- try {
- transceiver = null;
- AvroSourceProtocol c = connect(agent.getHost(), agent.getPort());
- Status status = (batch == null) ? c.append(avroEvent) : c.appendBatch(batch);
- if (!status.equals(Status.OK)) {
- if (i == retries - 1) {
- String warnMsg = "RPC communication failed to " + getName() + " at " +
- agent.getHost() + ":" + agent.getPort();
- LOGGER.warn(warnMsg);
- }
- continue;
- }
- client = c;
- current = i;
- return;
- } catch (Exception ex) {
- if (i == retries - 1) {
- String warnMsg = "Error writing to " + getName() + " at " + agent.getHost() + ":" +
- agent.getPort();
- LOGGER.warn(warnMsg, ex);
- break;
- }
- sleep(delay);
- }
- } while (++i < retries);
- }
-
- throw new AppenderRuntimeException(msg);
-
- }
-
- private void sleep(int delay) {
- try {
- Thread.sleep(delay);
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- }
-
- /**
- * There is a very good chance that this will always return the first agent even if it isn't available.
- * @param agents The list of agents to choose from
- * @return The FlumeEventAvroServer.
- */
- private AvroSourceProtocol connect(Agent[] agents) {
- int i = 0;
- for (Agent agent : agents) {
- AvroSourceProtocol server = connect(agent.getHost(), agent.getPort());
- if (server != null) {
- current = i;
- return server;
- }
- ++i;
- }
- throw new AppenderRuntimeException("Unable to connect to any agents");
- }
-
- private AvroSourceProtocol connect(String hostname, int port) {
- try {
- if (transceiver == null) {
- transceiver = new NettyTransceiver(new InetSocketAddress(hostname, port));
- }
- } catch (IOException ioe) {
- LOGGER.error("Unable to create transceiver", ioe);
- return null;
- }
- try {
- return SpecificRequestor.getClient(AvroSourceProtocol.class, transceiver);
- } catch (IOException ioe) {
- LOGGER.error("Unable to create Avro client");
- return null;
- }
- }
-
- @Override
- protected void releaseSub() {
- if (transceiver != null) {
- try {
- transceiver.close();
- } catch (IOException ioe) {
- LOGGER.error("Attempt to clean up Avro transceiver failed", ioe);
- }
- }
- client = null;
- }
-
- /**
- * Thread-safe List management of a batch.
- */
- private static class EventList extends ArrayList<AvroFlumeEvent> {
-
- public synchronized List<AvroFlumeEvent> addAndGet(AvroFlumeEvent event, int batchSize) {
- super.add(event);
- if (this.size() >= batchSize) {
- List<AvroFlumeEvent> events = new ArrayList<AvroFlumeEvent>();
- events.addAll(this);
- clear();
- return events;
- } else {
- return null;
- }
- }
- }
-
- /**
- * Factory data.
- */
- private static class FactoryData {
- private Agent[] agents;
- private int batchSize;
-
- /**
- * Constructor.
- * @param agents The agents.
- * @param batchSize The number of events to include in a batch.
- */
- public FactoryData(Agent[] agents, int batchSize) {
- this.agents = agents;
- this.batchSize = batchSize;
- }
- }
-
- /**
- * Avro Manager Factory.
- */
- private static class AvroManagerFactory implements ManagerFactory<FlumeAvroManager, FactoryData> {
-
- /**
- * Create the FlumeAvroManager.
- * @param name The name of the entity to manage.
- * @param data The data required to create the entity.
- * @return The FlumeAvroManager.
- */
- public FlumeAvroManager createManager(String name, FactoryData data) {
- try {
-
- return new FlumeAvroManager(name, data.agents, data.batchSize);
- } catch (Exception ex) {
- LOGGER.error("Could not create FlumeAvroManager", ex);
- }
- return null;
- }
- }
-
-}
diff --git a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEvent.java b/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEvent.java
deleted file mode 100644
index 3de917d..0000000
--- a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEvent.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flume.appender;
-
-import org.apache.flume.event.SimpleEvent;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.helpers.UUIDUtil;
-import org.apache.logging.log4j.message.MapMessage;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.StructuredDataId;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * Class that is both a Flume and Log4j Event.
- */
-public class FlumeEvent extends SimpleEvent implements LogEvent {
-
- private static final String DEFAULT_MDC_PREFIX = "mdc:";
-
- private static final String DEFAULT_EVENT_PREFIX = "";
-
- private static final String EVENT_TYPE = "eventType";
-
- private static final String EVENT_ID = "eventId";
-
- private static final String GUID = "guId";
-
- private final LogEvent event;
-
- private final Map<String, String> ctx = new HashMap<String, String>();
-
- private final boolean compress;
-
- /**
- * Construct the FlumeEvent.
- * @param event The Log4j LogEvent.
- * @param includes A comma separated list of MDC elements to include.
- * @param excludes A comma separated list of MDC elements to exclude.
- * @param required A comma separated list of MDC elements that are required to be defined.
- * @param mdcPrefix The value to prefix to MDC keys.
- * @param eventPrefix The value to prefix to event keys.
- * @param compress If true the event body should be compressed.
- */
- public FlumeEvent(LogEvent event, String includes, String excludes, String required,
- String mdcPrefix, String eventPrefix, boolean compress) {
- this.event = event;
- this.compress = compress;
- Map<String, String> headers = getHeaders();
- if (mdcPrefix == null) {
- mdcPrefix = DEFAULT_MDC_PREFIX;
- }
- if (eventPrefix == null) {
- eventPrefix = DEFAULT_EVENT_PREFIX;
- }
- Map<String, String> mdc = event.getContextMap();
- if (includes != null) {
- String[] array = includes.split(",");
- if (array.length > 0) {
- for (String str : array) {
- if (mdc.containsKey(str)) {
- ctx.put(str, mdc.get(str));
- }
- }
- }
- } else if (excludes != null) {
- String[] array = excludes.split(",");
- if (array.length > 0) {
- List<String> list = Arrays.asList(array);
- for (Map.Entry<String, String> entry : mdc.entrySet()) {
- if (!list.contains(entry.getKey())) {
- ctx.put(entry.getKey(), entry.getValue());
- }
- }
- }
- }
-
- if (required != null) {
- String[] array = required.split(",");
- if (array.length > 0) {
- for (String str : array) {
- if (!mdc.containsKey(str)) {
- throw new LoggingException("Required key " + str + " is missing from the MDC");
- }
- }
- }
- }
- Message message = event.getMessage();
- if (message instanceof MapMessage) {
- if (message instanceof StructuredDataMessage) {
- addStructuredData(eventPrefix, headers, (StructuredDataMessage) message);
- }
- addMapData(eventPrefix, headers, (MapMessage) message);
- }
-
- addContextData(mdcPrefix, headers, ctx);
-
- addGuid(headers);
- }
-
- protected void addStructuredData(String prefix, Map<String, String> fields, StructuredDataMessage msg) {
- fields.put(prefix + EVENT_TYPE, msg.getType());
- StructuredDataId id = msg.getId();
- fields.put(prefix + EVENT_ID, id.getName());
- }
-
- protected void addMapData(String prefix, Map<String, String> fields, MapMessage msg) {
- Map<String, String> data = msg.getData();
- for (Map.Entry<String, String> entry : data.entrySet()) {
- fields.put(prefix + entry.getKey(), entry.getValue());
- }
- }
-
- protected void addContextData(String prefix, Map<String, String> fields, Map<String, String> context) {
- for (Map.Entry<String, String> entry : context.entrySet()) {
- fields.put(prefix + entry.getKey(), entry.getValue());
- }
- }
-
- protected void addGuid(Map<String, String> fields) {
- fields.put(GUID, UUIDUtil.getTimeBasedUUID().toString());
- }
-
- /**
- * Set the body in the event.
- * @param body The body to add to the event.
- */
- public void setBody(byte[] body) {
- if (body == null || body.length == 0) {
- super.setBody(new byte[0]);
- return;
- }
- if (compress) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- GZIPOutputStream os = new GZIPOutputStream(baos);
- os.write(body);
- os.close();
- } catch (IOException ioe) {
- throw new LoggingException("Unable to compress message", ioe);
- }
- super.setBody(baos.toByteArray());
- } else {
- super.setBody(body);
- }
- }
-
- /**
- * Get the Frequently Qualified Class Name.
- * @return the FQCN String.
- */
- public String getFQCN() {
- return event.getFQCN();
- }
-
- /**
- * Return the logging Level.
- * @return the Level.
- */
- public Level getLevel() {
- return event.getLevel();
- }
-
- /**
- * Return the logger name.
- * @return the logger name.
- */
- public String getLoggerName() {
- return event.getLoggerName();
- }
-
- /**
- * Return the StackTraceElement for the caller of the logging API.
- * @return the StackTraceElement of the caller.
- */
- public StackTraceElement getSource() {
- return event.getSource();
- }
-
- /**
- * Return the Message.
- * @return the Message.
- */
- public Message getMessage() {
- return event.getMessage();
- }
-
- /**
- * Return the Marker.
- * @return the Marker.
- */
- public Marker getMarker() {
- return event.getMarker();
- }
-
- /**
- * Return the name of the Thread.
- * @return the name of the Thread.
- */
- public String getThreadName() {
- return event.getThreadName();
- }
-
- /**
- * Return the event timestamp.
- * @return the event timestamp.
- */
- public long getMillis() {
- return event.getMillis();
- }
-
- /**
- * Return the Throwable associated with the event, if any.
- * @return the Throwable.
- */
- public Throwable getThrown() {
- return event.getThrown();
- }
-
- /**
- * Return a copy of the context Map.
- * @return a copy of the context Map.
- */
- public Map<String, String> getContextMap() {
- return ctx;
- }
-
- /**
- * Return a copy of the context stack.
- * @return a copy of the context stack.
- */
- public Stack<String> getContextStack() {
- return event.getContextStack();
- }
-}
diff --git a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEventFactory.java b/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEventFactory.java
deleted file mode 100644
index b93ee89..0000000
--- a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEventFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flume.appender;
-
-import org.apache.logging.log4j.core.LogEvent;
-
-/**
- * Factory to create Flume events.
- */
-public interface FlumeEventFactory {
- /**
- * Create a Flume event.
- * @param event The Log4j LogEvent.
- * @param includes A comma separated list of MDC elements to include.
- * @param excludes A comma separated list of MDC elements to exclude.
- * @param required A comma separated list of MDC elements that are required.
- * @param mdcPrefix The value to prefix to MDC keys.
- * @param eventPrefix The value to prefix to event keys.
- * @param compress If true the event body should be compressed.
- * @return A FlumeEvent.
- */
- FlumeEvent createEvent(LogEvent event, String includes, String excludes, String required,
- String mdcPrefix, String eventPrefix, boolean compress);
-}
diff --git a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/package-info.java b/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/package-info.java
deleted file mode 100644
index 18edf09..0000000
--- a/rgoers/log4j2-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Apache Flume Appender. Requires the user specifically include Flume and its dependencies.
- */
-package org.apache.logging.log4j.flume.appender;
diff --git a/rgoers/log4j2-flume-ng/src/site/site.xml b/rgoers/log4j2-flume-ng/src/site/site.xml
deleted file mode 100644
index e416901..0000000
--- a/rgoers/log4j2-flume-ng/src/site/site.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project name="Flume NG Appender">
- <bannerLeft>
- <name>Logging Services</name>
- <src>../images/ls-logo.jpg</src>
- <href>../index.html</href>
- </bannerLeft>
- <bannerRight>
- <src>../images/logo.jpg</src>
- </bannerRight>
- <body>
- <links>
- <item name="Apache" href="http://www.apache.org/" />
- <item name="Logging Services" href="http://logging.apache.org/"/>
- <item name="Log4j" href="../index.html"/>
- </links>
- <menu ref="reports"/>
- </body>
-</project>
diff --git a/rgoers/log4j2-flume-ng/src/site/xdoc/index.xml b/rgoers/log4j2-flume-ng/src/site/xdoc/index.xml
deleted file mode 100644
index 3f51af6..0000000
--- a/rgoers/log4j2-flume-ng/src/site/xdoc/index.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Flume Next Gen Appender</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Flume Next Gen Appender">
-
- <p>
- The Flume NG Appender allows applications to send events to Flume NG Agents.
- </p>
-
- </section>
-
- <section name="Requirements">
- <p>
- The Flume NG Appender requires at least Java 5.
- </p>
- </section>
-
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/log4j2-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeAvroAppenderTest.java b/rgoers/log4j2-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeAvroAppenderTest.java
deleted file mode 100644
index 054cb01..0000000
--- a/rgoers/log4j2-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeAvroAppenderTest.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flume.appender;
-
-import org.apache.flume.Channel;
-import org.apache.flume.ChannelException;
-import org.apache.flume.Context;
-import org.apache.flume.Event;
-
-import org.apache.flume.Transaction;
-import org.apache.flume.channel.MemoryChannel;
-import org.apache.flume.conf.Configurables;
-import org.apache.flume.lifecycle.LifecycleController;
-import org.apache.flume.lifecycle.LifecycleState;
-import org.apache.flume.source.AvroSource;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.plugins.PluginManager;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.zip.GZIPInputStream;
-
-/**
- *
- */
-public class FlumeAvroAppenderTest {
-
- private static LoggerContext ctx;
-
- private static final int testServerPort = 12345;
-
- private AvroSource eventSource;
- private Channel channel;
- private Logger avroLogger;
-
- private String testPort;
-
- @BeforeClass
- public static void setupClass() {
- PluginManager.addPackage("org.apache.logging.log4j.flume");
- ctx = (LoggerContext) LogManager.getContext();
- }
-
- @AfterClass
- public static void cleanupClass() {
-
- }
-
- @Before
- public void setUp() throws Exception {
- eventSource = new AvroSource();
- channel = new MemoryChannel();
-
- Configurables.configure(channel, new Context());
-
- eventSource.setChannel(channel);
-
- avroLogger = (Logger) LogManager.getLogger("avrologger");
- /*
- * Clear out all other appenders associated with this logger to ensure we're
- * only hitting the Avro appender.
- */
- removeAppenders(avroLogger);
- boolean bound = false;
-
- for (int i = 0; i < 100 && !bound; i++) {
- try {
- Context context = new Context();
- testPort = String.valueOf(testServerPort + i);
- context.put("port", testPort);
- context.put("bind", "0.0.0.0");
-
- Configurables.configure(eventSource, context);
-
- eventSource.start();
- bound = true;
- } catch (ChannelException e) {
-
- }
- }
- Assert.assertTrue("Reached start or error", LifecycleController.waitForOneOf(
- eventSource, LifecycleState.START_OR_ERROR));
- Assert.assertEquals("Server is started", LifecycleState.START, eventSource.getLifecycleState());
- }
-
- @After
- public void teardown() throws Exception {
- removeAppenders(avroLogger);
- eventSource.stop();
- Assert.assertTrue("Reached stop or error",
- LifecycleController.waitForOneOf(eventSource, LifecycleState.STOP_OR_ERROR));
- Assert.assertEquals("Server is stopped", LifecycleState.STOP,
- eventSource.getLifecycleState());
- }
-
- @Test
- public void testLog4jAvroAppender() throws InterruptedException, IOException {
- Agent[] agents = new Agent[] {Agent.createAgent("localhost", testPort)};
- FlumeAvroAppender avroAppender = FlumeAvroAppender.createAppender(agents, "100", "3", "avro", "false", null,
- null, null, null, null, "true", "1", null, null, null);
- avroAppender.start();
- avroLogger.addAppender(avroAppender);
- avroLogger.setLevel(Level.ALL);
-
- Assert.assertNotNull(avroLogger);
-
- avroLogger.info("Test message");
-
- Transaction transaction = channel.getTransaction();
- transaction.begin();
-
- Event event = channel.take();
- Assert.assertNotNull(event);
- Assert.assertTrue("Channel contained event, but not expected message",
- getBody(event).endsWith("Test message"));
- transaction.commit();
- transaction.close();
-
- eventSource.stop();
- }
-
-
- @Test
- public void testMultiple() throws InterruptedException, IOException {
- Agent[] agents = new Agent[] {Agent.createAgent("localhost", testPort)};
- FlumeAvroAppender avroAppender = FlumeAvroAppender.createAppender(agents, "100", "3", "avro", "false", null,
- null, null, null, null, "true", "1", null, null, null);
- avroAppender.start();
- avroLogger.addAppender(avroAppender);
- avroLogger.setLevel(Level.ALL);
-
- Assert.assertNotNull(avroLogger);
-
- for (int i = 0; i < 10; ++i) {
- avroLogger.info("Test message " + i);
- }
-
- for (int i = 0; i < 10; ++i) {
- Transaction transaction = channel.getTransaction();
- transaction.begin();
-
- Event event = channel.take();
- Assert.assertNotNull(event);
- Assert.assertTrue("Channel contained event, but not expected message",
- getBody(event).endsWith("Test message " + i));
- transaction.commit();
- transaction.close();
- }
-
- eventSource.stop();
- }
-
- @Test
- public void testBatch() throws InterruptedException, IOException {
- Agent[] agents = new Agent[] {Agent.createAgent("localhost", testPort)};
- FlumeAvroAppender avroAppender = FlumeAvroAppender.createAppender(agents, "100", "3", "avro", "false", null,
- null, null, null, null, "true", "10", null, null, null);
- avroAppender.start();
- avroLogger.addAppender(avroAppender);
- avroLogger.setLevel(Level.ALL);
-
- Assert.assertNotNull(avroLogger);
-
- for (int i = 0; i < 10; ++i) {
- avroLogger.info("Test message " + i);
- }
-
- Transaction transaction = channel.getTransaction();
- transaction.begin();
-
- for (int i = 0; i < 10; ++i) {
- Event event = channel.take();
- Assert.assertNotNull("No event for item " + i, event);
- Assert.assertTrue("Channel contained event, but not expected message",
- getBody(event).endsWith("Test message " + i));
- }
- transaction.commit();
- transaction.close();
-
- eventSource.stop();
- }
-
-
- @Test
- public void testConnectionRefused() {
- Agent[] agents = new Agent[] {Agent.createAgent("localhost", testPort)};
- FlumeAvroAppender avroAppender = FlumeAvroAppender.createAppender(agents, "100", "3", "avro", "false", null,
- null, null, null, null, "true", "1", null, null, null);
- avroAppender.start();
- avroLogger.addAppender(avroAppender);
- avroLogger.setLevel(Level.ALL);
- eventSource.stop();
-
- boolean caughtException = false;
-
- try {
- avroLogger.info("message 1");
- } catch (Throwable t) {
- //logger.debug("Logging to a non-existant server failed (as expected)", t);
-
- caughtException = true;
- }
-
- Assert.assertTrue(caughtException);
- }
-
-
-
- @Test
- public void testReconnect() throws Exception {
- String altPort = Integer.toString(Integer.parseInt(testPort) + 1);
- Agent[] agents = new Agent[] {Agent.createAgent("localhost", testPort),
- Agent.createAgent("localhost", altPort)};
- FlumeAvroAppender avroAppender = FlumeAvroAppender.createAppender(agents, "100", "3", "avro", "false", null,
- null, null, null, null, "true", "1", null, null, null);
- avroAppender.start();
- avroLogger.addAppender(avroAppender);
- avroLogger.setLevel(Level.ALL);
-
- avroLogger.info("Test message");
-
- Transaction transaction = channel.getTransaction();
- transaction.begin();
-
- Event event = channel.take();
- Assert.assertNotNull(event);
- Assert.assertTrue("Channel contained event, but not expected message",
- getBody(event).endsWith("Test message"));
- transaction.commit();
- transaction.close();
-
- eventSource.stop();
- try {
- Context context = new Context();
- context.put("port", altPort);
- context.put("bind", "0.0.0.0");
-
- Configurables.configure(eventSource, context);
-
- eventSource.start();
- } catch (ChannelException e) {
- Assert.fail("Caught exception while resetting port to " + altPort + " : " + e.getMessage());
- }
-
- avroLogger.info("Test message 2");
-
- transaction = channel.getTransaction();
- transaction.begin();
-
- event = channel.take();
- Assert.assertNotNull(event);
- Assert.assertTrue("Channel contained event, but not expected message",
- getBody(event).endsWith("Test message 2"));
- transaction.commit();
- transaction.close();
- }
-
-
-
- private void removeAppenders(Logger logger) {
- Map<String,Appender> map = logger.getAppenders();
- for (Map.Entry<String, Appender> entry : map.entrySet()) {
- Appender app = entry.getValue();
- avroLogger.removeAppender(app);
- app.stop();
- }
- }
-
- private Appender getAppender(Logger logger, String name) {
- Map<String,Appender> map = logger.getAppenders();
- return map.get(name);
- }
-
- private String getBody(Event event) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- InputStream is = new GZIPInputStream(new ByteArrayInputStream(event.getBody()));
- int n = 0;
- while (-1 != (n = is.read())) {
- baos.write(n);
- }
- return new String(baos.toByteArray());
-
- }
-}
diff --git a/rgoers/log4j2-flume-og/pom.xml b/rgoers/log4j2-flume-og/pom.xml
deleted file mode 100644
index 67597f9..0000000
--- a/rgoers/log4j2-flume-og/pom.xml
+++ /dev/null
@@ -1,210 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2</artifactId>
- <version>1.99.0-SNAPSHOT</version>
- </parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-flume-og</artifactId>
- <packaging>jar</packaging>
- <name>Log4J2 Flume OG</name>
- <description>Log4j 2.0 Flume (Original) Appender</description>
- <properties>
- <log4j.parent.dir>${basedir}/..</log4j.parent.dir>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>slf4j-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.7</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.cloudera</groupId>
- <artifactId>flume-core</artifactId>
- <version>0.9.4-cdh3u1</version>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <forkMode>always</forkMode>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <version>2.6</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>changes-report</report>
- </reports>
- </reportSet>
- </reportSets>
- <configuration>
- <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.7</version>
- <configuration>
- <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
- <configLocation>${log4j.parent.dir}/checkstyle.xml</configLocation>
- <suppressionsLocation>${log4j.parent.dir}/checkstyle-suppressions.xml</suppressionsLocation>
- <enableRulesSummary>false</enableRulesSummary>
- <propertyExpansion>basedir=${basedir}</propertyExpansion>
- <propertyExpansion>licensedir=${log4j.parent.dir}/checkstyle-header.txt</propertyExpansion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8</version>
- <configuration>
- <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
- project -->
- <detectOfflineLinks>false</detectOfflineLinks>
- <linksource>true</linksource>
- <tags>
- <tag>
- <name>issue</name>
- <placement>a</placement>
- <head>JIRA issue:</head>
- </tag>
- <tag>
- <name>doubt</name>
- <placement>a</placement>
- <head>Troublesome:</head>
- </tag>
- <tag>
- <name>compare</name>
- <placement>a</placement>
- <head>Compare with:</head>
- </tag>
- </tags>
- </configuration>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <threshold>Normal</threshold>
- <effort>Default</effort>
- <excludeFilterFile>findbugs-exclude-filter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.3</version>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>jxr</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <targetJdk>1.5</targetJdk>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.2</version>
- <reportSets>
- <reportSet>
- <!-- Disabled at it kills the site generation via a NoClassDefFoundError -->
- <reports/>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
- <repositories>
- <repository>
- <id>cloudera</id>
- <url>https://repository.cloudera.com/content/repositories/releases/</url>
- </repository>
- </repositories>
-</project>
-
diff --git a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/Agent.java b/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/Agent.java
deleted file mode 100644
index 49f377a..0000000
--- a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/Agent.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flumeog.appender;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Agent Specification for FlumeAvroAppender.
- */
-@Plugin(name = "Agent", type = "Core", printObject = true)
-public final class Agent {
-
- private static final String DEFAULT_HOST = "localhost";
-
- private static final int DEFAULT_PORT = 35853;
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private final String host;
-
- private final int port;
-
- private Agent(String host, int port) {
- this.host = host;
- this.port = port;
- }
-
- /**
- * Retrieve the host name.
- * @return The name of the host.
- */
- public String getHost() {
- return host;
- }
-
- /**
- * Retrieve the port number.
- * @return The port number.
- */
- public int getPort() {
- return port;
- }
-
- @Override
- public String toString() {
- return "host=" + host + " port=" + port;
- }
-
- /**
- * Create an Agent.
- * @param host The host name.
- * @param port The port number.
- * @return The Agent.
- */
- @PluginFactory
- public static Agent createAgent(@PluginAttr("host") String host,
- @PluginAttr("port") String port) {
- if (host == null) {
- host = DEFAULT_HOST;
- }
-
- int portNum;
- if (port != null) {
- try {
- portNum = Integer.parseInt(port);
- } catch (Exception ex) {
- LOGGER.error("Error parsing port number " + port, ex);
- return null;
- }
- } else {
- portNum = DEFAULT_PORT;
- }
- return new Agent(host, portNum);
- }
-}
diff --git a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeAvroAppender.java b/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeAvroAppender.java
deleted file mode 100644
index 9b8a417..0000000
--- a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeAvroAppender.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flumeog.appender;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.AppenderBase;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttr;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.RFC5424Layout;
-
-import java.net.InetAddress;
-
-/**
- * An Appender that uses the Avro protocol to route events to Flume.
- */
-@Plugin(name = "Flume", type = "Core", elementType = "appender", printObject = true)
-public final class FlumeAvroAppender extends AppenderBase implements FlumeEventFactory {
-
- private FlumeAvroManager manager;
-
- private final String mdcIncludes;
- private final String mdcExcludes;
- private final String mdcRequired;
-
- private final String eventPrefix;
-
- private final String mdcPrefix;
-
- private final boolean compressBody;
-
- private final String hostname;
-
- private final int reconnectDelay;
-
- private final int retries;
-
- private final FlumeEventFactory factory;
-
- private FlumeAvroAppender(String name, Filter filter, Layout layout, boolean handleException,
- String hostname, String includes, String excludes, String required, String mdcPrefix,
- String eventPrefix, boolean compress, int delay, int retries,
- FlumeEventFactory factory, FlumeAvroManager manager) {
- super(name, filter, layout, handleException);
- this.manager = manager;
- this.mdcIncludes = includes;
- this.mdcExcludes = excludes;
- this.mdcRequired = required;
- this.eventPrefix = eventPrefix;
- this.mdcPrefix = mdcPrefix;
- this.compressBody = compress;
- this.hostname = hostname;
- this.reconnectDelay = delay;
- this.retries = retries;
- this.factory = factory == null ? this : factory;
- }
-
- /**
- * Publish the event.
- * @param event The LogEvent.
- */
- public void append(LogEvent event) {
-
- FlumeEvent flumeEvent = factory.createEvent(event, hostname, mdcIncludes, mdcExcludes, mdcRequired, mdcPrefix,
- eventPrefix, compressBody);
- flumeEvent.setBody(getLayout().format(flumeEvent));
- manager.send(flumeEvent, reconnectDelay, retries);
- }
-
- @Override
- public void stop() {
- super.stop();
- manager.release();
- }
-
- /**
- * Create a Flume event.
- * @param event The Log4j LogEvent.
- * @param hostname The host name.
- * @param includes comma separated list of mdc elements to include.
- * @param excludes comma separated list of mdc elements to exclude.
- * @param required comma separated list of mdc elements that must be present with a value.
- * @param mdcPrefix The prefix to add to MDC key names.
- * @param eventPrefix The prefix to add to event fields.
- * @param compress If true the body will be compressed.
- * @return A Flume Event.
- */
- public FlumeEvent createEvent(LogEvent event, String hostname, String includes, String excludes, String required,
- String mdcPrefix, String eventPrefix, boolean compress) {
- return new FlumeEvent(event, hostname, mdcIncludes, mdcExcludes, mdcRequired, mdcPrefix,
- eventPrefix, compressBody);
- }
-
- /**
- * Create a Flume Avro Appender.
- * @param agents An array of Agents.
- * @param delay The amount of time in milliseconds to wait between retries.
- * @param agentRetries The number of times to retry an agent before failing to the next agent.
- * @param name The name of the Appender.
- * @param suppress If true exceptions will be handled in the appender.
- * @param excludes A comma separated list of MDC elements to exclude.
- * @param includes A comma separated list of MDC elements to include.
- * @param required A comma separated list of MDC elements that are required.
- * @param mdcPrefix The prefix to add to MDC key names.
- * @param eventPrefix The prefix to add to event key names.
- * @param compressBody If true the event body will be compressed.
- * @param factory The factory to use to create Flume events.
- * @param layout The layout to format the event.
- * @param filter A Filter to filter events.
- * @return A Flume Avro Appender.
- */
- @PluginFactory
- public static FlumeAvroAppender createAppender(@PluginElement("agents") Agent[] agents,
- @PluginAttr("reconnectionDelay") String delay,
- @PluginAttr("agentRetries") String agentRetries,
- @PluginAttr("name") String name,
- @PluginAttr("suppressExceptions") String suppress,
- @PluginAttr("mdcExcludes") String excludes,
- @PluginAttr("mdcIncludes") String includes,
- @PluginAttr("mdcRequired") String required,
- @PluginAttr("mdcPrefix") String mdcPrefix,
- @PluginAttr("eventPrefix") String eventPrefix,
- @PluginAttr("compress") String compressBody,
- @PluginElement("flumeEventFactory") FlumeEventFactory factory,
- @PluginElement("layout") Layout layout,
- @PluginElement("filters") Filter filter) {
-
- String hostname;
- try {
- hostname = InetAddress.getLocalHost().getHostName();
- } catch (Exception ex) {
- LOGGER.error("Unable to determine local hostname", ex);
- return null;
- }
- if (agents == null || agents.length == 0) {
- LOGGER.debug("No agents provided, using defaults");
- agents = new Agent[] {Agent.createAgent(null, null)};
- }
-
- boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
- boolean compress = compressBody == null ? true : Boolean.valueOf(compressBody);
-
- int reconnectDelay = delay == null ? 0 : Integer.parseInt(delay);
- int retries = agentRetries == null ? 0 : Integer.parseInt(agentRetries);
-
- if (layout == null) {
- layout = RFC5424Layout.createLayout(null, null, null, null, "True", null, null, null, null, excludes,
- includes, required, null);
- }
-
- if (name == null) {
- LOGGER.error("No name provided for Appender");
- return null;
- }
-
- FlumeAvroManager manager = FlumeAvroManager.getManager(agents);
- if (manager == null) {
- return null;
- }
-
- return new FlumeAvroAppender(name, filter, layout, handleExceptions, hostname, includes,
- excludes, required, mdcPrefix, eventPrefix, compress, reconnectDelay, retries, factory, manager);
- }
-}
diff --git a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeAvroManager.java b/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeAvroManager.java
deleted file mode 100644
index e0c047d..0000000
--- a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeAvroManager.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flumeog.appender;
-
-import com.cloudera.flume.handlers.avro.AvroFlumeEvent;
-import org.apache.avro.ipc.HttpTransceiver;
-import org.apache.avro.ipc.specific.SpecificRequestor;
-import org.apache.logging.log4j.core.appender.AbstractManager;
-import org.apache.logging.log4j.core.appender.AppenderRuntimeException;
-import org.apache.logging.log4j.core.appender.ManagerFactory;
-
-import com.cloudera.flume.handlers.avro.FlumeEventAvroServer;
-import com.cloudera.flume.handlers.avro.AvroEventConvertUtil;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * Manager for FlumeAvroAppenders.
- */
-public class FlumeAvroManager extends AbstractManager {
-
- /**
- The default reconnection delay (500 milliseconds or .5 seconds).
- */
- public static final int DEFAULT_RECONNECTION_DELAY = 500;
-
- private static final int DEFAULT_RECONNECTS = 3;
-
- private static ManagerFactory factory = new AvroManagerFactory();
-
- private FlumeEventAvroServer client;
-
- private final Agent[] agents;
-
- private int current = 0;
-
- protected FlumeAvroManager(String name, Agent[] agents) {
- super(name);
- this.agents = agents;
- this.client = connect(agents);
- }
-
- /**
- * Return a FlumeAvroManager.
- * @param agents The agents to use.
- * @return A FlumeAvroManager.
- */
- public static FlumeAvroManager getManager(Agent[] agents) {
- if (agents == null || agents.length == 0) {
- throw new IllegalArgumentException("At least one agent is required");
- }
-
- StringBuilder sb = new StringBuilder("FlumeAvro[");
- boolean first = true;
- for (Agent agent : agents) {
- if (!first) {
- sb.append(",");
- }
- sb.append(agent.getHost()).append(":").append(agent.getPort());
- first = false;
- }
- sb.append("]");
- return (FlumeAvroManager) getManager(sb.toString(), factory, new FactoryData(agents));
- }
-
- /**
- * Return the agents.
- * @return The agent array.
- */
- public Agent[] getAgents() {
- return agents;
- }
-
- /**
- * Returns the index of the current agent.
- * @return The index for the current agent.
- */
- public int getCurrent() {
- return current;
- }
-
- protected synchronized void send(FlumeEvent event, int delay, int retries) {
- if (delay == 0) {
- delay = DEFAULT_RECONNECTION_DELAY;
- }
- if (retries == 0) {
- retries = DEFAULT_RECONNECTS;
- }
- AvroFlumeEvent avroEvent = AvroEventConvertUtil.toAvroEvent(event);
- int i = 0;
-
- String msg = "Error writing to " + getName();
-
- do {
- try {
- client.append(avroEvent);
- return;
- } catch (Exception ex) {
- if (i == retries - 1) {
- msg = "Error writing to " + getName() + " at " + agents[0].getHost() + ":" + agents[0].getPort();
- LOGGER.warn(msg, ex);
- break;
- }
- sleep(delay);
- }
- } while (++i < retries);
-
- for (int index = 0; index < agents.length; ++index) {
- if (index == current) {
- continue;
- }
- Agent agent = agents[index];
- i = 0;
- do {
- try {
-
- FlumeEventAvroServer c = connect(agent.getHost(), agent.getPort());
- c.append(avroEvent);
- client = c;
- current = i;
- return;
- } catch (Exception ex) {
- if (i == retries - 1) {
- String warnMsg = "Error writing to " + getName() + " at " + agent.getHost() + ":" +
- agent.getPort();
- LOGGER.warn(warnMsg, ex);
- break;
- }
- sleep(delay);
- }
- } while (++i < retries);
- }
-
- throw new AppenderRuntimeException(msg);
-
- }
-
- private void sleep(int delay) {
- try {
- Thread.sleep(delay);
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- }
-
- /**
- * There is a very good chance that this will always return the first agent even if it isn't available.
- * @param agents The list of agents to choose from
- * @return The FlumeEventAvroServer.
- */
- private FlumeEventAvroServer connect(Agent[] agents) {
- int i = 0;
- for (Agent agent : agents) {
- FlumeEventAvroServer server = connect(agent.getHost(), agent.getPort());
- if (server != null) {
- current = i;
- return server;
- }
- ++i;
- }
- throw new AppenderRuntimeException("Unable to connect to any agents");
- }
-
- private FlumeEventAvroServer connect(String hostname, int port) {
- URL url;
-
- try {
- url = new URL("http", hostname, port, "/");
- } catch (MalformedURLException ex) {
- LOGGER.error("Unable to create a URL for hostname " + hostname + " at port " + port, ex);
- return null;
- }
-
- try {
- return SpecificRequestor.getClient(FlumeEventAvroServer.class, new HttpTransceiver(url));
- } catch (IOException ioe) {
- LOGGER.error("Unable to create Avro client");
- return null;
- }
- }
-
- /**
- * Factory data.
- */
- private static class FactoryData {
- private Agent[] agents;
-
- /**
- * Constructor.
- * @param agents The agents.
- */
- public FactoryData(Agent[] agents) {
- this.agents = agents;
- }
- }
-
- /**
- * Avro Manager Factory.
- */
- private static class AvroManagerFactory implements ManagerFactory<FlumeAvroManager, FactoryData> {
-
- /**
- * Create the FlumeAvroManager.
- * @param name The name of the entity to manage.
- * @param data The data required to create the entity.
- * @return The FlumeAvroManager.
- */
- public FlumeAvroManager createManager(String name, FactoryData data) {
- try {
-
- return new FlumeAvroManager(name, data.agents);
- } catch (Exception ex) {
- LOGGER.error("Could not create FlumeAvroManager", ex);
- }
- return null;
- }
- }
-
-}
diff --git a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeEvent.java b/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeEvent.java
deleted file mode 100644
index 8f22b65..0000000
--- a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeEvent.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flumeog.appender;
-
-import com.cloudera.flume.core.EventBaseImpl;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.helpers.UUIDUtil;
-import org.apache.logging.log4j.message.MapMessage;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.StructuredDataId;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * Class that is both a Flume and Log4j Event.
- */
-public class FlumeEvent extends EventBaseImpl implements LogEvent {
-
- private static final String DEFAULT_MDC_PREFIX = "mdc:";
-
- private static final String DEFAULT_EVENT_PREFIX = "";
-
- private static final String EVENT_TYPE = "eventType";
-
- private static final String EVENT_ID = "eventId";
-
- private static final String GUID = "guId";
-
- private final LogEvent event;
-
- private byte[] body;
-
- private final String hostname;
-
- private final Map<String, String> ctx = new HashMap<String, String>();
-
- private final boolean compress;
-
- /**
- * Construct the FlumeEvent.
- * @param event The Log4j LogEvent.
- * @param hostname The host name.
- * @param includes A comma separated list of MDC elements to include.
- * @param excludes A comma separated list of MDC elements to exclude.
- * @param required A comma separated list of MDC elements that are required to be defined.
- * @param mdcPrefix The value to prefix to MDC keys.
- * @param eventPrefix The value to prefix to event keys.
- * @param compress If true the event body should be compressed.
- */
- public FlumeEvent(LogEvent event, String hostname, String includes, String excludes, String required,
- String mdcPrefix, String eventPrefix, boolean compress) {
- this.event = event;
- this.hostname = hostname;
- this.compress = compress;
- if (mdcPrefix == null) {
- mdcPrefix = DEFAULT_MDC_PREFIX;
- }
- if (eventPrefix == null) {
- eventPrefix = DEFAULT_EVENT_PREFIX;
- }
- this.fields = new HashMap<String, byte[]>();
- Map<String, String> mdc = event.getContextMap();
- if (includes != null) {
- String[] array = includes.split(",");
- if (array.length > 0) {
- for (String str : array) {
- if (mdc.containsKey(str)) {
- ctx.put(str, mdc.get(str));
- }
- }
- }
- } else if (excludes != null) {
- String[] array = excludes.split(",");
- if (array.length > 0) {
- List<String> list = Arrays.asList(array);
- for (Map.Entry<String, String> entry : mdc.entrySet()) {
- if (!list.contains(entry.getKey())) {
- ctx.put(entry.getKey(), entry.getValue());
- }
- }
- }
- }
-
- if (required != null) {
- String[] array = required.split(",");
- if (array.length > 0) {
- for (String str : array) {
- if (!mdc.containsKey(str)) {
- throw new LoggingException("Required key " + str + " is missing from the MDC");
- }
- }
- }
- }
- Message message = event.getMessage();
- if (message instanceof MapMessage) {
- if (message instanceof StructuredDataMessage) {
- addStructuredData(eventPrefix, fields, (StructuredDataMessage) message);
- }
- addMapData(eventPrefix, fields, (MapMessage) message);
- }
-
- addContextData(mdcPrefix, fields, ctx);
-
- addGuid(fields);
- }
-
- protected void addStructuredData(String prefix, Map<String, byte[]> fields, StructuredDataMessage msg) {
- fields.put(prefix + EVENT_TYPE, msg.getType().getBytes());
- StructuredDataId id = msg.getId();
- fields.put(prefix + EVENT_ID, id.getName().getBytes());
- }
-
- protected void addMapData(String prefix, Map<String, byte[]> fields, MapMessage msg) {
- Map<String, String> data = msg.getData();
- for (Map.Entry<String, String> entry : data.entrySet()) {
- fields.put(prefix + entry.getKey(), entry.getValue().getBytes());
- }
- }
-
- protected void addContextData(String prefix, Map<String, byte[]> fields, Map<String, String> context) {
- for (Map.Entry<String, String> entry : ctx.entrySet()) {
- fields.put(prefix + entry.getKey(), entry.getValue().toString().getBytes());
- }
- }
-
- protected void addGuid(Map<String, byte[]> fields) {
- fields.put(GUID, UUIDUtil.getTimeBasedUUID().toString().getBytes());
- }
-
- /**
- * Set the body in the event.
- * @param body The body to add to the event.
- */
- public void setBody(byte[] body) {
- if (body == null || body.length == 0) {
- this.body = new byte[0];
- return;
- }
- if (compress) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- GZIPOutputStream os = new GZIPOutputStream(baos);
- os.write(body);
- os.close();
- } catch (IOException ioe) {
- throw new LoggingException("Unable to compress message", ioe);
- }
- this.body = baos.toByteArray();
- } else {
- this.body = body;
- }
- }
-
- @Override
- public byte[] getBody() {
- return this.body;
- }
-
- @Override
- public Priority getPriority() {
- switch (event.getLevel()) {
- case INFO:
- return Priority.INFO;
- case ERROR:
- return Priority.ERROR;
- case DEBUG:
- return Priority.DEBUG;
- case WARN:
- return Priority.WARN;
- case TRACE:
- return Priority.TRACE;
- case FATAL:
- return Priority.FATAL;
- }
- return Priority.INFO;
- }
-
- /**
- * Get the Frequently Qualified Class Name.
- * @return the FQCN String.
- */
- public String getFQCN() {
- return event.getFQCN();
- }
-
- @Override
- public long getTimestamp() {
- return event.getMillis();
- }
-
- @Override
- public long getNanos() {
- return System.nanoTime();
- }
-
- @Override
- public String getHost() {
- return hostname;
- }
-
- /**
- * Return the logging Level.
- * @return the Level.
- */
- public Level getLevel() {
- return event.getLevel();
- }
-
- /**
- * Return the logger name.
- * @return the logger name.
- */
- public String getLoggerName() {
- return event.getLoggerName();
- }
-
- /**
- * Return the StackTraceElement for the caller of the logging API.
- * @return the StackTraceElement of the caller.
- */
- public StackTraceElement getSource() {
- return event.getSource();
- }
-
- /**
- * Return the Message.
- * @return the Message.
- */
- public Message getMessage() {
- return event.getMessage();
- }
-
- /**
- * Return the Marker.
- * @return the Marker.
- */
- public Marker getMarker() {
- return event.getMarker();
- }
-
- /**
- * Return the name of the Thread.
- * @return the name of the Thread.
- */
- public String getThreadName() {
- return event.getThreadName();
- }
-
- /**
- * Return the event timestamp.
- * @return the event timestamp.
- */
- public long getMillis() {
- return event.getMillis();
- }
-
- /**
- * Return the Throwable associated with the event, if any.
- * @return the Throwable.
- */
- public Throwable getThrown() {
- return event.getThrown();
- }
-
- /**
- * Return a copy of the context Map.
- * @return a copy of the context Map.
- */
- public Map<String, String> getContextMap() {
- return ctx;
- }
-
- /**
- * Return a copy of the context stack.
- * @return a copy of the context stack.
- */
- public Stack<String> getContextStack() {
- return event.getContextStack();
- }
-}
diff --git a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeEventFactory.java b/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeEventFactory.java
deleted file mode 100644
index 61c34ad..0000000
--- a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/FlumeEventFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flumeog.appender;
-
-import org.apache.logging.log4j.core.LogEvent;
-
-/**
- * Factory to create Flume events.
- */
-public interface FlumeEventFactory {
- /**
- * Create a Flume event.
- * @param event The Log4j LogEvent.
- * @param hostname The name of the host.
- * @param includes A comma separated list of MDC elements to include.
- * @param excludes A comma separated list of MDC elements to exclude.
- * @param required A comma separated list of MDC elements that are required.
- * @param mdcPrefix The value to prefix to MDC keys.
- * @param eventPrefix The value to prefix to event keys.
- * @param compress If true the event body should be compressed.
- * @return A FlumeEvent.
- */
- FlumeEvent createEvent(LogEvent event, String hostname, String includes, String excludes, String required,
- String mdcPrefix, String eventPrefix, boolean compress);
-}
diff --git a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/package-info.java b/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/package-info.java
deleted file mode 100644
index 4c7b820..0000000
--- a/rgoers/log4j2-flume-og/src/main/java/org/apache/logging/log4j/flumeog/appender/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Apache Flume Appender. Requires the user specifically include Flume and its dependencies.
- */
-package org.apache.logging.log4j.flumeog.appender;
diff --git a/rgoers/log4j2-flume-og/src/site/site.xml b/rgoers/log4j2-flume-og/src/site/site.xml
deleted file mode 100644
index 86db476..0000000
--- a/rgoers/log4j2-flume-og/src/site/site.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project name="Flume Original Appender">
- <bannerLeft>
- <name>Logging Services</name>
- <src>../images/ls-logo.jpg</src>
- <href>../index.html</href>
- </bannerLeft>
- <bannerRight>
- <src>../images/logo.jpg</src>
- </bannerRight>
- <body>
- <links>
- <item name="Apache" href="http://www.apache.org/" />
- <item name="Logging Services" href="http://logging.apache.org/"/>
- <item name="Log4j" href="../index.html"/>
- </links>
- <menu ref="reports"/>
- </body>
-</project>
diff --git a/rgoers/log4j2-flume-og/src/site/xdoc/index.xml b/rgoers/log4j2-flume-og/src/site/xdoc/index.xml
deleted file mode 100644
index 24b4407..0000000
--- a/rgoers/log4j2-flume-og/src/site/xdoc/index.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Flume Original Appender</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Flume Original Appender">
-
- <p>
- The Flume OG Appender allows applications to write to a legacy Flume agent.
- </p>
-
- </section>
-
- <section name="Requirements">
- <p>
- The Flume OG Appender requires at least Java 5.
- </p>
- </section>
-
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/log4j2-flume-og/src/test/java/org/apache/logging/log4j/flumeog/appender/FlumeAvroAppenderTest.java b/rgoers/log4j2-flume-og/src/test/java/org/apache/logging/log4j/flumeog/appender/FlumeAvroAppenderTest.java
deleted file mode 100644
index 7d1d93b..0000000
--- a/rgoers/log4j2-flume-og/src/test/java/org/apache/logging/log4j/flumeog/appender/FlumeAvroAppenderTest.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.flumeog.appender;
-
-import com.cloudera.flume.core.Event;
-import com.cloudera.flume.handlers.avro.AvroEventSource;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.zip.GZIPInputStream;
-
-/**
- *
- */
-public class FlumeAvroAppenderTest {
-
- private LoggerContext ctx = (LoggerContext) LogManager.getContext();
-
- private static final String LOGBACK_CONF = "logback.configurationFile";
- private static final String LOGBACK_CONFIG = "logback-flume.xml";
-
- private static final int testServerPort = 12345;
- private static final int testEventCount = 100;
-
- private AvroEventSource eventSource;
- private Logger avroLogger;
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(LOGBACK_CONF, LOGBACK_CONFIG);
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(LOGBACK_CONF);
- }
-
- @Before
- public void setUp() throws IOException {
- eventSource = new AvroEventSource(testServerPort);
- avroLogger = (Logger) LogManager.getLogger("avrologger");
- /*
- * Clear out all other appenders associated with this logger to ensure we're
- * only hitting the Avro appender.
- */
- removeAppenders(avroLogger);
- eventSource.open();
- }
-
- @After
- public void teardown() throws IOException {
- removeAppenders(avroLogger);
- eventSource.close();
- }
-
- @Test
- public void testLog4jAvroAppender() throws InterruptedException, IOException {
- Agent[] agents = new Agent[] {Agent.createAgent("localhost", Integer.toString(testServerPort))};
- FlumeAvroAppender avroAppender = FlumeAvroAppender.createAppender(agents, "100", "3", "avro", "false", null,
- null, null, null, null, "true", null, null, null);
- avroAppender.start();
- avroLogger.addAppender(avroAppender);
- avroLogger.setLevel(Level.ALL);
-
- Assert.assertNotNull(avroLogger);
-
- int loggedCount = 0;
- int receivedCount = 0;
-
- for (int i = 0; i < testEventCount; i++) {
- avroLogger.info("test i:" + i);
- loggedCount++;
- }
-
- /*
- * We perform this in another thread so we can put a time SLA on it by using
- * Future#get(). Internally, the AvroEventSource uses a BlockingQueue.
- */
- ExecutorService executor = Executors.newSingleThreadExecutor();
- Callable<Event> callable = new Callable<Event>() {
-
- public Event call() throws Exception {
- return eventSource.next();
- }
- };
-
- for (int i = 0; i < loggedCount; i++) {
- try {
- Future<Event> future = executor.submit(callable);
-
- /*
- * We must receive events in less than 1 second. This should be more
- * than enough as all events should be held in AvroEventSource's
- * BlockingQueue.
- */
- Event event = future.get(1, TimeUnit.SECONDS);
-
- Assert.assertNotNull(event);
- Assert.assertNotNull(event.getBody());
- String body = getBody(event);
- Assert.assertTrue(body.endsWith("test i:" + i));
-
- receivedCount++;
- } catch (ExecutionException e) {
- Assert.fail("Flume failed to handle an event: " + e.getMessage());
- break;
- } catch (TimeoutException e) {
- Assert
- .fail("Flume failed to handle an event within the given time SLA: "
- + e.getMessage());
- break;
- } catch (InterruptedException e) {
- Assert
- .fail("Flume source executor thread was interrupted. We count this as a failure.");
- Thread.currentThread().interrupt();
- break;
- }
- }
-
- executor.shutdown();
-
- if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
- throw new IllegalStateException(
- "Executor is refusing to shutdown cleanly");
- }
-
- Assert.assertEquals(loggedCount, receivedCount);
- }
-
- @Test
- public void testConnectionRefused() {
- Agent[] agents = new Agent[] {Agent.createAgent("localhost", Integer.toString(44000))};
- FlumeAvroAppender avroAppender = FlumeAvroAppender.createAppender(agents, "100", "3", "avro", "false", null,
- null, null, null, null, "true", null, null, null);
- avroAppender.start();
- avroLogger.addAppender(avroAppender);
- avroLogger.setLevel(Level.ALL);
-
- boolean caughtException = false;
-
- try {
- avroLogger.info("message 1");
- } catch (Throwable t) {
- //logger.debug("Logging to a non-existant server failed (as expected)", t);
-
- caughtException = true;
- }
-
- Assert.assertTrue(caughtException);
- }
-
- @Test
- public void testReconnect() throws IOException {
- Agent[] agents = new Agent[] {Agent.createAgent("localhost", Integer.toString(testServerPort))};
- FlumeAvroAppender avroAppender = FlumeAvroAppender.createAppender(agents, "500", "10", "avro", "false", null,
- null, null, null, null, "true", null, null, null);
- avroAppender.start();
- avroLogger.addAppender(avroAppender);
- avroLogger.setLevel(Level.ALL);
- avroLogger.info("message 1");
-
- Event event = eventSource.next();
-
- Assert.assertNotNull(event);
- String body = getBody(event);
- Assert.assertTrue(body.endsWith("message 1"));
-
- eventSource.close();
-
- Callable<Void> logCallable = new Callable<Void>() {
-
- public Void call() throws Exception {
- avroLogger.info("message 2");
- return null;
- }
- };
-
- ExecutorService logExecutor = Executors.newSingleThreadExecutor();
-
- boolean caughtException = false;
-
- try {
- logExecutor.submit(logCallable);
-
- Thread.sleep(1500);
-
- eventSource.open();
-
- logExecutor.shutdown();
-
- if (!logExecutor.awaitTermination(10, TimeUnit.SECONDS)) {
- throw new IllegalStateException(
- "Log executor is refusing to shutdown cleanly");
- }
- } catch (Throwable t) {
- System.err.println("Failed to reestablish a connection and log to an avroSource");
-
- caughtException = true;
- }
-
- Assert.assertFalse(caughtException);
-
- event = eventSource.next();
-
- Assert.assertNotNull(event);
- body = getBody(event);
- Assert.assertTrue(body.endsWith("message 2"));
-
- caughtException = false;
-
- try {
- avroLogger.info("message 3");
- } catch (Throwable t) {
- System.err.println("Logging to a closed server failed (not expected)");
-
- caughtException = true;
- }
-
- Assert.assertFalse(caughtException);
-
- event = eventSource.next();
-
- Assert.assertNotNull(event);
- body = getBody(event);
- Assert.assertTrue(body.endsWith("message 3"));
- }
-
-
- private void removeAppenders(Logger logger) {
- Map<String,Appender> map = logger.getAppenders();
- for (Map.Entry<String, Appender> entry : map.entrySet()) {
- Appender app = entry.getValue();
- avroLogger.removeAppender(app);
- app.stop();
- }
- }
-
- private Appender getAppender(Logger logger, String name) {
- Map<String,Appender> map = logger.getAppenders();
- return map.get(name);
- }
-
- private String getBody(Event event) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- InputStream is = new GZIPInputStream(new ByteArrayInputStream(event.getBody()));
- int n = 0;
- while (-1 != (n = is.read())) {
- baos.write(n);
- }
- return new String(baos.toByteArray());
-
- }
-}
diff --git a/rgoers/log4j2-jcl/pom.xml b/rgoers/log4j2-jcl/pom.xml
deleted file mode 100644
index b5b2b14..0000000
--- a/rgoers/log4j2-jcl/pom.xml
+++ /dev/null
@@ -1,177 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>log4j2</artifactId>
- <groupId>org.apache.logging.rgoers</groupId>
- <version>1.99.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-jcl</artifactId>
- <version>1.99.0-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>Log4J2 Commons Logging</name>
- <description>Log4j2 Commons Logging Adapter</description>
- <properties>
- <log4j.parent.dir>${basedir}/..</log4j.parent.dir>
- </properties>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.3.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-core</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <version>2.6</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>changes-report</report>
- </reports>
- </reportSet>
- </reportSets>
- <configuration>
- <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.7</version>
- <configuration>
- <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
- <configLocation>${log4j.parent.dir}/checkstyle.xml</configLocation>
- <suppressionsLocation>${log4j.parent.dir}/checkstyle-suppressions.xml</suppressionsLocation>
- <enableRulesSummary>false</enableRulesSummary>
- <propertyExpansion>basedir=${basedir}</propertyExpansion>
- <propertyExpansion>licensedir=${log4j.parent.dir}/checkstyle-header.txt</propertyExpansion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8</version>
- <configuration>
- <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
- project -->
- <detectOfflineLinks>false</detectOfflineLinks>
- <linksource>true</linksource>
- <tags>
- <tag>
- <name>issue</name>
- <placement>a</placement>
- <head>JIRA issue:</head>
- </tag>
- <tag>
- <name>doubt</name>
- <placement>a</placement>
- <head>Troublesome:</head>
- </tag>
- <tag>
- <name>compare</name>
- <placement>a</placement>
- <head>Compare with:</head>
- </tag>
- </tags>
- </configuration>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <threshold>Normal</threshold>
- <effort>Default</effort>
- <excludeFilterFile>findbugs-exclude-filter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.3</version>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>jxr</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <targetJdk>1.5</targetJdk>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.2</version>
- <reportSets>
- <reportSet>
- <!-- Disabled at it kills the site generation via a NoClassDefFoundError -->
- <reports/>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
-
-</project>
\ No newline at end of file
diff --git a/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4JLog.java b/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4JLog.java
deleted file mode 100644
index 04fd3ec..0000000
--- a/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4JLog.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.jcl;
-
-import org.apache.commons.logging.Log;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.spi.AbstractLoggerWrapper;
-
-/**
- *
- */
-public class Log4JLog extends AbstractLoggerWrapper implements Log {
-
- public Log4JLog(AbstractLogger logger, String name) {
- super(logger, name);
- }
-}
diff --git a/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java b/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
deleted file mode 100644
index 05a7b19..0000000
--- a/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.jcl;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogConfigurationException;
-import org.apache.commons.logging.LogFactory;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.spi.LoggerContext;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- *
- */
-public class LogFactoryImpl extends LogFactory {
-
- private final Map<LoggerContext, ConcurrentMap<String, Log>> contextMap =
- new WeakHashMap<LoggerContext, ConcurrentMap<String, Log>>();
-
- private ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<String, Object>();
-
- public Log getInstance(String name) throws LogConfigurationException {
- LoggerContext context = PrivateManager.getContext();
- ConcurrentMap<String, Log> loggers = getLoggersMap();
- if (loggers.containsKey(name)) {
- return loggers.get(name);
- }
- org.apache.logging.log4j.Logger logger = PrivateManager.getLogger(name);
- if (logger instanceof AbstractLogger) {
- loggers.putIfAbsent(name, new Log4JLog((AbstractLogger) logger, name));
- return loggers.get(name);
- }
- throw new LogConfigurationException(
- "SLF4J Adapter requires base logging system to extend Log4J AbstractLogger");
- }
-
- private ConcurrentMap<String, Log> getLoggersMap() {
- LoggerContext context = PrivateManager.getContext();
- synchronized (contextMap) {
- ConcurrentMap<String, Log> map = contextMap.get(context);
- if (map == null) {
- map = new ConcurrentHashMap<String, Log>();
- contextMap.put(context, map);
- }
- return map;
- }
- }
-
- @Override
- public Object getAttribute(String name) {
- return attributes.get(name);
- }
-
- @Override
- public String[] getAttributeNames() {
- return attributes.keySet().toArray(new String[attributes.size()]);
- }
-
- @Override
- public Log getInstance(Class clazz) throws LogConfigurationException {
- return getInstance(clazz.getName());
- }
-
- /**
- * This method is supposed to clear all loggers. In this implementation it will clear all the logger
- * wrappers but the loggers managed by the underlying logger context will not be.
- */
- @Override
- public void release() {
- getLoggersMap().clear();
- }
-
- @Override
- public void removeAttribute(String name) {
- attributes.remove(name);
- }
-
- @Override
- public void setAttribute(String name, Object value) {
- attributes.put(name, value);
- }
-
- /**
- * The real bridge between commons logging and Log4j.
- */
- private static class PrivateManager extends LogManager {
- private static final String FQCN = LogFactory.class.getName();
-
- public static LoggerContext getContext() {
- return getContext(FQCN, false);
- }
-
- public static org.apache.logging.log4j.Logger getLogger(String name) {
- return getLogger(FQCN, name);
- }
- }
-
-}
diff --git a/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/package-info.java b/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/package-info.java
deleted file mode 100644
index 48ad554..0000000
--- a/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 adapter for Commons Logging.
- */
-package org.apache.logging.log4j.jcl;
diff --git a/rgoers/log4j2-jcl/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory b/rgoers/log4j2-jcl/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
deleted file mode 100644
index a20a589..0000000
--- a/rgoers/log4j2-jcl/src/main/resources/META-INF/services/org.apache.commons.logging.LogFactory
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.logging.log4j.jcl.LogFactoryImpl
\ No newline at end of file
diff --git a/rgoers/log4j2-jcl/src/site/site.xml b/rgoers/log4j2-jcl/src/site/site.xml
deleted file mode 100644
index 832d7b8..0000000
--- a/rgoers/log4j2-jcl/src/site/site.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project name="Component">
- <bannerLeft>
- <name>Logging Services</name>
- <src>../images/ls-logo.jpg</src>
- <href>../index.html</href>
- </bannerLeft>
- <bannerRight>
- <src>../images/logo.jpg</src>
- </bannerRight>
- <body>
- <links>
- <item name="Apache" href="http://www.apache.org/" />
- <item name="Logging Services" href="http://logging.apache.org/"/>
- <item name="Log4j" href="../index.html"/>
- </links>
- <menu ref="reports"/>
- </body>
-</project>
diff --git a/rgoers/log4j2-jcl/src/site/xdoc/api.xml b/rgoers/log4j2-jcl/src/site/xdoc/api.xml
deleted file mode 100644
index a910df1..0000000
--- a/rgoers/log4j2-jcl/src/site/xdoc/api.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Commons Logging Bridge</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Commons Logging Bridge">
-
- <p>
- The Commons Logging Bridge allows applications coded to the Commons Logging API to use
- Log4j 2.0 as the implementation.
- </p>
-
- </section>
-
- <section name="Requirements">
- <p>
- The Commons Logging bridge requires at least Java 5.
- </p>
- </section>
-
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/log4j2-jcl/src/site/xdoc/index.xml b/rgoers/log4j2-jcl/src/site/xdoc/index.xml
deleted file mode 100644
index a910df1..0000000
--- a/rgoers/log4j2-jcl/src/site/xdoc/index.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Commons Logging Bridge</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Commons Logging Bridge">
-
- <p>
- The Commons Logging Bridge allows applications coded to the Commons Logging API to use
- Log4j 2.0 as the implementation.
- </p>
-
- </section>
-
- <section name="Requirements">
- <p>
- The Commons Logging bridge requires at least Java 5.
- </p>
- </section>
-
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/log4j2-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java b/rgoers/log4j2-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
deleted file mode 100644
index 5f71b75..0000000
--- a/rgoers/log4j2-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.log4j.jcl;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class LoggerTest {
-
- private static final String CONFIG = "log4j-test1.xml";
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
- Configuration config = ctx.getConfiguration();
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- }
-
- Log logger = LogFactory.getLog("LoggerTest");
-
- @Test
- public void testLog() {
- logger.debug("Test message");
- verify("List", "o.a.l.l.j.LoggerTest Test message MDC{}\n");
- logger.debug("Exception: " , new NullPointerException("Test"));
- verify("List", "o.a.l.l.j.LoggerTest Exception: MDC{}\n");
- logger.info("Info Message");
- verify("List", "o.a.l.l.j.LoggerTest Info Message MDC{}\n");
- logger.info("Info Message {}");
- verify("List", "o.a.l.l.j.LoggerTest Info Message {} MDC{}\n");
- }
-
- private void verify(String name, String expected) {
- LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
- Map<String, Appender> list = ctx.getConfiguration().getAppenders();
- Appender listApp = list.get(name);
- assertNotNull("Missing Appender", listApp);
- assertTrue("Not a ListAppender", listApp instanceof ListAppender);
- List<String> events = ((ListAppender) listApp).getMessages();
- assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size()== 1);
- String actual = events.get(0);
- assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
- ((ListAppender) listApp).clear();
- }
-
-}
diff --git a/rgoers/log4j2-jcl/src/test/resources/log4j-test1.xml b/rgoers/log4j2-jcl/src/test/resources/log4j-test1.xml
deleted file mode 100644
index a639d4f..0000000
--- a/rgoers/log4j2-jcl/src/test/resources/log4j-test1.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration packages="org.apache.logging.log4j.test" status="debug" name="LoggerTest">
- <properties>
- <property name="filename">target/test.log</property>
- </properties>
- <ThresholdFilter level="trace"/>
-
- <appenders>
- <List name="EventLogger">
- <PatternLayout pattern="%C{1.} %m%n"/>
- </List>
- <Console name="STDOUT">
- <PatternLayout pattern="%C{1.} %m MDC%X%n"/>
- </Console>
- <File name="File" fileName="${filename}">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- </File>
- <List name="List">
- <PatternLayout pattern="%C{1.} %m MDC%X%n"/>
- </List>
- </appenders>
-
- <loggers>
- <logger name="EventLogger" level="info" additivity="false">
- <appender-ref ref="EventLogger"/>
- </logger>>
-
- <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
- <appender-ref ref="File"/>
- </logger>>
-
- <root level="trace">
- <appender-ref ref="List"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/pom.xml b/rgoers/pom.xml
deleted file mode 100644
index 62aeb9f..0000000
--- a/rgoers/pom.xml
+++ /dev/null
@@ -1,326 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2</artifactId>
- <packaging>pom</packaging>
- <name>Apache Log4j 2</name>
- <version>1.99.0-SNAPSHOT</version>
- <parent>
- <groupId>org.apache</groupId>
- <artifactId>apache</artifactId>
- <version>9</version>
- </parent>
- <description>Apache Log4j 2</description>
- <url>http://logging.apache.org/log4j/2.0/</url>
- <issueManagement>
- <system>Jira</system>
- <url>http://issues.apache.org/jira/browse/LOG4J2</url>
- </issueManagement>
- <ciManagement>
- <system>Gump</system>
- <url>http://vmgump.apache.org/gump/public/logging-log4j-20/logging-log4j-20/index.html</url>
- </ciManagement>
- <inceptionYear>1999</inceptionYear>
- <developers>
- <developer>
- <id>rgoers</id>
- <name>Ralph Goers</name>
- <email>rgoers@apache.org</email>
- <organization>Intuit Financial Services</organization>
- </developer>
- </developers>
- <mailingLists>
- <mailingList>
- <name>log4j-user</name>
- <subscribe>log4j-user-subscribe@logging.apache.org</subscribe>
- <unsubscribe>log4j-user-unsubscribe@logging.apache.org</unsubscribe>
- <post>log4j-user@logging.apache.org</post>
- <archive>http://mail-archives.apache.org/mod_mbox/logging-log4j-dev/</archive>
- <otherArchives>
- <otherArchive>http://marc.info/?l=log4j-user</otherArchive>
- <otherArchive>http://dir.gmane.org/gmane.comp.jakarta.log4j.user</otherArchive>
- </otherArchives>
- </mailingList>
- <mailingList>
- <name>log4j-dev</name>
- <subscribe>log4j-dev-subscribe@logging.apache.org</subscribe>
- <unsubscribe>log4j-dev-unsubscribe@logging.apache.org</unsubscribe>
- <post>log4j-dev@logging.apache.org</post>
- <archive>http://mail-archives.apache.org/mod_mbox/logging-log4j-dev/</archive>
- <otherArchives>
- <otherArchive>http://marc.info/?l=log4j-dev</otherArchive>
- <otherArchive>http://dir.gmane.org/gmane.comp.jakarta.log4j.devel</otherArchive>
- </otherArchives>
- </mailingList>
- </mailingLists>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL
- </developerConnection>
- <url>http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL</url>
- </scm>
- <organization>
- <name>Apache Software Foundation</name>
- <url>http://www.apache.org</url>
- </organization>
- <properties>
- <slf4j.version>1.6.4</slf4j.version>
- <logback.version>1.0.0</logback.version>
- <log4j.parent.dir>${basedir}</log4j.parent.dir>
- </properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-ext</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>${logback.version}</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>${logback.version}</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>${logback.version}</version>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-core</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>slf4j-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-jcl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.3.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <version>2.6</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.2.1</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.7</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8.1-SNAPSHOT</version>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.0</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-ssh</artifactId>
- <version>1.0-beta-7</version>
- </dependency>
- </dependencies>
- <configuration>
- <!-- Exclude the navigation file for Maven 1 sites
- and the changes file used by the changes-plugin,
- as they interfere with the site generation. -->
- <moduleExcludes>
- <xdoc>navigation.xml,changes.xml</xdoc>
- </moduleExcludes>
- </configuration>
- </plugin>
- <!-- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>clean</id>
- <goals>
- <goal>clean</goal>
- </goals>
- </execution>
- </executions>
- </plugin> -->
- </plugins>
- </build>
- <reporting>
- <plugins>
- <!-- Changes report -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <version>2.6</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>changes-report</report>
- <report>jira-report</report>
- </reports>
- </reportSet>
- </reportSets>
- <configuration>
- <statusIds>Resolved, Closed</statusIds>
- <columnNames>Type,Key,Summary,Assignee,Status,Resolution,Fix Version</columnNames>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.4</version>
- </plugin>
- <!-- Surefire report -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-report-plugin</artifactId>
- <version>2.11</version>
- </plugin>
-
- <!-- RAT report -->
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <version>0.8</version>
- <configuration>
- <excludes>
- <exclude>.idea/**/*</exclude>
- <exclude>src/test/resources/**/*</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-
- <distributionManagement>
- <repository>
- <id>apache.releases.https</id>
- <name>Apache Release Distribution Repository</name>
- <url>https://repository.apache.org/service/local/staging/deploy/maven2</url>
- </repository>
- <snapshotRepository>
- <id>apache.snapshots.https</id>
- <name>Apache Development Snapshot Repository</name>
- <url>https://repository.apache.org/content/repositories/snapshots</url>
- </snapshotRepository>
- <site>
- <id>apache.website</id>
- <url>scp://people.apache.org/www/logging.apache.org/log4j/2.0</url>
- </site>
- </distributionManagement>
- <modules>
- <module>log4j2-api</module>
- <module>log4j12-api</module>
- <module>log4j2-core</module>
- <module>slf4j-impl</module>
- <module>log4j2-jcl</module>
- </modules>
- <profiles>
- <profile>
- <id>include-flume</id>
- <modules>
- <module>log4j2-flume-og</module>
- <module>log4j2-flume-ng</module>
- </modules>
- </profile>
- <profile>
- <id>include-flume-ng</id>
- <modules>
- <module>log4j2-flume-ng</module>
- </modules>
- </profile>
- <profile>
- <id>include-flume-og</id>
- <modules>
- <module>log4j2-flume-og</module>
- </modules>
- </profile>
- </profiles>
-</project>
diff --git a/rgoers/slf4j-impl/pom.xml b/rgoers/slf4j-impl/pom.xml
deleted file mode 100644
index 0e68138..0000000
--- a/rgoers/slf4j-impl/pom.xml
+++ /dev/null
@@ -1,179 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2</artifactId>
- <version>1.99.0-SNAPSHOT</version>
- </parent>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>slf4j-impl</artifactId>
- <packaging>jar</packaging>
- <name>SLF4J Binding</name>
- <description>Binding between SLF4J API and Log4J2 Core</description>
- <properties>
- <log4j.parent.dir>${basedir}/..</log4j.parent.dir>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-ext</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.rgoers</groupId>
- <artifactId>log4j2-core</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <version>2.6</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>changes-report</report>
- </reports>
- </reportSet>
- </reportSets>
- <configuration>
- <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.7</version>
- <configuration>
- <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
- <configLocation>${log4j.parent.dir}/checkstyle.xml</configLocation>
- <suppressionsLocation>${log4j.parent.dir}/checkstyle-suppressions.xml</suppressionsLocation>
- <enableRulesSummary>false</enableRulesSummary>
- <propertyExpansion>basedir=${basedir}</propertyExpansion>
- <propertyExpansion>licensedir=${log4j.parent.dir}/checkstyle-header.txt</propertyExpansion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8</version>
- <configuration>
- <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
- project -->
- <detectOfflineLinks>false</detectOfflineLinks>
- <linksource>true</linksource>
- <tags>
- <tag>
- <name>issue</name>
- <placement>a</placement>
- <head>JIRA issue:</head>
- </tag>
- <tag>
- <name>doubt</name>
- <placement>a</placement>
- <head>Troublesome:</head>
- </tag>
- <tag>
- <name>compare</name>
- <placement>a</placement>
- <head>Compare with:</head>
- </tag>
- </tags>
- </configuration>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <threshold>Normal</threshold>
- <effort>Default</effort>
- <excludeFilterFile>findbugs-exclude-filter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.3</version>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>jxr</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <targetJdk>1.5</targetJdk>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.2</version>
- <reportSets>
- <reportSet>
- <!-- Disabled at it kills the site generation via a NoClassDefFoundError -->
- <reports/>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
-</project>
-
diff --git a/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java b/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java
deleted file mode 100644
index 41ba9cd..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/SLF4JLoggingException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.slf4j;
-
-/**
- * Exception thrown when the SLF4J apapter encounters a problem.
- *
- */
-public class SLF4JLoggingException extends RuntimeException {
-
- public SLF4JLoggingException(String msg) {
- super(msg);
- }
-
- public SLF4JLoggingException(String msg, Exception ex) {
- super(msg, ex);
- }
-
- public SLF4JLoggingException(Exception ex) {
- super(ex);
- }
-}
diff --git a/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/package-info.java b/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/package-info.java
deleted file mode 100644
index 092c09a..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/apache/logging/slf4j/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * SLF4J support.
- */
-package org.apache.logging.slf4j;
diff --git a/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java b/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java
deleted file mode 100644
index 5e50791..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.slf4j.helpers;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.spi.LoggerContext;
-import org.apache.logging.slf4j.SLF4JLoggingException;
-import org.slf4j.ILoggerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.impl.SLF4JLogger;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- *
- */
-public class Log4JLoggerFactory implements ILoggerFactory {
-
- private static final String FQCN = Log4JLoggerFactory.class.getName();
- private static final String PACKAGE = "org.slf4j";
-
- private final Map<LoggerContext, ConcurrentMap<String, Logger>> contextMap =
- new WeakHashMap<LoggerContext, ConcurrentMap<String, Logger>>();
-
- public Logger getLogger(String name) {
- LoggerContext context = getContext();
- ConcurrentMap<String, Logger> loggers = getLoggersMap(context);
-
- if (loggers.containsKey(name)) {
- return loggers.get(name);
- }
- String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME : name;
- org.apache.logging.log4j.Logger logger = context.getLogger(key);
- if (logger instanceof AbstractLogger) {
- loggers.putIfAbsent(name, new SLF4JLogger((AbstractLogger) logger, name));
- return loggers.get(name);
- }
- throw new SLF4JLoggingException("SLF4J Adapter requires base logging system to extend Log4J AbstractLogger");
- }
-
- private ConcurrentMap<String, Logger> getLoggersMap(LoggerContext context) {
- synchronized (contextMap) {
- ConcurrentMap<String, Logger> map = contextMap.get(context);
- if (map == null) {
- map = new ConcurrentHashMap<String, Logger>();
- contextMap.put(context, map);
- }
- return map;
- }
- }
- private LoggerContext getContext() {
- Throwable t = new Throwable();
- boolean next = false;
- boolean pkg = false;
- String fqcn = LoggerFactory.class.getName();
- for (StackTraceElement element : t.getStackTrace()) {
- if (FQCN.equals(element.getClassName())) {
- next = true;
- continue;
- }
- if (next && element.getClassName().startsWith(PACKAGE)) {
- fqcn = element.getClassName();
- pkg = true;
- continue;
- }
- if (pkg) {
- break;
- }
- }
- return PrivateManager.getContext(fqcn);
- }
-
- /**
- * The real bridge between SLF4J and Log4j.
- */
- private static class PrivateManager extends LogManager {
- private static final String FQCN = LoggerFactory.class.getName();
-
- public static LoggerContext getContext() {
- return getContext(FQCN, false);
- }
-
- public static LoggerContext getContext(String fqcn) {
- return getContext(fqcn, false);
- }
-
- public static org.apache.logging.log4j.Logger getLogger(String name) {
- return getLogger(FQCN, name);
- }
- }
-
-}
diff --git a/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMDCAdapter.java b/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMDCAdapter.java
deleted file mode 100644
index ee3a582..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMDCAdapter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.slf4j.helpers;
-
-import org.apache.logging.log4j.ThreadContext;
-import org.slf4j.spi.MDCAdapter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- */
-public class Log4JMDCAdapter implements MDCAdapter {
-
- public void put(String key, String val) {
- ThreadContext.put(key, val);
- }
-
- public String get(String key) {
- return ThreadContext.get(key);
- }
-
- public void remove(String key) {
- ThreadContext.remove(key);
- }
-
- public void clear() {
- ThreadContext.clear();
- }
-
- public Map getCopyOfContextMap() {
- return ThreadContext.getContext();
- }
-
- public void setContextMap(Map map) {
- ThreadContext.clear();
- for (Map.Entry<String, String> entry : ((Map<String, String>) map).entrySet()) {
- ThreadContext.put(entry.getKey(), entry.getValue());
- }
- }
-}
diff --git a/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMarkerFactory.java b/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMarkerFactory.java
deleted file mode 100644
index b71c3d5..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMarkerFactory.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.slf4j.helpers;
-
-import org.slf4j.IMarkerFactory;
-import org.slf4j.Marker;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- *
- */
-public class Log4JMarkerFactory implements IMarkerFactory {
-
- private ConcurrentMap<String, Marker> markerMap = new ConcurrentHashMap<String, Marker>();
-
- public Marker getMarker(String name) {
- if (name == null) {
- throw new IllegalArgumentException("Marker name must not be null");
- }
- Marker marker = markerMap.get(name);
- if (marker == null) {
- marker = new MarkerWrapper(name);
- }
- return marker;
- }
-
- public boolean exists(String name) {
- return markerMap.containsKey(name);
- }
-
- public boolean detachMarker(String name) {
- return false;
- }
-
- public Marker getDetachedMarker(String name) {
- return new MarkerWrapper(name);
- }
-}
diff --git a/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/MarkerWrapper.java b/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/MarkerWrapper.java
deleted file mode 100644
index a8489de..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/MarkerWrapper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.slf4j.helpers;
-
-import org.apache.logging.log4j.Marker;
-
-/**
- *
- */
-public class MarkerWrapper extends BasicMarker implements Marker {
- private static final long serialVersionUID = 1903952589649545191L;
-
- private MarkerWrapper parent;
-
- MarkerWrapper(String name) {
- super(name);
- }
-
- @Override
- public void add(org.slf4j.Marker reference) {
- super.add(reference);
- ((MarkerWrapper) reference).setParent(this);
- }
-
- private void setParent(MarkerWrapper marker) {
- parent = marker;
- }
-
- public org.apache.logging.log4j.Marker getParent() {
- return this.parent;
- }
-
- public boolean isInstanceOf(org.apache.logging.log4j.Marker marker) {
- if (marker == null) {
- throw new IllegalArgumentException("A marker parameter is required");
- }
-
- return contains((MarkerWrapper) marker);
- }
-}
diff --git a/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/package-info.java b/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/package-info.java
deleted file mode 100644
index 67dd502..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 SLF4J adapter helper classes.
- */
-package org.slf4j.helpers;
diff --git a/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java b/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java
deleted file mode 100644
index daf9071..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/SLF4JLogger.java
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.slf4j.impl;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.message.StructuredDataMessage;
-import org.apache.logging.log4j.spi.AbstractLogger;
-import org.apache.logging.log4j.spi.AbstractLoggerWrapper;
-import org.slf4j.Marker;
-import org.slf4j.MarkerFactory;
-import org.slf4j.ext.EventData;
-import org.slf4j.spi.LocationAwareLogger;
-
-import java.util.Map;
-
-/**
- *
- */
-public class SLF4JLogger implements LocationAwareLogger {
-
- private static final String FQCN = SLF4JLogger.class.getName();
- private static final Marker EVENT_MARKER = MarkerFactory.getMarker("EVENT");
- private final boolean eventLogger;
- private final AbstractLoggerWrapper logger;
- private final String name;
-
- public SLF4JLogger(AbstractLogger logger, String name) {
- Logger l = LogManager.getLogger(name);
- this.logger = new AbstractLoggerWrapper(logger, name);
- eventLogger = "EventLogger".equals(name);
- this.name = name;
- }
-
- public void trace(String format) {
- if (logger.isTraceEnabled()) {
- logger.log(null, FQCN, Level.TRACE, new SimpleMessage(format), null);
- }
- }
-
- public void trace(String format, Object o) {
- if (logger.isTraceEnabled()) {
- logger.log(null, FQCN, Level.TRACE, new ParameterizedMessage(format, o), null);
- }
- }
-
- public void trace(String format, Object arg1, Object arg2) {
- if (logger.isTraceEnabled()) {
- ParameterizedMessage msg = new ParameterizedMessage(format, arg1, arg2);
- logger.log(null, FQCN, Level.TRACE, msg, msg.getThrowable());
- }
- }
-
- public void trace(String format, Object[] args) {
- if (logger.isTraceEnabled()) {
- ParameterizedMessage msg = new ParameterizedMessage(format, args);
- logger.log(null, FQCN, Level.TRACE, msg, msg.getThrowable());
- }
- }
-
- public void trace(String format, Throwable t) {
- if (logger.isTraceEnabled()) {
- logger.log(null, FQCN, Level.TRACE, new SimpleMessage(format), t);
- }
- }
-
- public boolean isTraceEnabled() {
- return logger.isTraceEnabled();
- }
-
- public boolean isTraceEnabled(Marker marker) {
- return logger.isTraceEnabled((org.apache.logging.log4j.Marker) marker);
- }
-
- public void trace(Marker marker, String s) {
- if (isTraceEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE, new SimpleMessage(s), null);
- }
- }
-
- public void trace(Marker marker, String s, Object o) {
- if (isTraceEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE,
- new ParameterizedMessage(s, o), null);
- }
- }
-
- public void trace(Marker marker, String s, Object o, Object o1) {
- if (isTraceEnabled(marker)) {
- ParameterizedMessage msg = new ParameterizedMessage(s, o, o1);
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE, msg, msg.getThrowable());
- }
- }
-
- public void trace(Marker marker, String s, Object[] objects) {
- if (isTraceEnabled(marker)) {
- ParameterizedMessage msg = new ParameterizedMessage(s, objects);
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE, msg, msg.getThrowable());
- }
- }
-
- public void trace(Marker marker, String s, Throwable throwable) {
- if (isTraceEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.TRACE,
- new SimpleMessage(s), throwable);
- }
- }
-
- public void debug(String format) {
- if (logger.isDebugEnabled()) {
- logger.log(null, FQCN, Level.DEBUG, new SimpleMessage(format), null);
- }
- }
-
- public void debug(String format, Object o) {
- if (logger.isDebugEnabled()) {
- logger.log(null, FQCN, Level.DEBUG, new ParameterizedMessage(format, o), null);
- }
- }
-
- public void debug(String format, Object arg1, Object arg2) {
- if (logger.isDebugEnabled()) {
- ParameterizedMessage msg = new ParameterizedMessage(format, arg1, arg2);
- logger.log(null, FQCN, Level.DEBUG, msg, msg.getThrowable());
- }
- }
-
- public void debug(String format, Object[] args) {
- if (logger.isDebugEnabled()) {
- ParameterizedMessage msg = new ParameterizedMessage(format, args);
- logger.log(null, FQCN, Level.DEBUG, msg, msg.getThrowable());
- }
- }
-
- public void debug(String format, Throwable t) {
- if (logger.isDebugEnabled()) {
- logger.log(null, FQCN, Level.DEBUG, new SimpleMessage(format), t);
- }
- }
-
- public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
- }
-
- public boolean isDebugEnabled(Marker marker) {
- return logger.isDebugEnabled((org.apache.logging.log4j.Marker) marker);
- }
-
- public void debug(Marker marker, String s) {
- if (isDebugEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG, new SimpleMessage(s), null);
- }
- }
-
- public void debug(Marker marker, String s, Object o) {
- if (isDebugEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG,
- new ParameterizedMessage(s, o), null);
- }
- }
-
- public void debug(Marker marker, String s, Object o, Object o1) {
- if (isDebugEnabled(marker)) {
- ParameterizedMessage msg = new ParameterizedMessage(s, o, o1);
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG, msg, msg.getThrowable());
- }
- }
-
- public void debug(Marker marker, String s, Object[] objects) {
- if (isDebugEnabled(marker)) {
- ParameterizedMessage msg = new ParameterizedMessage(s, objects);
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG, msg, msg.getThrowable());
- }
- }
-
- public void debug(Marker marker, String s, Throwable throwable) {
- if (isDebugEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.DEBUG,
- new SimpleMessage(s), throwable);
- }
- }
-
- public void info(String format) {
- if (logger.isInfoEnabled()) {
- logger.log(null, FQCN, Level.INFO, new SimpleMessage(format), null);
- }
- }
-
- public void info(String format, Object o) {
- if (logger.isInfoEnabled()) {
- logger.log(null, FQCN, Level.INFO, new ParameterizedMessage(format, o), null);
- }
- }
-
- public void info(String format, Object arg1, Object arg2) {
- if (logger.isInfoEnabled()) {
- ParameterizedMessage msg = new ParameterizedMessage(format, arg1, arg2);
- logger.log(null, FQCN, Level.INFO, msg, msg.getThrowable());
- }
- }
-
- public void info(String format, Object[] args) {
- if (logger.isInfoEnabled()) {
- ParameterizedMessage msg = new ParameterizedMessage(format, args);
- logger.log(null, FQCN, Level.INFO, msg, msg.getThrowable());
- }
- }
-
- public void info(String format, Throwable t) {
- if (logger.isInfoEnabled()) {
- logger.log(null, FQCN, Level.INFO, new SimpleMessage(format), t);
- }
- }
-
- public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
- }
-
- public boolean isInfoEnabled(Marker marker) {
- return logger.isInfoEnabled((org.apache.logging.log4j.Marker) marker);
- }
-
- public void info(Marker marker, String s) {
- if (isInfoEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO, new SimpleMessage(s), null);
- }
- }
-
- public void info(Marker marker, String s, Object o) {
- if (isInfoEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO,
- new ParameterizedMessage(s, o), null);
- }
- }
-
- public void info(Marker marker, String s, Object o, Object o1) {
- if (isInfoEnabled(marker)) {
- ParameterizedMessage msg = new ParameterizedMessage(s, o, o1);
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO, msg, msg.getThrowable());
- }
- }
-
- public void info(Marker marker, String s, Object[] objects) {
- if (isInfoEnabled(marker)) {
- ParameterizedMessage msg = new ParameterizedMessage(s, objects);
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO, msg, msg.getThrowable());
- }
- }
-
- public void info(Marker marker, String s, Throwable throwable) {
- if (isInfoEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.INFO,
- new SimpleMessage(s), throwable);
- }
- }
-
- public void warn(String format) {
- if (logger.isWarnEnabled()) {
- logger.log(null, FQCN, Level.WARN, new SimpleMessage(format), null);
- }
- }
-
- public void warn(String format, Object o) {
- if (logger.isWarnEnabled()) {
- logger.log(null, FQCN, Level.WARN, new ParameterizedMessage(format, o), null);
- }
- }
-
- public void warn(String format, Object arg1, Object arg2) {
- if (logger.isWarnEnabled()) {
- ParameterizedMessage msg = new ParameterizedMessage(format, arg1, arg2);
- logger.log(null, FQCN, Level.WARN, msg, msg.getThrowable());
- }
- }
-
- public void warn(String format, Object[] args) {
- if (logger.isWarnEnabled()) {
- ParameterizedMessage msg = new ParameterizedMessage(format, args);
- logger.log(null, FQCN, Level.WARN, msg, msg.getThrowable());
- }
- }
-
- public void warn(String format, Throwable t) {
- if (logger.isWarnEnabled()) {
- logger.log(null, FQCN, Level.WARN, new SimpleMessage(format), t);
- }
- }
-
- public boolean isWarnEnabled() {
- return logger.isWarnEnabled();
- }
-
- public boolean isWarnEnabled(Marker marker) {
- return logger.isWarnEnabled((org.apache.logging.log4j.Marker) marker);
- }
-
- public void warn(Marker marker, String s) {
- if (isWarnEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN, new SimpleMessage(s), null);
- }
- }
-
- public void warn(Marker marker, String s, Object o) {
- if (isWarnEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN,
- new ParameterizedMessage(s, o), null);
- }
- }
-
- public void warn(Marker marker, String s, Object o, Object o1) {
- if (isWarnEnabled(marker)) {
- ParameterizedMessage msg = new ParameterizedMessage(s, o, o1);
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN, msg, msg.getThrowable());
- }
- }
-
- public void warn(Marker marker, String s, Object[] objects) {
- if (isWarnEnabled(marker)) {
- ParameterizedMessage msg = new ParameterizedMessage(s, objects);
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN, msg, msg.getThrowable());
- }
- }
-
- public void warn(Marker marker, String s, Throwable throwable) {
- if (isWarnEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.WARN,
- new SimpleMessage(s), throwable);
- }
- }
-
- public void error(String format) {
- if (logger.isErrorEnabled()) {
- logger.log(null, FQCN, Level.ERROR, new SimpleMessage(format), null);
- }
- }
-
- public void error(String format, Object o) {
- if (logger.isErrorEnabled()) {
- logger.log(null, FQCN, Level.ERROR, new ParameterizedMessage(format, o), null);
- }
- }
-
- public void error(String format, Object arg1, Object arg2) {
- if (logger.isErrorEnabled()) {
- ParameterizedMessage msg = new ParameterizedMessage(format, arg1, arg2);
- logger.log(null, FQCN, Level.ERROR, msg, msg.getThrowable());
- }
- }
-
- public void error(String format, Object[] args) {
- if (logger.isErrorEnabled()) {
- ParameterizedMessage msg = new ParameterizedMessage(format, args);
- logger.log(null, FQCN, Level.ERROR, msg, msg.getThrowable());
- }
- }
-
- public void error(String format, Throwable t) {
- if (logger.isErrorEnabled()) {
- logger.log(null, FQCN, Level.ERROR, new SimpleMessage(format), t);
- }
- }
-
- public boolean isErrorEnabled() {
- return logger.isErrorEnabled();
- }
-
- public boolean isErrorEnabled(Marker marker) {
- return logger.isErrorEnabled((org.apache.logging.log4j.Marker) marker);
- }
-
- public void error(Marker marker, String s) {
- if (isErrorEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR, new SimpleMessage(s), null);
- }
- }
-
- public void error(Marker marker, String s, Object o) {
- if (isErrorEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR,
- new ParameterizedMessage(s, o), null);
- }
- }
-
- public void error(Marker marker, String s, Object o, Object o1) {
- if (isErrorEnabled(marker)) {
- ParameterizedMessage msg = new ParameterizedMessage(s, o, o1);
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR, msg, msg.getThrowable());
- }
- }
-
- public void error(Marker marker, String s, Object[] objects) {
- if (isErrorEnabled(marker)) {
- ParameterizedMessage msg = new ParameterizedMessage(s, objects);
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR, msg, msg.getThrowable());
- }
- }
-
- public void error(Marker marker, String s, Throwable throwable) {
- if (isErrorEnabled(marker)) {
- logger.log((org.apache.logging.log4j.Marker) marker, FQCN, Level.ERROR,
- new SimpleMessage(s), throwable);
- }
- }
-
-
- public void log(Marker marker, String fqcn, int i, String s1, Object[] objects, Throwable throwable) {
- Message msg;
- if (eventLogger && marker != null && marker.contains(EVENT_MARKER)) {
- try {
- EventData data = (objects != null && objects[0] instanceof EventData) ? (EventData) objects[0] :
- new EventData(s1);
- msg = new StructuredDataMessage(data.getEventId(), data.getMessage(), data.getEventType());
- for (Map.Entry entry : data.getEventMap().entrySet()) {
- String key = entry.getKey().toString();
- if (EventData.EVENT_TYPE.equals(key) || EventData.EVENT_ID.equals(key) ||
- EventData.EVENT_MESSAGE.equals(key)) {
- continue;
- }
- ((StructuredDataMessage) msg).put(entry.getKey().toString(), entry.getValue().toString());
- }
- } catch (Exception ex) {
- msg = new ParameterizedMessage(s1, objects, throwable);
- }
-
- } else if (objects == null) {
- msg = new SimpleMessage(s1);
- } else {
- msg = new ParameterizedMessage(s1, objects, throwable);
- if (throwable != null) {
- throwable = ((ParameterizedMessage) msg).getThrowable();
- }
- }
- logger.log((org.apache.logging.log4j.Marker) marker, fqcn, getLevel(i), msg, throwable);
- }
-
- public String getName() {
- return name;
- }
-
- private Level getLevel(int i) {
-
- switch (i) {
- case TRACE_INT :
- return Level.TRACE;
- case DEBUG_INT :
- return Level.DEBUG;
- case INFO_INT :
- return Level.INFO;
- case WARN_INT :
- return Level.WARN;
- case ERROR_INT :
- return Level.ERROR;
- }
- return Level.ERROR;
- }
-}
diff --git a/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
deleted file mode 100644
index e11e630..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.slf4j.impl;
-
-import org.slf4j.ILoggerFactory;
-import org.slf4j.helpers.Log4JLoggerFactory;
-import org.slf4j.spi.LoggerFactoryBinder;
-
-/**
- *
- */
-public final class StaticLoggerBinder implements LoggerFactoryBinder {
-
- /**
- * Declare the version of the SLF4J API this implementation is compiled
- * against. The value of this field is usually modified with each release.
- */
- // to avoid constant folding by the compiler, this field must *not* be final
- public static String REQUESTED_API_VERSION = "1.6"; // !final
-
- private static final String LOGGER_FACTORY_CLASS_STR = Log4JLoggerFactory.class.getName();
-
- /**
- * The unique instance of this class.
- */
- private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
-
- /**
- * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
- * method should always be the same object
- */
- private final ILoggerFactory loggerFactory;
-
- /**
- * Private constructor to prevent instantiation
- */
- private StaticLoggerBinder() {
- loggerFactory = new Log4JLoggerFactory();
- }
-
- /**
- * Return the singleton of this class.
- *
- * @return the StaticLoggerBinder singleton
- */
- public static StaticLoggerBinder getSingleton() {
- return SINGLETON;
- }
-
- /**
- * Return the factory.
- * @return the factor.
- */
- public ILoggerFactory getLoggerFactory() {
- return loggerFactory;
- }
-
- /**
- * Return the class name.
- * @return the class name;
- */
- public String getLoggerFactoryClassStr() {
- return LOGGER_FACTORY_CLASS_STR;
- }
-}
diff --git a/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/StaticMDCBinder.java
deleted file mode 100644
index f011008..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/StaticMDCBinder.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.slf4j.impl;
-
-import org.slf4j.helpers.Log4JMDCAdapter;
-import org.slf4j.spi.MDCAdapter;
-
-/**
- *
- */
-public final class StaticMDCBinder {
-
- /**
- * The unique instance of this class.
- */
- public static final StaticMDCBinder SINGLETON = new StaticMDCBinder();
-
- private StaticMDCBinder() {
- }
-
- /**
- * Currently this method always returns an instance of {@link StaticMDCBinder}.
- * @return an MDC adapter
- */
- public MDCAdapter getMDCA() {
- return new Log4JMDCAdapter();
- }
-
- /**
- * Retrieve the adapter class name.
- * @return The adapter class name.
- */
- public String getMDCAdapterClassStr() {
- return Log4JMDCAdapter.class.getName();
- }
-}
diff --git a/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
deleted file mode 100644
index e205348..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.slf4j.impl;
-
-import org.slf4j.IMarkerFactory;
-import org.slf4j.helpers.Log4JMarkerFactory;
-import org.slf4j.spi.MarkerFactoryBinder;
-
-/**
- *
- */
-public class StaticMarkerBinder implements MarkerFactoryBinder {
-
- /**
- * The unique instance of this class.
- */
- public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
-
- private final IMarkerFactory markerFactory = new Log4JMarkerFactory();
-
- public IMarkerFactory getMarkerFactory() {
- return markerFactory;
- }
-
- public String getMarkerFactoryClassStr() {
- return Log4JMarkerFactory.class.getName();
- }
-}
diff --git a/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/package-info.java b/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/package-info.java
deleted file mode 100644
index bc74690..0000000
--- a/rgoers/slf4j-impl/src/main/java/org/slf4j/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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 2.0 SLF4J Binding.
- */
-package org.slf4j.impl;
diff --git a/rgoers/slf4j-impl/src/site/site.xml b/rgoers/slf4j-impl/src/site/site.xml
deleted file mode 100644
index 832d7b8..0000000
--- a/rgoers/slf4j-impl/src/site/site.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project name="Component">
- <bannerLeft>
- <name>Logging Services</name>
- <src>../images/ls-logo.jpg</src>
- <href>../index.html</href>
- </bannerLeft>
- <bannerRight>
- <src>../images/logo.jpg</src>
- </bannerRight>
- <body>
- <links>
- <item name="Apache" href="http://www.apache.org/" />
- <item name="Logging Services" href="http://logging.apache.org/"/>
- <item name="Log4j" href="../index.html"/>
- </links>
- <menu ref="reports"/>
- </body>
-</project>
diff --git a/rgoers/slf4j-impl/src/site/xdoc/api.xml b/rgoers/slf4j-impl/src/site/xdoc/api.xml
deleted file mode 100644
index ca0ec0f..0000000
--- a/rgoers/slf4j-impl/src/site/xdoc/api.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>SLF4J Bridge</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="SLF4J Bridge">
-
- <p>
- The SLF4J Bridge allows applications coded to the SLF4J API to use
- Log4j 2.0 as the implementation.
- </p>
-
- </section>
-
- <section name="Requirements">
- <p>
- The SLF4J bridge requires at least Java 5.
- </p>
- </section>
-
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/slf4j-impl/src/site/xdoc/index.xml b/rgoers/slf4j-impl/src/site/xdoc/index.xml
deleted file mode 100644
index ca0ec0f..0000000
--- a/rgoers/slf4j-impl/src/site/xdoc/index.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>SLF4J Bridge</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="SLF4J Bridge">
-
- <p>
- The SLF4J Bridge allows applications coded to the SLF4J API to use
- Log4j 2.0 as the implementation.
- </p>
-
- </section>
-
- <section name="Requirements">
- <p>
- The SLF4J bridge requires at least Java 5.
- </p>
- </section>
-
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java b/rgoers/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
deleted file mode 100644
index 95f6642..0000000
--- a/rgoers/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.logging.slf4j;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.ext.EventData;
-import org.slf4j.ext.EventLogger;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-import org.slf4j.impl.SLF4JLogger;
-import org.slf4j.spi.LocationAwareLogger;
-
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class LoggerTest {
-
- private static final String CONFIG = "log4j-test1.xml";
- private static LoggerContext ctx;
-
- @BeforeClass
- public static void setupClass() {
- System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
- ctx = (LoggerContext) LogManager.getContext(false);
- Configuration config = ctx.getConfiguration();
- }
-
- @AfterClass
- public static void cleanupClass() {
- System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- ctx.reconfigure();
- StatusLogger.getLogger().reset();
- }
-
- Logger logger = LoggerFactory.getLogger("LoggerTest");
- XLogger xlogger = XLoggerFactory.getXLogger("LoggerTest");
-
- @Test
- public void basicFlow() {
- xlogger.entry();
- verify("List", "o.a.l.s.LoggerTest entry MDC{}\n");
- xlogger.exit();
- verify("List", "o.a.l.s.LoggerTest exit MDC{}\n");
- }
-
- @Test
- public void simpleFlow() {
- xlogger.entry(CONFIG);
- verify("List", "o.a.l.s.LoggerTest entry with (log4j-test1.xml) MDC{}\n");
- xlogger.exit(0);
- verify("List", "o.a.l.s.LoggerTest exit with (0) MDC{}\n");
- }
-
- @Test
- public void throwing() {
- xlogger.throwing(new IllegalArgumentException("Test Exception"));
- verify("List", "o.a.l.s.LoggerTest throwing MDC{}\n");
- }
-
- @Test
- public void catching() {
- try {
- throw new NullPointerException();
- } catch (Exception e) {
- xlogger.catching(e);
- verify("List", "o.a.l.s.LoggerTest catching MDC{}\n");
- }
- }
-
- @Test
- public void debug() {
- logger.debug("Debug message");
- verify("List", "o.a.l.s.LoggerTest Debug message MDC{}\n");
- }
-
- @Test
- public void debugNoParms() {
- logger.debug("Debug message {}");
- verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}\n");
- logger.debug("Debug message {}", (Object[]) null);
- verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}\n");
- ((LocationAwareLogger)logger).log(null, SLF4JLogger.class.getName(), LocationAwareLogger.DEBUG_INT,
- "Debug message {}", null, null);
- verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}\n");
- }
-
-
- @Test
- public void debugWithParms() {
- logger.debug("Hello, {}", "World");
- verify("List", "o.a.l.s.LoggerTest Hello, World MDC{}\n");
- }
-
- @Test
- public void mdc() {
-
- MDC.put("TestYear", "2010");
- logger.debug("Debug message");
- verify("List", "o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}\n");
- MDC.clear();
- logger.debug("Debug message");
- verify("List", "o.a.l.s.LoggerTest Debug message MDC{}\n");
- }
-
- @Test
- public void testRootLogger() {
- Logger l = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
- assertNotNull("No Root Logger", l);
- assertEquals(Logger.ROOT_LOGGER_NAME, l.getName());
- }
-
- @Test
- public void doubleSubst() {
- logger.debug("Hello, {}", "Log4j {}");
- verify("List", "o.a.l.s.LoggerTest Hello, Log4j {} MDC{}\n");
- xlogger.debug("Hello, {}", "Log4j {}");
- verify("List", "o.a.l.s.LoggerTest Hello, Log4j Log4j {} MDC{}\n");
- }
-
- @Test
- public void testEventLogger() {
- MDC.put("loginId", "JohnDoe");
- MDC.put("ipAddress", "192.168.0.120");
- MDC.put("locale", Locale.US.getDisplayName());
- EventData data = new EventData();
- data.setEventType("Transfer");
- data.setEventId("Audit@18060");
- data.setMessage("Transfer Complete");
- data.put("ToAccount", "123456");
- data.put("FromAccount", "123457");
- data.put("Amount", "200.00");
- EventLogger.logEvent(data);
- MDC.clear();
- verify("EventLogger", "o.a.l.s.LoggerTest Transfer [Audit@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete\n");
- }
-
- private void verify(String name, String expected) {
- //LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
- Map<String, Appender> list = ctx.getConfiguration().getAppenders();
- Appender listApp = list.get(name);
- assertNotNull("Missing Appender", listApp);
- assertTrue("Not a ListAppender", listApp instanceof ListAppender);
- List<String> events = ((ListAppender) listApp).getMessages();
- assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size()== 1);
- String actual = events.get(0);
- assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
- ((ListAppender) listApp).clear();
- }
-
- @Before
- public void cleanup()
- {
- Map<String, Appender> list = ctx.getConfiguration().getAppenders();
- Appender listApp = list.get("List");
- ((ListAppender) listApp).clear();
- Appender eventApp = list.get("EventLogger");
- ((ListAppender) eventApp).clear();
- }
-}
diff --git a/rgoers/slf4j-impl/src/test/resources/log4j-test1.xml b/rgoers/slf4j-impl/src/test/resources/log4j-test1.xml
deleted file mode 100644
index 85ce3f3..0000000
--- a/rgoers/slf4j-impl/src/test/resources/log4j-test1.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration packages="org.apache.logging.log4j.test" status="debug" name="LoggerTest">
- <properties>
- <property name="filename">target/test.log</property>
- </properties>
- <ThresholdFilter level="trace"/>
-
- <appenders>
- <List name="EventLogger">
- <PatternLayout pattern="%C{1.} %m%n"/>
- </List>
- <Console name="STDOUT">
- <PatternLayout pattern="%C{1.} %m MDC%X%n"/>
- </Console>
- <File name="File" fileName="${filename}">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- </File>
- <List name="List">
- <PatternLayout pattern="%C{1.} %m MDC%X%n"/>
- </List>
- <SLF4J name="SLF4J"/>
- </appenders>
-
- <loggers>
- <logger name="EventLogger" level="info" additivity="false">
- <appender-ref ref="EventLogger"/>
- </logger>>
-
- <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
- <appender-ref ref="File"/>
- </logger>>
-
- <root level="trace">
- <appender-ref ref="List"/>
- </root>
- </loggers>
-
-</configuration>
\ No newline at end of file
diff --git a/rgoers/src/changes/changes.xml b/rgoers/src/changes/changes.xml
deleted file mode 100644
index 2059461..0000000
--- a/rgoers/src/changes/changes.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document>
- <properties>
- <title>Changes</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <release version="2.0" date="TBD" description="Rewrite of Log4j">
- <action issue="LOG4J2-56" dev="rgoers" type="fix" due-to="John Owen Atala">
- Level.toLevel would throw an IllegalArgumentException instead of returning the default value.
- </action>
- <action issue="LOG4J2-51" dev="rgoers" type="fix" due-to="John Vasileff">
- Remove LoggerContext support for custom logger factories. All Loggers returned
- by LoggerContext should be compatibile and of the same type.
- </action>
- <action issue="LOG4J2-50" dev="rgoers" type="fix" due-to="John Vasileff">
- Make sure all application facing log methods use their own FQCN. This patch
- resolves a unit test failure for the %C pattern when using the Category logger.
- </action>
- </release>
- </body>
-</document>
diff --git a/rgoers/src/site/apt/download.apt b/rgoers/src/site/apt/download.apt
deleted file mode 100644
index 6828f81..0000000
--- a/rgoers/src/site/apt/download.apt
+++ /dev/null
@@ -1,60 +0,0 @@
-~~ Licensed to the Apache Software Foundation (ASF) under one or more
-~~ contributor license agreements. See the NOTICE file distributed with
-~~ this work for additional information regarding copyright ownership.
-~~ The ASF licenses this file to You under the Apache License, Version 2.0
-~~ (the "License"); you may not use this file except in compliance with
-~~ the License. You may obtain a copy of the License at
-~~
-~~ http://www.apache.org/licenses/LICENSE-2.0
-~~
-~~ Unless required by applicable law or agreed to in writing, software
-~~ distributed under the License is distributed on an "AS IS" BASIS,
-~~ WITHOUT 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 2.0
- ------
- ------
- ------
-
-Download Apache log4j 2.0
-
- Apache log4j 2.0 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 2.0 (tar.gz) | {{{http://www.apache.org/dyn/closer.cgi/logging/log4j/2.0/apache-log4j-2.0.tar.gz} apache-log4j-2.0.tar.gz}} | {{{http://www.apache.org/dist/logging/log4j/2.0/apache-log4j-2.0.tar.gz.md5} apache-log4j-2.0.tar.gz.md5}} | {{{http://www.apache.org/dist/logging/log4j/2.0/apache-log4j-2.0.tar.gz.asc} apache-log4j-2.0.tar.gz.asc}} |
-*-------------------------+---------+----------+-----------+
-| Apache log4j 2.0 (zip) | {{{http://www.apache.org/dyn/closer.cgi/logging/log4j/2.0/apache-log4j-2.0.zip} apache-log4j-2.0.zip}} | {{{http://www.apache.org/dist/logging/log4j/2.0/apache-log4j-2.0.zip.md5} apache-log4j-2.0.zip.md5}} | {{{http://www.apache.org/dist/logging/log4j/2.0/apache-log4j-2.0.zip.asc} apache-log4j-2.0.zip.asc}} |
-*-------------------------+---------+----------+-----------+
-
- It is essential that you verify the integrity of the downloaded files using the PGP or MD5 signatures.
- Please read {{{http://httpd.apache.org/dev/verification.html}Verifying Apache HTTP Server Releases}} for more
- information on why you should verify our releases.
-
- The PGP signatures can be verified using PGP or GPG. First download the {{{http://www.apache.org/dist/logging/KEYS}KEYS}}
- as well as the asc signature file for the relevant distribution. Make sure you get these files from the
- {{{http://www.apache.org/dist/logging/}main distribution directory}}, rather than from a mirror. Then verify the signatures using
-
----
-% gpg --import KEYS
-% gpg --verify log4j-2.0.tar.gz.asc
----
-
- Apache log4j 2.0 is signed by Ralph Goers B3D8E1BA
-
- Alternatively, you can verify the MD5 signature on the files. A unix program called md5 or md5sum is included
- in many unix distributions.
-
-
-
-* 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/rgoers/src/site/resources/images/Log4jClasses.jpg b/rgoers/src/site/resources/images/Log4jClasses.jpg
deleted file mode 100755
index ea16084..0000000
--- a/rgoers/src/site/resources/images/Log4jClasses.jpg
+++ /dev/null
Binary files differ
diff --git a/rgoers/src/site/resources/images/logo.jpg b/rgoers/src/site/resources/images/logo.jpg
deleted file mode 100644
index 5b6ede8..0000000
--- a/rgoers/src/site/resources/images/logo.jpg
+++ /dev/null
Binary files differ
diff --git a/rgoers/src/site/resources/images/ls-logo.jpg b/rgoers/src/site/resources/images/ls-logo.jpg
deleted file mode 100755
index 35f2f47..0000000
--- a/rgoers/src/site/resources/images/ls-logo.jpg
+++ /dev/null
Binary files differ
diff --git a/rgoers/src/site/site.xml b/rgoers/src/site/site.xml
deleted file mode 100644
index 4704d44..0000000
--- a/rgoers/src/site/site.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache license, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the license at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the license.
-
--->
-<project name="Log4j">
- <skin>
- <groupId>org.apache.maven.skins</groupId>
- <artifactId>maven-fluido-skin</artifactId>
- <version>1.0-SNAPSHOT</version>
- </skin>
- <custom>
- <fluidoSkin>
- <topBarEnabled>false</topBarEnabled>
- <sideBarEnabled>true</sideBarEnabled>
- <searchEnabled>true</searchEnabled>
- </fluidoSkin>
- </custom>
- <bannerLeft>
- <name>Logging Services™</name>
- <src>images/ls-logo.jpg</src>
- <href>http://logging.apache.org/</href>
- </bannerLeft>
- <bannerRight>
- <src>images/logo.jpg</src>
- </bannerRight>
- <body>
- <menu name="Apache Log4j™ 2" inherit="top">
- <item name="About" href="/index.html"/>
- <item name="Download" href="/download.html"/>
- <item name="Build and Install" href="/build.html"/>
- <item name="Changelog" href="/changelog.html"/>
- </menu>
- <menu name="Manual" inherit="top">
- <item name="Introduction" href="/manual/index.html"/>
- <item name="Architecture" href="/manual/architecture.html"/>
- <item name="API" href="/manual/api.html" collapse="true">
- <item name="Overview" href="manual/api.html#Overview"/>
- <item name="Flow Tracing" href="manual/flowtracing.html"/>
- <item name="Markers" href="manual/markers.html"/>
- <item name="Event Logging" href="/manual/eventlogging.html"/>
- <item name="Messages" href="/manual/messages.html"/>
- <item name="ThreadContext" href="/manual/thread-context.html"/>
- </item>
- <item name="Configuration" href="/manual/configuration.html" collapse="true">
- <item name="Automatic Configuration" href="/manual/configuration.html#AutomaticConfiguration"/>
- <item name="Additivity" href="/manual/configuration.html#Additivity"/>
- <item name="Automatic Reconfiguration" href="/manual/configuration.html#AutomaticReconfiguration"/>
- <item name="Configuration Syntax" href="/manual/configuration.html#ConfigurationSyntax"/>
- <item name="Property Substitution" href="/manual/configuration.html#PropertySubstitution"/>
- <item name="Status Messages" href="/manual/configuration.html#StatusMessages"/>
- <item name="Unit Testing in Maven" href="/manual/configuration.html#UnitTestingInMaven"/>
- </item>
- <item name="Plugins" href="/manual/plugins.html" collapse="true">
- <item name="Core" href="/manual/plugins.html#Core"/>
- <item name="Converters" href="/manual/plugins.html#Converters"/>
- <item name="Lookups" href="/manual/plugins.html#Lookups"/>
- </item>
- <item name="Lookups" href="/manual/lookups.html" collapse="true">
- <item name="ContextMap" href="/manual/lookups.html#ContextMapLookup"/>
- <item name="Date" href="/manual/lookups.html#DateLookcup"/>
- <item name="Environment" href="/manual/lookups.html#EnvironmentLookup"/>
- <item name="Map" href="/manual/lookups.html#MapLookup"/>
- <item name="StructuredData" href="/manual/lookups.html#StructuredDataLookup"/>
- <item name="SystemProperties" href="/manual/lookups.html#SystemPropertiesLookup"/>
- </item>
- <item name="Appenders" href="/manual/appenders.html" collapse="true">
- <item name="Console" href="/manual/appenders.html@ConsoleAppender"/>
- <item name="Failover" href="/manual/appenders.html@FailoverAppender"/>
- <item name="File" href="/manual/appenders.html#FileAppender"/>
- <item name="Flume" href="/manual/appenders.html#FlumeAvroAppender"/>
- <item name="JMSQueue" href="/manual/appenders.html#JMSQueueAppender"/>
- <item name="JSMTopic" href="/manual/appenders.html#JMSTopicAppender"/>
- <item name="OutputStream" href="/manual/appenders.html#OutputStreamAppender"/>
- <item name="Rewrite" href="/manual/appenders.html#RewriteAppender"/>
- <item name="RollingFile" href="/manual/appenders.html#RollingFileAppender"/>
- <item name="Routing" href="/manual/appenders.html#RoutingAppender"/>
- <item name="Socket" href="/manual/appenders.html#SocketAppender"/>
- <item name="Syslog" href="/manual/appenders.html#SyslogAppender"/>
- </item>
- <item name="Layouts" href="/manual/layouts.html" collapse="true">
- <item name="HTML" href="/manual/layouts.html#HTMLLayout"/>
- <item name="Pattern" href="/manual/layouts.html#PatternLayout"/>
- <item name="RFC5424" href="/manual/layouts.html#RFC5424Layout"/>
- <item name="Serialized" href="/manual/layouts.html#SerializedLayout"/>
- <item name="Syslog" href="/manual/layouts.html#SyslogLayout"/>
- <item name="XML" href="/manual/layouts.html#XMLLayout"/>
- </item>
- <item name="Filters" href="/manual/filters.html" collapse="true">
- <item name="Burst" href="/manual/filters.html#BurstFilter"/>
- <item name="CompositeFilter" href="/manual/filters.html#CompositeFilter"/>
- <item name="DynamicThreshold" href="/manual/filters.html#DynamicThresholdFilter"/>
- <item name="Map" href="/manual/filters.html#MapFilter"/>
- <item name="Marker" href="/manual/filters.html#MarkerFilter"/>
- <item name="Regex" href="/manual/filters.html#RegexFilter"/>
- <item name="StructuredData" href="/manual/filters.html#StructuredDataFilter"/>
- <item name="ThreadContextMap" href="/manual/filters.html#ThreadContextMapFilter"/>
- <item name="Threshold" href="/manual/filters.html#ThresholdFilter"/>
- <item name="Time" href="/manual/filters.html#TimeFilter"/>
- </item>
- <item name="JMX" href="/manual/jmx.html"/>
- <item name="Logging Separation" href="/manual/logsep.html"/>
- <item name="Extending Log4j" href="/manual/extending.html" collapse="true">
- <item name="LoggerContextFactory" href="/manual/extending.html#LoggerContextFactory"/>
- <item name="ContextSelector" href="/manual/extending.html#ContextSelector"/>
- <item name="ConfigurationFactory" href="/manual/extending.html#ConfigurationFactory"/>
- <item name="LoggerConfig" href="/manual/extending.html#LoggerConfig"/>
- <item name="Lookups" href="/manual/extending.html#Lookups"/>
- <item name="Filters" href="/manual/extending.html#Filters"/>
- <item name="Appenders" href="/manual/extending.html#Appenders"/>
- <item name="Layouts" href="/manual/extending.html#Layouts"/>
- <item name="PatternConverters" href="/manual/extending.html#PatternConverters"/>
- <item name="Custom Plugins" href="/manual/extending.html#Custom"/>
- </item>
- </menu>
- <menu name="Logging Adapters" inherit="top">
- <item name="Log4j 1.x API" href="log4j12-api/api.html"/>
- <item name="Commons Logging" href="log4j2-jcl/api.html"/>
- <item name="SLF4J" href="slf4j-impl/api.html"/>
- </menu>
- <menu name="Components" inherit="top">
- <item name="API" href="log4j2-api/index.html"/>
- <item name="Impl" href="log4j2-core/index.html"/>
- <item name="Log4J 1.2 API" href="log4j12-api/index.html"/>
- <item name="Commons Logging Bridge" href="log4j2-jcl/index.html"/>
- <item name="SLF4J Binding" href="slf4j-impl/index.html"/>
- <item name="Flume OG" href="log4j2-flume-og/index.html"/>
- <item name="Flume NG" href="log4j2-flume-ng/index.html"/>
- </menu>
- <links>
- <item name="Logging Wiki" href="http://wiki.apache.org/logging"/>
- <item name="Apache" href="http://www.apache.org/"/>
- <item name="Logging Services" href="http://logging.apache.org/"/>
- <item name="Log4j" href="http://logging.apache.org/log4j/"/>
- <item name="Log4j Companions" href="http://logging.apache.org/log4j/companions"/>
- </links>
- <menu ref="reports"/>
- </body>
-</project>
diff --git a/rgoers/src/site/xdoc/api/audit-logging.html b/rgoers/src/site/xdoc/api/audit-logging.html
deleted file mode 100644
index 5a4ba56..0000000
--- a/rgoers/src/site/xdoc/api/audit-logging.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Overview</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- Log4J 2.0
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/api/index.html b/rgoers/src/site/xdoc/api/index.html
deleted file mode 100644
index 5a4ba56..0000000
--- a/rgoers/src/site/xdoc/api/index.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Overview</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- Log4J 2.0
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/api/messages.html b/rgoers/src/site/xdoc/api/messages.html
deleted file mode 100644
index 5a4ba56..0000000
--- a/rgoers/src/site/xdoc/api/messages.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Overview</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- Log4J 2.0
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/build.xml b/rgoers/src/site/xdoc/build.xml
deleted file mode 100644
index 843992a..0000000
--- a/rgoers/src/site/xdoc/build.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Build and Install</title>
- </properties>
-
- <body>
- <section name="Releases">
-
-
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/changelog.xml b/rgoers/src/site/xdoc/changelog.xml
deleted file mode 100644
index 9d2edd4..0000000
--- a/rgoers/src/site/xdoc/changelog.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Releases</title>
- </properties>
-
- <body>
- <section name="Releases">
-
- <macro name="toc">
- <param name="fromDepth" value="2"/>
- </macro>
-
- <subsection name="Apache Log4j v2.0" id="Apache_Log4j_v2.0">
-
- <p>Release date: TBA</p>
- <p><a href="changes-report.html#a2.0">JIRA change log</a></p>
-
- <p>Apache Log4j 2.0 is not compatible with the previous versions. Please have the following in mind
- when upgrading to Log4j 2.0 in your project:</p>
-
- <ul>
- <li>Java 5 is required</li>
- <li>The XML configuration has been simplified and is not compatible with Log4j 1.x</li>
- <li>Configuration via property files is not supported.</li>
- <li>Configuration via JSON is supported.</li>
- <li>Although Log4j 2 is not directly compatible with Log4j 1.x and compatibility bridge
- has been provided to reduce the need to make coding changes.</li>
- </ul>
- </subsection>
-
- </section>
- </body>
-</document>
diff --git a/rgoers/src/site/xdoc/index.xml b/rgoers/src/site/xdoc/index.xml
deleted file mode 100644
index 3b9e857..0000000
--- a/rgoers/src/site/xdoc/index.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4J 2.0 Guide</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="About Log4j 2.0">
-
- <p>
- Log4Jj 2.0 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j
- 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in
- Logback's architecture.
- </p>
-
- <p>Some of the features and improvements in Log4j 2.0 are:</p>
-
- <h3>API Separation</h3>
- <p>
- The API for Log4j is separate from the implementation. It is now clear to application developers
- what classes and methods they can use with compatibility being assured while allowing
- improvements to be made to the implementation.
- </p>
- <h3>Improved Performance</h3>
- <p>
- Faster performance than Log4j 1.x in critical areas and similar performance to Logback in
- most circumstances. See <a href="performance.html">Performance</a> for more information.
- </p>
- <h3>Support for multiple APIs</h3>
- <p>
- While the Log4j 2.0 API will provide the best performance, support for the SL4J and Commons Logging
- APIs are provided.
- </p>
- <h3>Automatic Reloading of Configurations</h3>
- <p>
- Like Logback, Log4j 2.0 can automatically reload its configuration upon modification. Unlike Logback,
- it will do so without losing log events while reconfiguration is taking place.
- </p>
- <h3>Advanced Filtering</h3>
- <p>
- Like Logback, Log4j 2.0 supports filtering based on context data, markers, regular expressions and
- other components in the Log event and can be specified to apply to all events before being passed
- to Loggers or as they pass through appenders. In addition, filters can also be associated with
- Loggers. Unlike Logback, a common Filter class can be used in any of these circumstances.
- </p>
- <h3>Plugin Architecture</h3>
- <p>
- All configurable components are defined as Log4j plugins. As such, no Log4j code must be changed to
- create a new Appender, Layout, Pattern Converter, etc. Log4j will automatically
- recognize properly defined plugins and use them when they are referenced in the configuration.
- </p>
- <h3>Property Support</h3>
- <p>
- Properties can be referenced in the configuration and either be directly replace or passed to the
- underlying component where they can be dynamically resolved. Properties can come from values
- defined in the configuration file, system properties, environment variables, the ThreadContext
- Map, and data present in the event. Users can further customize the property providers by
- adding their own <a href="../lookups.html">Lookup</a> Plugin.
- </p>
-
- </section>
-
- <section name="Requirements">
- <p>
- Log4j 2.0 requires Java 5 but has will take advantage of enhancements in Java 6 to improve performance.
- Some features may require optional dependencies. These dependencies are
- specified in the documentation for those features.
- </p>
- </section>
-
- <section name="News">
- <p>
- Log4j 2.0 is now available. The API for Log4j 2.0 is not compatible with Log4j 1.x, however an adapter
- is available to allow applications to continue to use the Log4j 1.x API. Adapters are also available for
- Commons Logging and SLF4J.
- </p>
- </section>
-
- </body>
-</document>
-
diff --git a/rgoers/src/site/xdoc/manual/api.xml b/rgoers/src/site/xdoc/manual/api.xml
deleted file mode 100644
index 820ab60..0000000
--- a/rgoers/src/site/xdoc/manual/api.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4J 2.0 API</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Log4j 2.0 API">
- <a name="Overview"/>
- <subsection name="Overview">
- <p>
- The Log4Jj 2.0 API provides the interface that applications should code to and provides the
- adapter components required for implementers to create a logging implementation. Although Log4j 2
- is broken up between an API and an implementation, the primary purpose of doing so was not to
- allow multiple implementations, although that is certainly possible, but to clearly define
- what classes and methods are safe to use in "normal" application code.
- </p>
- <h4>Hello World!</h4>
- <p>
- No introduction would be complete without the customary Hello, World example. Here is ours. First,
- a Logger with the name "HelloWorld" is obtained from the LogManager. Next, the logger is used to
- write the "Hello, World!" message, however the message will be written only if the Logger is
- configured to allow informational messages.
- </p>
- <source> import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
-
- public class HelloWorld {
- private static Logger logger = LogManager.getLogger("HelloWorld");
- public static void main(String[] args) {
- logger.info("Hello, World!");
- }
- }</source>
- <p>
- The output from the call to logger.info() will vary significantly depending on the configuration
- used. See the <a href="./configuration.html">Configuration</a> section for more details.
- </p>
- <h4>Parameter Substitution</h4>
- <p>
- Frequently the purpose of logging is to provide information about what is happening in the system,
- which requires including information about the objects being manipulated. In Log4j 1.x this could
- be accomplished by doing:
- </p>
- <source> if (logger.isDebugEnabled()) {
- logger.debug("Logging in user " + user.getName() + " with id " + user.getId());
- }</source>
- <p>
- Doing this repeatedly has the effect of making the code feel like it is more about logging than the
- actual task at hand. In addition, it results in the logging level being checked twice; once on the
- call to isDebugEnabled and once on the debug method. A better alternative would be:
- </p>
- <source> logger.debug("Logging in user {} with id {}", user.getName(), user.getId());</source>
- <p>
- With the code above the logging level will only be checked once and the String construction will
- only occur when debug logging is enabled.
- </p>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/appenders.xml b/rgoers/src/site/xdoc/manual/appenders.xml
deleted file mode 100644
index 2d4b752..0000000
--- a/rgoers/src/site/xdoc/manual/appenders.xml
+++ /dev/null
@@ -1,1241 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4j 2 Appenders</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Appenders">
- <p>
- Appenders are the component responsible for delivering LogEvents to their destination. Every Appender must
- implement the <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/Appender.html">Appender</a>
- interface. Most Appenders will extend
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/appender/AppenderBase.html">AppenderBase</a>
- which adds <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/Lifecycle.html">Lifecycle</a>
- and <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/filter/Filterable">Filterable</a>
- support. Lifecycle allows components to finish initialization after configuration has completed and to
- perform cleanup during shutdown. Filterable allows the component to have Filters attached to it which are
- evaluated during event processing.
- </p>
- <p>
- Appenders usually are only responsible for writing the event data to the target destination. In most cases
- they delegate responsibility for formatting the event to a <a href="../layouts.html">layout</a>. Some
- appenders wrap other appenders so that they can modify the LogEvent, handle a failure in an Appender,
- route the event to a subordinate Appender based on advanced Filter criteria or provide similar functionality
- that does not directly format the event for viewing.
- </p>
- <p>
- Appenders always have a name so that they can be referenced from Loggers.
- </p>
- <a name="ConsoleAppender"/>
- <subsection name="ConsoleAppender">
- <p>
- As one might expect, the ConsoleAppender writes its output to either System.err or System.out with System.err
- being the default target. A Layout must be provided to format the LogEvent.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>filter</td>
- <td>Filter</td>
- <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
- may be used by using a CompositeFilter.</td>
- </tr>
- <tr>
- <td>layout</td>
- <td>Layout</td>
- <td>The Layout to use to format the LogEvent. If no layout is supplied the default pattern layout
- of "%m%n" will be used.</td>
- </tr>
- <tr>
- <td>name</td>
- <td>String</td>
- <td>The name of the Appender.</td>
- </tr>
- <tr>
- <td>suppressExceptions</td>
- <td>boolean</td>
- <td>The default is true, causing exceptions to be internally logged and then ignored. When set to
- false exceptions will be percolated to the caller.</td>
- </tr>
- <tr>
- <td>target</td>
- <td>String</td>
- <td>Either "SYSTEM_OUT" or "SYSTEM_ERR". The default is "SYSTEM_ERR".</td>
- </tr>
- <caption align="top">ConsoleAppender Parameters</caption>
- </table>
- <p>
- A typical Console configuration might look like:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <Console name="STDOUT" target="SYSTEM_OUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="STDOUT"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="FailoverAppender"/>
- <subsection name="FailoverAppender">
- <p>The FailoverAppender wraps a set of appenders. If the primary Appender fails the secondary appenders will be
- tried in order until one succeeds or there are no more secondaries to try.</p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>filter</td>
- <td>Filter</td>
- <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
- may be used by using a CompositeFilter.</td>
- </tr>
- <tr>
- <td>primary</td>
- <td>String</td>
- <td>The name of the primary Appender to use.</td>
- </tr>
- <tr>
- <td>failovers</td>
- <td>String[]</td>
- <td>The names of the secondary Appenders to use.</td>
- </tr>
-
- <tr>
- <td>name</td>
- <td>String</td>
- <td>The name of the Appender.</td>
- </tr>
- <tr>
- <td>suppressExceptions</td>
- <td>boolean</td>
- <td>The default is true, causing exceptions to be internally logged and then ignored. When set to
- false exceptions will be percolated to the caller.</td>
- </tr>
- <tr>
- <td>target</td>
- <td>String</td>
- <td>Either "SYSTEM_OUT" or "SYSTEM_ERR". The default is "SYSTEM_ERR".</td>
- </tr>
- <caption align="top">FailoverAppender Parameters</caption>
- </table>
- <p>
- A Failover configuration might look like:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- <Console name="STDOUT" target="SYSTEM_OUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- <Failover name="Failover" primary="RollingFile" suppressExceptions="false">
- <Failovers>
- <appender-ref ref="Console"/>
- </Failovers>
- </Failover>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="Failover"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="FileAppender"/>
- <subsection name="FileAppender">
- <p>The FileAppender is an OutputStreamAppender that writes to the File named in the fileName parameter. The
- FileAppender uses a FileManager (which extends OutputStreamManager) to actually perform the file I/O. While
- FileAppenders from different Configurations cannot be shared, the FileManagers can be if the Manager is
- accessible. For example, two webapps in a servlet container can have their own configuration and safely
- write to the same file if Log4J is in a ClassLoader that is common to both of them.</p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>append</td>
- <td>boolean</td>
- <td>When true - the default, records will be appended to the end of the file. When set to false,
- the file will be cleared before new reocrds are written.</td>
- </tr>
- <tr>
- <td>bufferedIO</td>
- <td>boolean</td>
- <td>When true - the default, records will be written to a buffer and the data will be written to
- disk when the buffer is full or, if immediateFlush is set, when the record is written.
- File locking cannot be used with bufferedIO. Performance tests have shown that using buffered I/O
- significantly improves performance, even if immediateFlush is enabled.</td>
- </tr>
- <tr>
- <td>filter</td>
- <td>Filter</td>
- <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
- may be used by using a CompositeFilter.</td>
- </tr>
- <tr>
- <td>fileName</td>
- <td>String</td>
- <td>The name of the file to write to. If the file, or any of its parent directories, do not exist,
- they will be created.</td>
- </tr>
- <tr>
- <td>immediateFlush</td>
- <td>boolean</td>
- <td>When set to true, each write will be followed by a flush. This will guarantee the data is written
- to disk but could impact performance.</td>
- </tr>
- <tr>
- <td>layout</td>
- <td>Layout</td>
- <td>The Layout to use to format the LogEvent</td>
- </tr>
- <tr>
- <td>locking</td>
- <td>boolean</td>
- <td>When set to true, I/O operations will occur only while the file lock is held allowing FileAppenders
- in multiple JVMs and potentially multiple hosts to write to the same file simultaneously. This
- will significantly impact performance so should be used carefully. Furthermore, on many systems
- the file lock is "advisory" meaning that other applications can perform operations on the file
- without acquiring a lock. The default value is false.</td>
- </tr>
-
- <tr>
- <td>name</td>
- <td>String</td>
- <td>The name of the Appender.</td>
- </tr>
- <tr>
- <td>suppressExceptions</td>
- <td>boolean</td>
- <td>The default is true, causing exceptions to be internally logged and then ignored. When set to
- false exceptions will be percolated to the caller.</td>
- </tr>
- <caption align="top">FileAppender Parameters</caption>
- </table>
- <p>
- Here is a sample File configuration:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <File name="MyFile" fileName="logs/app.log">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- </File>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="MyFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="FlumeAvroAppender"/>
- <subsection name="FlumeAvroAppender">
- <p><i>This is an optional component supplied in a separate jar.</i></p>
- <p><a href="http://incubator.apache.org/projects/flume.html">Apache Flume</a> is a distributed, reliable,
- and available system for efficiently collecting, aggregating, and moving large amounts of log data
- from many different sources to a centralized data store. The FlumeAppender takes LogEvents and sends
- them to a Flume agent as serialized Avro events for consumption.</p>
- <p>
- There are two versions of the Flume Appender available. The first is for "Flume OG", the original
- version of Flume before it became an Apache project. The second is for "Flume NG", which is
- maintained by the Apache Flume project.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>agents</td>
- <td>Agent[]</td>
- <td>An array of Agents to which the logging events should be sent. If more than one agent is specified
- the first Agent will be the primary and subsequent Agents will be used in the order specified as
- secondaries should the primary Agent fail. Each Agent definition supplies the Agents host and port.</td>
- </tr>
- <tr>
- <td>agentRetries</td>
- <td>integer</td>
- <td>The number of times the agent should be retried before failing to a secondary.</td>
- </tr>
- <tr>
- <td>batchSize</td>
- <td>integer</td>
- <td>Specifies the number of events that should be sent as a batch. The default is 1. <i>This
- parameter only applies to the Flume NG Appender.</i></td>
- </tr>
- <tr>
- <td>compress</td>
- <td>boolean</td>
- <td>When set to true the message body will be compressed using gzip</td>
- </tr>
- <tr>
- <td>filter</td>
- <td>Filter</td>
- <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
- may be used by using a CompositeFilter.</td>
- </tr>
- <tr>
- <td>eventPrefix</td>
- <td>String</td>
- <td>The character string to prepend to each event attribute in order to distinguish it from MDC attributes.
- The default is an empty string.</td>
- </tr>
- <tr>
- <td>flumeEventFactory</td>
- <td>FlumeEventFactory</td>
- <td>Factory that generates the Flume events from Log4j events. The default factory is the
- FlumeAvroAppender itself.</td>
- </tr>
- <tr>
- <td>layout</td>
- <td>Layout</td>
- <td>The Layout to use to format the LogEvent. If no layout is specified RFC5424Layout will be used.</td>
- </tr>
- <tr>
- <td>mdcExcludes</td>
- <td>String</td>
- <td>A comma separated list of mdc keys that should be excluded from the FlumeEvent. This is mutually
- exclusive with the mdcIncludes attribute.</td>
- </tr>
- <tr>
- <td>mdcIncludes</td>
- <td>String</td>
- <td>A comma separated list of mdc keys that should be included in the FlumeEvent. Any keys in the MDC
- not found in the list will be excluded. This option is mutually exclusive with the mdcExcludes
- attribute.</td>
- </tr>
- <tr>
- <td>mdcRequired</td>
- <td>String</td>
- <td>A comma separated list of mdc keys that must be present in the MDC. If a key is not present a
- LoggingException will be thrown.</td>
- </tr>
- <tr>
- <td>mdcPrefix</td>
- <td>String</td>
- <td>A string that should be prepended to each MDC key in order to distinguish it from event attributes.
- The default string is "mdc:".</td>
- </tr>
- <tr>
- <td>name</td>
- <td>String</td>
- <td>The name of the Appender.</td>
- </tr>
- <tr>
- <td>reconnectionDelay</td>
- <td>integer</td>
- <td>The number of milliseconds the application should wait before trying again to connect to the
- agent.</td>
- </tr>
-
- <tr>
- <td>suppressExceptions</td>
- <td>boolean</td>
- <td>The default is true, causing exceptions to be internally logged and then ignored. When set to
- false exceptions will be percolated to the caller.</td>
- </tr>
- <caption align="top">FlumeAvroAppender Parameters</caption>
- </table>
- <p>
- A sample FlumeAvroAppender configuration that is configured with a primary and a secondary agent,
- compresses the body, and formats the body using the RFC5424Layout:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <Flume name="eventLogger" suppressExceptions="false" compress="true">
- <Agent host="192.168.10.101" port="8800"/>
- <Agent host="192.168.10.102" port="8800"/>
- <RFC5424Layout enterpriseNumber="18060" includeMDC="true" appName="MyApp"/>
- </Flume>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="eventLogger"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="JMSQueueAppender"/>
- <subsection name="JMSQueueAppender">
- <p>The JMSQueueAppender sends the formatted log event to a JMS Queue.</p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>factoryBindingName</td>
- <td>String</td>
- <td>The name to locate in the Context that provides the
- <a href="http://download.oracle.com/javaee/5/api/javax/jms/QueueConnectionFactory.html">QueueConnectionFactory</a>.</td>
- </tr>
- <tr>
- <td>factoryName</td>
- <td>String</td>
- <td>The fully qualified class name that should be used to define the Initial Context Factory as
- defined in <a href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#INITIAL_CONTEXT_FACTORY">INITIAL_CONTEXT_FACTORY</a>.
- If no value is provided the
- default InitialContextFactory will be used. If a factoryName is specified without a providerURL
- a warning message will be logged as this is likely to cause problems.</td>
- </tr>
- <tr>
- <td>filter</td>
- <td>Filter</td>
- <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
- may be used by using a CompositeFilter.</td>
- </tr>
- <tr>
- <td>layout</td>
- <td>Layout</td>
- <td>The Layout to use to format the LogEvent. If no layout is specified SerializedLayout will be used.</td>
- </tr>
- <tr>
- <td>name</td>
- <td>String</td>
- <td>The name of the Appender.</td>
- </tr>
- <tr>
- <td>password</td>
- <td>String</td>
- <td>The password to use to create the queue connection.</td>
- </tr>
- <tr>
- <td>providerURL</td>
- <td>String</td>
- <td>The URL of the provider to use as defined by
- <a href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#PROVIDER_URL">PROVIDER_URL</a>.
- If this value is null the default system provider will be used.</td>
- </tr>
- <tr>
- <td>queueBindingName</td>
- <td>String</td>
- <td>The name to use to locate the <a href="http://download.oracle.com/javaee/5/api/javax/jms/Queue.html">Queue</a>.</td>
- </tr>
- <tr>
- <td>securityPrincipalName</td>
- <td>String</td>
- <td>The name of the identity of the Principal as specified by
- <a href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#SECURITY_PRINCIPAL">SECURITY_PRINCIPAL</a>.
- If a securityPrincipalName is specified without securityCredentials a warning message will be
- logged as this is likely to cause problems.</td>
- </tr>
- <tr>
- <td>securityCredentials</td>
- <td>String</td>
- <td>The security credentials for the principal as specified by
- <a href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#SECURITY_CREDENTIALS">SECURITY_CREDENTIALS</a>.</td>
- </tr>
- <tr>
- <td>suppressExceptions</td>
- <td>boolean</td>
- <td>The default is true, causing exceptions to be internally logged and then ignored. When set to
- false exceptions will be percolated to the caller.</td>
- </tr>
- <tr>
- <td>urlPkgPrefixes</td>
- <td>String</td>
- <td>A colon-separated list of package prefixes for the class name of the factory class that will create
- a URL context factory as defined by
- <a href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#URL_PKG_PREFIXES">URL_PKG_PREFIXES</a>.</td>
- </tr>
- <tr>
- <td>userName</td>
- <td>String</td>
- <td>The user id used to create the queue connection.</td>
- </tr>
- <caption align="top">JMSQueueAppender Parameters</caption>
- </table>
- <p>
- Here is a sample JMSQueueAppender configuration:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <JMSQueue name="jmsQueue" queueBindingName="MyQueue" factoryBindingName="MyQueueConnectionFactory"/>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="jmsQueue"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="JMSTopicAppender"/>
- <subsection name="JMSTopicAppender">
- <p>The JMSTopicAppender sends the formatted log event to a JMS Topic.</p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>factoryBindingName</td>
- <td>String</td>
- <td>The name to locate in the Context that provides the
- <a href="http://download.oracle.com/javaee/5/api/javax/jms/TopicConnectionFactory.html">TopicConnectionFactory</a>.</td>
- </tr>
- <tr>
- <td>factoryName</td>
- <td>String</td>
- <td>The fully qualified class name that should be used to define the Initial Context Factory as
- defined in <a href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#INITIAL_CONTEXT_FACTORY">INITIAL_CONTEXT_FACTORY</a>.
- If no value is provided the
- default InitialContextFactory will be used. If a factoryName is specified without a providerURL
- a warning message will be logged as this is likely to cause problems.</td>
- </tr>
- <tr>
- <td>filter</td>
- <td>Filter</td>
- <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
- may be used by using a CompositeFilter.</td>
- </tr>
- <tr>
- <td>layout</td>
- <td>Layout</td>
- <td>The Layout to use to format the LogEvent. If no layout is specified SerializedLayout will be used.</td>
- </tr>
- <tr>
- <td>name</td>
- <td>String</td>
- <td>The name of the Appender.</td>
- </tr>
- <tr>
- <td>password</td>
- <td>String</td>
- <td>The password to use to create the queue connection.</td>
- </tr>
- <tr>
- <td>providerURL</td>
- <td>String</td>
- <td>The URL of the provider to use as defined by
- <a href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#PROVIDER_URL">PROVIDER_URL</a>.
- If this value is null the default system provider will be used.</td>
- </tr>
- <tr>
- <td>topicBindingName</td>
- <td>String</td>
- <td>The name to use to locate the
- <a href="http://download.oracle.com/javaee/5/api/javax/jms/Topic.html">Topic</a>.</td>
- </tr>
- <tr>
- <td>securityPrincipalName</td>
- <td>String</td>
- <td>The name of the identity of the Principal as specified by
- <a href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#SECURITY_PRINCIPAL">SECURITY_PRINCIPAL</a>.
- If a securityPrincipalName is specified without securityCredentials a warning message will be
- logged as this is likely to cause problems.</td>
- </tr>
- <tr>
- <td>securityCredentials</td>
- <td>String</td>
- <td>The security credentials for the principal as specified by
- <a href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#SECURITY_CREDENTIALS">SECURITY_CREDENTIALS</a>.</td>
- </tr>
- <tr>
- <td>suppressExceptions</td>
- <td>boolean</td>
- <td>The default is true, causing exceptions to be internally logged and then ignored. When set to
- false exceptions will be percolated to the caller.</td>
- </tr>
- <tr>
- <td>urlPkgPrefixes</td>
- <td>String</td>
- <td>A colon-separated list of package prefixes for the class name of the factory class that will create
- a URL context factory as defined by
- <a href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#URL_PKG_PREFIXES">URL_PKG_PREFIXES</a>.</td>
- </tr>
- <tr>
- <td>userName</td>
- <td>String</td>
- <td>The user id used to create the queue connection.</td>
- </tr>
- <caption align="top">JMSTopicAppender Parameters</caption>
- </table>
- <p>
- Here is a sample JMSTopicAppender configuration:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <JMSTopic name="jmsTopic" topicBindingName="MyTopic" factoryBindingName="MyTopicConnectionFactory"/>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="jmsQueue"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="OutputStreamAppender"/>
- <subsection name="OutputStreamAppender">
- The OutputStreamAppender provides the base for many of the other Appenders such as the File and Socket
- appenders that write the event to an Output Stream. It cannot be directly configured. Support for
- immediateFlush and buffering is provided by the OutputStreamAppender. The OutputStreamAppender uses an
- OutputStreamManager to handle the actual I/O, allowing the stream to be shared by Appenders in multiple
- configurations.
- </subsection>
- <a name="RewriteAppender"/>
- <subsection name="RewriteAppender">
- <p>
- The RewriteAppender allows the LogEvent to manipulated before it is processed by another Appender. This
- can be used to mask sensitive information such as passwords or to inject information into each event.
- The RewriteAppender must be configured with a <a href="RewritePolicy">RewritePolicy</a>.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>appender-ref</td>
- <td>String</td>
- <td>The name of the Appender to call after the LogEvent has been manipulated.</td>
- </tr>
- <tr>
- <td>filter</td>
- <td>Filter</td>
- <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
- may be used by using a CompositeFilter.</td>
- </tr>
- <tr>
- <td>name</td>
- <td>String</td>
- <td>The name of the Appender.</td>
- </tr>
- <tr>
- <td>rewritePolicy</td>
- <td>RewritePolciy</td>
- <td>The RewritePolicy that will manipulate the LogEvent.</td>
- </tr>
- <tr>
- <td>suppressExceptions</td>
- <td>boolean</td>
- <td>The default is true, causing exceptions to be internally logged and then ignored. When set to
- false exceptions will be percolated to the caller.</td>
- </tr>
- <caption align="top">RewriteAppender Parameters</caption>
- </table>
- <h4>RewritePolicy</h4>
- <p>
- RewritePolicy is an interface that allows implementations to inspect and possibly modify LogEvents
- before they are passed to Appender. RewritePolicy declares a single method named rewrite that must
- be implemented. The method is passed the LogEvent and can return the same event or create a new one.
- </p>
- <h5>MapRewritePolicy</h5>
- <p>
- MapRewritePolicy will evaluate LogEvents that contain a MapMessage and will add or update
- elements of the Map.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>mode</td>
- <td>String</td>
- <td>"Add" or "Update"</td>
- </tr>
- <tr>
- <td>keyValuePair</td>
- <td>KeyValuePair[]</td>
- <td>An array of keys and their values.</td>
- </tr>
- </table>
- <p>
- The following configuration shows a RewriteAppender configured to add a product key and its value
- to the MapMessage.:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <Console name="STDOUT" target="SYSTEM_OUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- <Rewrite name="rewrite">
- <appender-ref ref="STDOUT"/>
- <MapRewritePolicy mode="Add">
- <KeyValuePair key="product" value="TestProduct"/>
- </MapRewritePolicy>
- </Rewrite>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="Rewrite"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="RollingFileAppender"/>
- <subsection name="RollingFileAppender">
- <p>The RollingFileAppender is an OutputStreamAppender that writes to the File named in the fileName parameter
- and rolls the file over according the TriggeringPolicy and the RolloverPolicy. The
- RollingFileAppender uses a RollingFileManager (which extends OutputStreamManager) to actually perform the
- file I/O and perform the rollover. While RolloverFileAppenders from different Configurations cannot be
- shared, the RollingFileManagers can be if the Manager is accessible. For example, two webapps in a
- servlet container can have their own configuration and safely
- write to the same file if Log4J is in a ClassLoader that is common to both of them.</p>
- <p>
- A RollingFileAppender requires a <a href="#TriggeringPolicies">TriggeringPolicy</a> and a
- <a href="#RolloverStrategies">RolloverStrategy</a>. The triggering policy determines if a rollover should
- be performed while the RolloverStrategy defines how the rollover should be done. If no RolloverStrategy
- is configured, RollingFileAppender will use the <a href="DefaultRolloverStrategy">DefaultRolloverStrategy</a>.
- </p>
- <p>
- File locking is not supported by the RollingFileAppender.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>append</td>
- <td>boolean</td>
- <td>When true - the default, records will be appended to the end of the file. When set to false,
- the file will be cleared before new reocrds are written.</td>
- </tr>
- <tr>
- <td>bufferedIO</td>
- <td>boolean</td>
- <td>When true - the default, records will be written to a buffer and the data will be written to
- disk when the buffer is full or, if immediateFlush is set, when the record is written.
- File locking cannot be used with bufferedIO. Performance tests have shown that using buffered I/O
- significantly improves performance, even if immediateFlush is enabled.</td>
- </tr>
- <tr>
- <td>filter</td>
- <td>Filter</td>
- <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
- may be used by using a CompositeFilter.</td>
- </tr>
- <tr>
- <td>fileName</td>
- <td>String</td>
- <td>The name of the file to write to. If the file, or any of its parent directories, do not exist,
- they will be created.</td>
- </tr>
- <tr>
- <td>filePattern</td>
- <td>String</td>
- <td>The pattern of the file name of the archived log file. The format of the pattern should is
- dependent on the RolloverPolicy that is used. The DefaultRolloverPolicy will accept both
- a date/time pattern compatible with
- <a href="http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat</a>
- and and/or a %d which represents an integer counter. The pattern also supports interpolation at
- runtime so any of the Lookups (such as the <a href="./lookups.html#DateLookup">DateLookup</a> can
- be included in the pattern.</td>
- </tr>
- <tr>
- <td>immediateFlush</td>
- <td>boolean</td>
- <td>When set to true, each write will be followed by a flush. This will guarantee the data is written
- to disk but could impact performance.</td>
- </tr>
- <tr>
- <td>layout</td>
- <td>Layout</td>
- <td>The Layout to use to format the LogEvent</td>
- </tr>
-
- <tr>
- <td>name</td>
- <td>String</td>
- <td>The name of the Appender.</td>
- </tr>
- <tr>
- <td>policy</td>
- <td>TriggeringPolicy</td>
- <td>The policy to use to determine if a rollover should occur.</td>
- </tr>
- <tr>
- <td>strategy</td>
- <td>RolloverStrategy</td>
- <td>The strategy to use to determine the name and location of the archive file.</td>
- </tr>
- <tr>
- <td>suppressExceptions</td>
- <td>boolean</td>
- <td>The default is true, causing exceptions to be internally logged and then ignored. When set to
- false exceptions will be percolated to the caller.</td>
- </tr>
- <caption align="top">RollingFileAppender Parameters</caption>
- </table>
- <a name="TriggeringPolicies"/>
- <h4>Triggering Policies</h4>
- <h5>Composite Triggering Policy</h5>
- <p>
- The CompositeTriggeringPolicy combines multiple triggering policies and returns true if any
- of the configured policies return true. The CompositeTriggeringPolicy is configured simply
- by wrapping other policies in a "Policies" element.
- </p>
- <h5>OnStartup Triggering Policy</h5>
- <p>
- The OnStartup policy takes no parameters and causes a rollover if the log file is older than the
- current JVM's start time.
- </p>
- <h5>SizeBased Triggering Policy</h5>
- <p>
- Causes a rollover once the file has reached the specified size. The size can be specified in bytes,
- KB, MB or GB.
- </p>
- <h5>TimeBased Triggering Policy</h5>
- <p>
- Causes a rollover once the date/time pattern no longer applies to the active file. This policy
- takes no parameters.
- </p>
- <a name="RolloverStrategies"/>
- <h4>Rollover Strategies</h4>
- <a name="DefaultRolloverStrategy"/>
- <h5>Default Rollover Strategy</h5>
- <p>
- The default rollover strategy accepts both a date/time pattern and an integer. If the date/time pattern
- is present it will be replaced with the current date and time values. If the pattern contains an integer
- it will be incremented on each rollover. If the pattern contains both a date/time and integer
- in the pattern the integer will be incremented until the result of the date/time pattern changes. If
- the file pattern ends with ".gz" or ".zip" the resulting archive will be compressed using the
- compression scheme that matches the suffix. The pattern may also contain lookup references that
- can be resolved at runtime such as is shown in the example below.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>min</td>
- <td>integer</td>
- <td>The minimum value of the counter. The default value is 1.</td>
- </tr>
- <tr>
- <td>max</td>
- <td>integer</td>
- <td>The maximum value of the counter. Once this values is reached. Older archives will be
- deleted on subsequent rollovers.</td>
- </tr>
- <caption align="top">DefaultRolloverStrategy Parameters</caption>
- </table>
- <p>
- Below is a sample configuration that uses a RollingFileAppender with both the time and size based
- triggering policies, will create up to 7 archives on the same day (1-7) that are stored in a directory
- based on the current year and month, and will compress each
- archive using gzip:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <RollingFile name="RollingFile" fileName="logs/app.log"
- filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%d.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <Policies>
- <TimeBasedTriggeringPolicy />
- <SizeBasedTriggeringPolicy size="250 MB"/>
- </Policies>
- </RollingFile>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="RollingFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="RoutingAppender"/>
- <subsection name="RoutingAppender">
- <p>
- The RoutingAppender evaluates LogEvents and then routes them to a subordinate Appender. The target
- Appender may be an appender previously configured and may be referenced by its name or the
- Appender can be dynamically created as needed.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>filter</td>
- <td>Filter</td>
- <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
- may be used by using a CompositeFilter.</td>
- </tr>
- <tr>
- <td>name</td>
- <td>String</td>
- <td>The name of the Appender.</td>
- </tr>
- <tr>
- <td>rewritePolicy</td>
- <td>RewritePolciy</td>
- <td>The RewritePolicy that will manipulate the LogEvent.</td>
- </tr>
- <tr>
- <td>routes</td>
- <td>Routes</td>
- <td>Contains one or more Route declarations to identify the criteria for choosing Appenders.</td>
- </tr>
- <tr>
- <td>suppressExceptions</td>
- <td>boolean</td>
- <td>The default is true, causing exceptions to be internally logged and then ignored. When set to
- false exceptions will be percolated to the caller.</td>
- </tr>
- <caption align="top">RoutingAppender Parameters</caption>
- </table>
- <h4>Routes</h4>
- <p>
- The Routes element accepts a single, required attribute named "pattern". The pattern is evaluated
- against all the registered Lookups and the result is used to select a Route. Each Route may be
- configured with a key. If the key matches the result of evaluating the pattern then that Route
- will be selected. If no key is specified on a Route then that Route is the default. Only one Route
- can be configured as the default.
- </p>
- <p>
- Each Route must reference an Appender. If the Route contains an appender-ref attribute then the
- Route will reference an Appender that was defined in the configuration. If the Route contains an
- Appender definition then an Appender will be created within the context of the RoutingAppender and
- will be reused each time a matching Appender name is referenced through a Route.
- </p>
- <p>
- Below is a sample configuration that uses a RoutingFileAppender to route all Audit events to
- a FlumeAppender and all other events will be routed to a RollingFileAppender that captures only
- the specific event type. Note that the AuditAppender was predefined while the RoutingFileAppenders
- are created as needed.
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <Flume name="AuditLogger" suppressExceptions="false" compress="true">
- <Agent host="192.168.10.101" port="8800"/>
- <Agent host="192.168.10.102" port="8800"/>
- <RFC5424Layout enterpriseNumber="18060" includeMDC="true" appName="MyApp"/>
- </Flume>
- <Routing name="Routing">
- <Routes pattern="$${sd:type}">
- <Route>
- <RollingFile name="Rolling-${sd:type}" fileName="${sd:type}.log"
- filePattern="${sd:type}.%i.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <SizeBasedTriggeringPolicy size="500" />
- </RollingFile>
- </Route>
- <Route appender-ref="AuditLogger" key="Audit"/>
- </Routes>
- </Routing>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="Routing"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="SocketAppender"/>
- <subsection name="SocketAppender">
- <p>
- The SocketAppender is an OutputStreamAppender that writes its output to a remote destination
- specified by a host and port. The data can be sent over either TCP or UDP and can be sent in any format.
- The default format is to send a Serialized LogEvent. Log4j 2.0 contains a SocketServer which is capable
- of receiving serialized LogEvents and routing them through the logging system on the server.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>filter</td>
- <td>Filter</td>
- <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
- may be used by using a CompositeFilter.</td>
- </tr>
- <tr>
- <td>host</td>
- <td>String</td>
- <td>The name or address of the system that is listening for log events. This parameter is required.</td>
- </tr>
- <tr>
- <td>immediateFlush</td>
- <td>boolean</td>
- <td>When set to true, each write will be followed by a flush. This will guarantee the data is written
- to disk but could impact performance.</td>
- </tr>
- <tr>
- <td>layout</td>
- <td>Layout</td>
- <td>The Layout to use to format the LogEvent. The default is SerializedLayout.</td>
- </tr>
- <tr>
- <td>name</td>
- <td>String</td>
- <td>The name of the Appender.</td>
- </tr>
- <tr>
- <td>port</td>
- <td>integer</td>
- <td>The port on the host that is listening for log events. This parameter must be specified.</td>
- </tr>
- <tr>
- <td>protocol</td>
- <td>String</td>
- <td>"TCP" or "UDP". This parameter is required.</td>
- </tr>
- <tr>
- <td>reconnectionDelay</td>
- <td>integer</td>
- <td>If set to a value greater than 0, after an error the SocketManager will attempt to reconnect to
- the server after waiting the specified number of milliseconds. If the reconnect fails then
- an exception will be thrown (which can be caught by the application if suppressExceptions is
- set to false).</td>
- </tr>
- <tr>
- <td>suppressExceptions</td>
- <td>boolean</td>
- <td>The default is true, causing exceptions to be internally logged and then ignored. When set to
- false exceptions will be percolated to the caller.</td>
- </tr>
- <caption align="top">SocketAppender Parameters</caption>
- </table>
- </subsection>
- <a name="SyslogAppender"/>
- <subsection name="SyslogAppender">
- <p>
- The SyslogAppender is a SocketAppender that writes its output to a remote destination
- specified by a host and port in a format that conforms with either the BSD Syslog format or the RFC 5424
- format. The data can be sent over either TCP or UDP.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>appName</td>
- <td>String</td>
- <td>The value to use as the APP-NAME in the RFC 5424 syslog record.</td>
- </tr>
- <tr>
- <td>charset</td>
- <td>String</td>
- <td>The character set to use when converting the syslog String to a byte array. The String must be
- a valid <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Charset</a>.
- If not specified, the default system Charset will be used.</td>
- </tr>
- <tr>
- <td>enterpriseNumber</td>
- <td>integer</td>
- <td>The IANA enterprise number as described in
- <a href="http://tools.ietf.org/html/rfc5424#section-7.2.2">RFC 5424</a></td>
- </tr>
- <tr>
- <td>filter</td>
- <td>Filter</td>
- <td>A Filter to determine if the event should be handled by this Appender. More than one Filter
- may be used by using a CompositeFilter.</td>
- </tr>
- <tr>
- <td>facility</td>
- <td>String</td>
- <td>The facility is used to try to classify the message. The facility option must be set to one of
- "KERN", "USER", "MAIL", "DAEMON", "AUTH", "SYSLOG", "LPR", "NEWS", "UUCP", "CRON", "AUTHPRIV",
- "FTP", "NTP", "AUDIT", "ALERT", "CLOCK", "LOCAL0", "LOCAL1", "LOCAL2", "LOCAL3", "LOCAL4", "LOCAL5",
- "LOCAL6", or "LOCAL7". These values may be specified as upper or lower case characters.</td>
- </tr>
- <tr>
- <td>format</td>
- <td>String</td>
- <td>If set to "RFC5424" the data will be formatted in accordance with RFC 5424. Otherwise, it will
- be formatted as a BSD Syslog record. Note that although BSD Syslog records are required to be
- 1024 bytes or shorter the SyslogLayout does not truncate them. The RFC5424Layout also does not
- truncate records since the receiver must accept records of up to 2048 bytes and may accept records
- that are longer.</td>
- </tr>
- <tr>
- <td>host</td>
- <td>String</td>
- <td>The name or address of the system that is listening for log events. This parameter is required.</td>
- </tr>
- <tr>
- <td>id</td>
- <td>String</td>
- <td>The default structured data id to use when formatting according to RFC 5424. If the LogEvent contains
- a StructuredDataMessage the id from the Message will be used instead of this value.</td>
- </tr>
- <tr>
- <td>immediateFlush</td>
- <td>boolean</td>
- <td>When set to true, each write will be followed by a flush. This will guarantee the data is written
- to disk but could impact performance.</td>
- </tr>
- <tr>
- <td>includeMDC</td>
- <td>boolean</td>
- <td>Indicates whether data from the ThreadContextMap will be included in the RFC 5424 Syslog record.
- Defaults to true.</td>
- </tr>
- <tr>
- <td>mdcExcludes</td>
- <td>String</td>
- <td>A comma separated list of mdc keys that should be excluded from the LogEvent. This is mutually
- exclusive with the mdcIncludes attribute. This attribute only applies to RFC 5424 syslog records.</td>
- </tr>
- <tr>
- <td>mdcIncludes</td>
- <td>String</td>
- <td>A comma separated list of mdc keys that should be included in the FlumeEvent. Any keys in the MDC
- not found in the list will be excluded. This option is mutually exclusive with the mdcExcludes
- attribute. This attribute only applies to RFC 5424 syslog records.</td>
- </tr>
- <tr>
- <td>mdcRequired</td>
- <td>String</td>
- <td>A comma separated list of mdc keys that must be present in the MDC. If a key is not present a
- LoggingException will be thrown. This attribute only applies to RFC 5424 syslog records.</td>
- </tr>
- <tr>
- <td>mdcPrefix</td>
- <td>String</td>
- <td>A string that should be prepended to each MDC key in order to distinguish it from event attributes.
- The default string is "mdc:". This attribute only applies to RFC 5424 syslog records.</td>
- </tr>
- <tr>
- <td>messageId</td>
- <td>String</td>
- <td>The default value to be used in the MSGID field of RFC 5424 syslog records. </td>
- </tr>
- <tr>
- <td>name</td>
- <td>String</td>
- <td>The name of the Appender.</td>
- </tr>
- <tr>
- <td>newLine</td>
- <td>boolean</td>
- <td>If true, a newline will be appended to the end of the syslog record. The default is false.</td>
- </tr>
- <tr>
- <td>port</td>
- <td>integer</td>
- <td>The port on the host that is listening for log events. This parameter must be specified.</td>
- </tr>
-
- <tr>
- <td>protocol</td>
- <td>String</td>
- <td>"TCP" or "UDP". This parameter is required.</td>
- </tr>
- <tr>
- <td>reconnectionDelay</td>
- <td>integer</td>
- <td>If set to a value greater than 0, after an error the SocketManager will attempt to reconnect to
- the server after waiting the specified number of milliseconds. If the reconnect fails then
- an exception will be thrown (which can be caught by the application if suppressExceptions is
- set to false).</td>
- </tr>
- <tr>
- <td>suppressExceptions</td>
- <td>boolean</td>
- <td>The default is true, causing exceptions to be internally logged and then ignored. When set to
- false exceptions will be percolated to the caller.</td>
- </tr>
- <caption align="top">SyslogAppender Parameters</caption>
- </table>
- <p>
- A sample syslogAppender configuration that is configured with two SyslogAppenders, one using the BSD
- format and one using RFC 5424.
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <Syslog name="bsd" host="localhost" port="514" protocol="TCP"/>
- <Syslog name="RFC5424" format="RFC5424" host="localhost" port="8514" protocol="TCP" appName="MyApp" includeMDC="true"
- facility="LOCAL0" enterpriseNumber="18060" newLine="true" messageId="Audit" id="App"/>
- </appenders>
- <loggers>
- <logger name="com.mycorp" level="error">
- <appender-ref ref="RFC5424"/>
- </logger>
- <root level="error">
- <appender-ref ref="bsd"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/architecture.xml b/rgoers/src/site/xdoc/manual/architecture.xml
deleted file mode 100644
index 028fbb1..0000000
--- a/rgoers/src/site/xdoc/manual/architecture.xml
+++ /dev/null
@@ -1,674 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4j 2 Architecture</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Architecture">
- <subsection name="Main Components">
- <p>Log4j uses the classes shown in the diagram below.</p>
- <img src="../images/Log4jClasses.jpg" title="Log4j 2.0 Class Relationships"
- caption="Log4j 2 Class Relationships"/>
- <p>Applications using the Log4j 2 API will request a Logger with a specific name from the
- LogManager. The LogManager will locate the appropriate LoggerContext and then obtain the Logger from it.
- If the Logger must be created it will be associated with the LoggerConfig that contains either a) the
- same name as the Logger, b) the name of a parent package, or c) the root LoggerConfig. LoggerConfig
- objects are created from Logger declarations in the configuration. The LoggerConfig is associated with
- the Appenders that actually deliver the LogEvents.
- </p>
- <h4>Logger Hierarchy</h4>
- <p>The first and foremost advantage of any logging API over plain
- <code>System.out.println</code>
- resides in its ability to disable
- certain log statements while allowing others to print unhindered. This
- capability assumes that the logging space, that is, the space of all
- possible logging statements, is categorized according to some
- developer-chosen criteria.
- </p>
- <p>In Log4j 1.x the Logger Hierarchy was maintained through a relationship between Loggers.
- In Log4j 2 this relationship no longers exists. Instead, the hierarchy is maintained
- in the relationship between LoggerConfig objects.
- </p>
-
- <p>Loggers and LoggerConfigs are named entities. Logger names are case-sensitive and
- they follow the hierarchical naming rule:
- </p>
-
- <p>
- <table bgcolor="#EEEE99">
- <tr>
- <td>
- <dl>
- <dt>
- <b>Named Hierarchy</b>
- </dt>
-
- <dd>A LoggerConfig is said to be an
- <em>ancestor</em>
- of another
- LoggerConfig if its name followed by a dot is a prefix of the
- <em>descendant</em>
- logger name. A LoggerConfig is said to be a
- <em>parent</em>
- of a
- <em>child</em>
- LoggerConfig if there are no
- ancestors between itself and the descendant LoggerConfig.
- </dd>
- </dl>
- </td>
- </tr>
- </table>
- </p>
- <p>For example, the LoggerConfig named
- <code>"com.foo"</code>
- is a parent
- of the LoggerConfig named<code>"com.foo.Bar"</code>. Similarly,
- <code>"java"</code>
- is a parent of
- <code>"java.util"</code>
- and an
- ancestor of<code>"java.util.Vector"</code>. This naming scheme
- should be familiar to most developers.
- </p>
-
- <p>The root LoggerConfig resides at the top of the LoggerConfig hierarchy. It
- is exceptional in that it always exists and it is part of every hierarchy. A Logger
- that is directly linked to the root LoggerConfig can be obtained as follows:
- <source>Logger logger = LogManager.getLogger(LogManager.ROOT_LOGGER_NAME);</source>
- All other Loggers can be retrieved using the
- <a href="../log4j2-api/apidocs/org/apache/logging/log4j/LogManager.html#getLogger(java.lang.String)">
- LogManager.getLogger
- </a>
- static method and passing the name of the desired Logger. Further informaiton on the Logging
- API can be found at<a href="../log4j2-api/api.html">Log4j 2 API</a>.
- </p>
- <h4>LoggerContext</h4>
- <p>
- The
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/LoggerContext.html">LoggerContext</a>
- acts as the anchor point for the Logging system. However, it is possible to have multiple active
- LoggerContexts in an application depending on the circumstances.
- More details on the LoggerContext are at<a href="logsep.html">Log Separation</a>.
- </p>
- <h4>Configuration</h4>
- <p>Every LoggerContext has an active
- <a href="../log4j/log4j2-core/apidocs/org/apache/logging/log4j/core/config/Configuration.html">
- Configuration</a>.
- The Configuration contains all the Appenders,
- context-wide Filtes, LoggerConfigs and contains the reference to the StrSubstitutor. During
- reconfiguration two Configuration objects will exist. Once all Loggers have been redirected to
- the new Configuration, the old Configuration will be stopped and discarded.
- </p>
- <h4>Logger</h4>
- <p>As stated previously, Loggers are created by calling
- <a href="../log4j2-api/apidocs/org/apache/logging/log4j/LogManager.html#getLogger(java.lang.String)">LogManager.getLogger</a>.
- The Logger itself performs no direct actions. It simply has a name and is associated with a LoggerConfig.
- It extends
- <a href="file:///Users/rgoers/log4j/log4j2-api/apidocs/org/apache/logging/log4j/spi/AbstractLogger.html">
- AbstractLogger
- </a>
- and implements the required methods. As the configuration is modified Loggers may become associated
- with a different LoggerConfig, thus causing their behavior to be modified.
- </p>
- <table bgcolor="#EEEE99">
- <tr>
- <td>Retrieving Loggers</td>
- </tr>
- </table>
- <p>Calling the
- <code>getLogger</code>
- method with the same name will
- always return a reference to the exact same Logger object.
- </p>
-
- <p>For example, in
- <source>
- Logger x = Logger.getLogger("wombat");
- Logger y = Logger.getLogger("wombat");
- </source>
- <code>x</code> and <code>y</code> refer to <em>exactly</em> the same Logger object.
- </p>
-
- <p>Configuration of the log4j environment is typically done at
- application initialization. The preferred way is by reading a
- configuration file. This is discussed in <a href="configuration.html">Configuration</a>.
- </p>
-
- <p>Log4j makes it easy to name Loggers by <em>software component</em>. This can be accomplished
- by instantiating a Logger in each class, with the logger name equal to the fully
- qualified name of the class. This is a useful and straightforward
- method of defining loggers. As the log output bears the name of the
- generating Logger, this naming strategy makes it easy to identify
- 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.
- </p>
-
- <p>Nevertheless, naming loggers after the class where they are
- located seems to be the best strategy known so far.
- </p>
- <h4>LoggerConfig</h4>
- <p>
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/config/LoggerConfig.html">LoggerConfig</a>
- objects are created when Loggers are declared in the logging configuration.
- The LoggerConfig contains a set of Filters that must allow the LogEvent to pass before it will be
- passed to any Appenders. It contains references to the set of Appenders that should be used to
- process the event.
- </p>
- <table bgcolor="#EEEE99">
- <tr>
- <td>Log Levels</td>
- </tr>
- </table>
- <p>LoggerConfigs will be assigned a Log
- <a href="../log4j2-api/apidocs/org/apache/logging/log4j/Level.html">Level</a>. The set of possible
- levels includes (TRACE, DEBUG, INFO, WARN, ERROR and FATAL). Note that in Log4j 2, the Level is
- an Enum and cannot be sub-classed. Users who desire more granularity are encouraged to use
- <a href="../log4j2-api/api.html#Markers">Markers</a>
- instead.
- </p>
- <p>
- <a href="http://logging.apache.org/log4j/1.2/manual.html">Log4j 1.x</a>
- and
- <a href="http://logback.qos.ch/manual/architecture.html#effectiveLevel">Logback</a>
- both have the concept of "Level Inheritance". In Log4j 2, Loggers and LoggerConfigs are two different
- objects so this concept is implemented differently. Each Logger references the
- appropriate LoggerConfig which in turn can reference its parent, thus achieving the same effect.
- </p>
- <p>Below are five tables with various assigned level values and the resulting levels that
- will be associated with each Logger. Note that in all these cases if the root LoggerConfig
- is not configured a default Level will be assigned to it.
- </p>
-
- <table border="1" width="40%">
- <tr>
- <th>Logger Name</th>
- <th>Assigned LoggerConfig</th>
- <th>level</th>
- </tr>
- <tr align="left">
- <td>root</td>
- <td>root</td>
- <td>DEBUG</td>
- </tr>
- <tr align="left">
- <td>X</td>
- <td>root</td>
- <td>DEBUG</td>
- </tr>
- <tr align="left">
- <td>X.Y</td>
- <td>root</td>
- <td>DEBUG</td>
- </tr>
- <tr align="left">
- <td>X.Y.Z</td>
- <td>root</td>
- <td>DEBUG</td>
- </tr>
- <caption align="bottom">Example 1</caption>
- </table>
-
- <p>In example 1 above, only the root logger is configured and has a Log Level. All the other
- Loggers reference the root LoggerConfig and use its Level.
- </p>
-
- <table border="1" width="40%">
- <tr>
- <th>Logger Name</th>
- <th>Assigned LoggerConfig</th>
- <th>level</th>
- </tr>
- <tr align="left">
- <td>root</td>
- <td>root</td>
- <td>DEBUG</td>
- </tr>
- <tr align="left">
- <td>X</td>
- <td>X</td>
- <td>ERROR</td>
- </tr>
- <tr align="left">
- <td>X.Y</td>
- <td>X.Y</td>
- <td>INFO</td>
- </tr>
- <tr align="left">
- <td>X.Y.Z</td>
- <td>X.Y.Z</td>
- <td>WARN</td>
- </tr>
- <caption align="bottom">Example 2</caption>
- </table>
-
- <p>In example 2, all loggers have a configured LoggerConfig and obtain their Level
- from it.
- </p>
-
- <table border="1" width="40%">
- <tr>
- <th>Logger Name</th>
- <th>Assigned LoggerConfig</th>
- <th>level</th>
- </tr>
- <tr align="left">
- <td>root</td>
- <td>root</td>
- <td>DEBUG</td>
- </tr>
- <tr align="left">
- <td>X</td>
- <td>X</td>
- <td>ERROR</td>
- </tr>
- <tr align="left">
- <td>X.Y</td>
- <td>X</td>
- <td>ERROR</td>
- </tr>
- <tr align="left">
- <td>X.Y.Z</td>
- <td>X.Y.Z</td>
- <td>WARN</td>
- </tr>
- <caption align="bottom">Example 3</caption>
- </table>
-
- <p>In example 3, the loggers<code>root</code>,
- <code>X</code>
- and
- <code>X.Y.Z</code>
- each have a configured LoggerConfig with the same name. The Logger
- <code>X.Y</code>
- does not have a configured LoggerConfig with a matching name so uses
- the configuration of LoggerConfig
- <code>X</code>
- since that is the LoggerConfig whose
- name has the longest match to the start of the Logger's name.
- </p>
-
- <table border="1" width="40%">
- <tr>
- <th>Logger Name</th>
- <th>Assigned LoggerConfig</th>
- <th>level</th>
- </tr>
- <tr align="left">
- <td>root</td>
- <td>root</td>
- <td>DEBUG</td>
- </tr>
- <tr align="left">
- <td>X</td>
- <td>X</td>
- <td>ERROR</td>
- </tr>
- <tr align="left">
- <td>X.Y</td>
- <td>X</td>
- <td>ERROR</td>
- </tr>
- <tr align="left">
- <td>X.Y.Z</td>
- <td>X</td>
- <td>ERROR</td>
- </tr>
- <caption align="bottom">Example 4</caption>
- </table>
-
- <p>In example 4, the loggers
- <code>root</code>
- and
- <code>X</code>
- each have a Configured
- LoggerConfig with the same name. The loggers
- <code>X.Y</code>
- and
- <code>X.Y.Z</code>
- do not have configured LoggerConfigs and so get their Level from the LoggerConfig
- assigned to them,<code>X</code>, since it is the LoggerCofnig whose name has the
- longest match to the start of the Logger's name.
- </p>
-
- <table border="1" width="40%">
- <tr>
- <th>Logger Name</th>
- <th>Assigned LoggerConfig</th>
- <th>level</th>
- </tr>
- <tr align="left">
- <td>root</td>
- <td>root</td>
- <td>DEBUG</td>
- </tr>
- <tr align="left">
- <td>X</td>
- <td>X</td>
- <td>ERROR</td>
- </tr>
- <tr align="left">
- <td>X.Y</td>
- <td>X.Y</td>
- <td>INFO</td>
- </tr>
- <tr align="left">
- <td>X.YZ</td>
- <td>X</td>
- <td>ERROR</td>
- </tr>
- <caption align="bottom">Example 5</caption>
- </table>
-
- <p>In example 5, the loggers<code>root</code>.<code>X</code>, and
- <code>X.Y</code>
- each
- have a Configured LoggerConfig with the same name. The logger
- <code>X.YZ</code>
- does not have configured LoggerConfig and so gets its Level from the LoggerConfig
- assigned to it,<code>X</code>, since it is the LoggerCofnig whose name has the
- longest match to the start of the Logger's name. It is not associated with LoggerConfig
- <code>X.Y</code>
- since tokens after periods must match exactly.
- </p>
- <p>The table below provides illustrates how Level filtering works. Im the table, the vertical
- header shows the Level of the LogEvent, while the horizontal header shows the Level associated
- with the appopriate LoggerConfig. The intersection identifies whether the LogEvent would
- be allowed to pass for further processing (Yes) or discarded (No).
- </p>
- <table width="100%">
- <tr>
- <th style="background-color:cyan; color:black" rowspan="2">Event Level</th>
- <th style="background-color:cyan; color:black; border-top: 1px solid #DDDDDD;"
- align="center" colspan="6">LoggerConfig Level
- </th>
- </tr>
- <tr align="left">
- <th style="background-color:cyan; color:black">TRACE</th>
- <th style="background-color:cyan; color:black">DEBUG</th>
- <th style="background-color:cyan; color:black">INFO</th>
- <th style="background-color:cyan; color:black">WARN</th>
- <th style="background-color:cyan; color:black">ERROR</th>
- <th style="background-color:cyan; color:black">FATAL</th>
- </tr>
- <tr align="left">
- <th style="background-color:cyan; color:black">ALL</th>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- </tr>
- <tr align="left">
- <th style="background-color:cyan; color:black">TRACE</th>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- </tr>
- <tr align="left">
- <th style="background-color:cyan; color:black">DEBUG</th>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- </tr>
- <tr align="left">
- <th style="background-color:cyan; color:black">INFO</th>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- </tr>
- <tr align="left">
- <th style="background-color:cyan; color:black">WARN</th>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:red;font-weight:bold">NO</td>
- <td style="color:red;font-weight:bold">NO</td>
- </tr>
- <tr align="left">
- <th style="background-color:cyan; color:black">ERROR</th>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:red;font-weight:bold">NO</td>
- </tr>
- <tr align="left">
- <th style="background-color:cyan; color:black">FATAL</th>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- </tr>
- <tr align="left">
- <th style="background-color:cyan; color:black">OFF</th>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- <td style="color:green;font-weight:bold">YES</td>
- </tr>
- </table>
-
- <h4>Filter</h4>
- <p>In addition to the automatic log Level filtering that takes place as described in the previous
- section, Log4j provides
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/Filter.html">Filter</a>s that can
- be applied before control is passed to any LoggerConfig, after control is pased to a LoggerConfig
- but before calling any Appenders, and on each Appender. In a manner very similar to firewall filters,
- each Filter can return one of three results, Accept, Deny or Neutral. A response of Accept means
- that no other Filters should be called and the event should progress. A response of Deny means
- the event should be immediately ignored and control should be returned to the caller. A response
- of Neutral indicates the event should be passed to other Filters. If there are no other Fitlers the
- event will be processed.
- </p>
- <p>Although an event may be accepted by a Filter the event still might not be logged. This can happen
- when the event is accepted by the pre-LoggerConfig Filter but is then denied by a LoggerConfig
- filter or is denied by all Appenders.
- </p>
- <h4>Appender</h4>
- <p>The ability to selectively enable or disable logging requests based
- 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
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/Appender.html">Appender</a>.
- Currently, appenders exist for the console, files, remote socket servers, Apache Flume,
- JMS, and remote UNIX Syslog daemons. More than one Appender can be attached to a Logger.
- </p>
- <p>An Appender can be added to a Logger by calling the
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/config/Configuration.html#addLoggerAppender(org.apache.logging.log4j.core.Logger, org.apache.logging.log4j.core.Appender)">addLoggerAppender</a>
- method of the current Configuration. If a LoggerConfig matching the name of the Logger does
- not exist, one will be created, the Appender will be attached to it and then all Loggers
- will be notified to update their LoggerConfig references.
- </p>
- <p><b>Each enabled logging request for a given logger will be forwarded to all the appenders in
- that Logger's LoggerConfig as well as the Appenders of the LoggerConfig's parents.</b> In
- other words, Appenders are inherited additively from the LoggerConfig hierarchy. For example,
- if a console appender is added to the root logger, then all enabled logging requests will at
- least print on the console. If in addition a file appender is added to a LoggerConfig, say
- <em>C</em>, then enabled logging requests for <em>C</em> and <em>C</em>'s children will print
- in a file <em>and</em> on the console. It is possible to override this default behavior so that
- Appender accumulation is no longer additive by setting <code>additivity="false"</code> on the
- Logger declaration in the configuration file.
- </p>
- <p>The rules governing appender additivity are summarized below.</p>
-
- <p>
- <a name="additivity"/>
- <table bgcolor="#EEEE99">
- <tr>
- <td>
- <dl>
- <dt><b>Appender Additivity</b></dt>
-
- <dd>
- <p>The output of a log statement of Logger <i>L</i> will
- go to all the Appenders in the LoggerConfig associated with <i>L</i>
- and the ancestors of that LoggerConfig. This is the meaning of the term "appender additivity".
- </p>
-
- <p>However, if an ancestor of the LoggerConfig associated with Logger <i>L</i>, say <i>P</i>,
- has the additivity flag set to <code>false</code>, then <i>L</i>'s output will be
- directed to all the appenders in <i>L</i>'s LoggerConfig and it's ancestors up to
- and including <i>P</i> but not the Appenders in any of the ancestors of <i>P</i>.
- </p>
-
- <p>Loggers have their additivity flag set to <code>true</code> by default.</p>
- </dd>
- </dl>
- </td>
- </tr>
- </table>
- </p>
-
- <p>The table below shows an example:</p>
-
- <p>
- <table align="center" border="3" cellpadding="10">
- <tr rowspan="2">
- <th>Logger<br />Name </th>
- <th>Added<br/>Appenders</th>
- <th>Additivity<br/>Flag</th>
- <th>Output Targets</th>
- <th>Comment</th>
- </tr>
- <tr>
- <td>root</td>
- <td>A1</td>
- <td>not applicable</td>
- <td>A1</td>
- <td>The root logger has no parent so additivity does not apply to it.</td>
- </tr>
- <tr>
- <td>x</td>
- <td>A-x1, A-x2</td>
- <td>true </td>
- <td>A1, A-x1, A-x2</td>
- <td>Appenders of "x" and root.</td>
- </tr>
- <tr>
- <td>x.y</td>
- <td>none</td>
- <td>true </td>
- <td>A1, A-x1, A-x2</td>
- <td>Appenders of "x" and root. It would not be typical to configure a Logger with no Appenders.</td>
- </tr>
- <tr>
- <td>x.y.z</td>
- <td>A-xyz1</td>
- <td>true </td>
- <td>A1, A-x1, A-x2, A-xyz1</td>
- <td>Appenders in "x.y.z", "x" and root.</td>
- </tr>
- <tr>
- <td>security</td>
- <td>A-sec</td>
- <td><font color="blue">false</font></td>
- <td>A-sec</td>
- <td>No appender accumulation since the additivity flag is set to <code>false</code>.</td>
- </tr>
- <tr>
- <td>security.access</td>
- <td>none</td>
- <td>true</td>
- <td>A-sec</td>
- <td>Only appenders of "security" because the additivity flag in "security" is
- set to <code>false</code>.
- </td>
- </tr>
- </table>
- </p>
- <h4>Layout</h4>
- <p>More often than not, users wish to customize not only the output destination but also the output format.
- This is accomplished by associating a
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/Layout.html">Layout</a>
- with an Appender. The Layout is responsible for formatting the LogEvent according to the user's
- wishes, whereas an appender takes care of sending the formatted output to its destination.
- The <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/layout/PatternLayout.html">PatternLayout</a>,
- part of the standard log4j distribution, lets the user specify the output
- format according to conversion patterns similar to the C language <code>printf</code> function.
- </p>
-
- <p>For example, the PatternLayout with the conversion pattern "%r [%t]
- %-5p %c - %m%n" will output something akin to:<br />
- <source>
- 176 [main] INFO org.foo.Bar - Located nearest gas station.
- </source>
- </p>
-
- <p>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.
- </p>
-
- <p>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 <code>Oranges</code>, an object type used in
- your current project, then you can create an OrangeMessage that accepts an
- Orange instance and pass that to Log4J so that the Orange object can
- be formatted into an appropriate byte array when required.
- </p>
-
- <h4>StrSubstitutor and StrLookup</h4>
- <p>The
- <a href="../log4j/log4j2-core/apidocs/org/apache/logging/log4j/core/lookup/StrSubstitutor.html">
- StrSubstitutor
- </a>
- class and
- <a href="../log4j/log4j2-core/apidocs/org/apache/logging/log4j/core/lookup/StrLookup.html">StrLookup</a>
- interface were borrowed from Apache Commons Lang and then modified to support evaluating LogEvents. In
- addition the
- <a href="../log4j/log4j2-core/apidocs/org/apache/logging/log4j/core/lookup/Interpolator.html">Interpolator</a>
- class was borrowed from Apache Commons Configuration to allow the StrSubstitutor to evaluate variables
- that from multiple StrLookups. It too was modified to support evaluating LogEvents. Together these
- provide a mechanism to allow the configuration to reference variables coming from System Properties,
- the configuration file, the ThreadContext Map, StructuredData in the LogEvent. The variables can
- either be resolved when the configuration is processed or as each event is processed, if the component
- is capable of handling it. See
- <a href="lookups.html">Lookups</a>
- for more information.
- </p>
-
- </subsection>
-
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/configuration.xml b/rgoers/src/site/xdoc/manual/configuration.xml
deleted file mode 100644
index 97e007f..0000000
--- a/rgoers/src/site/xdoc/manual/configuration.xml
+++ /dev/null
@@ -1,894 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Configuring Log4j 2</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Configuration">
- <p>Inserting log requests into the application code requires a fair
- amount of planning and effort. Observation shows that approximately 4
- 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.
- </p>
- <p>
- Configuration of Log4j 2 can be accomplished in 1 of 4 ways:
- <ol>
- <li>Through a configuration file written in XML or JSON.</li>
- <li>Programmatically, by creating a ConfigurationFactory and Configuration implementation.</li>
- <li>Programmatically, by calling the APIs exposed in the Configuration interface to add
- components to the default configuration.</li>
- <li>Programmatically, by calling methods on the internal Logger class.</li>
- </ol>
- </p>
- <p>
- This page focuses primarily on configuring Log4j through a configuration file. Information on
- programmatically configuring Log4j can be found at <a href="./extending.html">Extending Log4j 2</a>.
- </p>
- <p>
- Note that unlike Log4j 1.x, the public Log4j 2 API does not expose methods to add, modify or remove
- appenders and filters or manipulate the configuration in any way.
- </p>
- <a name="AutomaticConfiguration"/>
- <subsection name="Automatic Configuration">
- <p>
- Log4j has the ability to automatically configure itself during initialization.
- When Log4j starts it will locate all the ConfigurationFactory plugins and arrange then in weighted
- order from highest to lowest. As delivered, Log4j contains two ConfigurationFactory implementations,
- one for JSON and one for XML.
- <ol>
- <li>Log4j will inspect the "log4j.configurationFile" system property and, if set, will attempt to
- load the configuration using the <code>ConfigurationFactory</code> that matches the file
- extension.</li>
- <li>If no system property is set the JSON ConfigurationFactory will look for log4j-test.json or
- log4j-test.jsn in the classpath.</li>
- <li>If no such file is found the XML ConfigurationFactory will look for log4j-test.xml in the
- classpath.</li>
- <li>If a test file cannot be located the JSON ConfigurationFactory will look for log4j.json or log4j.jsn
- on the classpath.</li>
- <li>If a JSON file cannot be located the XML ConfigurationFactory will try to locate
- log4j.xml on the classpath.</li>
- <li>If no configuration file could be located the <code>DefaultConfiguration</code> will
- be used. This will cause logging output to go to the console.</li>
- </ol>
- </p>
- <p>An example application named <code>MyApp</code> that uses log4j can be used to illustrate how
- this is done.
- </p>
- <p>
-<source> import com.foo.Bar;
-
- // Import log4j classes.
- import org.apache.logging.log4j.Logger;
-
- public class MyApp {
-
- // Define a static logger variable so that it references the
- // Logger instance named "MyApp".
- Logger logger = LogManager.getLogger(MyApp.class.getName());
-
- public static void main(String[] args) {
-
- // Set up a simple configuration that logs on the console.
-
- logger.trace("Entering application.");
- Bar bar = new Bar();
- if (!bar.doIt() {
- logger.error("Didn't do it.");
- }
- logger.trace("Exiting application." }
- }</source>
- </p>
- <p>
- <code>MyApp</code> begins by importing log4j related classes. It
- then defines a static logger variable with the name <code>MyApp</code>
- which happens to be the fully qualified name of the class.
- </p>
- <p>
- <code>MyApp</code> uses the <code>Bar</code> class defined in the package<code>com.foo</code>.
- </p>
- <p>
-<source> package com.foo;
- import org.apache.logging.log4j.Logger;
-
- public class Bar {
- static Logger logger = LogManager.getLogger(Bar.class.getName());
-
- public boolean doIt() {
- logger.entry();
- logger.error("Did it again!");
- logger.exit();
- return false;
- }
- }</source>
- </p>
- <p>
- If no configuration files are present logback will default to the DefaultConfiguration which
- will set up a minimal logging environment consisting of a
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/appender/ConsoleAppender.html">ConsoleAppender</a>
- attached to the root logger. The output will be formatted using a
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/layout/PatternLayout.html">PatternLayout</a>
- set to the pattern "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n".
- </p>
- <p>
- Note that by default, the root logger is assigned to <code>Level.ERROR</code>.
- </p>
- <p>The output of MyApp would be similar to:
- <pre>
- 17:13:01.540 [main] ERROR com.foo.Bar - Did it again!
- 17:13:01.540 [main] ERROR MyApp - Didn't do it.
- </pre>
- </p>
- <p>
- As was described previously, Log4j will first attempt to configure itself from configuration files. A
- configuration equivalent to the default would look like:
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="OFF">
- <appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </Console>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="Console"/>
- </root>
- </loggers>
-</configuration>]]></source>
- Once the file above is placed into the classpath as log4j.xml you will get results identical to
- those listed above. Changing the root level to trace will result in results similar to:
- <source>
- 17:13:01.540 [main] TRACE MyApp - Entering application.
- 17:13:01.540 [main] TRACE com.foo.Bar - entry
- 17:13:01.540 [main] ERROR com.foo.Bar - Did it again!
- 17:13:01.540 [main] TRACE com.foo.Bar - exit
- 17:13:01.540 [main] ERROR MyApp - Didn't do it.
- 17:13:01.540 [main] TRACE MyApp - Exiting application.</source>
- </p>
- <p>
- Note that status logging is disabled when the default configuration is used.
- </p>
- <p>
- Perhaps it is desired to eliminate all the TRACE output from everything except com.foo.BAR. Simply
- changing the log level would not accomplish the task. Instead, the solution is to
- add a new logger definition to the configuration:
- </p>
- <source><![CDATA[ <logger name="com.foo.Bar" level="TRACE"/>
- <root level="ERROR">
- <appender-ref ref="STDOUT">
- </root>]]></source>
- <p>
- With this configuration all log events from com.foo.Bar will be recorded while only error events will
- be recorded from all other components.
- </p>
- </subsection>
- <a name="Additivity"/>
- <subsection name="Additivity">
- <p>
- In the previous example all the events from com.foo.Bar were still written to the Console. This is
- because the logger for com.foo.Bar did not have any appenders configured while its parent did. In fact,
- the following configuration
- </p>
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="OFF">
- <appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </Console>
- </appenders>
- <loggers>
- <logger name="com.foo.Bar" level="trace">
- <appender-ref ref="Console"/>
- </logger>
- <root level="error">
- <appender-ref ref="Console"/>
- </root>
- </loggers>
-</configuration>]]></source>
- <p>would result in</p>
- <source>
- 17:13:01.540 [main] TRACE com.foo.Bar - entry
- 17:13:01.540 [main] TRACE com.foo.Bar - entry
- 17:13:01.540 [main] ERROR com.foo.Bar - Did it again!
- 17:13:01.540 [main] TRACE com.foo.Bar - exit
- 17:13:01.540 [main] TRACE com.foo.Bar - exit
- 17:13:01.540 [main] ERROR MyApp - Didn't do it.</source>
- <p>Notice that the trace messages from com.foo.Bar appear twice. This is because the appender associated
- with logger com.foo.Bar is first used, which writes the first instance to the Console. Next, the parent
- of com.foo.Bar, which in this case is the root logger, is referenced. The event is then passed to its
- appender, which is also writes to the Console, resulting in the second instance. This is known as
- additivity. While additivity can be quite a convenient feature (as in the first previous example where
- no appender reference needed to be configured), in many cases this behavior is considered undesirable
- and so it is possible to disable it by setting the additivity attribute on the logger to false:
- </p>
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="OFF">
- <appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </Console>
- </appenders>
- <loggers>
- <logger name="com.foo.Bar" level="trace" additivity="false">
- <appender-ref ref="Console"/>
- </logger>
- <root level="error">
- <appender-ref ref="Console"/>
- </root>
- </loggers>
-</configuration>]]></source>
- <p>
- Once an event reaches a logger with its additivity set to false the event will not be passed to
- any of its parent loggers, regardless of their additivity setting.
- </p>
- </subsection>
- <a name="AutomaticReconfiguration"/>
- <subsection name="Automatic Reconfiguration">
- <p>
- When configured from a File, Log4j has the ability to automatically detect changes to the configuration
- file and reconfigure itself. If the monitorInterval attribute is specified on the configuration element
- and is set to a non-zero value then the file will be checked the next time a log event is evaluated
- and/or logged and the monitorInterval has elapsed since the last check. The example below shows how
- to configure the attribute so that the configuration file will be checked for changes only after at
- least 30 seconds have elapsed. The minimum, and default, interval is 30 seconds.
- </p>
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration monitorInterval="30">
-...
-</configuration>]]></source>
- </subsection>
- <a name="ConfigurationSyntax"/>
- <subsection name="Configuration Syntax">
- <p>
- As the previous examples have shown as well as those to follow, Log4j allows you to easily
- redefine logging behavior without needing to modify your application. It is possible to
- disable logging for certain parts of the application, log only when specific criteria are met such
- as the action being performed for a specific user, route output to Flume or a log reporting system,
- etc. Being able to do this requires understanding the syntax of the configuration files.
- </p>
- <h4>Configuration with XML</h4>
- <p>
- The configuration element in the XML file accetps several attributes:
- <table>
- <tr>
- <th>Attribute Name</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>monitorInterval</td>
- <td>The minimum amount of time, in seconds, that must elapse before the file configuration
- is checked for changes.</td>
- </tr>
- <tr>
- <td>name</td>
- <td>The name of the configuration.</td>
- </tr>
- <tr>
- <td>packages</td>
- <td>A comma separated list of package names to search for plugins. Plugins are only loaded
- once per classloader so changing this value may not have any effect upon reconfiguration.</td>
- </tr>
- <tr>
- <td>schema</td>
- <td>Identifies the location for the classloader to located the XML Schema to use to validate
- the configuration. Only valid when strict is set to true. If not set no schema validation
- will take place.</td>
- </tr>
- <tr>
- <td>status</td>
- <td>The level of internal Log4j events that should be logged to the console.</td>
- </tr>
- <tr>
- <td>strict</td>
- <td>Enables the use of the strict XML format. Not supported in JSON configurations.</td>
- </tr>
- <tr>
- <td>verbose</td>
- <td>Enables diagnostic information while loading plugins.</td>
- </tr>
- </table>
- </p>
- <p>
- Log4j can be configured using two XML flavors; concise and strict. The concise format makes
- configuration very easy as the element names match the components they represent however it
- cannot be validated with an XML schema. For example, the ConsoleAppender is configured by
- declaring an XML element named Console under its parent appenders element. However, element
- and attribute names are are not case sensitive. In addition, attributes can either be specified
- as an XML attribute or as an XML element that has no attributes and has a text value. So
- </p>
- <source><![CDATA[<patternLayout pattern="%m%n"/>]]></source>
- <p>and</p>
- <source><![CDATA[<PatternLayout>
- <pattern>%m%n</pattern>
-</PatternLayout>]]></source>
- <p>
- are equivalent.
- </p>
- <p>
- The file below represents the structure of an XML configuration, but note
- that the elements in italics below represent the concise element names that would appear in their place.
- </p>
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>;
-<configuration>
- <properties>
- <property name="name1">value</property>
- <property name="name2" value="value2"/>
- </properties>
- <]]><i>filter</i> ... <![CDATA[/>
- <appenders>
- <]]><i>appender</i> ... <![CDATA[>
- <]]><i>filter</i> ... <![CDATA[/>
- </]]><i>appender</i><![CDATA[>
- ...
- </appenders>
- <loggers>
- <logger name="name1">
- <]]><i>filter</i> ... <![CDATA[/>
- </logger>
- ...
- <root level="level">
- <appender-ref ref="name"/>
- </root>
- </loggers>
-</configuration>]]></source>
- <p>
- See the many examples on this page for sample appender, filter and logger declarations.
- </p>
- <h5>Strict XML</h5>
- <p>
- In addition to the concise XML format above, Log4j allows configurations to be specified in a
- more "normal" XML manner that can be validated using an XML Schema. This is accomplished by
- replacing the friendly element names above with their object type as shown below. For example,
- instead of the ConsoleAppender being configuerd using an element named Console it is instead
- configured as an appender element with a type attribute containing "Console".
- </p>
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>;
-<configuration>
- <properties>
- <property name="name1">value</property>
- <property name="name2" value="value2"/>
- </properties>
- <filter type="type" ... />
- <appenders>
- <appender type="type" name="name">
- <filter type="type" ... />
- </appender>
- ...
- </appenders>
- <loggers>
- <logger name="name1">
- <filter type="type" ... />
- </logger>
- ...
- <root level="level">
- <appender-ref ref="name"/>
- </root>
- </loggers>
-</configuration>]]></source>
- <p>
- Below is a sample configuration using the strict format.
- </p>
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="debug" strict="true" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
- <properties>
- <property name="filename">target/test.log</property>
- </properties>
- <filter type="ThresholdFilter" level="trace"/>
-
- <appenders>
- <appender type="Console" name="STDOUT">
- <layout type="PatternLayout" pattern="%m MDC%X%n"/>
- <filters>
- <filter type="MarkerFilter" marker="FLOW" onMatch="DENY" onMismatch="NEUTRAL"/>
- <filter type="MarkerFilter" marker="EXCEPTION" onMatch="DENY" onMismatch="ACCEPT"/>
- </filters>
- </appender>
- <appender type="Console" name="FLOW">
- <layout type="PatternLayout" pattern="%C{1}.%M %m %ex%n"/>
- <filters>
- <filter type="MarkerFilter" marker="FLOW" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
- <filter type="MarkerFilter" marker="EXCEPTION" onMatch="ACCEPT" onMismatch="DENY"/>
- </filters>
- </appender>
- <appender type="File" name="File" fileName="${filename}">
- <layout type="PatternLayout">
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </layout>
- </appender>
- <appender type="List" name="List">
- </appender>
- </appenders>
-
- <loggers>
- <logger name="org.apache.logging.log4j.test1" level="debug" additivity="false">
- <filter type="ThreadContextMapFilter">
- <KeyValuePair key="test" value="123"/>
- </filter>
- <appender-ref ref="STDOUT"/>
- </logger>>
-
- <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
- <appender-ref ref="File"/>
- </logger>>
-
- <root level="trace">
- <appender-ref ref="List"/>
- </root>
- </loggers>
-
-</configuration>]]></source>
- <h4>Configuration with JSON</h4>
- <p>
- In addition to XML, Log4j can be configured using JSON. The JSON format is very similar to the
- concise XML format. Each key represents the name of a plugin and the key/value pairs associated
- with it are its attributes. Where a key contains more than a simple value it itself will be a
- subordinate plugin. In the example below, ThresholdFilter, Console, and PatternLayout are all
- plugins while the Console plugin will be assigned a value of STDOUT for its name attribute and the
- ThresholdFilter will be assigned a level of debug.
- </p>
- <source>{ "configuration": { "status": "error", "name": "RoutingTest", "packages": "org.apache.logging.log4j.test",
- "properties": {
- "property": { "name": "filename", "value" : "target/rolling1/rollingtest-$${sd:type}.log" }
- },
- "ThresholdFilter": { "level": "debug" },
- "appenders": {
- "Console": { "name": "STDOUT",
- "PatternLayout": { "pattern": "%m%n" }
- },
- "List": { "name": "List",
- "ThresholdFilter": { "level": "debug" }
- },
- "Routing": { "name": "Routing",
- "Routes": { "pattern": "$${sd:type}",
- "Route": [
- {
- "RollingFile": {
- "name": "Rolling-${sd:type}", "fileName": "${filename}",
- "filePattern": "target/rolling1/test1-${sd:type}.%i.log.gz",
- "PatternLayout": {"pattern": "%d %p %C{1.} [%t] %m%n"},
- "SizeBasedTriggeringPolicy": { "size": "500" }
- }
- },
- { "appender-ref": "STDOUT", "key": "Audit"},
- { "appender-ref": "List", "key": "Service"}
- ]
- }
- }
- },
- "loggers": {
- "logger": { "name": "EventLogger", "level": "info", "additivity": "false", "appender-ref": { "ref": "Routing" }},
- "root": { "level": "error", "appender-ref": { "ref": "STDOUT" }}
- }
- }
-}</source>
- <p>
- Note that in the RoutingAppender the Route element has been declared as an array. This is
- valid because each array element will be a Route component. This won't work for elements such as
- appenders and filters, where each element has a different name in the concise format. Appenders and
- filters can be defined as array elements if each appender or filter declares an attribute named "type"
- that contains the type of the appender. The following example illustrates this as well as how to
- declare multiple loggers as an array.
- </p>
- <source>{ "configuration": { "status": "debug", "name": "RoutingTest", "packages": "org.apache.logging.log4j.test",
- "properties": {
- "property": { "name": "filename", "value" : "target/rolling1/rollingtest-$${sd:type}.log" }
- },
- "ThresholdFilter": { "level": "debug" },
- "appenders": {
- "appender": [
- { "type": "Console", "name": "STDOUT", "PatternLayout": { "pattern": "%m%n" }},
- { "type": "List", "name": "List", "ThresholdFilter": { "level": "debug" }},
- { "type": "Routing", "name": "Routing",
- "Routes": { "pattern": "$${sd:type}",
- "Route": [
- {
- "RollingFile": {
- "name": "Rolling-${sd:type}", "fileName": "${filename}",
- "filePattern": "target/rolling1/test1-${sd:type}.%i.log.gz",
- "PatternLayout": {"pattern": "%d %p %C{1.} [%t] %m%n"},
- "SizeBasedTriggeringPolicy": { "size": "500" }
- }
- },
- { "appender-ref": "STDOUT", "key": "Audit"},
- { "appender-ref": "List", "key": "Service"}
- ]
- }
- }
- ]
- },
- "loggers": {
- "logger": [
- { "name": "EventLogger", "level": "info", "additivity": "false", "appender-ref": { "ref": "Routing" }},
- { "name": "com.foo.bar", "level": "error", "additivity": "false", "appender-ref": { "ref": "Console" }}
- ],
- "root": { "level": "error", "appender-ref": { "ref": "STDOUT" }}
- }
- }
-}</source>
- <h4>Configuring loggers</h4>
- <p>
- An understanding of how loggers work in Log4j is critical before trying to configure them.
- Please reference the Log4j <a href="./architecture.html">architecture</a> if more information is
- required. Trying to configure Log4j without understanding those concepts will lead to frustration.
- </p>
- <p>
- A LoggerConfig is configured using the <code>logger</code> element. The <code>logger</code> eleemnt
- must have a name attribute specified, will usually have a level attribute specified and may
- also have an additivity attribute specified. The level may be configured with one of TRACE,
- DEBUG, INFO, WARN, ERROR, ALL or OFF. If no level is specified it will default to ERROR. The
- additivity attribute may be assigned a value of true or false. If the attribute is omitted
- the default value of false will be used.
- </p>
- <p>
- The LoggerConfig may also be configured with one or more appender-ref elements. Each appender
- referenced will become associated with the specified LoggerConfig. If multiple appenders
- are configured on the LoggerConfig each of them be called when processing logging events.
- </p>
- <p>
- Every configuration must have a root logger. If one is not configured the default root LoggerConfig,
- which has a level of ERROR but with no appenders attached, will be used. The main differences
- between the root logger and other loggers are
- <ol>
- <li>The root logger does not have a name attribute.</li>
- <li>The root logger does not support the additivity attribute since it has no parent.</li>
- </ol>
- </p>
- <h4>Configuring Appenders</h4>
- <p>
- An appender is configured either using the specific appender plugin's name or with an appender
- element and the type attibute containing the appender plugin's name. In addition each appender
- must have a name attribute specified with a value that is unique within the set of appenders.
- The name will be used by loggers to reference the appender as described in the previous section.
- </p>
- <p>
- Most appenders also support a layout to be configured (which again may be specified either
- using the specific Layout plugin's name as the eleemnt or with "layout" as the element name
- along with a type attribute that contains the layout plugin's name. The various appenders
- will contain other attributes or elements that are required for them to function properly.
- </p>
- <h4>Configuring Filters</h4>
- <p>
- Log4j allows a filter to be specified in any of 3 places:
- <ol>
- <li>At the same level as the appenders, loggers and properties elements. These filters can accept
- or reject events before they have been passed to a LoggerConfig.</li>
- <li>In a logger element. These filters can accept or reject events for specific loggers.</li>
- <li>In an appender element. These filters can prevent or cause events to be processed by
- the appender.</li>
- </ol>
- </p>
- <p>
- Although only a single <code>filter</code> element can be configured, that element may be the
- <code>filters</code> element which represents the CompositeFilter. The <code>filters</code> element
- allows any number of <code>filter</code> elements to be configured within it. The following example
- shows how multiple filters can be configured on the ConsoleAppender.
- </p>
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="debug" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
- <properties>
- <property name="filename">target/test.log</property>
- </properties>
- <ThresholdFilter level="trace"/>
-
- <appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m MDC%X%n"/>
- <filters>
- <MarkerFilter marker="FLOW" onMatch="DENY" onMismatch="NEUTRAL"/>
- <MarkerFilter marker="EXCEPTION" onMatch="DENY" onMismatch="ACCEPT"/>
- </filters>
- </Console>
- <Console name="FLOW">
- <PatternLayout pattern="%C{1}.%M %m %ex%n"/>
- <filters>
- <MarkerFilter marker="FLOW" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
- <MarkerFilter marker="EXCEPTION" onMatch="ACCEPT" onMismatch="DENY"/>
- </filters>
- </Console>
- <File name="File" fileName="${filename}">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- </File>
- <List name="List">
- </List>
- </appenders>
-
- <loggers>
- <logger name="org.apache.logging.log4j.test1" level="debug" additivity="false">
- <ThreadContextMapFilter>
- <KeyValuePair key="test" value="123"/>
- </ThreadContextMapFilter>
- <appender-ref ref="STDOUT"/>
- </logger>>
-
- <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
- <appender-ref ref="File"/>
- </logger>>
-
- <root level="trace">
- <appender-ref ref="List"/>
- </root>
- </loggers>
-
-</configuration>]]></source>
- </subsection>
- <a name="PropertySubstitution"/>
- <subsection name="Property Substitution">
- <p>
- Log4j 2 supports the ability to specify tokens in the configuration as references to properties defined
- elsewhere. Some of these properties will be resolved when the configuration file is interpreted while
- others may be passed to components where they will be evaluated at runtime. To accomplish this, Log4j
- uses variations Apache Commons Lang's
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/lookup/StrSubstitutor">StrSubstitutor</a>
- and <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/lookup/StrLookup">StrLookup</a>
- classes. In a manner similar to Ant or Maven, this allows variables declared as <code>${name}</code>
- to be resolved using properties declared in the configuration itself. For example, the following example
- shows the filename for the rolling file appender being declared as a property.
- </p>
-<source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="debug" name="RoutingTest" packages="org.apache.logging.log4j.test">
- <properties>
- <property name="filename">target/rolling1/rollingtest-$${sd:type}.log</property>
- </properties>
- <ThresholdFilter level="debug"/>
-
- <appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- <List name="List">
- <ThresholdFilter level="debug"/>
- </List>
- <Routing name="Routing">
- <Routes pattern="$${sd:type}">
- <Route>
- <RollingFile name="Rolling-${sd:type}" fileName="${filename}"
- filePattern="target/rolling1/test1-${sd:type}.%i.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <SizeBasedTriggeringPolicy size="500" />
- </RollingFile>
- </Route>
- <Route appender-ref="STDOUT" key="Audit"/>
- <Route appender-ref="List" key="Service"/>
- </Routes>
- </Routing>
- </appenders>
-
- <loggers>
- <logger name="EventLogger" level="info" additivity="false">
- <appender-ref ref="Routing"/>
- </logger>
-
- <root level="error">
- <appender-ref ref="STDOUT"/>
- </root>
- </loggers>
-
-</configuration>]]></source>
- <p>
- While this is useful, there are many more places properties can originate from. To accommodate this,
- Log4j also supports the syntax <code>${prefix:name}</code> where the prefix identifies tells Log4j
- that variable name should be evaluated in a specific context. The contexts that are built in to Logj4
- are:
- <table>
- <tr>
- <th>Prefix</th>
- <th>Context</th>
- </tr>
- <tr>
- <td>ctx</td>
- <td>Thread Context Map (MDC)</td>
- </tr>
- <tr>
- <td>env</td>
- <td>System environment variables</td>
- </tr>
- <tr>
- <td>map</td>
- <td>A value from a MapMessage</td>
- </tr>
- <tr>
- <td>sd</td>
- <td>A value from a StructuredDataMessage. The key "id" will return the name of the StructuredDataId
- without the enterprise number. The key "type" will return the message type. Other keys will
- retrieve individual elements from the Map.</td>
- </tr>
- <tr>
- <td>sys</td>
- <td>System properties</td>
- </tr>
- </table>
- </p>
- <p>
- An interesting feature of StrLookup processing is that when a variable reference is declared with
- multiple leading '$' characters each time the variable is resolved the leading '$' is simply removed.
- In the previous example the "Routes" element is capable of resolving the variable at runtime. To allow
- this the prefix value is specified as a variable with two leading '$' characters. When the configuration
- file is first processed the first variable is simply removed. Thus, when the Routes element is evaluated
- at runtime it is the variable declaration "${sd:type}" which causes the event to be inspected for a
- StructuredDataMessage and if one is present the value of its type attribute to be used as the routing key.
- Not all elements support resolving variables at runtime. Components that do will specifically call that
- out in their documentation.
- </p>
- <p>
- If no value is found for the key in the Lookup associated with the prefix then the value associated with
- the key in the properties declaration in the configuration file will be used. If no value is found
- the variable declaration will be returned as the value. Default values may be declared in the configuration
- by doing:
- </p>
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>;
-<configuration>
- <properties>
- <property name="type">Audit</property>
- </properties>
- ...
-</configuration>]]></source>
- <p>
- <i>As a footnote, it is worth pointing out that the variables in the RollingFile appender declaration
- will also not be evaluated when the configuration is processed. This is simply because the resolution
- of the whole RollingFile element is deferred until a match occurs.
- See <a href="../appenders.html#RoutingAppender">RoutingAppender</a> for more information.</i>
- </p>
- </subsection>
- <a name="StatusMessages"/>
- <subsection name="Status Messages">
- <p>
- Just as it is desirable to be able to diagnose problems in applications, it is frequently necessary
- to be able to diagnose problems in the logging configuration or in the configured components. Since
- logging has not been configured, "normal" logging cannot be used during initialization. In addition,
- normal logging within appenders could create infinite recursion which Log4j will detect and cause
- the recursive events to be ignored. To accomodate this need, the Log4j 2 API includes a
- <a href="../log4j2-api/apidocs/org/apache/logging/log4j/status/StatusLogger.html">StatusLogger</a>.
- Components declare an instance of the StatusLogger similar to</p>
-<source>
- protected final static Logger logger = StatusLogger.getLogger();</source>
- <p>
- Since StatusLogger implements the Log4j 2 API's Logger interface, all the normal Logger methods may
- be used.
- </p>
- <p>
- When configuring Log4j it is sometimes necessary to view the generated status events. This can be
- accomplished by adding the status attribute to the configuration element. The following
- configuration has the status attribute set to debug.
-
-<source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>;
-<configuration status="debug" name="RoutingTest" packages="org.apache.logging.log4j.test">
- <properties>
- <property name="filename">target/rolling1/rollingtest-$${sd:type}.log</property>
- </properties>
- <ThresholdFilter level="debug"/>
-
- <appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- <List name="List">
- <ThresholdFilter level="debug"/>
- </List>
- <Routing name="Routing">
- <Routes pattern="$${sd:type}">
- <Route>
- <RollingFile name="Rolling-${sd:type}" fileName="${filename}"
- filePattern="target/rolling1/test1-${sd:type}.%i.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <SizeBasedTriggeringPolicy size="500" />
- </RollingFile>
- </Route>
- <Route appender-ref="STDOUT" key="Audit"/>
- <Route appender-ref="List" key="Service"/>
- </Routes>
- </Routing>
- </appenders>
-
- <loggers>
- <logger name="EventLogger" level="info" additivity="false">
- <appender-ref ref="Routing"/>
- </logger>
-
- <root level="error">
- <appender-ref ref="STDOUT"/>
- </root>
- </loggers>
-
-</configuration>]]></source>
- During startup this configuration produces:
-<source>
- 2011-11-23 17:08:00,769 DEBUG Generated plugins in 0.003374000 seconds
- 2011-11-23 17:08:00,789 DEBUG Calling createProperty on class org.apache.logging.log4j.core.config.Property for element property with params(name="filename", value="target/rolling1/rollingtest-${sd:type}.log")
- 2011-11-23 17:08:00,792 DEBUG Calling configureSubstitutor on class org.apache.logging.log4j.core.config.plugins.PropertiesPlugin for element properties with params(properties={filename=target/rolling1/rollingtest-${sd:type}.log})
- 2011-11-23 17:08:00,794 DEBUG Generated plugins in 0.001362000 seconds
- 2011-11-23 17:08:00,797 DEBUG Calling createFilter on class org.apache.logging.log4j.core.filter.ThresholdFilter for element ThresholdFilter with params(level="debug", onMatch="null", onMismatch="null")
- 2011-11-23 17:08:00,800 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%m%n", Configuration(RoutingTest), null, charset="null")
- 2011-11-23 17:08:00,802 DEBUG Generated plugins in 0.001349000 seconds
- 2011-11-23 17:08:00,804 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%m%n), null, target="null", name="STDOUT", suppressExceptions="null")
- 2011-11-23 17:08:00,804 DEBUG Calling createFilter on class org.apache.logging.log4j.core.filter.ThresholdFilter for element ThresholdFilter with params(level="debug", onMatch="null", onMismatch="null")
- 2011-11-23 17:08:00,806 DEBUG Calling createAppender on class org.apache.logging.log4j.test.appender.ListAppender for element List with params(name="List", entryPerNewLine="null", raw="null", null, ThresholdFilter(DEBUG))
- 2011-11-23 17:08:00,813 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.routing.Route for element Route with params(appender-ref="null", key="null", Node=Route)
- 2011-11-23 17:08:00,823 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.routing.Route for element Route with params(appender-ref="STDOUT", key="Audit", Node=Route)
- 2011-11-23 17:08:00,824 DEBUG Calling createRoute on class org.apache.logging.log4j.core.appender.routing.Route for element Route with params(appender-ref="List", key="Service", Node=Route)
- 2011-11-23 17:08:00,825 DEBUG Calling createRoutes on class org.apache.logging.log4j.core.appender.routing.Routes for element Routes with params(pattern="${sd:type}", routes={Route(type=dynamic default), Route(type=static Reference=STDOUT key='Audit'), Route(type=static Reference=List key='Service')})
- 2011-11-23 17:08:00,827 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.routing.RoutingAppender for element Routing with params(name="Routing", suppressExceptions="null", Routes({Route(type=dynamic default),Route(type=static Reference=STDOUT key='Audit'),Route(type=static Reference=List key='Service')}), Configuration(RoutingTest), null, null)
- 2011-11-23 17:08:00,827 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(appenders={STDOUT, List, Routing})
- 2011-11-23 17:08:00,828 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.plugins.AppenderRefPlugin for element appender-ref with params(ref="Routing")
- 2011-11-23 17:08:00,829 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="false", level="info", name="EventLogger", appender-ref={Routing}, null)
- 2011-11-23 17:08:00,830 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.plugins.AppenderRefPlugin for element appender-ref with params(ref="STDOUT")
- 2011-11-23 17:08:00,831 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="error", appender-ref={STDOUT}, null)
- 2011-11-23 17:08:00,833 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(loggers={EventLogger, root})
- 2011-11-23 17:08:00,834 DEBUG Reconfiguration completed
- 2011-11-23 17:08:00,846 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d %p %C{1.} [%t] %m%n", Configuration(RoutingTest), null, charset="null")
- 2011-11-23 17:08:00,849 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy for element SizeBasedTriggeringPolicy with params(size="500")
- 2011-11-23 17:08:00,851 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile with params(fileName="target/rolling1/rollingtest-Unknown.log", filePattern="target/rolling1/test1-Unknown.%i.log.gz", append="null", name="Rolling-Unknown", bufferedIO="null", immediateFlush="null", SizeBasedTriggeringPolicy(SizeBasedTriggeringPolicy(size=500)), null, PatternLayout(%d %p %C{1.} [%t] %m%n), null, suppressExceptions="null")
- 2011-11-23 17:08:00,858 DEBUG Generated plugins in 0.002014000 seconds
- 2011-11-23 17:08:00,889 DEBUG Reconfiguration started for context sun.misc.Launcher$AppClassLoader@37b90b39
- 2011-11-23 17:08:00,890 DEBUG Generated plugins in 0.001355000 seconds
- 2011-11-23 17:08:00,959 DEBUG Generated plugins in 0.001239000 seconds
- 2011-11-23 17:08:00,961 DEBUG Generated plugins in 0.001197000 seconds
- 2011-11-23 17:08:00,965 WARN No Loggers were configured, using default
- 2011-11-23 17:08:00,976 DEBUG Reconfiguration completed</source>
- </p>
- <p>
- If the status attribute is set to error than only error messages will be written to the console. This
- makes troubleshooting configuration errors possible. As an example, if the configuration above is changed
- to have the status set to error and the logger declaration is:</p>
-<source><![CDATA[ <logger name="EventLogger" level="info" additivity="false">
- <appender-ref ref="Routng"/>
- </logger>]]></source>
- <p>
- the following error message will be produced.
-<source>
- 2011-11-24 23:21:25,517 ERROR Unable to locate appender Routng for logger EventLogger</source>
- </p>
- <p>
- Applications may wish to direct the status output to some other destination. This can be accomplished
- by insuring the configured status is set to OFF and then configuring the application programmatically
- such as:
-<source>
- StatusConsoleListener listener = new StatusConsoleListener(Level.ERROR);
- ((StatusLogger) logger).registerListener(listener);
-</source>
- </p>
- </subsection>
- <a name="UnitTestingInMaven"/>
- <subsection name="Testing in Maven">
- <p>
- Maven can run unit and functional tests during the build cycle. By default, any files placed in
- <code>src/test/resources</code> are automatically copied to target/test-classes and are included
- in the classpath during execution of any tests. As such, placing a log4j-test.xml into this directory
- will cause it to be used instead of a log4j.xml or log4j.json that might be present. Thus a different
- log configuration can be used during testing than what is used in production.
- </p>
- <p>
- A second approach, which is extensively used by Log4j 2, is to set the log4j.configurationFile property
- in the method annotated with @BeforeClass in the junit test class. This will allow an arbitrarily
- named file to be used during the test.
- </p>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/eventlogging.xml b/rgoers/src/site/xdoc/manual/eventlogging.xml
deleted file mode 100644
index fb37656..0000000
--- a/rgoers/src/site/xdoc/manual/eventlogging.xml
+++ /dev/null
@@ -1,141 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4J 2.0 API</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Log4j 2.0 API">
- <a name="EventLogging"/>
- <subsection name="Event Logging">
- <p>
- The EventLogger class provides a simple mechansim for logging events that occur in an application.
- While the EventLogger is useful as a way of initiating events that should be processed by an audit
- Logging system, by itself it does not implement any of the features an audit logging system would require
- such as guaranteed delivery.
- </p>
- <p>The recommended way of using the EventLogger in a typcial web application is to populate
- the ThreadContext Map with data that is related to the entire lifespan of the request such as the user's
- id, the user's ip address, the product name, etc. This can easily be done in a servlet fileter where
- the ThreadContext Map can also be cleared at the end of the request. When an event that needs to be
- recorded occurs a StructuredDataMessage should be created and populated.
- Then call EventLogger.logEvent(msg) where msg is a reference to the StructuredDataMessage.</p>
-
- <source> import org.apache.logging.log4j.ThreadContext;
- import org.apache.commons.lang.time.DateUtils;
-
- import javax.servlet.Filter;
- import javax.servlet.FilterConfig;
- import javax.servlet.ServletException;
- import javax.servlet.ServletRequest;
- import javax.servlet.ServletResponse;
- import javax.servlet.FilterChain;
- import javax.servlet.http.HttpSession;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.Cookie;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.util.TimeZone;
-
- public class RequestFilter implements Filter {
- private FilterConfig filterConfig;
- private static String TZ_NAME = "timezoneOffset";
-
- public void init(FilterConfig filterConfig) throws ServletException {
- this.filterConfig = filterConfig;
- }
-
- /**
- * Sample filter that populates the MDC on every request.
- */
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
- throws IOException, ServletException {
- HttpServletRequest request = (HttpServletRequest)servletRequest;
- HttpServletResponse response = (HttpServletResponse)servletResponse;
- ThreadContext.put("ipAddress", request.getRemoteAddr());
- HttpSession session = request.getSession(false);
- TimeZone timeZone = null;
- if (session != null) {
- // Something should set this after authentication completes
- String loginId = (String)session.getAttribute("LoginId");
- if (loginId != null) {
- ThreadContext.put("loginId", loginId);
- }
- // This assumes there is some javascript on the user's page to create the cookie.
- if (session.getAttribute(TZ_NAME) == null) {
- if (request.getCookies() != null) {
- for (Cookie cookie : request.getCookies()) {
- if (TZ_NAME.equals(cookie.getName())) {
- int tzOffsetMinutes = Integer.parseInt(cookie.getValue());
- timeZone = TimeZone.getTimeZone("GMT");
- timeZone.setRawOffset((int)(tzOffsetMinutes * DateUtils.MILLIS_PER_MINUTE));
- request.getSession().setAttribute(TZ_NAME, tzOffsetMinutes);
- cookie.setMaxAge(0);
- response.addCookie(cookie);
- }
- }
- }
- }
- }
- ThreadContext.put("hostname", servletRequest.getServerName());
- ThreadContext.put("productName", filterConfig.getInitParameter("ProductName"));
- Threadcontext.put("locale", servletRequest.getLocale().getDisplayName());
- if (timeZone == null) {
- timeZone = TimeZone.getDefault();
- }
- ThreadContext.put("timezone", timeZone.getDisplayName());
- filterChain.doFilter(servletRequest, servletResponse);
- ThreadContext.clear();
- }
-
- public void destroy() {
- }
- }</source>
- <p>Sample class that uses EventLogger.</p>
- <source> import org.apache.logging.log4j.StructuredDataMessage;
- import org.apache.logging.log4j.EventLogger;
-
- import java.util.Date;
- import java.util.UUID;
-
- public class MyApp {
-
- public String doFundsTransfer(Account toAccount, Account fromAccount, long amount) {
- toAccount.deposit(amount);
- fromAccount.withdraw(amount);
- String confirm = UUID.randomUUID().toString();
- StructuredDataMessage msg = new StructureDataMessage(confirm, null, "transfer");
- msg.put("toAccount", toAccount);
- msg.put("fromAccount", fromAccount);
- msg.put("amount", amount);
- EventLogger.logEvent(data);
- return confirm;
- }
- }</source>
- <p>The EventLogger class uses a Logger named "EventLogger". EventLogger uses a logging level
- of OFF as the default to indicate that it cannot be filtered. These events can be
- formatted for printing using the
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/layout/StructuredDataLayout.html">StructuredDataLayout</a>.
- </p>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/extending.xml b/rgoers/src/site/xdoc/manual/extending.xml
deleted file mode 100644
index 70e0b67..0000000
--- a/rgoers/src/site/xdoc/manual/extending.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Extending Log4j 2</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Extending Log4j">
- <subsection name="LoggerContextFactory">
-
- </subsection>
- <subsection name="ContextSelector">
-
- </subsection>
- <subsection name="ConfigurationFactory">
-
- </subsection>
- <subsection name="LoggerConfig">
-
- </subsection>
- <subsection name="Lookups">
-
- </subsection>
- <subsection name="Filters">
-
- </subsection>
- <subsection name="Appenders">
-
- </subsection>
- <subsection name="Layouts">
-
- </subsection>
- <subsection name="PatternConverters">
-
- </subsection>
- <subsection name="Custom Plugins">
-
- </subsection>
- </section>
-
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/filters.xml b/rgoers/src/site/xdoc/manual/filters.xml
deleted file mode 100644
index e0cce93..0000000
--- a/rgoers/src/site/xdoc/manual/filters.xml
+++ /dev/null
@@ -1,658 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4J 2 Filters</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Filters">
- <p>
- Filters allow Log Events to be evaluated to determine if or how they should be published. A Filter
- will be called on one if its filter methods and will return a Result, which is an Enum that has
- one of 3 values - ACCEPT, DENY or NEUTRAL.
- </p>
- <p>
- Filters may be configured in one of three locations;
- <ol>
- <li>Context-wide Filters are configured directly in the configuration. Events that are
- rejected by these filters will not be passed to loggers for further processing. Once an
- event has been accepted by a Context-wide filter it will not be evaluated by any other
- Context-wide Filters nor will the Logger's Level be used to filter the event. The event
- will be evaluated by Logger and Appender Filters however.</li>
- <li>Logger Filters are configured on a specified Logger. These are evaluated after the
- Context-wide Filters and the Log Level for the Logger. Events that are rejected by these
- filters will be discarded and the event will not be passed to a parent Logger regardless
- of the additivity setting.</li>
- <li>Appender Filters are used to determine if a specific Appender should handle the
- formatting and publication of the event.</li>
- </ol>
- </p>
- <a name="BurstFilter"/>
- <subsection name="BurstFilter">
- <p>
- The BurstFilter provides a mechanism to control the rate at which LogEvents are processed by
- silently discarding events after the maximum limit has been reached.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>level</td>
- <td>String</td>
- <td>Level of messages to be filtered. Anything at or below this level will be
- filtered out if <code>maxBurst</code> has been exceeded. The default is
- WARN meaning any messages that are higher than warn will be logged
- regardless of the size of a burst.
- </td>
- </tr>
- <tr>
- <td>rate</td>
- <td>float</td>
- <td>The average number of events per second to allow.</td>
- </tr>
- <tr>
- <td>maxBurst</td>
- <td>integer</td>
- <td>The maximum number of events that can occur before events are filtered for exceeding the
- average rate. The default is 10 times the rate.</td>
- </tr>
- <tr>
- <td>omMatch</td>
- <td>String</td>
- <td>Action to take when the filter matches. May be ACCEPT, DENY or NEUTRAL. The default value is NEUTRAL.</td>
- </tr>
- <tr>
- <td>omMismatch</td>
- <td>String</td>
- <td>Action to take when the filter does not match. May be ACCEPT, DENY or NEUTRAL. The default value is
- DENY.</td>
- </tr>
- <caption align="top">Burst Filter Parameters</caption>
- </table>
- <p>
- A configuration containing the BurstFilter might look like:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
- <BurstFilter level="INFO" rate="16" maxBurst="100"/>
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="RollingFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="CompositeFilter"/>
- <subsection name="CompositeFilter">
- <p>
- The CompositeFilter provides a way to specify more than one filter. It is added to the
- configuration as a filters element and contains other filters to be evaluated. The filters
- element accepts no parameters.
- </p>
- <p>
- A configuration containing the CompositeFilter might look like:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <filters>
- <Marker marker="EVENT" onMatch="ACCEPT" onMismatch="NETURAL"/>
- <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR" onMatch="ACCEPT" onMismatch="NEUTRAL">
- <KeyValuePair key="User1" value="DEBUG"/>
- </DynamicThresholdFilter>
- </filters>
- <appenders>
- <File name="Audit" fileName="logs/audit.log">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- </File>
- <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
- <BurstFilter level="INFO" rate="16" maxBurst="100"/>
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- </appenders>
- <loggers>
- <logger name="EventLogger" level="info">
- <appender-ref ref="Audit"/>
- </logger>
- <root level="error">
- <appender-ref ref="RollingFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="DynamicThresholdFilter"/>
- <subsection name="DynamicThresholdFilter">
- <p>
- The DynamicThresholdFilter allows filtering by log level based on specific attributes. For example,
- if the user's loginid is being captured in the ThreadContext Map then it is possible to enable
- debug logging for only that user.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>defaultThreshold</td>
- <td>String</td>
- <td>Level of messages to be filtered. If there is no matching key in the key/value pairs
- then this level will be compared against the event's level.
- </td>
- </tr>
- <tr>
- <td>keyValuePair</td>
- <td>KeyValuePair[]</td>
- <td>One or more KeyValuePair elements that define the matching value for the key and the Level
- to evaluate when the key matches.</td>
- </tr>
- <tr>
- <td>omMatch</td>
- <td>String</td>
- <td>Action to take when the filter matches. May be ACCEPT, DENY or NEUTRAL. The default value is NEUTRAL.</td>
- </tr>
- <tr>
- <td>omMismatch</td>
- <td>String</td>
- <td>Action to take when the filter does not match. May be ACCEPT, DENY or NEUTRAL. The default value is
- DENY.</td>
- </tr>
- <caption align="top">Dynamic Threshold Filter Parameters</caption>
- </table>
- <p>
- Here is a sample configuration containing the DynamicThresholdFilter:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR" onMatch="ACCEPT" onMismatch="NEUTRAL">
- <KeyValuePair key="User1" value="DEBUG"/>
- </DynamicThresholdFilter>
- <appenders>
- <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
- <BurstFilter level="INFO" rate="16" maxBurst="100"/>
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="RollingFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="MapFilter"/>
- <subsection name="MapFilter">
- <p>
- The MapFilter allows filtering against data elements that are in a MapMessage.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>keyValuePair</td>
- <td>KeyValuePair[]</td>
- <td>One or more KeyValuePair elements that define the key in the map and the value to match on.</td>
- </tr>
- <tr>
- <td>operator</td>
- <td>String</td>
- <td>If the operator is "or" then a match by any one of the key/value pairs will be considered to be
- a match, otherwise all the key/value pairs must match.</td>
- </tr>
- <tr>
- <td>omMatch</td>
- <td>String</td>
- <td>Action to take when the filter matches. May be ACCEPT, DENY or NEUTRAL. The default value is NEUTRAL.</td>
- </tr>
- <tr>
- <td>omMismatch</td>
- <td>String</td>
- <td>Action to take when the filter does not match. May be ACCEPT, DENY or NEUTRAL. The default value is
- DENY.</td>
- </tr>
- <caption align="top">Map Filter Parameters</caption>
- </table>
- <p>
- As in this configuration, the MapFilter can be used to log particular events:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <MapFilter onMatch="ACCEPT" onMismatch="NEUTRAL" operator="or">
- <KeyValuePair key="eventId" value="Login"/>
- <KeyValuePari key="eventId" value="Logout"/>
- </MapFilter>
- <appenders>
- <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
- <BurstFilter level="INFO" rate="16" maxBurst="100"/>
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="RollingFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="MarkerFilter"/>
- <subsection name="MarkerFilter">
- <p>
- The MarkerFilter compares the configured Marker value against the Marker that is included
- in the LogEvent. A match occurs when the Marker name matches either the Log Event's Marker
- or one of its parents.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>marker</td>
- <td>String</td>
- <td>
- The name of the Marker to compare.
- </td>
- </tr>
- <tr>
- <td>omMatch</td>
- <td>String</td>
- <td>Action to take when the filter matches. May be ACCEPT, DENY or NEUTRAL. The default value is NEUTRAL.</td>
- </tr>
- <tr>
- <td>omMismatch</td>
- <td>String</td>
- <td>Action to take when the filter does not match. May be ACCEPT, DENY or NEUTRAL. The default value is
- DENY.</td>
- </tr>
- <caption align="top">Marker Filter Parameters</caption>
- </table>
- <p>
- A sample configuration that only allows the event to be written by the appender if the Marker matches:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
- <MarkerFilter marker="FLOW" onMatch="ACCEPT" onMismatch="DENY"/>
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="RollingFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="RegexFilter"/>
- <subsection name="RegexFilter">
- <p>
- The RegexFilter allows the formatted or unformatted message to be compared against a regular expression.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>regex</td>
- <td>String</td>
- <td>
- The regular expression.
- </td>
- </tr>
- <tr>
- <td>useRawMsg</td>
- <td>boolean</td>
- <td>If true the unformatted message will be used, otherwise the formatted message will be used. The
- default value is false.</td>
- </tr>
- <tr>
- <td>omMatch</td>
- <td>String</td>
- <td>Action to take when the filter matches. May be ACCEPT, DENY or NEUTRAL. The default value is NEUTRAL.</td>
- </tr>
- <tr>
- <td>omMismatch</td>
- <td>String</td>
- <td>Action to take when the filter does not match. May be ACCEPT, DENY or NEUTRAL. The default value is
- DENY.</td>
- </tr>
- <caption align="top">Regex Filter Parameters</caption>
- </table>
- <p>
- A sample configuration that only allows the event to be written by the appender if it contains the word "test":
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
- <RegexFilter regex=".* test .*" onMatch="ACCEPT" onMismatch="DENY"/>
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="RollingFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="StructuredDataFilter"/>
- <subsection name="StructuredDataFilter">
- <p>
- The StructuredDataFilter is a MapFilter that also allows filtering on the event id, type and message.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>keyValuePair</td>
- <td>KeyValuePair[]</td>
- <td>One or more KeyValuePair elements that define the key in the map and the value to match on. "id",
- "id.name", "type", and "message" should be used to match on the StructuredDataId, the name
- portion of the StructuredDataId, the type, and the formatted message respectively.
- </td>
- </tr>
- <tr>
- <td>operator</td>
- <td>String</td>
- <td>If the operator is "or" then a match by any one of the key/value pairs will be considered to be
- a match, otherwise all the key/value pairs must match.</td>
- </tr>
- <tr>
- <td>omMatch</td>
- <td>String</td>
- <td>Action to take when the filter matches. May be ACCEPT, DENY or NEUTRAL. The default value is NEUTRAL.</td>
- </tr>
- <tr>
- <td>omMismatch</td>
- <td>String</td>
- <td>Action to take when the filter does not match. May be ACCEPT, DENY or NEUTRAL. The default value is
- DENY.</td>
- </tr>
- <caption align="top">StructuredData Filter Parameters</caption>
- </table>
- <p>
- As in this configuration, the StructuredDataFilter can be used to log particular events:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <StructuredDataFilter onMatch="ACCEPT" onMismatch="NEUTRAL" operator="or">
- <KeyValuePair key="id" value="Login"/>
- <KeyValuePari key="id" value="Logout"/>
- </StructuredDataFilter>
- <appenders>
- <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
- <BurstFilter level="INFO" rate="16" maxBurst="100"/>
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="RollingFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="ThreadContextMapFilter"/>
- <subsection name="ThreadContextMapFilter">
- <p>
- The ThreadContextMapFilter allows filtering against data elements that are in the ThreadContext Map.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>keyValuePair</td>
- <td>KeyValuePair[]</td>
- <td>One or more KeyValuePair elements that define the key in the map and the value to match on.</td>
- </tr>
- <tr>
- <td>operator</td>
- <td>String</td>
- <td>If the operator is "or" then a match by any one of the key/value pairs will be considered to be
- a match, otherwise all the key/value pairs must match.</td>
- </tr>
- <tr>
- <td>omMatch</td>
- <td>String</td>
- <td>Action to take when the filter matches. May be ACCEPT, DENY or NEUTRAL. The default value is NEUTRAL.</td>
- </tr>
- <tr>
- <td>omMismatch</td>
- <td>String</td>
- <td>Action to take when the filter does not match. May be ACCEPT, DENY or NEUTRAL. The default value is
- DENY.</td>
- </tr>
- <caption align="top">ThreadContext Map Filter Parameters</caption>
- </table>
- <p>
- A configuration containing the ThreadContextMapFilter might look like:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <DynamicThresholdFilter key="loginId" defaultThreshold="ERROR" onMatch="ACCEPT" onMismatch="NEUTRAL">
- <KeyValuePair key="User1" value="DEBUG"/>
- </DynamicThresholdFilter>
- <appenders>
- <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
- <BurstFilter level="INFO" rate="16" maxBurst="100"/>
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="RollingFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="ThresholdFilter"/>
- <subsection name="ThresholdFilter">
- <p>
- This filter returns the onMatch result if the level in the LogEvent is the same or more specific
- than the configured level and the onMismatch value otherwise. For example, if the ThresholdFilter
- is configured with Level ERROR and the LogEvent contains Level DEBUG then the onMismatch value will
- be returned since ERROR events are more specific than DEBUG.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>level</td>
- <td>String</td>
- <td>
- A valid Level name to match on.
- </td>
- </tr>
- <tr>
- <td>omMatch</td>
- <td>String</td>
- <td>Action to take when the filter matches. May be ACCEPT, DENY or NEUTRAL. The default value is NEUTRAL.</td>
- </tr>
- <tr>
- <td>omMismatch</td>
- <td>String</td>
- <td>Action to take when the filter does not match. May be ACCEPT, DENY or NEUTRAL. The default value is
- DENY.</td>
- </tr>
- <caption align="top">Threshold Filter Parameters</caption>
- </table>
- <p>
- A sample configuration that only allows the event to be written by the appender if the level matches:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
- <ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="RollingFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- <a name="TimeFilter"/>
- <subsection name="TimeFilter">
- <p>
- The time filter can be used to restrict filter to only a certain portion of the day.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>start</td>
- <td>String</td>
- <td>
- A time in HH:mm:ss format.
- </td>
- </tr>
- <tr>
- <td>end</td>
- <td>String</td>
- <td>
- A time in HH:mm:ss format. Specifying an end time less than the start time will result in no
- log entries being written.
- </td>
- </tr>
- <tr>
- <td>timezone</td>
- <td>String</td>
- <td>
- The timezone to use when comparing to the event timestamp.
- </td>
- </tr>
- <tr>
- <td>omMatch</td>
- <td>String</td>
- <td>Action to take when the filter matches. May be ACCEPT, DENY or NEUTRAL. The default value is NEUTRAL.</td>
- </tr>
- <tr>
- <td>omMismatch</td>
- <td>String</td>
- <td>Action to take when the filter does not match. May be ACCEPT, DENY or NEUTRAL. The default value is
- DENY.</td>
- </tr>
- <caption align="top">Time Filter Parameters</caption>
- </table>
- <p>
- A sample configuration that only allows the event to be written by the appender from 5:00 to 5:30 am each
- day using the default timezone:
-
- <source><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<configuration status="warn" name="MyApp" packages="">
- <appenders>
- <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
- <TiemFilter start="05:00:00" end="05:30:00" onMatch="ACCEPT" onMismatch="DENY"/>
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <TimeBasedTriggeringPolicy />
- </RollingFile>
- </appenders>
- <loggers>
- <root level="error">
- <appender-ref ref="RollingFile"/>
- </root>
- </loggers>
-</configuration>
- ]]></source>
- </p>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/flowtracing.xml b/rgoers/src/site/xdoc/manual/flowtracing.xml
deleted file mode 100644
index 9222297..0000000
--- a/rgoers/src/site/xdoc/manual/flowtracing.xml
+++ /dev/null
@@ -1,242 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4J 2.0 API</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Log4j 2.0 API">
- <a name="FlowTracing"/>
- <subsection name="Flow Tracing">
- <p>
- The Logger class provides logging methods that are quite useful for following the
- execution path of applications. These methods generate logging events that can be filtered
- separately from other debug logging. Liberal use of these methods is encouraged as the output has
- been found to
- <ul>
- <li>aid in problem diagnosis in development without requiring a debug session</li>
- <li>aid in problem diagnosis in production where no debugging is possible</li>
- <li>help educate new deveopers in learning the application.</li>
- </ul>
- </p>
- <p>
- The two most used methods are the entry() and exit() methods. entry() should be placed at the
- beginning of methods, except perhaps ofr simple getters and setters. entry() can be called
- passing from 0 to 4 parameters. Typically these will be parameters passed to the method.
- The entry() method logs with a level of TRACE and uses a Marker with a name of "ENTER" which
- is also a "FLOW" Marker.
- </p>
- <p>
- The exit() method should be placed before any return statement or as the last statement of
- methods without a return. exit() can be called with or without a parameter. Typically, methods
- that return void will use exit() while methods that return an Object will use exit(Object obj).
- The entry() method logs with a level of TRACE and uses a Marker with a name of "EXIT" which is
- also a "FLOW" Marker.
- </p>
- <p>
- The throwing() method can be used by an application when it is throwing an exception that is
- unlikely to be handled, such as a RuntimeExcpetion. This will insure that proper diagnostics
- are available if needed. The logging event generated will have a level of ERROR and will have
- an associated Marker with a name of "THROWING" which is also an "EXCEPTION" Marker.
- </p>
- <p>
- The catching() method can be used by an application when it catches an Exception that it is not
- going to rethrow, either explicitely or attached to another Exception. The logging event generated
- will have a level of ERROR and will have an associated Marker with a name of "CATCHING" which is
- also an "EXCEPTION" Marker.
- </p>
- <p>
- The following example shows a simple application using these methods in a fairly typcial manner. The
- throwing() is not present since no Exceptions are explicitely thrown and not handled.
- </p>
- <source> package com.test;
-
- import org.apache.logging.log4j.Logger;
- import org.apache.logging.log4j.LogManager;
-
- import java.util.Random;
-
- public class TestService {
- private Logger logger = LogManager.getLogger(TestService.class.getName());
-
- private String[] messages = new String[] {
- "Hello, World",
- "Goodbye Cruel World",
- "You had me at hello"
- };
- private Random rand = new Random(1);
-
- public String retrieveMessage() {
- logger.entry();
-
- String testMsg = getMessage(getKey());
-
- return logger.exit(testMsg);
- }
-
- public void exampleException() {
- logger.entry();
- try {
- String msg = messages[messages.length];
- logger.error("An exception should have been thrown");
- } catch (Exception ex) {
- logger.catching(ex);
- }
- logger.exit();
- }
-
- public String getMessage(int key) {
- logger.entry(key);
-
- String value = messages[key];
-
- return logger.exit(value);
- }
-
- private int getKey() {
- logger.entry();
- int key = rand.nextInt(messages.length);
- return logger.exit(key);
- }
- }</source>
- <p>
- This test application uses the preceding service to generate logging events.
- </p>
- <source> package com.test;
-
- public class App {
-
- public static void main( String[] args ) {
- TestService service = new TestService();
- service.retrieveMessage();
- service.retrieveMessage();
- service.exampleException();
- }
- }</source>
- <p>
- The configuration below will cause all output to be routed to target/test.log. The pattern for
- the FileAppender includes the class name, line number and method name. Including these
- in the pattern are critical for the log to be of value.
- </p>
- <source><![CDATA[ <?xml version="1.0" encoding="UTF-8"?>
- <configuration status="error">
- <appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
- <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
- </Console>
- <File name="log" fileName="target/test.log" append="false">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
- </File>
- </appenders>
- <loggers>
- <root level="trace">
- <appender-ref ref="log"/>
- </root>
- </loggers>
- </configuration>]]></source>
- <p>
- Here is the output that results from the Java classes and configuration above.
- </p>
- <source>
- 19:08:07.056 TRACE com.test.TestService 19 retrieveMessage - entry
- 19:08:07.060 TRACE com.test.TestService 46 getKey - entry
- 19:08:07.060 TRACE com.test.TestService 48 getKey - exit with (0)
- 19:08:07.060 TRACE com.test.TestService 38 getMessage - entry parms(0)
- 19:08:07.060 TRACE com.test.TestService 42 getMessage - exit with (Hello, World)
- 19:08:07.060 TRACE com.test.TestService 23 retrieveMessage - exit with (Hello, World)
- 19:08:07.061 TRACE com.test.TestService 19 retrieveMessage - entry
- 19:08:07.061 TRACE com.test.TestService 46 getKey - entry
- 19:08:07.061 TRACE com.test.TestService 48 getKey - exit with (1)
- 19:08:07.061 TRACE com.test.TestService 38 getMessage - entry parms(1)
- 19:08:07.061 TRACE com.test.TestService 42 getMessage - exit with (Goodbye Cruel World)
- 19:08:07.061 TRACE com.test.TestService 23 retrieveMessage - exit with (Goodbye Cruel World)
- 19:08:07.062 TRACE com.test.TestService 27 exampleException - entry
- 19:08:07.077 DEBUG com.test.TestService 32 exampleException - catching java.lang.ArrayIndexOutOfBoundsException: 3
- at com.test.TestService.exampleException(TestService.java:29) [classes/:?]
- at com.test.App.main(App.java:9) [classes/:?]
- at com.test.AppTest.testApp(AppTest.java:15) [test-classes/:?]
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_29]
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_29]
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_29]
- at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_29]
- at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) [junit-4.3.1.jar:?]
- at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35) [surefire-junit4-2.7.2.jar:2.7.2]
- at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115) [surefire-junit4-2.7.2.jar:2.7.2]
- at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97) [surefire-junit4-2.7.2.jar:2.7.2]
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_29]
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_29]
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_29]
- at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_29]
- at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103) [surefire-booter-2.7.2.jar:2.7.2]
- at $Proxy0.invoke(Unknown Source) [?:?]
- at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150) [surefire-booter-2.7.2.jar:2.7.2]
- at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91) [surefire-booter-2.7.2.jar:2.7.2]
- at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69) [surefire-booter-2.7.2.jar:2.7.2]
- 19:08:07.087 TRACE com.test.TestService 34 exampleException - exit</source>
- <p>
- Simply changing the root logger level to DEBUG in the example above will reduce the output
- considerably.
- </p>
- <source>
- 19:13:24.963 DEBUG com.test.TestService 32 exampleException - catching java.lang.ArrayIndexOutOfBoundsException: 3
- at com.test.TestService.exampleException(TestService.java:29) [classes/:?]
- at com.test.App.main(App.java:9) [classes/:?]
- at com.test.AppTest.testApp(AppTest.java:15) [test-classes/:?]
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_29]
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_29]
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_29]
- at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_29]
- at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) [junit-4.3.1.jar:?]
- at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) [junit-4.3.1.jar:?]
- at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35) [surefire-junit4-2.7.2.jar:2.7.2]
- at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115) [surefire-junit4-2.7.2.jar:2.7.2]
- at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97) [surefire-junit4-2.7.2.jar:2.7.2]
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_29]
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_29]
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_29]
- at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_29]
- at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103) [surefire-booter-2.7.2.jar:2.7.2]
- at $Proxy0.invoke(Unknown Source) [?:?]
- at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150) [surefire-booter-2.7.2.jar:2.7.2]
- at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91) [surefire-booter-2.7.2.jar:2.7.2]
- at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69) [surefire-booter-2.7.2.jar:2.7.2]</source>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/index.xml b/rgoers/src/site/xdoc/manual/index.xml
deleted file mode 100644
index 22cde41..0000000
--- a/rgoers/src/site/xdoc/manual/index.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Overview</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Welcome to Log4J 2.0!">
- <subsection name="Introduction">
- <p>Almost every large application includes its own logging or tracing
- API. In conformance with this rule, the E.U. <a
- href="http://www.semper.org">SEMPER</a> project decided to write its
- 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 <a href="../LICENSE">Apache Software License</a>, a
- fully-fledged open source license certified by the <a
- href="http://www.opensource.org">open source</a> initiative. The
- latest log4j version, including full-source code, class files and
- documentation can be found at <a
- href="http://logging.apache.org/log4j/2.0/index.html"><b>http://logging.apache.org/log4j/2.0/index.html</b></a>.
- </p>
-
- <p>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.</p>
-
- <p>Experience indicates that logging was an important component of the
- development cycle. It offeres several advantages. It provides precise
- <em>context</em> about a run of the application. Once inserted into
- the code, the generation of logging output requires no human
- 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.</p>
-
- <p>As Brian W. Kernighan and Rob Pike put it in their truly excellent
- book <i>"The Practice of Programming"</i>
- <pre>
- As personal choice, we tend not to use debuggers beyond getting a
- stack trace or the value of a variable or two. One reason is that it
- is easy to get lost in details of complicated data structures and
- control flow; we find stepping through a program less productive
- than thinking harder and adding output statements and self-checking
- code at critical places. Clicking over statements takes longer than
- scanning the output of judiciously-placed displays. It takes less
- time to decide where to put print statements than to single-step to
- the critical section of code, even assuming we know where that
- is. More important, debugging statements stay with the program;
- debugging sessions are transient.
- </pre></p>
-
- <p>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,
- the log4j API strives to be simple to understand and to use.</p>
- </subsection>
- <subsection name="Log4j 2.0">
- Log4j 1.x has been widely adopted and used in many applications. However,
- through the years development on it has slowed down. It has become more
- difficult to maintain due to its need to be compliant with very old versions
- of Java. Its alternative, SLF4J/Logback made many needed improvements to the
- framework. So why bother with Log4j 2.0? Here are a few of the reasons.
- <ol>
- <li>Log4j 2.0 is designed to be usable as an audit logging framework. Both Log4j
- 1.x and Logback will lose events while reconfiguring. Log4j 2.0 will not. in
- Logback exceptions in Appenders are never visible to the application. In
- Log4j 2.0 Appenders can be configured to allow the exception to percolate
- to the application</li>
- <li>Log4j 2.0 uses a Plugin system that makes it extremely easy to extend the
- framework by adding new Appenders, Filters, Layouts, Lookups,
- and Pattern Converters without requiring any changes to Log4j.</li>
- <li>The performance of Log4j 2.0 is similar to that of Logback. It is slightly
- slower in some tests and faster in others.</li>
- <li>Due to the Plugin system configuration is simpler. Entries in the configuration
- do not require a class name to be specified.</li>
- <li>Support for Message objects. Messages allow support for interesting and
- complex constructs to be passed through the logging system and be efficiently
- manipulated. Users are free to create their own Message types and write custom
- Layouts, Filters and Lookups to manipulate them.</li>
- <li>Log4j 1.x supports Filters on Appenders. Logback added TurboFilters to allow
- filtering of events before they are processed by a Logger. Log4j 2.0 supports
- Filters that can be configured to process events before they are handled by
- a Logger, as they are processed by a Logger or on an Appender.</li>
- <li>Many Logback Appenders do not accept a Layout and will only send data in a
- fixed format. Most Log4j 2.0 Appenders accept a Layout, allowing the data to
- be transported in any format desired.</li>
- <li>Layouts in Log4j 1.x and Logback return a String. This resulted in the problems
- discussed at <a href="http://logback.qos.ch/manual/encoders.html">Logback Encoders</a>.
- Log4j 2.0 takes the simpler approach that Layouts always return a byte array. This has
- the advantage that it means they can be used in virtually any Appender, not just
- the ones that write to an OutputStream.</li>
- <li>The Syslog Appender supports both TCP and UDP as well as support for the BSD syslog
- and the <a href="http://tools.ietf.org/html/rfc5424">RFC 5424</a> formats.</li>
- <li>Log4j 2.0 takes advantage of Java 5 concurrency support and performs locking
- at the lowest level possible. Log4j 1.x has known deadlock issues. Many of these
- are fixed in Logback but many Logback classes still require synchronization at
- a fairly high level.</li>
- <li>It is an Apache Software Foundation project following the community and support
- model used by all ASF projects. If you want to contribute or gain the right to
- commit changes just follow the path outlined at
- <a href="http://jakarta.apache.org/site/contributing.html">Contributing</a></li>
- </ol>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/jmx.xml b/rgoers/src/site/xdoc/manual/jmx.xml
deleted file mode 100644
index f340e6c..0000000
--- a/rgoers/src/site/xdoc/manual/jmx.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>JMX</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="JMX">
- <p>
- JMX support is incomplete at this time. Patches are welcome!
- </p>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/layouts.xml b/rgoers/src/site/xdoc/manual/layouts.xml
deleted file mode 100644
index adc11a4..0000000
--- a/rgoers/src/site/xdoc/manual/layouts.xml
+++ /dev/null
@@ -1,769 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4j 2 Layouts</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Layouts">
- <p>
- Layouts are used by Appenders to format the LogEvent into a form that meets the needs of whoever will be
- consuming the log events. In Log4j 1.x and Logback Layouts were expected to transform an event into a
- String. In Log4j 2.0 Layouts return a byte array. This allows the result of the Layout to be useful in
- many more types of Appenders. However, this means most Layouts need to be configured with a
- <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Charset</a> to
- insure the byte array contains correct values.
- </p>
- <a name="HTMLLayout"/>
- <subsection name="HTMLLayout">
- <p>
- The HTMLLayout generates an HTML page and adds each LogEvent to a row in a table.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>charset</td>
- <td>String</td>
- <td>The character set to use when converting the HTML String to a byte array. The value must be
- a valid <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Charset</a>.
- If not specified, the default system Charset will be used.</td>
- </tr>
- <tr>
- <td>contentType</td>
- <td>String</td>
- <td>The value to assign to the Content-Type header. The default is "text/html".</td>
- </tr>
- <tr>
- <td>locationInfo</td>
- <td>boolean</td>
- <td>If true, the filename and line number will be included in the HTML output. The default value is
- false.</td>
- </tr>
- <tr>
- <td>title</td>
- <td>String</td>
- <td>A String that will appear as the HTML title.</td>
- </tr>
- <caption align="top">HTML Layout Parameters</caption>
- </table>
- </subsection>
- <a name="PatternLayout"/>
- <subsection name="PatternLayout">
- <p>
- A flexible layout configurable with pattern string. The goal of this class is to format a LogEvent and
- return the results. The format of the result depends on the <em>conversion pattern</em>.
- </p>
- <p>
- The conversion pattern is closely related to the conversion pattern of the printf function in C.
- A conversion pattern is composed of literal text and format control expressions called
- <em>conversion specifiers</em>.
- </p>
- <p>
- <i>Note that any literal text may be included in the conversion pattern.</i>
- </p>
- <p>
- Each conversion specifier starts with a percent sign (%) and is followed by optional <em>format
- modifiers</em> and a <em>conversion character</em>. The conversion character specifies the type of
- data, e.g. category, priority, date, thread name. The format modifiers control such things as field width,
- padding, left and right justification. The following is a simple example.
- </p>
- <p>
- Let the conversion pattern be <b>"%-5p [%t]: %m%n"</b> and assume that the log4j environment was set to
- use a PatternLayout. Then the statements
- <pre>
- Logger logger = LogManager.getLogger("MyLogger");
- logger.debug("Message 1");
- logger.warn("Message 2");
- </pre>
- would yield the output
- <pre>
- DEBUG [main]: Message 1
- WARN [main]: Message 2
- </pre>
- </p>
- <p>
- Note that there is no explicit separator between text and conversion specifiers. The pattern parser
- knows when it has reached the end of a conversion specifier when it reads a conversion character.
- In the example above the conversion specifier <b>%-5p</b> means the priority of the logging event should
- be left justified to a width of five characters.
- </p>
-
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>charset</td>
- <td>String</td>
- <td>The character set to use when converting the syslog String to a byte array. The String must be
- a valid<a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Charset</a>.
- If not specified, the default system Charset will be used.
- </td>
- </tr>
- <tr>
- <td>pattern</td>
- <td>String</td>
- <td></td>
- </tr>
- <tr>
- <td>replace</td>
- <td>RegexReplacement</td>
- <td>Allows portions of the resulting String to be replaced. If configured, the replace element must
- specify the regular expression to match and the substitution. This performs a function similar to
- the RegexReplacement converter but applies to the whole message while the converter only
- applies to the String its pattern generates.
- </td>
- </tr>
- <caption align="top">Pattern Layout Parameters</caption>
- </table>
- <h4>Patterns</h4>
- <p>
- The conversions that are provided with Log4j are:
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Conversion Pattern</th>
- <th>Description</th>
- </tr>
- <tr>
- <td align="center">
- <b>c</b>{precision}<br />
- <b>logger</b>{precision}
- </td>
- <td>
- <p>
- Used to output the name of the logger that published the logging event. The logger conversion
- specifier can be optionally followed by<em>precision specifier</em>, which consists of a
- decimal integer, or a pattern starting with a decimal integer.
- </p>
- <p>If a precision specifier is given and it is an integer value, then only the corresponding number
- of right most components of the logger name will be printed. If the precision contains
- other non-integer characters then the name will be abbreviated based on the pattern. If the
- precision integer is less than one the right-most token will still be printed in full.
- By default the logger name is printed in full.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Conversion Pattern</th>
- <th>Logger Name</th>
- <th>Result</th>
- </tr>
- <tr>
- <td>%c{1}</td>
- <td>org.apache.commons.Foo</td>
- <td>Foo</td>
- </tr>
- <tr>
- <td>%c{2}</td>
- <td>org.apache.commons.Foo</td>
- <td>commons.Foo</td>
- </tr>
- <tr>
- <td>%c{1.}</td>
- <td>org.apache.commons.Foo</td>
- <td>o.a.c.Foo</td>
- </tr>
- <tr>
- <td>%c{1.1.~.~}</td>
- <td>org.apache.commons.test.Foo</td>
- <td>o.a.~.~.Foo</td>
- </tr>
- <tr>
- <td>%c{.}</td>
- <td>org.apache.commons.test.Foo</td>
- <td>....Foo</td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>C</b>{precision}<br />
- <b>class</b>{precision}
- </td>
- <td>
- <p>
- Used to output the fully qualified class name of the caller issuing the logging request.
- This conversion specifier can be optionally followed by<em>precision specifier</em>, that
- follows the same rules as the logger name converter.
- </p>
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>d</b>{pattern}<br />
- <b>date</b>{pattern}
- </td>
- <td>
- <p>
- Used to output the date of the logging event. The date conversion specifier may be
- followed by a set of braces containing a date and time pattern strings
- <a href="http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html">
- SimpleDateFormat</a>,
- <em>ABSOLUTE</em>,
- <em>DATE</em>
- or
- <em>ISO8601</em>
- and a set of braces containing a time zone id per
- <a href="http://docs.oracle.com/javase/6/docs/api/java/util/TimeZone.html#getTimeZone(java.lang.String)">
- java.util.TimeZone.getTimeZone</a>.
- For example,<b>%d{HH:mm:ss,SSS}</b>,<b>%d{dd MMM yyyy HH:mm:ss,SSS}</b>,
- <b>%d{DATE}</b>
- or<b>%d{HH:mm:ss}{GMT+0}</b>. If no date format specifier is given then
- ISO8601 format is assumed.
- </p>
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>ex</b>{depth}<br />
- <b>exception</b>{depth}<br />
- <b>throwable</b>{depth}
- </td>
- <td>
- <p>Used to output the Throwable trace that has been bound to the LoggingEvent, by
- default this will output the full trace as one would normally find by a call to
- Throwable.printStackTrace().
- The throwable conversion word can be followed by an option in the form
- <b>%throwable{short}</b>
- which will only output the first line of the Throwable or <b>%throwable{n}</b> where
- the first n lines of the stacktrace will be printed.
- </p>
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>F</b><br />
- <b>file</b>
- </td>
- <td>
- Used to output the file name where the logging request was issued.
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>K</b>{key}<br />
- <b>map</b>{key}<br />
- <b>MAP</b>{key}
- </td>
- <td>
- <p>Used to output the entries in a <a href="../log4j2-api/apidocs/index.html">MapMessage</a>,
- if one is present in the event. The <b>K</b> conversion character can be followed by the key
- for the map placed between braces, as in
- <b>%K{clientNumber}</b> where <code>clientNumber</code> is the key. The value in the Map
- corresponding to the key will be output. If no additional sub-option
- is specified, then the entire contents of the Map key value pair set
- is output using a format {{key1,val1},{key2,val2}}
- </p>
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>l</b><br />
- <b>location</b>
- </td>
- <td>
- <p>
- Used to output location information of the caller which generated the logging event.
- </p>
- <p>
- The location information depends on the JVM implementation but usually consists of the fully
- qualified name of the calling method followed by the callers source the file name and line
- number between parentheses.
- </p>
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>L</b><br />
- <b>line</b>
- </td>
- <td>Used to output the line number from where the logging request
- was issued.
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>m</b><br />
- <b>msg</b><br />
- <b>message</b>
- </td>
- <td>Used to output the application supplied message associated with the logging event.
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>M</b><br />
- <b>method</b>
- </td>
- <td>Used to output the method name where the logging request was issued.
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>marker</b>
- </td>
- <td>The name of the marker, if one is present.</td>
- </tr>
- <tr>
- <td align="center">
- <b>n</b>
- </td>
- <td>
- <p>
- Outputs the platform dependent line separator character or characters.
- </p>
- <p>This conversion character offers practically the same
- performance as using non-portable line separator strings such as
- "\n", or "\r\n". Thus, it is the preferred way of specifying a
- line separator.
- </p>
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>p</b><br />
- <b>level</b>
- </td>
- <td>Used to output the level of the logging event.</td>
- </tr>
- <tr>
- <td align="center">
- <b>r</b><br />
- <b>relative</b>
- </td>
- <td>Used to output the number of milliseconds elapsed since the JVM was started until the creation
- of the logging event.
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>replace</b>{pattern}{regex}{substitution}
- </td>
- <td>
- <p>
- Replaces occurrences of 'regex', a regular expression, with its replacement 'substitution' in the
- string resulting from evaluation of the pattern. For example, "%replace(%msg}{\s}{}" will remove
- all spaces contained in the event message.
- </p>
- <p>
- The pattern can be arbitrarily complex and in particular can contain multiple conversion keywords.
- For instance, "%replace{%logger %msg}{\.}{/}" will replace all dots in the logger or the message of
- the event with a forward slash.
- </p>
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>rEx</b>{depth}<br />
- <b>rException</b>{depth}<br />
- <b>rThrowable</b>{depth}
- </td>
- <td>
- <p>
- The same as the %throwable conversion word but the stack trace is printed starting with the
- first exception that was thrown followed by each subsequent wrapping exception.
- </p>
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>sn</b><br />
- <b>sequenceNumber</b>
- </td>
- <td>Includes a sequence number that will be incremented in every event. The counter is a
- static variable so will only be unique within applications that share the same converter Class
- object.</td>
- </tr>
- <tr>
- <td align="center">
- <b>t</b><br />
- <b>thread</b>
- </td>
- <td>Used to output the name of the thread that generated the logging event.</td>
- </tr>
- <tr>
- <td align="center">
- <b>x</b><br />
- <b>NDC</b>
- </td>
- <td>Used to output the Thread Context Stack (also known as the Nested Diagnostic Context or NDC)
- associated with the thread that generated the logging event.
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>X</b>{key}<br />
- <b>mdc</b>{key}<br />
- <b>MDC</b>{key}
- </td>
- <td>
- <p>Used to output the Thread Context Map (also known as the Mapped Diagnostic Context or MDC)
- associated with the thread that generated the logging event. The
- <b>X</b>
- conversion character can be followed by the key for the
- map placed between braces, as in
- <b>%X{clientNumber}</b>
- where
- <code>clientNumber</code>
- is the key. The value in the MDC
- corresponding to the key will be output. If no additional sub-option
- is specified, then the entire contents of the MDC key value pair set
- is output using a format {{key1,val1},{key2,val2}}
- </p>
- <p>See the
- <a href="../../log4j2-api/apidocs/org/apache/logging/log4j/ThreadContext.html">ThreadContext</a>
- class for more details.
- </p>
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>u</b>{"RANDOM" | "TIME"}<br />
- <b>uuid</b>
- </td>
- <td>Includes either a random or a time-based UUID. The time-based UUID is a Type 1 UUID that can
- generate up to 10,000 unique ids per millisecond, will use the MAC address of each host, and to
- try to insure uniqueness across multiple JVMs and/or ClassLoaders on the same host a
- random number between 0 and 16,384 will be associated with each instance of the UUID generator
- Class and included in each time-based UUID generated. Because time-based UUIDs contain
- the MAC address and timestamp they should be used with care as they can cause a security
- vulnerability.
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>xEx</b>{depth}<br />
- <b>xException</b>{depth}<br />
- <b>xThrowable</b>{depth}
- </td>
- <td>
- <p>
- The same as the %throwable conversion word but also includes class packaging information.
- </p>
- <p>
- At the end of each stack element of the exception, a string containing the name of the jar file
- that contains the class or the directory the class is located in and the "Implementation-Version"
- as found in that jar's manifest will be added. If the information is uncertain, then the class
- packaging data will be preceded by a tilde, i.e. the '~' character.
- </p>
- </td>
- </tr>
- <tr>
- <td align="center">
- <b>%</b>
- </td>
- <td>The sequence %% outputs a single percent sign.
- </td>
- </tr>
- </table>
- <p>By default the relevant information is output as is. However,
- with the aid of format modifiers it is possible to change the
- minimum field width, the maximum field width and justification.
- </p>
- <p>The optional format modifier is placed between the percent sign
- and the conversion character.
- </p>
- <p>The first optional format modifier is the
- <em>left justification
- flag
- </em>
- which is just the minus (-) character. Then comes the
- optional
- <em>minimum field width</em>
- modifier. This is a decimal
- constant that represents the minimum number of characters to
- output. If the data item requires fewer characters, it is padded on
- either the left or the right until the minimum width is
- reached. The default is to pad on the left (right justify) but you
- can specify right padding with the left justification flag. The
- padding character is space. If the data item is larger than the
- minimum field width, the field is expanded to accommodate the
- data. The value is never truncated.
- </p>
- <p>This behavior can be changed using the
- <em>maximum field
- width
- </em>
- modifier which is designated by a period followed by a
- decimal constant. If the data item is longer than the maximum
- field, then the extra characters are removed from the
- <em>beginning</em>
- of the data item and not from the end. For
- example, it the maximum field width is eight and the data item is
- ten characters long, then the first two characters of the data item
- are dropped. This behavior deviates from the printf function in C
- where truncation is done from the end.
- </p>
- <p>Below are various format modifier examples for the category
- conversion specifier.
- </p>
- <table BORDER="1" CELLPADDING="8">
- <tr>
- <th>Format modifier</th>
- <th>left justify</th>
- <th>minimum width</th>
- <th>maximum width</th>
- <th>comment</th>
- </tr>
- <tr>
- <td align="center">%20c</td>
- <td align="center">false</td>
- <td align="center">20</td>
- <td align="center">none</td>
- <td>Left pad with spaces if the category name is less than 20
- characters long.
- </td>
- </tr>
- <tr>
- <td align="center">%-20c</td>
- <td align="center">true</td>
- <td
- align="center">20
- </td>
- <td align="center">none</td>
- <td>Right pad with
- spaces if the category name is less than 20 characters long.
- </td>
- </tr>
- <tr>
- <td align="center">%.30c</td>
- <td align="center">NA</td>
- <td align="center">none</td>
- <td align="center">30</td>
- <td>Truncate from the beginning if the category name is longer than 30
- characters.
- </td>
- </tr>
- <tr>
- <td align="center">%20.30c</td>
- <td align="center">false</td>
- <td align="center">20</td>
- <td align="center">30</td>
- <td>Left pad with spaces if the category name is shorter than 20
- characters. However, if category name is longer than 30 characters,
- then truncate from the beginning.
- </td>
- </tr>
- <tr>
- <td align="center">%-20.30c</td>
- <td align="center">true</td>
- <td align="center">20</td>
- <td align="center">30</td>
- <td>Right pad with spaces if the category name is shorter than 20
- characters. However, if category name is longer than 30 characters,
- then truncate from the beginning.
- </td>
- </tr>
- <caption align="top">Pattern Converters</caption>
- </table>
- </subsection>
- <a name="RFC5424Layout"/>
- <subsection name="RFC5424Layout">
- <p>
- As the name implies, the RFC5424Layout formats LogEvents in accordance with
- <a href="http://tools.ietf.org/html/rfc5424">RFC 5424</a>, the enhanced Syslog specification. Although the specification
- is primarily directed at sending messages via Syslog, this format is quite useful for
- other purposes since items are passed in the message as self-describing key/value pairs.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>appName</td>
- <td>String</td>
- <td>The value to use as the APP-NAME in the RFC 5424 syslog record.</td>
- </tr>
- <tr>
- <td>charset</td>
- <td>String</td>
- <td>The character set to use when converting the syslog String to a byte array. The String must be
- a valid <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Charset</a>.
- If not specified, the default system Charset will be used.</td>
- </tr>
- <tr>
- <td>enterpriseNumber</td>
- <td>integer</td>
- <td>The IANA enterprise number as described in
- <a href="http://tools.ietf.org/html/rfc5424#section-7.2.2">RFC 5424</a></td>
- </tr>
- <tr>
- <td>facility</td>
- <td>String</td>
- <td>The facility is used to try to classify the message. The facility option must be set to one of
- "KERN", "USER", "MAIL", "DAEMON", "AUTH", "SYSLOG", "LPR", "NEWS", "UUCP", "CRON", "AUTHPRIV",
- "FTP", "NTP", "AUDIT", "ALERT", "CLOCK", "LOCAL0", "LOCAL1", "LOCAL2", "LOCAL3", "LOCAL4", "LOCAL5",
- "LOCAL6", or "LOCAL7". These values may be specified as upper or lower case characters.</td>
- </tr>
- <tr>
- <td>format</td>
- <td>String</td>
- <td>If set to "RFC5424" the data will be formatted in accordance with RFC 5424. Otherwise, it will
- be formatted as a BSD Syslog record. Note that although BSD Syslog records are required to be
- 1024 bytes or shorter the SyslogLayout does not truncate them. The RFC5424Layout also does not
- truncate records since the receiver must accept records of up to 2048 bytes and may accept records
- that are longer.</td>
- </tr>
- <tr>
- <td>id</td>
- <td>String</td>
- <td>The default structured data id to use when formatting according to RFC 5424. If the LogEvent contains
- a StructuredDataMessage the id from the Message will be used instead of this value.</td>
- </tr>
- <tr>
- <td>immediateFlush</td>
- <td>boolean</td>
- <td>When set to true, each write will be followed by a flush. This will guarantee the data is written
- to disk but could impact performance.</td>
- </tr>
- <tr>
- <td>includeMDC</td>
- <td>boolean</td>
- <td>Indicates whether data from the ThreadContextMap will be included in the RFC 5424 Syslog record.
- Defaults to true.</td>
- </tr>
- <tr>
- <td>mdcExcludes</td>
- <td>String</td>
- <td>A comma separated list of mdc keys that should be excluded from the LogEvent. This is mutually
- exclusive with the mdcIncludes attribute. This attribute only applies to RFC 5424 syslog records.</td>
- </tr>
- <tr>
- <td>mdcIncludes</td>
- <td>String</td>
- <td>A comma separated list of mdc keys that should be included in the FlumeEvent. Any keys in the MDC
- not found in the list will be excluded. This option is mutually exclusive with the mdcExcludes
- attribute. This attribute only applies to RFC 5424 syslog records.</td>
- </tr>
- <tr>
- <td>mdcRequired</td>
- <td>String</td>
- <td>A comma separated list of mdc keys that must be present in the MDC. If a key is not present a
- LoggingException will be thrown. This attribute only applies to RFC 5424 syslog records.</td>
- </tr>
- <tr>
- <td>mdcPrefix</td>
- <td>String</td>
- <td>A string that should be prepended to each MDC key in order to distinguish it from event attributes.
- The default string is "mdc:". This attribute only applies to RFC 5424 syslog records.</td>
- </tr>
- <tr>
- <td>messageId</td>
- <td>String</td>
- <td>The default value to be used in the MSGID field of RFC 5424 syslog records. </td>
- </tr>
- <tr>
- <td>newLine</td>
- <td>boolean</td>
- <td>If true, a newline will be appended to the end of the syslog record. The default is false.</td>
- </tr>
- <caption align="top">RFC5424Layout Parameters</caption>
- </table>
- </subsection>
- <a name="SerializedLayout"/>
- <subsection name="SerializedLayout">
- <p>
- The SerializedLayout simply serializes the LogEvent into a byte array. This is useful when
- sending messages via JMS or via a Socket connection. The SerializedLayout accepts no parameters.
- </p>
- </subsection>
- <a name="SyslogLayout"/>
- <subsection name="SyslogLayout">
- <p>
- The SyslogLayout formats the LogEvent as BSD Syslog records matching the same format used by
- Log4j 1.2.
- </p>
- <table border="1" width="100%">
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>charset</td>
- <td>String</td>
- <td>The character set to use when converting the syslog String to a byte array. The String must be
- a valid <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Charset</a>.
- If not specified, the default system Charset will be used.</td>
- </tr>
- <tr>
- <td>facility</td>
- <td>String</td>
- <td>The facility is used to try to classify the message. The facility option must be set to one of
- "KERN", "USER", "MAIL", "DAEMON", "AUTH", "SYSLOG", "LPR", "NEWS", "UUCP", "CRON", "AUTHPRIV",
- "FTP", "NTP", "AUDIT", "ALERT", "CLOCK", "LOCAL0", "LOCAL1", "LOCAL2", "LOCAL3", "LOCAL4", "LOCAL5",
- "LOCAL6", or "LOCAL7". These values may be specified as upper or lower case characters.</td>
- </tr>
- <tr>
- <td>newLine</td>
- <td>boolean</td>
- <td>If true, a newline will be appended to the end of the syslog record. The default is false.</td>
- </tr>
- <caption align="top">SyslogLayout Parameters</caption>
- </table>
- </subsection>
- <a name="XMLLayout"/>
- <subsection name="XMLLayout">
- <p>
- The output of the XMLLayout consists of a series of log4j:event
- elements as defined in the<a href="log4j.dtd">log4j.dtd</a>. If configured to do so it will
- output a complete well-formed XML file. The output is designed to be
- included as an
- <em>external entity</em>
- in a separate file to form
- a correct XML file.
- </p>
- <p>For example, if <code>abc</code> is the name of the file where
- the XMLLayout ouput goes, then a well-formed XML file would be:
- </p>
- <pre>
- <?xml version="1.0" ?>
- *
- <!DOCTYPE log4j:eventSet SYSTEM "log4j.dtd" [<!ENTITY data SYSTEM "abc">]>
- *
- <log4j:eventSet version="2.0" xmlns:log4j="http://logging.apache.org/log4j/">
- &data;
- </log4j:eventSet>
- </pre>
- <p>
- This approach enforces the independence of the XMLLayout and the appender where it is embedded.
- </p>
- <p>
- The <code>version</code> attribute helps components to correctly intrepret output generated by XMLLayout.
- The value of this attribute should be "2.0".
- </p>
- <p>
- 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.
- </p>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/logsep.xml b/rgoers/src/site/xdoc/manual/logsep.xml
deleted file mode 100644
index cef6652..0000000
--- a/rgoers/src/site/xdoc/manual/logsep.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Logging Separation</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- Log4J 2.0
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/lookups.xml b/rgoers/src/site/xdoc/manual/lookups.xml
deleted file mode 100644
index a34463f..0000000
--- a/rgoers/src/site/xdoc/manual/lookups.xml
+++ /dev/null
@@ -1,153 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4j 2 Lookups</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Lookups">
- <p>
- Lookups provide a way to add values to the Log4j configuration at arbitrary places. They are
- a particular type of Plugin that implements the
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/lookup/StrLookup.html">StrLookup</a> interface.
- Information on how to use Lookups in configuration files can be found in the
- <a href="./configuration.html#PropertySubstitution">Property Substitution</a> section of the
- <a href="./configuration.html">Configuration</a> page.
- </p>
- <a name="ContextMapLookup"/>
- <subsection name="ContextMapLookup">
- <p>
- The ContextMapLookup allows applications to store data in the Log4j ThreadContext Map and
- then retrieve the values in the Log4j configuration. In the example below, the application
- would store the current user's login id in the ThreadContext Map with the key "loginId". During
- initial configuration processing the first '$' will be removed. The PatternLayout supports
- interpolation with Lookups and will then resolve the variable for each event. Note that
- the pattern "%X{loginId}" would achieve the same result.
- </p>
- <source><![CDATA[ <File name="Application" fileName="application.log">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] $${ctx:loginId} %m%n</pattern>
- </PatternLayout>
- </File>]]></source>
- </subsection>
- <a name="DateLookup"/>
- <subsection name="DateLookup">
- <p>
- The DateLookup is somewhat unusual from the other lookups as it doesn't use the key to locate an item.
- Instead, the key can be used to specify a date format string that is valid for
- <a href="http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat</a>.
- The current date, or the date associated with the current log event will be formatted as specified.
- </p>
- <source><![CDATA[ <RollingFile name="Rolling-${map:type}" fileName="${filename}"
- filePattern="target/rolling1/test1-$${date:MM-dd-yyyy}.%i.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <SizeBasedTriggeringPolicy size="500" />
- </RollingFile>]]></source>
- </subsection>
- <a name="EnvironmentLookup"/>
- <subsection name="EnvironmentLookup">
- <p>
- The EnvironmentLookup allows systems to configure environment variables, either in global files
- such as /etc/profile or in the startup scripts for applications, and then retrieve those variables
- from within the logging configuration. The example below includes the name of the currently logged
- in user in the application log.
- </p>
- <source><![CDATA[ <File name="Application" fileName="application.log">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] $${env:USER} %m%n</pattern>
- </PatternLayout>
- </File>]]></source>
- </subsection>
- <a name="MapLookup"/>
- <subsection name="MapLookup">
- <p>
- The MapLookup serves two purposes.
- <ol>
- <li>Provide the base for Properties declared in the configuration file.</li>
- <li>Retrieve values from MapMessages in LogEvents.</li>
- </ol>
- The first item simply means that the MapLookup is used to substitute properties that are defined
- in the configuration file. These variables are specified without a prefix - e.g. <code>${name}</code>.
- The second usage allows a value from the current
- <a href="../log4j2-api/apidocs/org/apache/logging/log4j/message/MapMessage.html">MapMessage</a>,
- if one is part of the current log event, to be substituted. In the example below the RoutingAppender will
- use a different RollingFileAppender for each unique value of the key named "type" in the MapMessage. Note
- that when used this way a value for "type" should be declared in the properties declaration to provide
- a default value in case the message is not a MapMessage or the MapMessage does not contain the key. See the
- <a href="./configuration.html#PropertySubstitution">Property Substitution</a> section of the
- <a href="./configuration.html">Configuration</a> page for information on how to set the default values.
- </p>
- <source><![CDATA[ <Routing name="Routing">
- <Routes pattern="$${map:type}">
- <Route>
- <RollingFile name="Rolling-${map:type}" fileName="${filename}"
- filePattern="target/rolling1/test1-${map:type}.%i.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <SizeBasedTriggeringPolicy size="500" />
- </RollingFile>
- </Route>
- </Routes>
- </Routing>
- ]]></source>
- </subsection>
- <a name="StructuredDataLookup"/>
- <subsection name="StructuredDataLookup">
- <p>
- The StructuredDataLookup is very similar to the MapLookup in that it will retrieve values from
- StructuredDataMessages. In addition to the Map values it will also return the name portion of the
- id (not including the enterprise number) and the type field. The main difference between the
- example below and the example for MapMessage is that the "type" is an attribute of the
- <a href="../log4j2-api/apidocs/org/apache/logging/log4j/message/StructuredDataMessage.html">StructuredDataMessage</a>
- while "type" would have to be an item in the Map in a MapMessage.
- </p>
- <source><![CDATA[ <Routing name="Routing">
- <Routes pattern="$${sd:type}">
- <Route>
- <RollingFile name="Rolling-${sd:type}" fileName="${filename}"
- filePattern="target/rolling1/test1-${sd:type}.%i.log.gz">
- <PatternLayout>
- <pattern>%d %p %C{1.} [%t] %m%n</pattern>
- </PatternLayout>
- <SizeBasedTriggeringPolicy size="500" />
- </RollingFile>
- </Route>
- </Routes>
- </Routing>
- ]]></source>
- </subsection>
- <a name="SystemPropertiesLookup"/>
- <subsection name="SystemPropertiesLookup">
- <p>
- As it is quite common to define values inside and outside the application by using System Properties,
- it is only natural that they should be accessible via a Lookup. As system properties are often
- defined outside the application it would be quite common to see something like:
- </p>
- <source><![CDATA[ <appenders>
- <File name="ApplicationLog" fileName="${sys:logPath}/app.log"/>
- </appenders>]]></source>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/markers.xml b/rgoers/src/site/xdoc/manual/markers.xml
deleted file mode 100644
index 4cee8a0..0000000
--- a/rgoers/src/site/xdoc/manual/markers.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4J 2.0 API</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Log4j 2.0 API">
- <a name="Markers"/>
- <subsection name="Markers">
- <p>
- One of the primary purpose of a logging framework is to provide the means to generate debugging and
- diagnostic information only when it is needed, and to allow filtering of that information so that it
- does not overwhelm the system or the individuals who need to make use of it. As an example, an
- application desires to log its entry, exit and other operations separately from SQL statements
- being executed, and wishes to be able to log queries separate from updates. One way to accomplish
- this is shown below:
- </p>
- <source><![CDATA[ import org.apache.logging.log4j.Logger;
- import org.apache.logging.log4j.LogManager;
- import java.util.Map;
-
- public class MyApp {
-
- private Logger logger = LogManager.getLogger(MyApp.class.getName());
- private static final Marker SQL_MARKER = MarkerManager.getMarker("SQL");
- private static final Marker UPDATE_MARKER = MarkerManager.getMarker("SQL_UPDATE", SQL_MARKER);
- private static final Marker QUERY_MARKER = MarkerManager.getMarker("SQL_QUERY", SQL_MARKER);
-
- public String doQuery(String table) {
- logger.entry(param);
-
- logger.debug(QUERY_MARKER, "SELECT * FROM {}", table);
-
- return logger.exit();
- }
-
- public String doUpdate(String table, Map<String, String> params) {
- logger.entry(param);
-
- if (logger.isDebugEnabled()) {
- logger.debug(UPDATE_MARKER, "UPDATE {} SET {}", table, formatCols);
-
- return logger.exit();
- }
-
- private String formatCols(Map<String, String> cols) {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (Map.Entry<String, String> entry : cols.entrySet()) {
- if (!first) {
- sb.append(", ");
- }
- sb.append(entry.getKey()).append("=").append(entry.getValue());
- first = false;
- }
- return sb.toString();
- }
- }]]></source>
- <p>
- In the example above it is now possible to add MarkerFilters to only allow SQL update operations
- to be logged, all SQL updates to be logged or to log everything in MyApp.
- </p>
- <p>
- Some important rules about Markers must be considered when using them.
- <ol>
- <li>Markers must be unique. They are permanently registered by name so care should be taken
- to insure that Markers used in your application are distinct from those in the application's
- dependencies, unless that is what is desired.</li>
- <li>Like many objects in Log4J2, Markers are immutable. If a marker has a parent, the parent
- must be named when the Marker is created and the parent cannot be changed after creation.</li>
- <li>Markers only have a single parent. Markers can, however, have many children that reference
- them.</li>
- </ol>
- </p>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/messages.xml b/rgoers/src/site/xdoc/manual/messages.xml
deleted file mode 100644
index eccc094..0000000
--- a/rgoers/src/site/xdoc/manual/messages.xml
+++ /dev/null
@@ -1,246 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4J 2.0 API Messages</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Log4j 2.0 API">
- <a name="Messages"/>
- <subsection name="Messages">
- <p>
- Although Log4j 2 provides Logger methods that accept Strings and Objects, all of these are ulitmately
- captured in Message objects that are then associated with the log event. Applications are free to
- construct Messages of their own and pass them to the Logger. Although it may seem more expensive than
- passing the message format and parameters directly to the event, testing has shown that with modern
- JVMs the cost of creating and destroying events is minor, especially when complex tasks are encapsulated
- in the Message instead of the application. In addition, when using the methods that accept Strings and
- parameters, the underlying Message object will only be created if any configured global filters
- or the Logger's log level allow the message to be processed.
- </p>
- <p>
- Consider an application that has a Map object containing {"Name" = "John Doe", "Address" = "123 Main
- St.",
- "Phone" = "(999) 555-1212"} and a User object that has a getId method that returns "jdoe". The developer
- would like to add an informational message that returns "User John Doe has logged in using id jdoe". The
- way this could be accomplished is by doing:
- </p>
- <pre>
- logger.info("User {} has logged in using id {}, map.get("Name"), user.getId());
- </pre>
- <p>
- While there is nothing inherently wrong with this, as the complexity of the objects and desired output
- increases this technique becomes harder to use. As an alternative, using Messages allows:
- </p>
- <pre>
- logger.info(new LoggedInMessage(map, user));
- </pre>
- <p>
- In this alternative the formatting is delegated to the LoggedInMessage object's getFormattedMessage
- method.
- Although in this alternative a new object is created, none of the methods on the objects passed to the
- LoggedInMessage are invoked until the LoggedInMessage is formatted. This is especially useful when an
- Object's toString method does not produce the information you would like to appear in the log.
- </p>
- <p>
- Another advantage to Messages is that they simplify writing Layouts. In other logging frameworks the
- Layout must loop through the parameters individually and determine what to do based on what objects
- are encountered. With Messages the Layout has the option of delegating the formatting to the Message or
- performing its formatting based on the type of Message encountered.
- </p>
- <p>
- Borrowing from the earlier example illustrating Markers to identify SQL statements being logged, Messages
- can also be leveraged. First, the Message is defined.
- </p>
- <source><![CDATA[
-
- public class SQLMessage implements Message {
- public enum SQLType {
- UPDATE,
- QUERY
- };
-
- prviate final SQLType type;
- private final String table;
- private final Map<String, String> cols;
-
- public SQLMessage(SQLType type, String table) {
- this(type, table, null);
- }
-
- public SQLMessage(SQLType type, String table, Map<String, String> cols) {
- this.type = type;
- this.table = table;
- this.cols = cols;
- }
-
- public String getFormattedMessage() {
- switch (type) {
- case UPDATE:
- return createUpdateString();
- break;
- case QUERY:
- return createQueryString();
- break;
- default;
- }
- }
-
- public String getMessageFormat() {
- return type + " " + table;
- }
-
- public Object getParameters() {
- return cols;
- }
-
- private String createUpdateString() {
- }
-
- private String createQueryString() {
- }
-
- private String formatCols(Map<String, String> cols) {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (Map.Entry<String, String> entry : cols.entrySet()) {
- if (!first) {
- sb.append(", ");
- }
- sb.append(entry.getKey()).append("=").append(entry.getValue());
- first = false;
- }
- return sb.toString();
- }
- }]]></source>
- <p>
- Next we can use the message in our application.
- </p>
- <source><![CDATA[ import org.apache.logging.log4j.Logger;
- import org.apache.logging.log4j.LogManager;
- import java.util.Map;
-
- public class MyApp {
-
- private Logger logger = LogManager.getLogger(MyApp.class.getName());
- private static final Marker SQL_MARKER = MarkerManager.getMarker("SQL");
- private static final Marker UPDATE_MARKER = MarkerManager.getMarker("SQL_UPDATE", SQL_MARKER);
- private static final Marker QUERY_MARKER = MarkerManager.getMarker("SQL_QUERY", SQL_MARKER);
-
- public String doQuery(String table) {
- logger.entry(param);
-
- logger.debug(QUERY_MARKER, new SQLMessage(SQLMessage.SQLType.QUERY, table);
-
- return logger.exit();
- }
-
- public String doUpdate(String table, Map<String, String> params) {
- logger.entry(param);
-
- logger.debug(UPDATE_MARKER, new SQLMessage(SQLMessage.SQLType.UPDATE, table, parmas);
-
- return logger.exit();
- }
- }]]></source>
- <p>
- Notice that in contrast to the prior version of this example, the logger.debug in doUpdate no longer
- needs to be wrapped in an isDebugEnabled call as creation of the SQLMessage is on the same order of
- magnitude of performing that check. Furthermore, all the formatting of the SQL columns is now hidden
- in the SQLMessage instead of having to take place in the business logic. Finally, if desired, Filters
- and/or Layouts can be written to take special action when an SQLMessage is encountered.
- </p>
- <a name="FormattedMessage"/>
- <h4>FormattedMessage</h4>
- <p>
- A FormattedMessage will have setFormat and getFormat methods. The setFormat method may be called by a
- Layout to provide advice on how the Message should be formatted. If the Message doesn't recognize the
- format name it will simply format the data using its default format. An example of this is the
- StructuredDataMessage which accepts a format String of "XML" which will cause it to format the event data
- as XML instead of the RFC 5424 format.
- </p>
- <a name="LocalizedMessage"/>
- <h4>LocalizedMessage</h4>
- <p>
- <a href="../log4j2-api/apidocs/org/apache/logging/log4j/message/LocalizedMessage.html">LocalizedMessage</a>
- is provided primarily to provide compatibility with Log4j 1.x. Generally,
- the best approach to localization is to have the client UI render the events in the client's locale.
- </p>
- <p>
- LocalizedMessage extends a ParameterizedMessage by incorporating a ResourceBundle and allowing
- the message pattern parameter to be the key to the message pattern in the bundle. If no bundle is specified,
- LocalizedMessage will attempt to locate a bundle with the name of the Logger used to log the event. The
- parameters to the Message will be incorporated into the Message whereever the "{}" placeholders occur.
- </p>
- <a name="LoggerNameAwareMessage"/>
- <h4>LoggerNameAwareMessage</h4>
- <p>
- LoggerNameAwareMessage is an interface with a setLoggerName method. This method will be called during
- event construction so that the Message has the name of the Logger used to log the event when the
- message is being formatted.
- </p>
- <a name="MapMessage"/>
- <h4>MapMessage</h4>
- <p>
- A MapMessage contains a Map of String keys and values. MapMessage implements FormattedMessage and accepts
- a format specifier of "XML", in which case the Map will be formatted as XML. Otherwise, the Map will be
- formatted as "key1=value1 key2=value2...".
- </p>
- <a name="ObjectMessage"/>
- <h4>ObjectMessage</h4>
- <p>
- Formats an Object by calling its toString method.
- </p>
- <a name="ParameterizedMessage"/>
- <h4>ParameterizedMessage</h4>
- <p>
- <a href="../log4j2-api/apidocs/org/apache/logging/log4j/message/ParameterizedMessage.html">ParameterizedMessage</a>
- handles messages that contain "{}" in the format to represent replaceable tokens and the replacement
- parameters.
- </p>
- <a name="SimpleMessage"/>
- <h4>SimpleMessage</h4>
- <p>
- SimpleMessage contains a String that requires no formatting.
- </p>
- <a name="StructuredDataMessage"/>
- <h4>StructuredDataMessage</h4>
- <p>
- <a href="../log4j2-api/apidocs/org/apache/logging/log4j/message/StructuredDataMessage.html">StructuredDataMessage</a>
- allows applications to add items to a Map as well as set the id to allow a message to be formatted as a
- Structured Data element in accordance with <a href="http://tools.ietf.org/html/rfc5424">RFC 5424</a>.
- </p>
- <a name="ThreadDumpMessage"/>
- <h4>ThreadDumpMessage</h4>
- <p>
- A ThreadDumpMessage, if logged, will generate stack traces for all threads. If running on Java 6+ the
- stack traces will include any locks that are held.
- </p>
- <a name="TimestampMessage"/>
- <h4>TimestampMessage</h4>
- <p>
- A TimestampMessage will provide a getTimestamp method that is called during event construction. The
- timestamp in the Message will be used in lieu of the current timestamp.
- </p>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/plugins.xml b/rgoers/src/site/xdoc/manual/plugins.xml
deleted file mode 100644
index 7431edb..0000000
--- a/rgoers/src/site/xdoc/manual/plugins.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4j 2 Plugins</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Plugins">
- <a name="Introduction"/>
- <subsection name="Introduction">
- <p>
- Log4j 1.x allowed for extension by requiring class attributes on most of the configuration
- declarations. In the case of some elements, notably the PatternLayout, the only way to add
- new pattern converters was to extend the PatternLayout class and add them via code. One of
- goals of Log4j 2 is to make extending it extremely easy through the use of plugins.
- </p>
- <p>
- In Log4j 2 a plugin is declared by adding a Plugin annotation to the class declaration. During
- initialization the Configuration will invoke the PluginManager to locate all the Log4j plugins
- that are located in the declared <a href="./configuration.html#ConfigurationSyntax">packages</a>.
- As the configuration is processed the appropriate plugins will be automatically configured and
- initialized. Log4j 2 utilizes a few different types of plugins which are described in the follownig
- sections.
- </p>
- </subsection>
- <a name="Core"/>
- <subsection name="Core">
- <p>
- Core plugins are those that are directly represented by an element in a configuration file, such as an
- Appender, Logger or Filter. Custom plugins that conform to the rules laid out in the next paragraph
- may simply be referenced in the configuration, provided they are appropriate configured to be
- loaded by the PluginManager.
- </p>
- <p>
- Every Core plugin must declare a static method that is marked with a PluginFactory annotation. To
- allow the Configuration to pass the correct parameters to the method, every
- parameter to the method must be annotated as one of the following attribute types. Each
- attribute or element annotation must include the name that must be present in the configuration
- in order to match the configuration item to its respective parameter.
- </p>
- <h4>Attribute Types</h4>
- <dl>
- <dt>PluginAttr</dt>
- <dd>The parameter must resolve to a String, although it can be the String representation of a
- boolean. numeric value, or any other Object that can be created from a String value.</dd>
- <dt>PluginElement</dt>
- <dd>The parameter may represent a complex object that itself has parameters that can be configured.</dd>
- <dt>PluginConfiguration</dt>
- <dd>The current Configuration object will be passed to the plugin as a parameter.</dd>
- </dl>
- </subsection>
- <a name="Converters"/>
- <subsection name="Converters">
- <p>
- Converters are used by
- <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/layout/PatternLayout.html">PatternLayout</a>
- to render the elements identified by the conversion pattern. Every converter must specify its type as
- "Converter" on the Plugin attribute, have a static newInstance method that accepts an array of Strings as
- its only parameter and returns an instance of the Converter, and must have a ConverterKeys annotation
- present that contains the array of converter patterns that will cause the Converter to be selected.
- Converters that are meant to handle LogEvents must extend the LogEventPatternConverter class and
- must implement a format method that accepts a LogEvent and a StringBuilder as arguments. The Converter
- should append the result of its operation to the StringBuilder.
- </p>
- <p>
- A second type of Converter is the FileConverter - which must have "FileConverter" specified in the
- type attribute of the Plugin annotation. While similar to a LogEventPatternConverter, instead
- of a single format method these Converters will have two variations; one that takes an Object and
- one that takes an array of Objects instead of the LogEvent. Both append to the provided StringBuilder
- in the same fashion as a LogEventPatternConverter. These Converters are typically used by the
- RollingFileAppender to construct the name of the file to log to.
- </p>
- </subsection>
- <a name="Lookups"/>
- <subsection name="Lookups">
- <p>
- Lookups are perhaps the simplest plugins of all. They must declare their type as "Lookup" on the
- plugin annotation and must implement the StrLookup interface. They will have two methods; a
- lookup method that accepts a String key and returns a String value and a second lookup method that
- accepts both a LogEvent and a String key and returns a String. Lookups may be referenced by
- specifying ${<i>name</i>:key} where <i>name</i> is the name specified in the Plugin annotation and
- key is the name of the item to locate.
- </p>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/manual/thread-context.xml b/rgoers/src/site/xdoc/manual/thread-context.xml
deleted file mode 100644
index 7799687..0000000
--- a/rgoers/src/site/xdoc/manual/thread-context.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Log4j 2 Thread Context</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Log4j 2.0 API">
- <subsection name="Thread Context">
- <h4>Introduction</h4>
- <p>Log4j introduced the concept of the Mapped Diagnostic Context or MDC. It has been documented and
- discussed in numerous places including
- <a href="http://veerasundar.com/blog/2009/10/log4j-mdc-mapped-diagnostic-context-what-and-why/">Log4j MDC: What and Why</a> and
- <a href="http://blog.f12.no/wp/2004/12/09/log4j-and-the-mapped-diagnostic-context/">Log4j and the Mappend Diagnostic Context</a>.
- In addition, Log4j 1.x provides support for a Nested Diagnostic Context or NDC. It too has been documented
- and discussed in various places such as
- <a href="http://lstierneyltd.com/blog/development/log4j-nested-diagnostic-contexts-ndc/">Log4j NDC</a>.
- SLF4J/Logback followed with its own implementation of the MDC, which is documented very well at
- <a href="http://logback.qos.ch/manual/mdc.html">Mapped Diagnostic Context</a>.
- </p>
- <p>Log4j 2 continues with the idea of the MDC and the NDC but merges them into a single Thread Context.
- The Thread Context Map is the equivalent of the MDC and the Thread Context Stack is the equivalent of the
- NDC. Although these are frequently used for purposes other than diagnosing problems, they are still
- frequently referred to as the MDC and NDC in Log4j 2 since they are already well known by those acronyms.
- </p>
- <h4>Fish Tagging</h4>
- <p>Most real-world systems have to deal with multiple clients simultaneously. In a typical multithreaded
- implementation of such asystem, different threads will handle different clients. Logging is
- especially well suited to trace and debug complex distributed applications. A common approach to
- differentiate the logging output of one client from another is to instantiate a new separate logger for
- each client. This promotes the proliferation of loggers and increases the management overhead of logging.
- </p>
- <p>A lighter technique is to uniquely stamp each log request initiated from the same client interaction.
- Neil Harrison described this method in the book "Patterns for Logging Diagnostic Messages," in <em>Pattern
- Languages of Program Design 3</em>, edited by R. Martin, D. Riehle, and F. Buschmann
- (Addison-Wesley, 1997). Just as a fish can be tagged and have its movement tracked, stamping log
- events with a common tag or set of data elements allows the complete flow of a transaction or a request
- to be tracked. We call this <i>Fish Tagging</i>.
- </p>
- <p>Log4j provides two mechanisms for performing Fish Tagging; the Thread Context Map and the Thread
- Context Stack. The Thread Context Map allows any number of items to be added and be identified
- using key/value pairs. The Thread Context Stack allows one or more items to be pushed on the
- Stack and then be identified by their order in the Stack or by the data itself. Since key/value
- pairs are more flexible, the Thread Context Map is recommended when data items may be added during
- the processing of the request or when there are more than one or two items.
- </p>
- <p>To uniquely stamp each request using the Thread Context Stack, the user pushes contextual information
- on to the Stack.
- </p>
- <pre>
- ThreadContext.push(UUID.randomUUID().toString()); // Add the fishtag;
-
- logger.debug("Message 1");
- .
- .
- .
- logger.debug("Message 2");
- .
- .
- ThreadContext.pop();</pre>
- <p>
- The alternative to the Thread Context Stack is the Thread Context Map. In this case, attributes
- associated with the request being processed are adding at the beginning and removed at the end
- as follows:
- </p>
- <pre>
- ThreadContext.put("id", UUID.randomUUID().toString(); // Add the fishtag;
- ThreadContext.put("ipAddress", request.getRemoteAddr());
- ThreadContext.put("loginId", session.getAttribute("loginId"));
- ThreadContext.put("hostName", request.getServerName());
- .
- logger.debug("Message 1");
- .
- .
- logger.debug("Message 2");
- .
- .
- ThreadContext.clear();</pre>
- <p>The Stack and the Map are managed per thread and is based on
- <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/InheritableThreadLocal.html">InheritableThreadLocal</a>.
- Thus, in many cases the contents of the Stack and Map will be passed to child threads. However, as
- discussed in the
- <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/Executors.html#privilegedThreadFactory()">Executors</a>
- class and in other cases where thread pooling is utilized, the ThreadContext may not always be
- automatically passed to worker threads. In those cases the pooling mechanism should provide a means for
- doing so. The getContext() and cloneStack() methods can be used to obtain copies of the Map and Stack
- respectively.
- </p>
- <p>
- Note that all methods of the
- <a href="../log4j2-api/apidocs/org/apache/logging/log4j/ThreadContext.html">ThreadContext</a>
- class are static.
- </p>
- <h4>Including the ThreadContext when writing logs</h4>
- <p>
- The PatternLayout provides mechanisms to print the contents of the ThreadContext Map and Stack. Using
- %X by itself will cause the full contents of the Map to be included while %X{key} will cause the value
- of the specified key to be included. %x will include the full contents of the Stack.
- </p>
- </subsection>
- </section>
- </body>
-</document>
\ No newline at end of file
diff --git a/rgoers/src/site/xdoc/performance.xml b/rgoers/src/site/xdoc/performance.xml
deleted file mode 100644
index a845b01..0000000
--- a/rgoers/src/site/xdoc/performance.xml
+++ /dev/null
@@ -1,209 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<document>
- <properties>
- <title>Performance</title>
- <author email="rgoers@apache.org">Ralph Goers</author>
- </properties>
-
- <body>
- <section name="Performance">
- <p>One of the often-cited arguments against logging is its
- computational cost. This is a legitimate concern as even moderately
- sized applications can generate thousands of log requests. Much
- effort was spent measuring and tweaking logging performance. Log4j
- claims to be fast and flexible: speed first, flexibility second.
- </p>
- <p>The user should be aware of the following performance issues.</p>
- <ol>
- <li>
- <b>Logging performance when logging is turned off.</b>
- <br/>
- <p>When logging is turned off entirely or just for a set of Levels, the cost of a log request consists of
- two method invocations plus an integer comparison. On a 2.53 GHz Intel Core 2 Duo MacBook Pro
- calling isDebugEnabled 10 million times produces an average result in nanoseconds of: <br />
- <pre>
- Log4j: 4
- Logback: 5
- Log4j 2.0: 3
- </pre>
- The numbers above will vary slightly from run to run so the only conclusion that should be
- drawn is that all 3 frameworks perform similarly on this task.
- </p>
- <p>However, The method invocation involves the "hidden" cost of parameter construction.
- </p>
- <p>For example,
- <pre>
- logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
- </pre>
- incurs the cost of constructing the message parameter, i.e. converting both integer
- <code>i</code> and <code>entry[i]</code> to a String, and concatenating intermediate strings,
- regardless of whether the message will be logged or not.
-
- This cost of parameter construction can be quite high and it
- depends on the size of the parameters involved.
-
- A comparison run on the same hardware as above yields:
- <pre>
- Log4j: 188
- Logback: 183
- Log4j 2.0: 188
- </pre>
-
- Again, no conclusion should be drawn regarding relative differences between the frameworks on
- this task, but it should be obvious that it is considerably more expensive than simply testing
- the level.
- </p>
- <p>
- The best approach to avoid the cost of parameter construction is to use Log4J 2.0's formatting
- capabilities. For example, instead of the above write:
- <pre>
- logger.debug("Entry number: {} is {}", i, entry[i]);
- </pre>
- Using this approach, a comparison run again on the same hardware produces:
- <pre>
- Log4j: Not supported
- Logback: 9
- Log4j 2.0: 4
- </pre>
- These results show that the difference in performance between the call to isDebugEnabled and
- logger.debug is barely discernable.
- </p>
- <p>In some circumstances one of the parameters to logger.debug will be a costly method call that
- should be avoided if debugging is disabled. In those cases write:
- <pre>
- if(logger.isDebugEnabled() {
- logger.debug("Entry number: " + i + " is " + entry[i].toString());
- }
- </pre>
- </p>
- <p>This will not incur the cost of whatever the toString() method needs to do if debugging is disabled.
- On the other hand, if the logger is enabled for the debug level, it will incur twice the cost of
- evaluating whether the logger is enabled or not: once
- in <code>isDebugEnabled</code> and once in <code>debug</code>. This is an insignificant
- overhead because evaluating a logger takes about 1% of the time it takes to actually log.
- </p>
- <p>Certain users resort to preprocessing or compile-time
- techniques to compile out all log statements. This leads to perfect
- performance efficiency with respect to logging. However, since the
- resulting application binary does not contain any log statements,
- logging cannot be turned on for that binary. This seems to be
- a disproportionate price to pay in exchange for a small performance
- gain.
- </p>
- </li>
- <li>
- <b>The performance of deciding whether to log or not to log when logging is turned on.</b>
- <br/>
- <p>
- Unlike Log4j and Logback, Log4j 2 Loggers don't "walk a hierarchy". Loggers point directly to the
- Logger configuration that best matches the Logger's name. This incurs extra overhead when the Logger
- is first created but reduces the overhead every time the Logger is used.
- </p>
- </li>
- <li>
- <b>Actually outputting log messages</b>
- <br/>
- <p>This is the cost of formatting the log output and sending it to its target destination. Here again,
- a serious effort was made to make layouts (formatters) perform as quickly as possible. The same
- is true for appenders. One of the fundamental tenants of Log4j 2.0 is to use immutable objects whenever
- possible and to lock at the lowest granularity possible. However, the cost of actually formatting and
- delivering log events will never be insignificant. For example, the results of writing to a simple log
- file using the same format using Log4j, Logback and Log4j 2 are:
- <pre>
- Log4j: 4220
- Logback: 9671
- Log4j 2.0: 4615
- </pre>
- </p>
- <p>
- These results show that actually writing out the events can be at least 1000 times more expensive than
- when they are disabled.
- </p>
- </li>
- <li>
- <b>Advanced Filtering</b>
- <br />
- <p>
- Both Logback and Log4j 2 support advanced filtering. Logback calls them TurboFilters while
- Log4j 2 has a single Filter object. Advanced filtering provides the capability to filter
- LogEvents using more than just the Level before the events are passed to Appenders.
- However, this flexibility does come with some cost. Since multi-threading can also have an impact on the
- performance of advanced filtering, the table below shows the difference in performance in two different
- sets of context-wide filters running on the same hardware as the previous tests using
- various numbers of threads.
- </p>
- <table>
- <tr>
- <th>Test</th>
- <th>1 thread</th>
- <th>2 threads</th>
- <th>5 threads</th>
- <th>10 threads</th>
- <th>20 threads</th>
- <th>50 threads</th>
- </tr>
- <tr>
- <td>Logback MDCFilter</td>
- <td>37</td>
- <td>50</td>
- <td>145</td>
- <td>316</td>
- <td>606</td>
- <td>1670</td>
- </tr>
- <tr>
- <td>Log4j 2 ThreadContextMapFilter</td>
- <td>30</td>
- <td>35</td>
- <td>85</td>
- <td>165</td>
- <td>341</td>
- <td>864</td>
- </tr>
- <tr>
- <td>Logback MarkerFilter</td>
- <td>17</td>
- <td>24</td>
- <td>59</td>
- <td>115</td>
- <td>234</td>
- <td>547</td>
- </tr>
- <tr>
- <td>Log4j 2 MarkerFilter</td>
- <td>4</td>
- <td>5</td>
- <td>7</td>
- <td>20</td>
- <td>35</td>
- <td>92</td>
- </tr>
- </table>
- </li>
-
- </ol>
- <p>
- The performance results above were all derived from running the DebugDisabledPerformanceComparison,
- FilterPerformanceComparison, and PerformanceComparison junit tests which can be found in the
- Log4j 2 unit test source directory.
- </p>
- </section>
- </body>
-</document>
\ No newline at end of file