diff options
author | Zhidao HONG <z.hong@f5.com> | 2024-01-23 18:57:30 +0800 |
---|---|---|
committer | Zhidao HONG <z.hong@f5.com> | 2024-01-29 13:48:53 +0800 |
commit | 4c91bebb50d06b28e369d68b23022caa072cf62d (patch) | |
tree | fb15434e915f77041e56b111bfca90ce8e83ebe6 /src/nxt_fs.c | |
parent | 37abe2e4633d66241bf1766a740d2b2734c132fa (diff) | |
download | unit-4c91bebb50d06b28e369d68b23022caa072cf62d.tar.gz unit-4c91bebb50d06b28e369d68b23022caa072cf62d.tar.bz2 |
HTTP: enhanced access log with conditional filtering.
This feature allows users to specify conditions to control if access log
should be recorded. The "if" option supports a string and JavaScript code.
If its value is empty, 0, false, null, or undefined, the logs will not be
recorded. And the '!' as a prefix inverses the condition.
Example 1: Only log requests that sent a session cookie.
{
"access_log": {
"if": "$cookie_session",
"path": "..."
}
}
Example 2: Do not log health check requests.
{
"access_log": {
"if": "`${uri == '/health' ? false : true}`",
"path": "..."
}
}
Example 3: Only log requests when the time is before 22:00.
{
"access_log": {
"if": "`${new Date().getHours() < 22}`",
"path": "..."
}
}
or
{
"access_log": {
"if": "!`${new Date().getHours() >= 22}`",
"path": "..."
}
}
Closes: https://github.com/nginx/unit/issues/594
Diffstat (limited to 'src/nxt_fs.c')
0 files changed, 0 insertions, 0 deletions