Author: pero Date: Thu Sep 13 15:05:56 2007 New Revision: 575482 URL: http://svn.apache.org/viewvc?rev=575482&view=rev Log: Support logging of all response header values at ExtendedAccessLogValve (ex. add x-O(Set-Cookie) to your pattern).
Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/valves/ExtendedAccessLogValve.java tomcat/container/tc5.5.x/webapps/docs/changelog.xml Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/valves/ExtendedAccessLogValve.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/valves/ExtendedAccessLogValve.java?rev=575482&r1=575481&r2=575482&view=diff ============================================================================== --- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/valves/ExtendedAccessLogValve.java (original) +++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/valves/ExtendedAccessLogValve.java Thu Sep 13 15:05:56 2007 @@ -72,6 +72,7 @@ * <li><code>time-taken</code>: Time (in seconds) taken to serve the request</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> * <li><code>x-R(XXX)</code>: Pull XXX attribute from the servlet request </li> * <li><code>x-S(XXX)</code>: Pull XXX attribute from the session </li> * <li><code>x-P(...)</code>: Call request.getParameter(...) @@ -130,6 +131,7 @@ * * * @author Tim Funk + * @author Peter Rossbach * @version $Revision$ $Date$ */ @@ -160,7 +162,7 @@ * The descriptive information about this implementation. */ protected static final String info = - "org.apache.catalina.valves.ExtendedAccessLogValve/1.0"; + "org.apache.catalina.valves.ExtendedAccessLogValve/1.1"; /** @@ -697,7 +699,29 @@ } + /** + * write a specific response header - x-O{xxx} + */ + protected String responseHeader(Request request,String header) { + Response response = request.getResponse() ; + if (null != response) { + String[] values = response.getHeaderValues(header); + if(values.length > 0) { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < values.length; i++) { + String string = values[i]; + buf.append(string) ; + if(i+1<values.length) + buf.append(","); + } + return buf.toString() ; + } + } + return "-" ; + } + + /** * Get app specific data. * @param fieldInfo The field to decode @@ -711,6 +735,8 @@ return wrap(urlEncode(request.getParameter(fieldInfo.value))); case FieldInfo.X_REQUEST: return wrap(request.getAttribute(fieldInfo.value)); + case FieldInfo.X_RESPONSE: + return wrap(responseHeader(request,fieldInfo.value)); case FieldInfo.X_SESSION: HttpSession session = null; if (request!=null){ @@ -1258,6 +1284,7 @@ * x-A(...) - Value in servletContext * x-S(...) - Value in session * x-R(...) - Value in servletRequest + * x-O(...) - Header value in servletResponse * @param fields The pattern to decode * @param i The string index where we are decoding. * @param fieldInfo Where to store the results @@ -1281,6 +1308,9 @@ case 'C': fieldInfo.xType = FieldInfo.X_COOKIE; break; + case 'O': + fieldInfo.xType = FieldInfo.X_RESPONSE; + break; case 'R': fieldInfo.xType = FieldInfo.X_REQUEST; break; @@ -1397,6 +1427,7 @@ static final short X_APP = 4; /* For x app specific */ static final short X_SERVLET_REQUEST = 5; /* For x app specific */ static final short X_PARAMETER = 6; /* For x app specific */ + static final short X_RESPONSE = 7; /* For x app specific */ static final short X_LOC_AUTHTYPE = 1; static final short X_LOC_REMOTEUSER = 2; 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=575482&r1=575481&r2=575482&view=diff ============================================================================== --- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original) +++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Thu Sep 13 15:05:56 2007 @@ -45,6 +45,9 @@ <add> Made session createTime accessible for all SessionManager via JMX (pero) </add> + <add> + Support logging of all response header values at ExtendedAccessLogValve (ex. add x-O(Set-Cookie) to your pattern). (pero) + </add> </changelog> </subsection> <subsection name="Cluster"> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]