Format
In ngx_log_error_core
, the cached time, log level surrounded by []
, pid#tid:
and *$connection
(connection serial number, if exists) are “printed” first. Then, the error message from the arguments is formatted and printed. The resulting string is then passed to log->handler
to get the final message to log.
In ngx_http_request.c
, c->log->handler
is set to ngx_http_log_error
, which appends while ...
if there is a log->action
, , client: ...
(the connection’s client address), and passes the error message to r->log_handler
.
r->log_handler
is ngx_http_log_error_handler
, also defined in ngx_http_request.c
. It appends , server: $server_name
, the request line, sub-request if exists, upstream information if exists, Host
request header if exists, and Referrer
request header if exists.
Therefore, the final format for an HTTP request is
1970/09/28 12:00:00 [$err_level] $pid#$tid: *$connection_serial_number $error___message while $action, client: $connection_addr, server: $server_name, request: "$request", subrequest: "$sr->uri", upstream: "schema://peer_name$upstream_uri", host: "$http_host", referrer: "$http_referer"