You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by pe...@apache.org on 2007/09/13 23:06:47 UTC

svn commit: r575451 - in /tomcat/tc6.0.x/trunk: java/org/apache/catalina/valves/AccessLogValve.java webapps/docs/changelog.xml webapps/docs/config/valve.xml

Author: pero
Date: Thu Sep 13 14:06:46 2007
New Revision: 575451

URL: http://svn.apache.org/viewvc?rev=575451&view=rev
Log:
Support logging of current thread name at AccessLogValve (ex. add %I to your pattern).

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
    tomcat/tc6.0.x/trunk/webapps/docs/config/valve.xml

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java?rev=575451&r1=575450&r2=575451&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java Thu Sep 13 14:06:46 2007
@@ -43,6 +43,7 @@
 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 @@
  * <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 @@
                     .getString("accessLogValve.notStarted"));
         lifecycle.fireLifecycleEvent(STOP_EVENT, null);
         started = false;
+        
         close();
     }
     
@@ -906,6 +909,21 @@
     }
     
     /**
+     * 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 @@
             return new RequestURIElement();
         case 'v':
             return new LocalServerNameElement();
+        case 'I':
+            return new ThreadNameElement();
         default:
             return new StringElement("???" + pattern + "???");
         }

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=575451&r1=575450&r2=575451&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Thu Sep 13 14:06:46 2007
@@ -71,6 +71,10 @@
       <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">

Modified: tomcat/tc6.0.x/trunk/webapps/docs/config/valve.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/config/valve.xml?rev=575451&r1=575450&r2=575451&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/config/valve.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/config/valve.xml Thu Sep 13 14:06:46 2007
@@ -179,6 +179,7 @@
     <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>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org