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 fileaccess-log: /path/to/access-log-file
Example. Emit access log through pipeaccess-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 theformat
property is treated as the format of the log file.Example. Emit access log to file using Common Log Formataccess-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 String Description %%
the percent sign %A
local address (e.g. 4.5.6.7
)%b
size of the response body in bytes %H
request protocol as sent by the client (e.g. HTTP/1.1
)%h
remote address (e.g. 1.2.3.4
)%l
remote logname (always -
)%m
request method (e.g. GET
,POST
)%p
local port %q
query string ( ?
is prepended if exists, otherwise an empty string)%r
request line (e.g. GET / HTTP/1.1
)%s
status code (e.g. 200
)%t
time when the request was received in format: [02/Jan/2006:15:04:05 -0700]
%{FORMAT}t
time when the request was received using the specified format. FORMAT
should be an argument tostrftime
, or one of:sec
number of seconds since Epoch msec
number of milliseconds since Epoch usec
number of microseconds since Epoch msec_frac
millisecond fraction usec_frac
microsecond fration %{%Y/%m/%d:%H:%M:%S}t.%{msec_frac}t
, which results in a timestamp like2006-01-02:15:04:05.000
.%U
requested URL path, not including the query string %u
remote user if the request was authenticated (always -
)%V
requested server name (or the default server name if not specified by the client) %v
canonical server name %{HEADERNAME}i
value of the given request header (e.g. %{user-agent}i
)%{HEADERNAME}o
value of the given response header (e.g. %{set-cookie}o
)%{NAME}x
various extensions. NAME
must be one of:connect-time
time spent to establish the connection (i.e. since connection gets accept(2)
-ed until first octet of the request is received)request-header-time
time spent receiving request headers request-body-time
time spent receiving request body request-total-time
sum of request-header-time
andrequest-body-time
process-time
time spent after receiving request, before starting to send response response-time
time spent sending response duration
sum of request-total-time
,process-time
,response-time
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.Note that you may need to quote (and escape) the format string as required by YAML (see Yaml Cookbook).
- Level:
- global, host, path, extension