Other default options
Besides site, proxy and security options, the http node holds a group of defaults that control how access logs are written.
1 Log format options
{
"http": {
"log_split": " ",
"log_format": [
"user_agent", "time", "type", "method", "path"
]
}
}
| Option | Type | Description |
|---|---|---|
log_split | String | Separator placed between log fields, a single space in the example |
log_format | Array of strings | Fields written to the log and their order; joined with log_split |
2 Variables accepted by log_format
Each entry of log_format is one of the following:
| Variable | Meaning |
|---|---|
user_agent | Client User-Agent |
ip_port | Client IP and port |
time | Request time |
type | Log type |
method | HTTP method |
path | Request path |
host | Requested host name |
status | Response status code |
size | Response body size |
referer | Referer address |
3 Examples
Log the client IP and port, time, method, path and status with the default separator:
{
"http": {
"log_split": " ",
"log_format": [
"ip_port", "time", "method", "path", "status"
]
}
}
To make logs easy to split later, pick a separator that never appears inside a field:
{
"http": {
"log_split": "|",
"log_format": [
"time", "ip_port", "method", "path", "status", "size", "user_agent"
]
}
}
User-Agent values can contain spaces, so a space separator makes the field count unstable when parsing. Prefer
|, \t or another character unlikely to appear in the content.