https://issues.apache.org/bugzilla/show_bug.cgi?id=51545
authortimw <timw@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 26 Jul 2011 09:41:36 +0000 (09:41 +0000)
committertimw <timw@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 26 Jul 2011 09:41:36 +0000 (09:41 +0000)
Adding ability to log current request thread name in ExtendedAccessLogValve using Tomcat specific x-threadname pattern format token.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1151043 13f79535-47bb-0310-9956-ffa450edef68

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

index 5d30bdb..50f8382 100644 (file)
@@ -64,6 +64,7 @@ import org.apache.tomcat.util.ExceptionUtils;
  * <li><code>sc-status</code>:  The status code</li>
  * <li><code>time</code>:  Time the request was served</li>
  * <li><code>time-taken</code>:  Time (in seconds) taken to serve the request</li>
+ * <li><code>x-threadname</code>: Current request thread name (can compare later with stacktraces)</li>
  * <li><code>x-A(XXX)</code>: Pull XXX attribute from the servlet context </li>
  * <li><code>x-C(XXX)</code>: Pull the first cookie of the name XXX </li>
  * <li><code>x-O(XXX)</code>: Pull the all response header values XXX </li>
@@ -745,6 +746,10 @@ public class ExtendedAccessLogValve extends AccessLogValve {
             return null;
         }
         String token = tokenizer.getToken();
+        if ("threadname".equals(token)) {
+            return new ThreadNameElement();
+        }
+
         if (!tokenizer.hasParameter()) {
             log.error("x param in wrong format. Needs to be 'x-#(...)' read the docs!");
             return null;
index 442e8e5..7b17529 100644 (file)
@@ -76,7 +76,7 @@
         &lt;others/&gt; tag when using absolute ordering. (markt)
       </fix>
       <add>
-        Move the SetCharacaterEncoding filter from the examples web application
+        Move the SetCharacterEncoding filter from the examples web application
         to the <code>org.apache.catalina.filters</code> package so it is
         available for all web applications. (markt)
       </add>
         <bug>51555</bug>: Allow destroy() to be called on Lifecycle components
         that are in the initialized state. (markt)
       </fix>
+      <add>
+        Add x-threadname pattern format token to ExtendedAccessLogValve to log
+        the current request thread name. Based on a patch from Felix Schumacher.
+        (timw)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Coyote">
index 4846782..d58703e 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>
+    <li><b>%I</b> - Current request thread name (can compare later with stacktraces)</li>
     </ul>
 
     <p>
     <li><b>sc-status</b> - HTTP status code of the response</li>
     <li><b>time</b> - Time the request was served in HH:mm:ss format for GMT</li>
     <li><b>time-taken</b> - Time (in seconds as floating point) taken to serve the request</li>
+    <li><b>x-threadname</b> - Current request thread name (can compare later with stacktraces)</li>
     </ul>
 
     <p>For any of the <code>x-H(XXX)</code> the following method will be called from the