Skip to content
wvanbergen edited this page Sep 4, 2010 · 4 revisions

Request-log-analyzer can parse and create reports for access logs created by Apache. However, Apache can be configured how accesses should be logged using a logging format string. Request-log-analyzer must be aware of this format string in order to parse the resulting files correctly. Apache also defines some default format strings, like “common” and “combined”.

You can pass the format string or constant by using the --apache-format command line switch. For example:

# using a format string
$ request-log-analyzer --apache-format "%h %l %u %t \"%r\" %>s %b" access.log
# using a format constant
$ request-log-analyzer --apache-format combined access.log

What is my format string?

If you haven’t changed your logging format, it usually is “common” or “combined” format. You can simply try these and see if it works. Otherwise, you can look for the format in your Apache configuration files. Look for the LogFormat and/or CustomLog directives, e.g.:

  LogFormat "%h %l %u %t \"%r\" %>s %b" common
  CustomLog logs/access_log common

Enabling performance analysis

By default, Apache does not include the request duration in the access log. To do performance analysis, this data is required. Fortunately, the request duration in microseconds can easily be added by adding the %D directive to the format string in your Apache configuration:

  CustomLog logs/access_log "%h %l %u %t \"%r\" %>s %b %D"

Do not forget to pass this new format string to request-log-analyzer. The report will then include duration statistics.

Note that the %T directive also exists. This directive will insert the request duration in seconds. Because most requests are served within a second, this information is not really useful. Use the %D directive instead.

Lighttpd

Lighttpd can create access logs that are compatible with Apache access logs. You can simply pass the Lighttp access log format string to the --apache-format command line switch.

Rack CommonLogger

The Rack CommonLogger also outputs Apache style access log lines. Therefore, r-l-a is able to parse these files as well, using the --apache-format rack command line option, or shorter: --format rack.