Bug 57710 - Wildcard matching for logging headers
Summary: Wildcard matching for logging headers
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_log_config (show other bugs)
Version: 2.4.12
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2015-03-15 14:12 UTC by Peter Pramberger
Modified: 2015-03-15 14:35 UTC (History)
0 users



Attachments
Patch for 2.2 (4.67 KB, patch)
2015-03-15 14:13 UTC, Peter Pramberger
Details | Diff
Patch for 2.4 (4.88 KB, patch)
2015-03-15 14:14 UTC, Peter Pramberger
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Pramberger 2015-03-15 14:12:54 UTC
I recently got the requirement to log all X-* headers in some sort of "mass-hosting" setup, where the header names are not known beforehand.

Unfortunately this is something not possible yet. While mod_log_forensic provides the possibility to dump headers, it is limited to all the request headers (sent by client), and which headers to log is not configurable.

So it would be great to allow for the use of wildcards in the %{...}i and %{...}o log formats.

Fortunately find_multiple_headers() in mod_log_config.c does already most of the work required for this, so extending it is not a big issue. Please have a look at the attached patches, they should apply cleanly to the 2.4 and 2.2 branches.

Using wildcards will prefix its header value with the header name, while non-wildcard header names keep the ususal value-only output. For example using LogFormat "\"%{*}o\"" to log all response headers would produce something like this in the access log:

"Vary: User-Agent, Content-Length: 4330, Keep-Alive: timeout=60, max=100, Connection: Keep-Alive, Content-Type: text/html; charset=ISO-8859-1"

Note that I tried to keep the overhead as low as possible for the usual non-wildcard use case, but there is probably room for optimization.

Would be great if you could review the patches (luckily the logging infrastructure in 2.2 and 2.4 is identical in this case) and maybe include them in the 2.2 and 2.4 branches.
Comment 1 Peter Pramberger 2015-03-15 14:13:39 UTC
Created attachment 32571 [details]
Patch for 2.2
Comment 2 Peter Pramberger 2015-03-15 14:14:06 UTC
Created attachment 32572 [details]
Patch for 2.4
Comment 3 Peter Pramberger 2015-03-15 14:35:46 UTC
BTW: It would also be nice to allow for case-insensitive matching, but I've no idea how to encode this in the log format options...