HTTP: added route logging.
- Configuration: added "/config/settings/http/log_route". Type: bool Default: false This adds configurability to the error log. It allows enabling and disabling logs related to how the router performs selection of the routes. - HTTP: logging request line. Log level: [notice] The request line is essential to understand which logs correspond to which request when reading the logs. - HTTP: logging route that's been discarded. Log level: [info] - HTTP: logging route whose action is selected. Log level: [notice] - HTTP: logging when "fallback" action is taken. Log level: [notice] Closes: <https://github.com/nginx/unit/issues/758> Link: <https://github.com/nginx/unit/pull/824> Link: <https://github.com/nginx/unit/pull/839> Suggested-by: Timo Stark <t.stark@nginx.com> Suggested-by: Mark L Wood-Patrick <mwoodpatrick@gmail.com> Suggested-by: Liam Crilly <liam@nginx.com> Tested-by: Liam Crilly <liam@nginx.com> Acked-by: Artem Konev <a.konev@f5.com> Cc: Andrew Clayton <a.clayton@nginx.com> Cc: Andrei Zeliankou <zelenkov@nginx.com> Reviewed-by: Zhidao Hong <z.hong@f5.com> Signed-off-by: Alejandro Colomar <alx@nginx.com>
This commit is contained in:
@@ -507,6 +507,7 @@ nxt_h1p_conn_request_init(nxt_task_t *task, void *obj, void *data)
|
||||
|
||||
r->conf = joint;
|
||||
skcf = joint->socket_conf;
|
||||
r->log_route = skcf->log_route;
|
||||
|
||||
if (c->local == NULL) {
|
||||
c->local = skcf->sockaddr;
|
||||
@@ -653,6 +654,11 @@ nxt_h1p_header_process(nxt_task_t *task, nxt_h1proto_t *h1p,
|
||||
r->path = &h1p->parser.path;
|
||||
r->args = &h1p->parser.args;
|
||||
|
||||
if (nxt_slow_path(r->log_route)) {
|
||||
nxt_log(task, NXT_LOG_NOTICE, "http request line \"%V %V %V\"",
|
||||
r->method, &r->target, &r->version);
|
||||
}
|
||||
|
||||
r->fields = h1p->parser.fields;
|
||||
|
||||
ret = nxt_http_fields_process(r->fields, &nxt_h1p_fields_hash, r);
|
||||
|
||||
Reference in New Issue
Block a user