H2O

the optimized HTTP/1.x, HTTP/2 server
Powered by Oktavia

Configure > Access Log Directives

This document describes the configuration directives of the access_log handler.

"access-log"

Description:

The directive sets the path and optionally the format of the access log.

If the supplied argument is a scalar, it is treated as the path of the log file, or if the value starts with a |, it is treated as a command to which the log should be emitted.

Example. Emit access log to file
access-log: /path/to/access-log-file
Example. Emit access log through pipe
access-log: "| rotatelogs /path/to/access-log-file.%Y%m%d 86400"

If the supplied argument is a mapping, its path property is considered as the path of the log file or the pipe command, and the format property is treated as the format of the log file.

Example. Emit access log to file using Common Log Format
access-log:
    path: /path/to/access-log-file
    format: "%h %l %u %t \"%r\" %>s %b"

The list of format strings recognized by H2O is as follows.

Format StringDescription
%%the percent sign
%bsize of the response body in bytes
%Hrequest protocol as sent by the client (e.g. HTTP/1.1)
%hremote address (e.g. 1.2.3.4)
%lremote logname (always -)
%mrequest method (e.g. GET, POST)
%qquery string (? is prepended if exists, otherwise an empty string)
%rrequest line (e.g. GET / HTTP/1.1)
%sstatus code (e.g. 200)
%Urequested URL path, not including the query string
%uremote user if the request was authenticated (always -)
%Vrequested server name (or the default server name if not specified by the client)
%vcanonical server name
%{HEADERNAME}ivalue of the given request header (e.g. %{user-agent}i)
%{HEADERNAME}ovalue of the given response header (e.g. %{set-cookie}o)

The default format is %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i", a.k.a. the NCSA extended/combined log format.

Level:
global, host, path, extension