tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: r575543 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/valves/AccessLogValve.java webapps/docs/changelog.xml webapps/docs/config/valve.xml
Date Fri, 14 Sep 2007 05:46:46 GMT
Author: pero
Date: Thu Sep 13 22:46:45 2007
New Revision: 575543

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

Modified:
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java
    tomcat/container/tc5.5.x/webapps/docs/changelog.xml
    tomcat/container/tc5.5.x/webapps/docs/config/valve.xml

Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java?rev=575543&r1=575542&r2=575543&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java
(original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java
Thu Sep 13 22:46:45 2007
@@ -41,6 +41,7 @@
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.util.LifecycleSupport;
 import org.apache.catalina.util.StringManager;
+import org.apache.coyote.RequestInfo;
 
 
 /**
@@ -75,6 +76,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>
@@ -118,6 +120,8 @@
     // ----------------------------------------------------------- Constructors
 
 
+    private static final String MARK_EMPTY = "-";
+
     /**
      * Construct a new instance of this class with default property values.
      */
@@ -150,7 +154,7 @@
      * The descriptive information about this implementation.
      */
     protected static final String info =
-        "org.apache.catalina.valves.AccessLogValve/1.0";
+        "org.apache.catalina.valves.AccessLogValve/1.1";
 
 
     /**
@@ -603,7 +607,7 @@
 
             long length = response.getContentCountLong() ;
             if (length <= 0)
-                value = "-";
+                value = MARK_EMPTY;
             else
                 value = "" + length;
             result.append(value);
@@ -615,7 +619,7 @@
                 if(referer != null)
                     result.append(referer);
                 else
-                    result.append("-");
+                    result.append(MARK_EMPTY);
                 result.append("\"");
 
                 result.append(space);
@@ -624,7 +628,7 @@
                 if(ua != null)
                     result.append(ua);
                 else
-                    result.append("-");
+                    result.append(MARK_EMPTY);
                 result.append("\"");
             }
 
@@ -808,7 +812,7 @@
         } else if (pattern == 'b') {
             long length = response.getContentCountLong() ;
             if (length <= 0)
-                value = "-";
+                value = MARK_EMPTY;
             else
                 value = "" + length;
         } else if (pattern == 'B') {
@@ -818,7 +822,7 @@
         } else if (pattern == 'H') {
             value = request.getProtocol();
         } else if (pattern == 'l') {
-            value = "-";
+            value = MARK_EMPTY;
         } else if (pattern == 'm') {
             if (request != null)
                 value = request.getMethod();
@@ -857,14 +861,14 @@
             if (request != null)
                 if (request.getSession(false) != null)
                     value = request.getSessionInternal(false).getIdInternal();
-                else value = "-";
+                else value = MARK_EMPTY;
             else
-                value = "-";
+                value = MARK_EMPTY;
         } else if (pattern == 's') {
             if (response != null)
                 value = "" + response.getStatus();
             else
-                value = "-";
+                value = MARK_EMPTY;
         } else if (pattern == 't') {
             StringBuffer temp = new StringBuffer("[");
             temp.append(dayFormatter.format(date));             // Day
@@ -884,14 +888,21 @@
             if (request != null)
                 value = request.getRemoteUser();
             if (value == null)
-                value = "-";
+                value = MARK_EMPTY;
         } else if (pattern == 'U') {
             if (request != null)
                 value = request.getRequestURI();
             else
-                value = "-";
+                value = MARK_EMPTY;
         } else if (pattern == 'v') {
             value = request.getServerName();
+        } else if (pattern == 'I' ) {
+            RequestInfo info = request.getCoyoteRequest().getRequestProcessor();
+            if(info != null) {
+                value= info.getWorkerThreadName();
+            } else {
+                value = MARK_EMPTY;
+            }
         } else {
             value = "???" + pattern + "???";
         }
@@ -974,9 +985,9 @@
                 else
                     return value.toString();
             else
-               return "-";
+               return MARK_EMPTY;
         } catch(Throwable e) {
-            return "-";
+            return MARK_EMPTY;
         }
     }
 
@@ -1017,7 +1028,7 @@
     private String calculateTimeZoneOffset(long offset) {
         StringBuffer tz = new StringBuffer();
         if ((offset<0))  {
-            tz.append("-");
+            tz.append(MARK_EMPTY);
             offset = -offset;
         } else {
             tz.append("+");

Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?rev=575543&r1=575542&r2=575543&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Thu Sep 13 22:46:45 2007
@@ -26,6 +26,7 @@
     <author email="remm@apache.org">Remy Maucherat</author>
     <author email="yoavs@apache.org">Yoav Shapira</author>
     <author email="fhanik@apache.org">Filip Hanik</author>
+    <author email="pero@apache.org">Peter Rossbach</author>
     <title>Changelog</title>
   </properties>
 
@@ -48,6 +49,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="Cluster">

Modified: tomcat/container/tc5.5.x/webapps/docs/config/valve.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/config/valve.xml?rev=575543&r1=575542&r2=575543&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/config/valve.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/config/valve.xml Thu Sep 13 22:46:45 2007
@@ -176,6 +176,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


Mime
View raw message