logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1470034 [1/2] - in /logging/log4j/log4j2/trunk: ./ src/site/xdoc/ taglib/ taglib/src/main/java/org/apache/logging/log4j/taglib/ taglib/src/test/ taglib/src/test/java/ taglib/src/test/java/org/ taglib/src/test/java/org/apache/ taglib/src/te...
Date Fri, 19 Apr 2013 20:46:15 GMT
Author: rgoers
Date: Fri Apr 19 20:46:14 2013
New Revision: 1470034

URL: http://svn.apache.org/r1470034
Log:
LOG4J2-187 - taglib documentation

Added:
    logging/log4j/log4j2/trunk/taglib/src/test/
    logging/log4j/log4j2/trunk/taglib/src/test/java/
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/CatchingTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/DebugTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/DumpTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/EntryTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ErrorTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ExceptionAwareTagSupportTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ExitTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/FatalTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/IfEnabledTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/InfoTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LogTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LoggerAwareTagSupportTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupportTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/SetLoggerTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/TraceTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/WarnTagTest.java
    logging/log4j/log4j2/trunk/taglib/src/test/resources/
    logging/log4j/log4j2/trunk/taglib/src/test/resources/log4j-test1.xml
Modified:
    logging/log4j/log4j2/trunk/pom.xml
    logging/log4j/log4j2/trunk/src/site/xdoc/build.xml.vm
    logging/log4j/log4j2/trunk/taglib/pom.xml
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/CatchingTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/DebugTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/DumpTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/EntryTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ErrorTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ExceptionAwareTagSupport.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ExitTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/FatalTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/IfEnabledTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/InfoTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LogTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LoggerAwareTagSupport.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupport.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/SetLoggerTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/TraceTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/WarnTag.java
    logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/package-info.java

Modified: logging/log4j/log4j2/trunk/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/pom.xml?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/pom.xml (original)
+++ logging/log4j/log4j2/trunk/pom.xml Fri Apr 19 20:46:14 2013
@@ -321,10 +321,18 @@
         <artifactId>maven-checkstyle-plugin</artifactId>
       </plugin>
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.0</version>
         <configuration>
           <source>${maven.compile.source}</source>
           <target>${maven.compile.target}</target>
+          <showDeprecation>true</showDeprecation>
+          <showWarnings>true</showWarnings>
+          <compilerArguments>
+            <Xmaxwarns>10000</Xmaxwarns>
+            <Xlint />
+          </compilerArguments>
         </configuration>
       </plugin>
       <plugin>

Modified: logging/log4j/log4j2/trunk/src/site/xdoc/build.xml.vm
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/xdoc/build.xml.vm?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/xdoc/build.xml.vm (original)
+++ logging/log4j/log4j2/trunk/src/site/xdoc/build.xml.vm Fri Apr 19 20:46:14 2013
@@ -41,7 +41,7 @@
       <subsection name="Using Log4J on your classpath">
        <p>
          To use Log4j 2 in your application make sure that both the API and Core jars are in the application's
-         classpath. Add the dependencies listed below to your classpath. 
+         classpath. Add the dependencies listed below to your classpath.
        </p>
        <ul>
          <li><code>log4j-api-${Log4jReleaseVersion}.jar</code></li>
@@ -53,7 +53,7 @@
       </subsection>
       <subsection name="Using Log4J in your Apache Maven build">
        <p>
-         To build with <a href="http://maven.apache.org/">Apache Maven</a>, add the dependencies listed below to your 
+         To build with <a href="http://maven.apache.org/">Apache Maven</a>, add the dependencies listed below to your
          <code>pom.xml</code> file.
        </p>
 <pre class="prettyprint linenums"><![CDATA[
@@ -68,7 +68,7 @@
     <artifactId>log4j-core</artifactId>
     <version>${Log4jReleaseVersion}</version>
   </dependency>
-</dependecies>
+</dependencies>
 ]]></pre>
       </subsection>
       <subsection name="Using Log4J in your Apache Ivy build">
@@ -80,7 +80,7 @@
 <dependencies>
   <dependency org="org.apache.logging.log4j" name="log4j-api" rev="${Log4jReleaseVersion}" />
   <dependency org="org.apache.logging.log4j" name="log4j-core" rev="${Log4jReleaseVersion}" />
-</dependecies>
+</dependencies>
 ]]></pre>
       </subsection>
       <subsection name="Optional Components">
@@ -112,7 +112,7 @@
     <artifactId>log4j-jcl</artifactId>
     <version>${Log4jReleaseVersion}</version>
   </dependency>
-</dependecies>
+</dependencies>
 ]]></pre>
           <h4>SLF4J</h4>
           <p>SLF4J is another popular logging API that may be bound to Log4j 2 by including the following
@@ -125,7 +125,21 @@
     <artifactId>log4j-slf4j-impl</artifactId>
     <version>${Log4jReleaseVersion}</version>
   </dependency>
-</dependecies>
+</dependencies>
+]]></pre>
+          <h4>Tag Library</h4>
+          <p>The Log4j Log Tag Library creates the capability of inserting log statements in JSPs without
+             the use of Java scripting. It uses the standard Log4j 2 API to log messages according to
+             your Log4j configuration.
+          </p>
+<pre class="prettyprint linenums"><![CDATA[
+<dependencies>
+  <dependency>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j-taglib</artifactId>
+    <version>${Log4jReleaseVersion}</version>
+  </dependency>
+</dependencies>
 ]]></pre>
       </subsection>
 		</section>

Modified: logging/log4j/log4j2/trunk/taglib/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/pom.xml?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/pom.xml (original)
+++ logging/log4j/log4j2/trunk/taglib/pom.xml Fri Apr 19 20:46:14 2013
@@ -39,6 +39,7 @@
     <log4jParentDir>${basedir}/..</log4jParentDir>
     <docLabel>Log4j Tag Library Documentation</docLabel>
     <projectDir>/taglib</projectDir>
+    <spring.version>3.1.2.RELEASE</spring.version>
   </properties>
   <dependencies>
     <dependency>
@@ -46,10 +47,6 @@
       <artifactId>log4j-api</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-core</artifactId>
-    </dependency>
-    <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
       <version>2.5</version>
@@ -64,6 +61,11 @@
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
@@ -72,6 +74,18 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-core</artifactId>
+      <version>${spring.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-test</artifactId>
+      <version>${spring.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <reporting>
     <plugins>
@@ -95,7 +109,6 @@
         <artifactId>maven-checkstyle-plugin</artifactId>
         <version>2.7</version>
         <configuration>
-          <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
           <configLocation>${log4jParentDir}/checkstyle.xml</configLocation>
           <suppressionsLocation>${log4jParentDir}/checkstyle-suppressions.xml</suppressionsLocation>
           <enableRulesSummary>false</enableRulesSummary>
@@ -185,7 +198,7 @@
         <version>2.2</version>
         <reportSets>
           <reportSet>
-            <!-- Disabled at it kills the site generation via a NoClassDefFoundError -->
+            <!-- Disabled as it kills the site generation via a NoClassDefFoundError -->
             <reports />
           </reportSet>
         </reportSets>

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/CatchingTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/CatchingTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/CatchingTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/CatchingTag.java Fri Apr 19 20:46:14 2013
@@ -27,6 +27,8 @@ import javax.servlet.jsp.tagext.Tag;
  * @since 2.0
  */
 public class CatchingTag extends ExceptionAwareTagSupport {
+    private static final long serialVersionUID = 1L;
+
     private static final String FQCN = CatchingTag.class.getName();
 
     private Level level;

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/DebugTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/DebugTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/DebugTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/DebugTag.java Fri Apr 19 20:46:14 2013
@@ -24,6 +24,8 @@ import org.apache.logging.log4j.Level;
  * @since 2.0
  */
 public class DebugTag extends LoggingMessageTagSupport {
+    private static final long serialVersionUID = 1L;
+
     @Override
     protected Level getLevel() {
         return Level.DEBUG;

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/DumpTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/DumpTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/DumpTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/DumpTag.java Fri Apr 19 20:46:14 2013
@@ -29,6 +29,8 @@ import java.util.Enumeration;
  * @since 2.0
  */
 public class DumpTag extends TagSupport {
+    private static final long serialVersionUID = 1L;
+
     private int scope;
 
     public DumpTag() {
@@ -55,7 +57,7 @@ public class DumpTag extends TagSupport 
         try {
             Enumeration<String> names = this.pageContext.getAttributeNamesInScope(this.scope);
             this.pageContext.getOut().write("<dl>");
-            while (names.hasMoreElements()) {
+            while (names != null && names.hasMoreElements()) {
                 String name = names.nextElement();
                 Object value = this.pageContext.getAttribute(name, this.scope);
 

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/EntryTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/EntryTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/EntryTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/EntryTag.java Fri Apr 19 20:46:14 2013
@@ -30,6 +30,8 @@ import java.util.List;
  * @since 2.0
  */
 public class EntryTag extends LoggerAwareTagSupport implements DynamicAttributes {
+    private static final long serialVersionUID = 1L;
+
     private static final String FQCN = EntryTag.class.getName();
 
     private List<Object> attributes;

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ErrorTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ErrorTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ErrorTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ErrorTag.java Fri Apr 19 20:46:14 2013
@@ -24,6 +24,8 @@ import org.apache.logging.log4j.Level;
  * @since 2.0
  */
 public class ErrorTag extends LoggingMessageTagSupport {
+    private static final long serialVersionUID = 1L;
+
     @Override
     protected Level getLevel() {
         return Level.ERROR;

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ExceptionAwareTagSupport.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ExceptionAwareTagSupport.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ExceptionAwareTagSupport.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ExceptionAwareTagSupport.java Fri Apr 19 20:46:14 2013
@@ -22,6 +22,8 @@ package org.apache.logging.log4j.taglib;
  * @since 2.0
  */
 abstract class ExceptionAwareTagSupport extends LoggerAwareTagSupport {
+    private static final long serialVersionUID = 1L;
+
     private Throwable exception;
 
     @Override

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ExitTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ExitTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ExitTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/ExitTag.java Fri Apr 19 20:46:14 2013
@@ -27,9 +27,11 @@ import javax.servlet.jsp.tagext.Tag;
  * @since 2.0
  */
 public class ExitTag extends LoggerAwareTagSupport {
+    private static final long serialVersionUID = 1L;
+
     private static final String FQCN = ExitTag.class.getName();
 
-    private Object result;
+    private transient Object result;
 
     @Override
     protected void init() {

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/FatalTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/FatalTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/FatalTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/FatalTag.java Fri Apr 19 20:46:14 2013
@@ -24,6 +24,8 @@ import org.apache.logging.log4j.Level;
  * @since 2.0
  */
 public class FatalTag extends LoggingMessageTagSupport {
+    private static final long serialVersionUID = 1L;
+
     @Override
     protected Level getLevel() {
         return Level.FATAL;

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/IfEnabledTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/IfEnabledTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/IfEnabledTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/IfEnabledTag.java Fri Apr 19 20:46:14 2013
@@ -28,7 +28,9 @@ import javax.servlet.jsp.tagext.Tag;
  * @since 2.0
  */
 public class IfEnabledTag extends LoggerAwareTagSupport {
-    private Object level;
+    private static final long serialVersionUID = 1L;
+
+    private transient Object level;
 
     private Marker marker;
 

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/InfoTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/InfoTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/InfoTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/InfoTag.java Fri Apr 19 20:46:14 2013
@@ -24,6 +24,8 @@ import org.apache.logging.log4j.Level;
  * @since 2.0
  */
 public class InfoTag extends LoggingMessageTagSupport {
+    private static final long serialVersionUID = 1L;
+
     @Override
     protected Level getLevel() {
         return Level.INFO;

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/Log4jTaglibLoggerContext.java Fri Apr 19 20:46:14 2013
@@ -24,8 +24,7 @@ import org.apache.logging.log4j.spi.Abst
 import org.apache.logging.log4j.spi.LoggerContext;
 
 import javax.servlet.ServletContext;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
+import java.util.WeakHashMap;
 
 /**
  * This bridge between the tag library and the Log4j API ensures that instances of {@link Log4jTaglibLogger} are
@@ -34,11 +33,13 @@ import java.util.concurrent.ConcurrentMa
  * @since 2.0
  */
 final class Log4jTaglibLoggerContext implements LoggerContext {
-    private static final ConcurrentMap<ServletContext, Log4jTaglibLoggerContext> CONTEXTS =
-            new ConcurrentHashMap<ServletContext, Log4jTaglibLoggerContext>();
+    // These were change to WeakHashMaps to avoid ClassLoader (memory) leak, something that's particularly
+    // important in Servlet containers.
+    private static final WeakHashMap<ServletContext, Log4jTaglibLoggerContext> CONTEXTS =
+            new WeakHashMap<ServletContext, Log4jTaglibLoggerContext>();
 
-    private final ConcurrentMap<String, Log4jTaglibLogger> loggers =
-            new ConcurrentHashMap<String, Log4jTaglibLogger>();
+    private final WeakHashMap<String, Log4jTaglibLogger> loggers =
+            new WeakHashMap<String, Log4jTaglibLogger>();
 
     private final ServletContext servletContext;
 
@@ -61,15 +62,22 @@ final class Log4jTaglibLoggerContext imp
             return logger;
         }
 
-        // wrap a logger from an underlying implementation
-        Logger original = factory == null ? LogManager.getLogger(name) : LogManager.getLogger(name, factory);
-        if (original instanceof AbstractLogger) {
-            logger = new Log4jTaglibLogger((AbstractLogger) original, name, original.getMessageFactory());
-            Log4jTaglibLogger existing = this.loggers.putIfAbsent(name, logger);
-            return existing == null ? logger : existing;
+        synchronized (this.loggers) {
+            logger = this.loggers.get(name);
+            if (logger == null) {
+                Logger original = factory == null ? LogManager.getLogger(name) : LogManager.getLogger(name, factory);
+                if (!(original instanceof AbstractLogger)) {
+                    throw new LoggingException(
+                            "Log4j Tag Library requires base logging system to extend Log4j AbstractLogger."
+                    );
+                }
+                // wrap a logger from an underlying implementation
+                logger = new Log4jTaglibLogger((AbstractLogger) original, name, original.getMessageFactory());
+                this.loggers.put(name, logger);
+            }
         }
 
-        throw new LoggingException("Log4j Tag Library requires base logging system to extend Log4j AbstractLogger.");
+        return logger;
     }
 
     public boolean hasLogger(String name) {
@@ -77,12 +85,19 @@ final class Log4jTaglibLoggerContext imp
     }
 
     static synchronized Log4jTaglibLoggerContext getInstance(ServletContext servletContext) {
-        if (CONTEXTS.containsKey(servletContext)) {
-            return CONTEXTS.get(servletContext);
+        Log4jTaglibLoggerContext loggerContext = CONTEXTS.get(servletContext);
+        if (loggerContext != null) {
+            return loggerContext;
         }
 
-        Log4jTaglibLoggerContext context = new Log4jTaglibLoggerContext(servletContext);
-        Log4jTaglibLoggerContext existing = CONTEXTS.putIfAbsent(servletContext, context);
-        return existing == null ? context : existing;
+        synchronized (CONTEXTS) {
+            loggerContext = CONTEXTS.get(servletContext);
+            if (loggerContext == null) {
+                loggerContext = new Log4jTaglibLoggerContext(servletContext);
+                CONTEXTS.put(servletContext, loggerContext);
+            }
+        }
+
+        return loggerContext;
     }
 }

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LogTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LogTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LogTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LogTag.java Fri Apr 19 20:46:14 2013
@@ -24,6 +24,8 @@ import org.apache.logging.log4j.Level;
  * @since 2.0
  */
 public class LogTag extends LoggingMessageTagSupport {
+    private static final long serialVersionUID = 1L;
+
     private Level level;
 
     @Override

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LoggerAwareTagSupport.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LoggerAwareTagSupport.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LoggerAwareTagSupport.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LoggerAwareTagSupport.java Fri Apr 19 20:46:14 2013
@@ -26,8 +26,11 @@ import javax.servlet.jsp.tagext.BodyTagS
  * @since 2.0
  */
 abstract class LoggerAwareTagSupport extends BodyTagSupport {
-    private Log4jTaglibLoggerContext loggerContext;
-    private Object logger;
+    private static final long serialVersionUID = 1L;
+
+    private transient Log4jTaglibLoggerContext loggerContext;
+
+    private transient Object logger;
 
     protected LoggerAwareTagSupport() {
         this.init();
@@ -44,7 +47,7 @@ abstract class LoggerAwareTagSupport ext
     }
 
     @Override
-    public void setPageContext(PageContext pageContext) {
+    public final void setPageContext(PageContext pageContext) {
         super.setPageContext(pageContext);
         this.loggerContext = Log4jTaglibLoggerContext.getInstance(pageContext.getServletContext());
     }

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupport.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupport.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupport.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupport.java Fri Apr 19 20:46:14 2013
@@ -33,9 +33,11 @@ import java.util.List;
  * @since 2.0
  */
 abstract class LoggingMessageTagSupport extends ExceptionAwareTagSupport implements DynamicAttributes {
+    private static final long serialVersionUID = 1L;
+
     private static final String FQCN = LoggingMessageTagSupport.class.getName();
 
-    private Object message;
+    private transient Object message;
 
     private Marker marker;
 

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/SetLoggerTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/SetLoggerTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/SetLoggerTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/SetLoggerTag.java Fri Apr 19 20:46:14 2013
@@ -29,11 +29,13 @@ import javax.servlet.jsp.tagext.Tag;
  * @since 2.0
  */
 public class SetLoggerTag extends BodyTagSupport {
-    private Log4jTaglibLoggerContext loggerContext;
+    private static final long serialVersionUID = 1L;
 
-    private Object logger;
+    private transient Log4jTaglibLoggerContext loggerContext;
 
-    private MessageFactory factory;
+    private transient Object logger;
+
+    private transient MessageFactory factory;
 
     private String var;
 

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/TraceTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/TraceTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/TraceTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/TraceTag.java Fri Apr 19 20:46:14 2013
@@ -24,6 +24,8 @@ import org.apache.logging.log4j.Level;
  * @since 2.0
  */
 public class TraceTag extends LoggingMessageTagSupport {
+    private static final long serialVersionUID = 1L;
+
     @Override
     protected Level getLevel() {
         return Level.TRACE;

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/WarnTag.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/WarnTag.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/WarnTag.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/WarnTag.java Fri Apr 19 20:46:14 2013
@@ -24,6 +24,8 @@ import org.apache.logging.log4j.Level;
  * @since 2.0
  */
 public class WarnTag extends LoggingMessageTagSupport {
+    private static final long serialVersionUID = 1L;
+
     @Override
     protected Level getLevel() {
         return Level.WARN;

Modified: logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/package-info.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/package-info.java?rev=1470034&r1=1470033&r2=1470034&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/package-info.java (original)
+++ logging/log4j/log4j2/trunk/taglib/src/main/java/org/apache/logging/log4j/taglib/package-info.java Fri Apr 19 20:46:14 2013
@@ -19,4 +19,4 @@
  +
  +  @since 2.0
  */
-package org.apache.logging.log4j.taglib;
\ No newline at end of file
+package org.apache.logging.log4j.taglib;

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/CatchingTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/CatchingTagTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/CatchingTagTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/CatchingTagTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+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.LoggerContext;
+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.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.mock.web.MockPageContext;
+
+import javax.servlet.jsp.tagext.Tag;
+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 CatchingTagTest {
+    private static final String CONFIG = "log4j-test1.xml";
+
+    @BeforeClass
+    public static void setUpClass() {
+        System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
+        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
+        context.getConfiguration();
+    }
+
+    @AfterClass
+    public static void cleanUpClass() {
+        System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
+        context.reconfigure();
+        StatusLogger.getLogger().reset();
+    }
+
+    private Logger logger = LogManager.getLogger("LoggingMessageTagSupportTestLogger");
+    private CatchingTag tag;
+
+    @Before
+    public void setUp() {
+        this.tag = new CatchingTag();
+        this.tag.setPageContext(new MockPageContext());
+        this.tag.setLogger(this.logger);
+    }
+
+    @Test
+    public void testDoEndTag() throws Exception {
+        this.tag.setException(new Exception("This is a test."));
+
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
+        verify("catching ERROR M-CATCHING[ EXCEPTION ] E java.lang.Exception: This is a test.");
+    }
+
+    @Test
+    public void testDoEndTagLevelString() throws Exception {
+        this.tag.setLevel("info");
+        this.tag.setException(new RuntimeException("This is another test."));
+
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
+        verify("catching INFO M-CATCHING[ EXCEPTION ] E java.lang.RuntimeException: This is another test.");
+    }
+
+    @Test
+    public void testDoEndTagLevelObject() throws Exception {
+        this.tag.setLevel(Level.WARN);
+        this.tag.setException(new Error("This is the last test."));
+
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
+        verify("catching WARN M-CATCHING[ EXCEPTION ] E java.lang.Error: This is the last test.");
+    }
+
+    private void verify(final String expected) {
+        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+        final Map<String, Appender<?>> list = ctx.getConfiguration().getAppenders();
+        final Appender<?> listApp = list.get("List");
+        assertNotNull("Missing Appender", listApp);
+        assertTrue("Not a ListAppender", listApp instanceof ListAppender);
+        final List<String> events = ((ListAppender) listApp).getMessages();
+        try
+        {
+            assertEquals("Incorrect number of messages.", 1, events.size());
+            assertEquals("Incorrect message.", "o.a.l.l.t.CatchingTagTest " + expected, events.get(0));
+        }
+        finally
+        {
+            ((ListAppender) listApp).clear();
+        }
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/DebugTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/DebugTagTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/DebugTagTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/DebugTagTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ *
+ */
+public class DebugTagTest {
+    @Test
+    public void testGetLevel() {
+        assertEquals("The logging level is not correct.", Level.DEBUG, new DebugTag().getLevel());
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/DumpTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/DumpTagTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/DumpTagTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/DumpTagTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.mock.web.MockJspWriter;
+import org.springframework.mock.web.MockPageContext;
+
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.Tag;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ *
+ */
+public class DumpTagTest {
+    private static final Charset UTF8 = Charset.forName("UTF-8");
+    private Writer writer;
+    private ByteArrayOutputStream output;
+    private MockPageContext context;
+    private DumpTag tag;
+
+    @Before
+    public void setUp() {
+        this.output = new ByteArrayOutputStream();
+        this.writer = new OutputStreamWriter(this.output, UTF8);
+
+        this.context = new MockPageContext() {
+            private MockJspWriter jspWriter = new MockJspWriter(writer);
+            @Override
+            public JspWriter getOut() {
+                return this.jspWriter;
+            }
+        };
+
+        this.tag = new DumpTag();
+        this.tag.setPageContext(this.context);
+    }
+
+    @Test
+    public void testDoEndTagDefaultPageScopeNoAttributes() throws Exception {
+        int returnValue = this.tag.doEndTag();
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
+
+        this.writer.flush();
+        String output = new String(this.output.toByteArray(), UTF8);
+        assertEquals("The output is not correct.", "<dl></dl>", output);
+    }
+
+    @Test
+    public void testDoEndTagDefaultPageScope() throws Exception {
+        this.context.setAttribute("testAttribute01", "testValue01", PageContext.PAGE_SCOPE);
+        this.context.setAttribute("anotherAttribute02", "finalValue02", PageContext.PAGE_SCOPE);
+        this.context.setAttribute("badAttribute03", "skippedValue03", PageContext.SESSION_SCOPE);
+
+        int returnValue = this.tag.doEndTag();
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
+
+        this.writer.flush();
+        String output = new String(this.output.toByteArray(), UTF8);
+        assertEquals("The output is not correct.",
+                "<dl>" +
+                        "<dt><code>testAttribute01</code></dt><dd><code>testValue01</code></dd>" +
+                        "<dt><code>anotherAttribute02</code></dt><dd><code>finalValue02</code></dd>" +
+                        "</dl>", output);
+    }
+
+    @Test
+    public void testDoEndTagSessionScopeNoAttributes() throws Exception {
+        this.context.setAttribute("badAttribute01", "skippedValue01", PageContext.PAGE_SCOPE);
+
+        this.tag.setScope("session");
+        int returnValue = this.tag.doEndTag();
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
+
+        this.writer.flush();
+        String output = new String(this.output.toByteArray(), UTF8);
+        assertEquals("The output is not correct.", "<dl></dl>", output);
+    }
+
+    @Test
+    public void testDoEndTagSessionScope() throws Exception {
+        this.context.setAttribute("otherAttribute03", "lostValue03", PageContext.PAGE_SCOPE);
+        this.context.setAttribute("coolAttribute01", "weirdValue01", PageContext.SESSION_SCOPE);
+        this.context.setAttribute("testAttribute02", "testValue02", PageContext.SESSION_SCOPE);
+
+        this.tag.setScope("session");
+        int returnValue = this.tag.doEndTag();
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);
+
+        this.writer.flush();
+        String output = new String(this.output.toByteArray(), UTF8);
+        assertEquals("The output is not correct.",
+                "<dl>" +
+                        "<dt><code>coolAttribute01</code></dt><dd><code>weirdValue01</code></dd>" +
+                        "<dt><code>testAttribute02</code></dt><dd><code>testValue02</code></dd>" +
+                        "</dl>", output);
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/EntryTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/EntryTagTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/EntryTagTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/EntryTagTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+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.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.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.mock.web.MockPageContext;
+
+import javax.servlet.jsp.tagext.Tag;
+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 EntryTagTest {
+    private static final String CONFIG = "log4j-test1.xml";
+
+    @BeforeClass
+    public static void setUpClass() {
+        System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
+        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
+        context.getConfiguration();
+    }
+
+    @AfterClass
+    public static void cleanUpClass() {
+        System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
+        context.reconfigure();
+        StatusLogger.getLogger().reset();
+    }
+
+    private Logger logger = LogManager.getLogger("LoggingMessageTagSupportTestLogger");
+    private EntryTag tag;
+
+    @Before
+    public void setUp() {
+        this.tag = new EntryTag();
+        this.tag.setPageContext(new MockPageContext());
+        this.tag.setLogger(this.logger);
+    }
+
+    @Test
+    public void testDoEndTag() throws Exception {
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
+        verify("entry TRACE M-ENTRY[ FLOW ] E");
+    }
+
+    @Test
+    public void testDoEndTagAttributes() throws Exception {
+        this.tag.setDynamicAttribute(null, null, CONFIG);
+        this.tag.setDynamicAttribute(null, null, 5792);
+
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
+        verify("entry params(log4j-test1.xml, 5792) TRACE M-ENTRY[ FLOW ] E");
+    }
+
+    private void verify(final String expected) {
+        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+        final Map<String, Appender<?>> list = ctx.getConfiguration().getAppenders();
+        final Appender<?> listApp = list.get("List");
+        assertNotNull("Missing Appender", listApp);
+        assertTrue("Not a ListAppender", listApp instanceof ListAppender);
+        final List<String> events = ((ListAppender) listApp).getMessages();
+        try
+        {
+            assertEquals("Incorrect number of messages.", 1, events.size());
+            assertEquals("Incorrect message.", "o.a.l.l.t.EntryTagTest " + expected, events.get(0));
+        }
+        finally
+        {
+            ((ListAppender) listApp).clear();
+        }
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ErrorTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ErrorTagTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ErrorTagTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ErrorTagTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ *
+ */
+public class ErrorTagTest {
+    @Test
+    public void testGetLevel() {
+        assertEquals("The logging level is not correct.", Level.ERROR, new ErrorTag().getLevel());
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ExceptionAwareTagSupportTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ExceptionAwareTagSupportTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ExceptionAwareTagSupportTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ExceptionAwareTagSupportTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+
+/**
+ *
+ */
+public class ExceptionAwareTagSupportTest {
+    private ExceptionAwareTagSupport tag;
+
+    @Before
+    public void setUp() {
+        this.tag = new ExceptionAwareTagSupport() {
+            private static final long serialVersionUID = 1L;
+        };
+    }
+
+    @Test
+    public void testException() {
+        assertNull("The exception should be null (1).", this.tag.getException());
+
+        Exception e = new Exception();
+        this.tag.setException(e);
+        assertSame("The exception is not correct (1).", e, this.tag.getException());
+
+        this.tag.init();
+        assertNull("The exception should be null (2).", this.tag.getException());
+
+        e = new RuntimeException();
+        this.tag.setException(e);
+        assertSame("The exception is not correct (2).", e, this.tag.getException());
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ExitTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ExitTagTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ExitTagTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/ExitTagTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+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.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.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.mock.web.MockPageContext;
+
+import javax.servlet.jsp.tagext.Tag;
+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 ExitTagTest {
+    private static final String CONFIG = "log4j-test1.xml";
+
+    @BeforeClass
+    public static void setUpClass() {
+        System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
+        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
+        context.getConfiguration();
+    }
+
+    @AfterClass
+    public static void cleanUpClass() {
+        System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
+        context.reconfigure();
+        StatusLogger.getLogger().reset();
+    }
+
+    private Logger logger = LogManager.getLogger("LoggingMessageTagSupportTestLogger");
+    private ExitTag tag;
+
+    @Before
+    public void setUp() {
+        this.tag = new ExitTag();
+        this.tag.setPageContext(new MockPageContext());
+        this.tag.setLogger(this.logger);
+    }
+
+    @Test
+    public void testDoEndTag() throws Exception {
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
+        verify("exit TRACE M-EXIT[ FLOW ] E");
+    }
+
+    @Test
+    public void testDoEndTagResult01() throws Exception {
+        this.tag.setResult(CONFIG);
+
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
+        verify("exit with(log4j-test1.xml) TRACE M-EXIT[ FLOW ] E");
+    }
+
+    @Test
+    public void testDoEndTagResult02() throws Exception {
+        this.tag.setResult(5792);
+
+        assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
+        verify("exit with(5792) TRACE M-EXIT[ FLOW ] E");
+    }
+
+    private void verify(final String expected) {
+        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+        final Map<String, Appender<?>> list = ctx.getConfiguration().getAppenders();
+        final Appender<?> listApp = list.get("List");
+        assertNotNull("Missing Appender", listApp);
+        assertTrue("Not a ListAppender", listApp instanceof ListAppender);
+        final List<String> events = ((ListAppender) listApp).getMessages();
+        try
+        {
+            assertEquals("Incorrect number of messages.", 1, events.size());
+            assertEquals("Incorrect message.", "o.a.l.l.t.ExitTagTest " + expected, events.get(0));
+        }
+        finally
+        {
+            ((ListAppender) listApp).clear();
+        }
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/FatalTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/FatalTagTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/FatalTagTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/FatalTagTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ *
+ */
+public class FatalTagTest {
+    @Test
+    public void testGetLevel() {
+        assertEquals("The logging level is not correct.", Level.FATAL, new FatalTag().getLevel());
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/IfEnabledTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/IfEnabledTagTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/IfEnabledTagTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/IfEnabledTagTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.MarkerManager;
+import org.apache.logging.log4j.core.LoggerContext;
+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.springframework.mock.web.MockPageContext;
+
+import javax.servlet.jsp.tagext.Tag;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ *
+ */
+public class IfEnabledTagTest {
+    private static final String CONFIG = "log4j-test1.xml";
+
+    @BeforeClass
+    public static void setUpClass() {
+        System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
+        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
+        context.getConfiguration();
+    }
+
+    @AfterClass
+    public static void cleanUpClass() {
+        System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
+        context.reconfigure();
+        StatusLogger.getLogger().reset();
+    }
+
+    private Logger logger = LogManager.getLogger("IfEnabledTagTest");
+    private IfEnabledTag tag;
+
+    @Before
+    public void setUp() {
+        this.tag = new IfEnabledTag();
+        this.tag.setPageContext(new MockPageContext());
+        this.tag.setLogger(this.logger);
+    }
+
+    @Test
+    public void testDoStartTagEnabledString() throws Exception {
+        this.tag.setLevel("warn");
+
+        assertEquals("The return value is not correct.", Tag.EVAL_BODY_INCLUDE, this.tag.doStartTag());
+    }
+
+    @Test
+    public void testDoStartTagEnabledLevel() throws Exception {
+        this.tag.setLevel(Level.WARN);
+
+        assertEquals("The return value is not correct.", Tag.EVAL_BODY_INCLUDE, this.tag.doStartTag());
+    }
+
+    @Test
+    public void testDoStartTagEnabledStringMarker() throws Exception {
+        this.tag.setMarker(MarkerManager.getMarker("E01"));
+        this.tag.setLevel("error");
+
+        assertEquals("The return value is not correct.", Tag.EVAL_BODY_INCLUDE, this.tag.doStartTag());
+    }
+
+    @Test
+    public void testDoStartTagEnabledLevelMarker() throws Exception {
+        this.tag.setMarker(MarkerManager.getMarker("F02"));
+        this.tag.setLevel(Level.ERROR);
+
+        assertEquals("The return value is not correct.", Tag.EVAL_BODY_INCLUDE, this.tag.doStartTag());
+    }
+
+    @Test
+    public void testDoStartTagDisabledString() throws Exception {
+        this.tag.setLevel("info");
+
+        assertEquals("The return value is not correct.", Tag.SKIP_BODY, this.tag.doStartTag());
+    }
+
+    @Test
+    public void testDoStartTagDisabledLevel() throws Exception {
+        this.tag.setLevel(Level.INFO);
+
+        assertEquals("The return value is not correct.", Tag.SKIP_BODY, this.tag.doStartTag());
+    }
+
+    @Test
+    public void testDoStartTagDisabledStringMarker() throws Exception {
+        this.tag.setMarker(MarkerManager.getMarker("E01"));
+        this.tag.setLevel("trace");
+
+        assertEquals("The return value is not correct.", Tag.SKIP_BODY, this.tag.doStartTag());
+    }
+
+    @Test
+    public void testDoStartTagDisabledLevelMarker() throws Exception {
+        this.tag.setMarker(MarkerManager.getMarker("F02"));
+        this.tag.setLevel(Level.TRACE);
+
+        assertEquals("The return value is not correct.", Tag.SKIP_BODY, this.tag.doStartTag());
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/InfoTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/InfoTagTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/InfoTagTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/InfoTagTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ *
+ */
+public class InfoTagTest {
+    @Test
+    public void testGetLevel() {
+        assertEquals("The logging level is not correct.", Level.INFO, new InfoTag().getLevel());
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LogTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LogTagTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LogTagTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LogTagTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+
+/**
+ *
+ */
+public class LogTagTest {
+    private LogTag tag;
+
+    @Before
+    public void setUp() {
+        this.tag = new LogTag();
+    }
+
+    @Test
+    public void testLevel() {
+        assertNull("The level should be null (1).", this.tag.getLevel());
+
+        this.tag.setLevel(Level.INFO);
+        assertEquals("The level is not correct (1).", Level.INFO, this.tag.getLevel());
+
+        this.tag.init();
+        assertNull("The level should be null (2).", this.tag.getLevel());
+
+        this.tag.setLevel("WARN");
+        assertEquals("The level is not correct (2).", Level.WARN, this.tag.getLevel());
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LoggerAwareTagSupportTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LoggerAwareTagSupportTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LoggerAwareTagSupportTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LoggerAwareTagSupportTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.spi.AbstractLogger;
+import org.junit.Test;
+import org.springframework.mock.web.MockPageContext;
+
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class LoggerAwareTagSupportTest {
+    private MockPageContext context;
+    private LoggerAwareTagSupport tag;
+
+    private void setUp(final Object page) {
+        this.context = new MockPageContext() {
+            @Override
+            public Object getPage() {
+                return page == null ? this : page;
+            }
+        };
+        this.tag = new LoggerAwareTagSupport() {
+            private static final long serialVersionUID = 1L;
+        };
+        this.tag.setPageContext(this.context);
+    }
+
+    @Test
+    public void testGetLoggerWithGenericLogger() throws Exception {
+        this.setUp(null);
+
+        Logger logger = LogManager.getLogger("testGetLoggerWithGenericLogger");
+
+        this.tag.setLogger(logger);
+        Log4jTaglibLogger returned = this.tag.getLogger();
+
+        assertNotNull("The first returned logger should not be null.", returned);
+        assertNotSame("The first returned logger should not be the same as the set.", logger, returned);
+        assertEquals("The name is not correct.", "testGetLoggerWithGenericLogger", returned.getName());
+
+        Log4jTaglibLogger returned2 = this.tag.getLogger();
+
+        assertNotNull("The second returned logger should not be null.", returned2);
+        assertSame("The second returned logger should be the same as the first.", returned, returned2);
+
+        this.tag.release();
+
+        Log4jTaglibLogger returned3 = this.tag.getLogger();
+
+        assertNotNull("The third returned logger should not be null.", returned3);
+        assertNotSame("The third returned logger should not be the same as the first.", returned, returned3);
+    }
+
+    @Test
+    public void testGetLoggerWithTaglibLogger() throws Exception {
+        this.setUp(null);
+
+        AbstractLogger wrapped = (AbstractLogger)LogManager.getLogger("testGetLoggerWithTaglibLogger");
+        Log4jTaglibLogger logger = new Log4jTaglibLogger(wrapped, wrapped.getName(), wrapped.getMessageFactory());
+
+        this.tag.setLogger(logger);
+        Log4jTaglibLogger returned = this.tag.getLogger();
+
+        assertNotNull("The first returned logger should not be null.", returned);
+        assertSame("The first returned logger should be the same as the set.", logger, returned);
+        assertEquals("The name is not correct.", "testGetLoggerWithTaglibLogger", returned.getName());
+
+        returned = this.tag.getLogger();
+
+        assertNotNull("The second returned logger should not be null.", returned);
+        assertSame("The second returned logger should be the same as the set.", logger, returned);
+    }
+
+    @Test
+    public void testGetLoggerWithStringLogger() throws Exception {
+        this.setUp(null);
+
+        this.tag.setLogger("testGetLoggerWithStringLogger");
+        Log4jTaglibLogger returned = this.tag.getLogger();
+
+        assertNotNull("The first returned logger should not be null.", returned);
+        assertEquals("The name is not correct.", "testGetLoggerWithStringLogger", returned.getName());
+
+        Log4jTaglibLogger returned2 = this.tag.getLogger();
+
+        assertNotNull("The second returned logger should not be null.", returned2);
+        assertSame("The second returned logger should be the same as the first.", returned, returned2);
+    }
+
+    @Test
+    public void testGetDefaultLogger01() throws Exception {
+        Object page = new Object() {};
+        this.setUp(page);
+
+        assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
+
+        Log4jTaglibLogger returned = this.tag.getLogger();
+        assertNotNull("The first returned logger should not be null.", returned);
+        assertEquals("The logger name is not correct.", page.getClass().getName(), returned.getName());
+
+        Log4jTaglibLogger defaultLogger = TagUtils.getDefaultLogger(this.context);
+        assertNotNull("The default logger should not be null anymore.", defaultLogger);
+        assertSame("The default logger should be the same as the returned logger.", returned, defaultLogger);
+
+        Log4jTaglibLogger returned2 = this.tag.getLogger();
+
+        assertNotNull("The second returned logger should not be null.", returned2);
+        assertSame("The second returned logger should be the same as the first.", returned, returned2);
+    }
+
+    @Test
+    public void testGetDefaultLogger02() throws Exception {
+        Object page = new Object() {};
+        this.setUp(page);
+
+        assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
+
+        Log4jTaglibLogger returned = this.tag.getLogger();
+        assertNotNull("The first returned logger should not be null.", returned);
+        assertEquals("The logger name is not correct.", page.getClass().getName(), returned.getName());
+
+        Log4jTaglibLogger defaultLogger = TagUtils.getDefaultLogger(this.context);
+        assertNotNull("The default logger should not be null anymore.", defaultLogger);
+        assertSame("The default logger should be the same as the returned logger.", returned, defaultLogger);
+
+        Log4jTaglibLogger returned2 = this.tag.getLogger();
+
+        assertNotNull("The second returned logger should not be null.", returned2);
+        assertSame("The second returned logger should be the same as the first.", returned, returned2);
+    }
+}

Added: logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupportTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupportTest.java?rev=1470034&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupportTest.java (added)
+++ logging/log4j/log4j2/trunk/taglib/src/test/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupportTest.java Fri Apr 19 20:46:14 2013
@@ -0,0 +1,326 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.taglib;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.MarkerManager;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.LoggerContext;
+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 org.springframework.mock.web.MockBodyContent;
+import org.springframework.mock.web.MockPageContext;
+
+import javax.servlet.jsp.tagext.BodyTag;
+import java.io.Writer;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class LoggingMessageTagSupportTest {
+    private static final String CONFIG = "log4j-test1.xml";
+
+    @BeforeClass
+    public static void setUpClass() {
+        System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
+        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
+        context.getConfiguration();
+    }
+
+    @AfterClass
+    public static void cleanUpClass() {
+        System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
+        context.reconfigure();
+        StatusLogger.getLogger().reset();
+    }
+
+    private Logger logger = LogManager.getLogger("LoggingMessageTagSupportTestLogger");
+    private LoggingMessageTagSupport tag;
+
+    private void setUp(final Level level) {
+        this.tag = new LoggingMessageTagSupport() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            protected Level getLevel() {
+                return level;
+            }
+        };
+        this.tag.setPageContext(new MockPageContext());
+        this.tag.setLogger(this.logger);
+    }
+
+    @Test
+    public void testDoStartTag() {
+        this.setUp(null);
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_BODY_BUFFERED, this.tag.doStartTag());
+    }
+
+    @Test
+    public void testMessageString() throws Exception {
+        this.setUp(null);
+
+        this.tag.setMessage("This is my message 01.");
+
+        assertEquals("The message is not correct.", "This is my message 01.", this.tag.getMessage());
+    }
+
+    @Test
+    public void testMessageObject() throws Exception {
+        this.setUp(null);
+
+        Object message = new Object();
+        this.tag.setMessage(message);
+
+        assertSame("The message is not correct.", message, this.tag.getMessage());
+    }
+
+    @Test
+    public void testMessageBody() throws Exception {
+        this.setUp(null);
+
+        MockBodyContent content = new MockBodyContent("This is the body content 01.", (Writer)null);
+        this.tag.setBodyContent(content);
+
+        assertEquals("The message is not correct.", "This is the body content 01.", this.tag.getMessage());
+    }
+
+    @Test
+    public void testMessageStringBodyIgnored() throws Exception {
+        this.setUp(null);
+
+        MockBodyContent content = new MockBodyContent("This is more body content 02.", (Writer)null);
+        this.tag.setBodyContent(content);
+        this.tag.setMessage("This is another message 02.");
+
+        assertEquals("The message is not correct.", "This is another message 02.", this.tag.getMessage());
+    }
+
+    @Test
+    public void testDoEndTagStringMessageNoMarkerNoException() throws Exception {
+        this.setUp(Level.WARN);
+
+        this.tag.setMessage("Hello message for testDoEndTagStringMessageNoMarkerNoException");
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Hello message for testDoEndTagStringMessageNoMarkerNoException WARN M- E");
+    }
+
+    @Test
+    public void testDoEndTagStringMessageMarkerNoException() throws Exception {
+        this.setUp(Level.INFO);
+
+        this.tag.setMarker(MarkerManager.getMarker("E01"));
+        this.tag.setMessage("Goodbye message for testDoEndTagStringMessageMarkerNoException");
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Goodbye message for testDoEndTagStringMessageMarkerNoException INFO M-E01 E");
+    }
+
+    @Test
+    public void testDoEndTagStringMessageNoMarkerException() throws Exception {
+        this.setUp(Level.ERROR);
+
+        this.tag.setException(new Exception("This is a test"));
+        this.tag.setMessage("Another message for testDoEndTagStringMessageNoMarkerException");
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Another message for testDoEndTagStringMessageNoMarkerException ERROR M- E java.lang.Exception: This is a test");
+    }
+
+    @Test
+    public void testDoEndTagStringMessageMarkerException() throws Exception {
+        this.setUp(Level.TRACE);
+
+        this.tag.setException(new RuntimeException("This is another test"));
+        this.tag.setMarker(MarkerManager.getMarker("F02"));
+        this.tag.setMessage("Final message for testDoEndTagStringMessageMarkerException");
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Final message for testDoEndTagStringMessageMarkerException TRACE M-F02 E java.lang.RuntimeException: This is another test");
+    }
+
+    @Test
+    public void testDoEndTagStringWithParameters() throws Exception {
+        this.setUp(Level.FATAL);
+
+        this.tag.setDynamicAttribute(null, null, "A");
+        this.tag.setDynamicAttribute(null, null, TimeUnit.HOURS);
+        this.tag.setMessage("Test message with [{}] parameter of [{}]");
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Test message with [A] parameter of [HOURS] FATAL M- E");
+
+    }
+
+    @Test
+    public void testDoEndTagStringWithParametersMarkerAndException() throws Exception {
+        this.setUp(Level.DEBUG);
+
+        this.tag.setException(new Error("This is the last test"));
+        this.tag.setMarker(MarkerManager.getMarker("N03"));
+        this.tag.setDynamicAttribute(null, null, "Z");
+        this.tag.setDynamicAttribute(null, null, TimeUnit.SECONDS);
+        this.tag.setMessage("Final message with [{}] parameter of [{}]");
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Final message with [Z] parameter of [SECONDS] DEBUG M-N03 E java.lang.Error: This is the last test");
+
+    }
+
+    @Test
+    public void testDoEndTagMessageNoMarkerNoException() throws Exception {
+        this.setUp(Level.INFO);
+
+        this.tag.setMessage(
+                logger.getMessageFactory().newMessage("First message for testDoEndTagMessageNoMarkerNoException")
+        );
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("First message for testDoEndTagMessageNoMarkerNoException INFO M- E");
+    }
+
+    @Test
+    public void testDoEndTagMessageMarkerNoException() throws Exception {
+        this.setUp(Level.WARN);
+
+        this.tag.setMarker(MarkerManager.getMarker("E01"));
+        this.tag.setMessage(
+                logger.getMessageFactory().newMessage("Another message for testDoEndTagMessageMarkerNoException")
+        );
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Another message for testDoEndTagMessageMarkerNoException WARN M-E01 E");
+    }
+
+    @Test
+    public void testDoEndTagMessageNoMarkerException() throws Exception {
+        this.setUp(Level.TRACE);
+
+        this.tag.setException(new Exception("This is a test"));
+        this.tag.setMessage(
+                logger.getMessageFactory().newMessage("Third message for testDoEndTagMessageNoMarkerException")
+        );
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Third message for testDoEndTagMessageNoMarkerException TRACE M- E java.lang.Exception: This is a test");
+    }
+
+    @Test
+    public void testDoEndTagMessageMarkerException() throws Exception {
+        this.setUp(Level.ERROR);
+
+        this.tag.setException(new RuntimeException("This is another test"));
+        this.tag.setMarker(MarkerManager.getMarker("F02"));
+        this.tag.setMessage(
+                logger.getMessageFactory().newMessage("Final message for testDoEndTagMessageMarkerException")
+        );
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Final message for testDoEndTagMessageMarkerException ERROR M-F02 E java.lang.RuntimeException: " +
+                "This is another test");
+    }
+
+    @Test
+    public void testDoEndTagObjectNoMarkerNoException() throws Exception {
+        this.setUp(Level.INFO);
+
+        this.tag.setMessage(new MyMessage("First message for testDoEndTagObjectNoMarkerNoException"));
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("First message for testDoEndTagObjectNoMarkerNoException INFO M- E");
+    }
+
+    @Test
+    public void testDoEndTagObjectMarkerNoException() throws Exception {
+        this.setUp(Level.WARN);
+
+        this.tag.setMarker(MarkerManager.getMarker("E01"));
+        this.tag.setMessage(new MyMessage("Another message for testDoEndTagObjectMarkerNoException"));
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Another message for testDoEndTagObjectMarkerNoException WARN M-E01 E");
+    }
+
+    @Test
+    public void testDoEndTagObjectNoMarkerException() throws Exception {
+        this.setUp(Level.TRACE);
+
+        this.tag.setException(new Exception("This is a test"));
+        this.tag.setMessage(new MyMessage("Third message for testDoEndTagObjectNoMarkerException"));
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Third message for testDoEndTagObjectNoMarkerException TRACE M- E java.lang.Exception: This is a test");
+    }
+
+    @Test
+    public void testDoEndTagObjectMarkerException() throws Exception {
+        this.setUp(Level.ERROR);
+
+        this.tag.setException(new RuntimeException("This is another test"));
+        this.tag.setMarker(MarkerManager.getMarker("F02"));
+        this.tag.setMessage(new MyMessage("Final message for testDoEndTagObjectMarkerException"));
+
+        assertEquals("The return value is not correct.", BodyTag.EVAL_PAGE, this.tag.doEndTag());
+        verify("Final message for testDoEndTagObjectMarkerException ERROR M-F02 E java.lang.RuntimeException: " +
+                "This is another test");
+    }
+
+    private void verify(final String expected) {
+        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+        final Map<String, Appender<?>> list = ctx.getConfiguration().getAppenders();
+        final Appender<?> listApp = list.get("List");
+        assertNotNull("Missing Appender", listApp);
+        assertTrue("Not a ListAppender", listApp instanceof ListAppender);
+        final List<String> events = ((ListAppender) listApp).getMessages();
+        try
+        {
+            assertEquals("Incorrect number of messages.", 1, events.size());
+            assertEquals("Incorrect message.", "o.a.l.l.t.LoggingMessageTagSupportTest " + expected, events.get(0));
+        }
+        finally
+        {
+            ((ListAppender) listApp).clear();
+        }
+    }
+
+    private static class MyMessage {
+        private final String internal;
+
+        public MyMessage(String internal) {
+            this.internal = internal;
+        }
+
+        @Override
+        public String toString() {
+            return this.internal;
+        }
+    }
+}



Mime
View raw message