Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions java/org/apache/catalina/valves/AbstractAccessLogValve.java
Original file line number Diff line number Diff line change
Expand Up @@ -2040,6 +2040,8 @@ protected AccessLogElement createAccessLogElement(String name, char pattern) {
*/
protected AccessLogElement createAccessLogElement(char pattern) {
switch (pattern) {
case '%':
return new StringElement("%");
case 'a':
return new RemoteAddrElement();
case 'A':
Expand Down
1 change: 1 addition & 0 deletions test/org/apache/catalina/valves/TestAccessLogValve.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public class TestAccessLogValve extends TomcatBaseTest {
public static Collection<Object[]> parameters() {
List<Object[]> parameterSets = new ArrayList<>();

parameterSets.add(new Object[] {"pct-pct", TEXT_TYPE, "/", "%%", "%"});
parameterSets.add(new Object[] {"pct-a", TEXT_TYPE, "/", "%a", LOCAL_IP_PATTERN});
parameterSets.add(new Object[] {"pct-a", JSON_TYPE, "/", "%a", "\\{\"remoteAddr\":\"" + LOCAL_IP_PATTERN + "\"\\}"});
parameterSets.add(new Object[] {"pct-A", TEXT_TYPE, "/", "%A", IP_PATTERN});
Expand Down
5 changes: 4 additions & 1 deletion webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@
Ensure <code>RealmBase</code> finds all matching extension based
security constraints. (markt)
</fix>
<add>
Add <code>%%</code> in AccessLogValve pattern.
Pull request <pr>1004</pr> provided by effhaa.
</add>
</changelog>
</subsection>
<subsection name="Coyote">
Expand Down Expand Up @@ -18296,4 +18300,3 @@
</section>
</body>
</document>

3 changes: 2 additions & 1 deletion webapps/docs/config/valve.xml
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,13 @@
the current request and response. The following pattern codes are
supported:</p>
<ul>
<li><b><code>%%</code></b> - Literal '%' character</li>
<li><b><code>%a</code></b> - Remote IP address.
See also <code>%{xxx}a</code> below.</li>
<li><b><code>%A</code></b> - Local IP address</li>
<li><b><code>%b</code></b> - Bytes sent, excluding HTTP headers, or '-' if zero</li>
<li><b><code>%B</code></b> - Bytes sent, excluding HTTP headers</li>
<li><b><code>%D</code></b> - Time taken to process the request in millis. Note: In
<li><b><code>%D</code></b> - Time taken to process the request, in millis. Note: In
httpd %D is microseconds. Behaviour will be aligned to httpd
in Tomcat 10 onwards.</li>
<li><b><code>%F</code></b> - Time taken to commit the response, in milliseconds</li>
Expand Down