Support logging of current thread name at AccessLogValve (ex. add %I to your pattern).
authorpero <pero@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 13 Sep 2007 21:06:46 +0000 (21:06 +0000)
committerpero <pero@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 13 Sep 2007 21:06:46 +0000 (21:06 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@575451 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/valves/AccessLogValve.java
webapps/docs/changelog.xml
webapps/docs/config/valve.xml

index ef3d6ab..013cc69 100644 (file)
@@ -43,6 +43,7 @@ import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.util.LifecycleSupport;
 import org.apache.catalina.util.StringManager;
+import org.apache.coyote.RequestInfo;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
@@ -79,6 +80,7 @@ import org.apache.juli.logging.LogFactory;
  * <li><b>%v</b> - Local server name
  * <li><b>%D</b> - Time taken to process the request, in millis
  * <li><b>%T</b> - Time taken to process the request, in seconds
+ * <li><b>%I</b> - current Request thread name (can compare later with stacktraces)
  * </ul>
  * <p>In addition, the caller can specify one of the following aliases for
  * commonly utilized patterns:</p>
@@ -893,6 +895,7 @@ public class AccessLogValve
                     .getString("accessLogValve.notStarted"));
         lifecycle.fireLifecycleEvent(STOP_EVENT, null);
         started = false;
+        
         close();
     }
     
@@ -906,6 +909,21 @@ public class AccessLogValve
     }
     
     /**
+     * write thread name - %I
+     */
+    protected class ThreadNameElement implements AccessLogElement {
+        public void addElement(StringBuffer buf, Date date, Request request,
+                Response response, long time) {
+            RequestInfo info = request.getCoyoteRequest().getRequestProcessor();
+            if(info != null) {
+                buf.append(info.getWorkerThreadName());
+            } else {
+                buf.append("-");
+            }
+        }
+    }
+    
+    /**
      * write local IP address - %A
      */
     protected class LocalAddrElement implements AccessLogElement {
@@ -1455,6 +1473,8 @@ public class AccessLogValve
             return new RequestURIElement();
         case 'v':
             return new LocalServerNameElement();
+        case 'I':
+            return new ThreadNameElement();
         default:
             return new StringElement("???" + pattern + "???");
         }
index 8edb17a..d2a4b38 100644 (file)
       <add>
         Support logging of all response header values at ExtendedAccessLogValve (ex. add x-O(Set-Cookie) to your pattern). (pero)
       </add>     
+      <add>
+        Support logging of current thread name at AccessLogValve (ex. add %I to your pattern).
+        Usefull to compare access logging entry later with a stacktraces. (pero)
+      </add>     
     </changelog>
   </subsection>
   <subsection name="Coyote">
index 68bf946..651dcce 100644 (file)
     <li><b>%v</b> - Local server name</li>
     <li><b>%D</b> - Time taken to process the request, in millis</li>
     <li><b>%T</b> - Time taken to process the request, in seconds</li>
+    <li><b>%I</b> - current request thread name (can compare later with stacktraces)</li>
     </ul>
 
     <p>