Skip to content

Commit dc4b500

Browse files
authored
Description for setting custom format for access_log or turning it OFF (#1394)
Guide how to turn data plane access_log OFF and how to configure custom log_format for access logs
1 parent c9005eb commit dc4b500

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

content/ngf/how-to/data-plane-configuration.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,44 @@ of a few arguments. {{< /call-out >}}
272272

273273
---
274274

275+
## Configure the data plane log format
276+
277+
NGINX records client requests immediately after each request is processed. You can use the `NginxProxy` resource to dynamically configure the access log format.
278+
279+
The following command creates a basic `NginxProxy` that defines a custom log format `$remote_addr - [$time_local] "$request" $status $body_bytes_sent`:
280+
281+
```yaml
282+
kubectl apply -f - <<EOF
283+
apiVersion: gateway.nginx.org/v1alpha2
284+
kind: NginxProxy
285+
metadata:
286+
name: ngf-proxy-config
287+
spec:
288+
logging:
289+
accessLog:
290+
format: $remote_addr - [$time_local] "$request" $status $body_bytes_sent
291+
EOF
292+
```
293+
294+
You can disable access logging entirely with the following configuration:
295+
296+
```yaml
297+
kubectl apply -f - <<EOF
298+
apiVersion: gateway.nginx.org/v1alpha2
299+
kind: NginxProxy
300+
metadata:
301+
name: ngf-proxy-config
302+
spec:
303+
logging:
304+
accessLog:
305+
disable: true
306+
EOF
307+
```
308+
309+
{{< call-out "note" >}} File destinations in `logging.accessLog` are not currently supported it is always set to `/dev/stdout`. {{< /call-out >}}
310+
311+
---
312+
275313
### Run NGINX Gateway Fabric with NGINX in debug mode
276314

277315
To run NGINX Gateway Fabric with NGINX in debug mode, during [installation]({{< ref "/ngf/install/" >}}), follow these additional steps:

0 commit comments

Comments
 (0)