diff --git a/java/org/apache/catalina/valves/AbstractAccessLogValve.java b/java/org/apache/catalina/valves/AbstractAccessLogValve.java index 31ed2c15e024..879da82d5d49 100644 --- a/java/org/apache/catalina/valves/AbstractAccessLogValve.java +++ b/java/org/apache/catalina/valves/AbstractAccessLogValve.java @@ -1545,17 +1545,26 @@ public CookieElement(String cookieNameToLog) { @Override public void addElement(CharArrayWriter buf, Date date, Request request, Response response, long time) { - String value = "-"; + StringBuilder value = new StringBuilder(); + boolean first = true; Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (cookieNameToLog.equals(cookie.getName())) { - value = cookie.getValue(); - break; + if (first) { + first = false; + } else { + value.append(','); + } + value.append(cookie.getValue()); } } } - escapeAndAppend(value, buf); + if (value.length() == 0) { + buf.append('-'); + } else { + escapeAndAppend(value.toString(), buf); + } } } diff --git a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java index d717bac90350..852a473c430a 100644 --- a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java +++ b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java @@ -64,7 +64,7 @@ *
time-taken
: Time (in seconds) taken to serve the requestx-threadname
: Current request thread name (can compare later with stacktraces)x-A(XXX)
: Pull XXX attribute from the servlet context x-C(XXX)
: Pull the first cookie of the name XXX x-C(XXX)
: Pull the cookie(s) of the name XXX x-O(XXX)
: Pull the all response header values XXX x-R(XXX)
: Pull XXX attribute from the servlet request x-S(XXX)
: Pull XXX attribute from the session INFO
. Pull request xxx=peer
)
%{xxx}i
write value of incoming header with name xxx
(escaped if required)%{xxx}o
write value of outgoing header with name xxx
(escaped if required)%{xxx}c
write value of cookie with name xxx
(escaped if required)%{xxx}c
write value of cookie(s) with name xxx
(comma separated and escaped if required)%{xxx}r
write value of ServletRequest attribute with name xxx
(escaped if required)%{xxx}s
write value of HttpSession attribute with name xxx
(escaped if required)%{xxx}p
write local (server) port (xxx==local
) or
@@ -493,7 +493,7 @@
cs(XXX)
for incoming request headers with name XXXsc(XXX)
for outgoing response headers with name XXXx-A(XXX)
for the servlet context attribute with name XXXx-C(XXX)
for the first cookie with name XXXx-C(XXX)
for the cookie(s) with name XXX (comma separated if required)x-O(XXX)
for a concatenation of all outgoing response headers with name XXXx-P(XXX)
for the URL encoded (using UTF-8) request parameter with name XXXx-R(XXX)
for the request attribute with name XXX