* It is modeled after the apache syntax:
* <ul>
* <li><code>%{xxx}i</code> for incoming headers
+ * <li><code>%{xxx}o</code> for outgoing response headers
* <li><code>%{xxx}c</code> for a specific cookie
* <li><code>%{xxx}r</code> xxx is an attribute in the ServletRequest
* <li><code>%{xxx}s</code> xxx is an attribute in the HttpSession
* @author Jason Brittain
* @author Remy Maucherat
* @author Takayuki Kaneko
- * @version $Revision$ $Date: 2007-01-04 12:17:11 +0900
+ * @author Peter Rossbach
+ *
+ * @version $Revision$ $Date$
*/
public class AccessLogValve
* The descriptive information about this implementation.
*/
protected static final String info =
- "org.apache.catalina.valves.AccessLogValve/2.0";
+ "org.apache.catalina.valves.AccessLogValve/2.1";
/**
}
/**
+ * write a specific response header - %{xxx}o
+ */
+ protected class ResponseHeaderElement implements AccessLogElement {
+ private String header;
+
+ public ResponseHeaderElement(String header) {
+ this.header = header;
+ }
+
+ public void addElement(StringBuffer buf, Date date, Request request,
+ Response response, long time) {
+ if (null != response) {
+ String[] values = response.getHeaderValues(header);
+ if(values.length > 0) {
+ for (int i = 0; i < values.length; i++) {
+ String string = values[i];
+ buf.append(string) ;
+ if(i+1<values.length)
+ buf.append(",");
+ }
+ return ;
+ }
+ }
+ buf.append("-");
+ }
+ }
+
+ /**
* write an attribute in the ServletRequest - %{xxx}r
*/
protected class RequestAttributeElement implements AccessLogElement {
return new HeaderElement(header);
case 'c':
return new CookieElement(header);
+ case 'o':
+ return new ResponseHeaderElement(header);
case 'r':
return new RequestAttributeElement(header);
case 's':
- return new SessionAttributeElement(header);
+ return new SessionAttributeElement(header);
default:
return new StringElement("???");
}
* <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(...)
*
*
* @author Tim Funk
+ * @author Peter Rossbach
+ *
* @version $Revision$ $Date$
*/
* The descriptive information about this implementation.
*/
protected static final String extendedAccessLogInfo =
- "org.apache.catalina.valves.ExtendedAccessLogValve/1.0";
+ "org.apache.catalina.valves.ExtendedAccessLogValve/2.1";
// ------------------------------------------------------------- Properties
super.open();
if (currentLogFile.length()==0) {
writer.println("#Fields: " + pattern);
- writer.println("#Version: 1.0");
+ writer.println("#Version: 2.0");
writer.println("#Software: " + ServerInfo.getServerInfo());
}
}
}
}
+ /**
+ * write a specific response header - x-O(xxx)
+ */
+ protected class ResponseAllHeaderElement implements AccessLogElement {
+ private String header;
+
+ public ResponseAllHeaderElement(String header) {
+ this.header = header;
+ }
+
+ public void addElement(StringBuffer buf, Date date, Request request,
+ Response response, long time) {
+ if (null != response) {
+ String[] values = response.getHeaderValues(header);
+ if(values.length > 0) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < values.length; i++) {
+ String string = values[i];
+ buffer.append(string) ;
+ if(i+1<values.length)
+ buffer.append(",");
+ }
+ buf.append(wrap(buffer.toString()));
+ return ;
+ }
+ }
+ buf.append("-");
+ }
+ }
+
protected class RequestAttributeElement implements AccessLogElement {
private String attribute;
return getServletRequestElement(parameter);
} else if ("P".equals(token)) {
return new RequestParameterElement(parameter);
+ } else if ("O".equals(token)) {
+ return new ResponseAllHeaderElement(parameter);
}
log.error("x param for servlet request, couldn't decode value: "
+ token);
<add>
Made session createTime accessible for all SessionManager via JMX (pero)
</add>
+ <update>
+ <bug>43129</bug>: Support logging of all response header values at AccessLogValve (ex. add %{Set-Cookie}o to your pattern). (pero)
+ </update>
+ <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="Coyote">
It is modeled after the apache syntax:
<ul>
<li><b><code>%{xxx}i</code></b> for incoming headers</li>
+ <li><b><code>%{xxx}o</code></b> for outgoing response headers</li>
<li><b><code>%{xxx}c</code></b> for a specific cookie</li>
<li><b><code>%{xxx}r</code></b> xxx is an attribute in the ServletRequest</li>
<li><b><code>%{xxx}s</code></b> xxx is an attribute in the HttpSession</li>