Logger: Custom

This module implements a flexible mechanism for logging requests made to the server, using a user-specified format.

The format in which the request will be logged is defined by a string. This string is used to log each request to the log. It can contain both literal characters and a set of variables. All the literal characters will be copied to the log. The following variables will be evaluated right before writing each log entry:

Variable Example Description


Remote IP-address


Local IP-address



Port of the server serving the request



Request Protocol



The query string, if exists



URL path requested


GET / HTTP/1.0

First line of HTTP request



URL path requested before any rewrite



Size of the response in bytes



Response status code


08/Apr/2009:12:02:11 +0200

Time: in common log format time format



Time: seconds since Epoch



Time: milliseconds since Epoch



Transport type: http or https



Remote user (authentication)



Virtual Server nick name


Requested host (Host: header), or vserver nickname if absent


"Host:" header of the request


"Referrer:" header of the request



"User-Agent:" header of the request



"Cookie:" header of the request

The templating subsystem provides slicing support in pretty much the same way that the Python strings do, allowing to use specific portions of any of these substitution macros. You can read more about this on the Template Subsystem section of the documentation.


For instance, the following format string:

[${now}] ${ip_remote}: ${request} (${status})

would generate this entry in the log:

[08/Apr/2009:12:02:11 +0200] /file.txt (200)

Apache’s comined format

The following formats are all like Apache’s combined format, except the second field not being the client ident but the (way more interesting) HTTP host or vserver name.

  • Virtual server name

    ${ip_remote} ${vserver_name} ${user_remote} [${now}] "${request_first_line}" ${status} ${response_size} "${http_referrer}" "${http_user_agent}"
  • Host

    ${ip_remote} ${http_host} ${user_remote} [${now}] "${request_first_line}" ${status} ${response_size} "${http_referrer}" "${http_user_agent}"
  • Host if present, otherwise virtual serven name

    ${ip_remote} ${vserver_name_req} ${user_remote} [${now}] "${request_first_line}" ${status} ${response_size} "${http_referrer}" "${http_user_agent}"