Index: src/main/org/jboss/test/web/test/PerApplicationLoggingTestCase.java
===================================================================
--- src/main/org/jboss/test/web/test/PerApplicationLoggingTestCase.java	(revision 0)
+++ src/main/org/jboss/test/web/test/PerApplicationLoggingTestCase.java	(revision 0)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.web.test;
+
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.util.web.HttpUtils;
+
+/**
+ * PerApplicationLoggingTestCase
+ * 
+ * Tests that the per application logging filter as explained here 
+ * http://www.jboss.org/community/wiki/SeparatingApplicationLogs
+ * works
+ *
+ * @see JBAS-6532
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PerApplicationLoggingTestCase extends JBossTestCase
+{
+
+   /**
+    * Logger
+    */
+   private static Logger logger = Logger.getLogger(PerApplicationLoggingTestCase.class);
+
+   /**
+    * Constructor
+    * @param name
+    */
+   public PerApplicationLoggingTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * Test that the log messages from an app are directed to the app specific log file 
+    * @throws Exception
+    */
+   public void testPerApplicationLogging() throws Exception
+   {
+
+      // first write a log message from app-one
+      String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+      String appOneLogMessage = "AppOneLogMessage";
+      URL appOneServletURL = new URL(baseURL + "jbas-6532-app-one/JBAS6532LoggingServlet?action=write-log&log-message="
+            + appOneLogMessage);
+      HttpUtils.accessURL(appOneServletURL);
+
+      // now check that the app-one log file contains log from only app-one
+      String appOneLogFileName = "jbas-6532-app-one.log";
+      appOneServletURL = new URL(baseURL + "jbas-6532-app-one/JBAS6532LoggingServlet?action=read-log&log-file-name="
+            + appOneLogFileName);
+      HttpMethodBase request = HttpUtils.accessURL(appOneServletURL);
+
+      Header errorHeader = request.getResponseHeader("X-JBAS6532-Error");
+      assertNull("Error reading log file of app one: " + errorHeader, errorHeader);
+      Header appOneLogFileContents = request.getResponseHeader("X-JBAS6532-Log");
+      assertEquals("Unexpected content in app one log file", appOneLogMessage, appOneLogFileContents.getValue());
+
+   }
+
+   /**
+    * Setup the test suite.
+    */
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(PerApplicationLoggingTestCase.class, "jbas-6532-app-one.war");
+   }
+
+}
Index: src/main/org/jboss/test/web/servlets/JBAS6532LoggingServlet.java
===================================================================
--- src/main/org/jboss/test/web/servlets/JBAS6532LoggingServlet.java	(revision 0)
+++ src/main/org/jboss/test/web/servlets/JBAS6532LoggingServlet.java	(revision 0)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.web.servlets;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * JBAS6532LoggingServlet
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class JBAS6532LoggingServlet extends HttpServlet
+{
+
+   /**
+    * Logger
+    */
+   private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("jbas-6532-logger");
+   
+   /**
+    * Process GET request
+    */
+   protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+   {
+      // we do the same thing as POST
+      doPost(request, response);
+   }
+
+   /**
+    * Process POST
+    */
+   protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+   {
+      // first log the message to this application's log file
+      String action = request.getParameter("action");
+      if (action.equals("write-log"))
+      {
+         String logMessage = request.getParameter("log-message");
+         logger.info(logMessage);
+         return;
+      }
+      else if (action.equals("read-log"))
+      {
+         String jbossLogDir = System.getProperty("jboss.server.log.dir");
+         File logDir = new File (jbossLogDir);
+         String logFileName = request.getParameter("log-file-name");
+         File appLogFile = new File (logDir, logFileName);
+         if (!appLogFile.exists())
+         {
+            response.addHeader("X-JBAS6532-Error", appLogFile + " does not exist");
+            return;
+         }
+         BufferedReader bufferedReader = new BufferedReader(new FileReader(appLogFile));
+         StringBuffer contents = new StringBuffer();
+         String line = null;
+         while ( (line = bufferedReader.readLine()) != null)
+         {
+            contents.append(line);
+         }
+         response.addHeader("X-JBAS6532-Log", contents.toString());
+         return;
+      }
+
+   }
+}
Index: src/resources/web/logging/web.xml
===================================================================
--- src/resources/web/logging/web.xml	(revision 0)
+++ src/resources/web/logging/web.xml	(revision 0)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
+   <description>Simple web app for JBAS-6532 testcase</description>
+   
+   <servlet>
+	   <servlet-name>JBAS6532LoggingServlet</servlet-name>
+	   <servlet-class>org.jboss.test.web.servlets.JBAS6532LoggingServlet</servlet-class>
+   </servlet>
+   
+   <servlet-mapping>
+	   <servlet-name>JBAS6532LoggingServlet</servlet-name>
+	   <url-pattern>/JBAS6532LoggingServlet</url-pattern>
+   </servlet-mapping>
+
+</web-app>

Property changes on: src/resources/web/logging/web.xml
___________________________________________________________________
Added: svn:executable
   + *

Index: src/resources/web/logging/log4j.xml
===================================================================
--- src/resources/web/logging/log4j.xml	(revision 0)
+++ src/resources/web/logging/log4j.xml	(revision 0)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+
+  <appender name="APP1_LOG_FILE" class="org.apache.log4j.RollingFileAppender">
+	<param name="File" value="${jboss.server.log.dir}/jbas-6532-app-one.log"/>
+	<param name="Append" value="false"/>
+	<param name="MaxFileSize" value="5000KB"/>
+	<param name="MaxBackupIndex" value="1"/>
+	<layout class="org.apache.log4j.PatternLayout">
+		<param name="ConversionPattern" value="%m%n"/>
+	</layout>	
+	<!-- The tcl filter -->
+	<filter class="org.jboss.logging.filter.TCLMCFilter">
+		<param name="AcceptOnMatch" value="true"/>
+		<param name="DeployURL" value="jbas-6532-app-one"/>
+	</filter>    
+	
+	<!-- end the filter chain here -->
+	<filter class="org.apache.log4j.varia.DenyAllFilter"></filter>
+		
+		
+   </appender>
+   
+ 
+   <!-- ======================= -->
+   <!-- Setup the Root category -->
+   <!-- ======================= -->
+
+   <root>
+	<appender-ref ref="APP1_LOG_FILE"></appender-ref>	   
+   </root>
+
+
+</log4j:configuration>
Index: imports/sections/web.xml
===================================================================
--- imports/sections/web.xml	(revision 96401)
+++ imports/sections/web.xml	(working copy)
@@ -919,5 +919,24 @@
            <include name="**"/>
          </fileset>
       </jar>
+      
+      <!-- build jbas-6532 war -->
+      <war warfile="${build.lib}/jbas-6532-app-one.war"
+	   webxml="${build.resources}/web/logging/web.xml">
+	      <lib dir="${apache.log4j.lib}">
+		      <include name="log4j.jar" />
+	      </lib>
+	      <lib dir="${jboss.common.logging.log4j.lib}">
+		      <include name="jboss-logging-log4j.jar" />
+         	</lib>
+	      <classes dir="${build.classes}">
+		      <include name="org/jboss/test/web/servlets/JBAS6532LoggingServlet.class"/>
+	      </classes>
+	      <classes dir="${build.resources}/web/logging/">
+		      <include name="log4j.xml"/>
+	      </classes>
+	      
+      </war>
+      
    </target>
 </project>
