How to take access_log URL-decoded

Solution Unverified - Updated -

Environment

  • Red Hat Enterprise Linux
  • httpd

Issue

  • How to take access_log URL-decoded.
  • access_log looks like below. How to decode?
::1 - - [14/Aug/2014:13:56:49 +0900] "GET /WebDAV%E5%88%A9/ HTTP/1.0" 404 284 "-" "ApacheBench/2.3"
::1 - - [14/Aug/2014:13:56:49 +0900] "GET /WebDAV%E5%88%A9/ HTTP/1.0" 404 284 "-" "ApacheBench/2.3"
::1 - - [14/Aug/2014:13:56:49 +0900] "GET /WebDAV%E5%88%A9/ HTTP/1.0" 404 284 "-" "ApacheBench/2.3"

Resolution

You can specify a filter program with CustomLog.

The following is just an example.

  • httpd.conf
#CustomLog logs/access_log combined
CustomLog "| /etc/httpd/conf/my_log.pl " combined
  • /etc/httpd/conf/my_log.pl
#!/usr/bin/perl

use strict;
use URI::Escape;


open(my $fh, ">>/var/log/httpd/my_log");

while(<STDIN>){
  print $fh uri_unescape($_);
}

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.