log_format custom '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $request_time'; access_log /var/log/nginx/access.log custom;
The log format uses variables like $remote_addr for client IP, $request for method and URI, $status for HTTP status, and $request_time for response time. The example request is GET /home with status 200 and response time 0.123 seconds, so option C matches exactly.
The directive access_log off; disables access logging for the specified location. Option B correctly uses this syntax. Option B is invalid because off cannot be used with a file path. Option B sends logs to /dev/null but does not disable logging. Option B disables error logging, not access logging.
If the log file cannot be written due to permission issues, no logs will appear. The location block disables logging only for /api, so other requests should still log. The combined format is standard and valid. Nginx reload or restart is needed only after config changes, but the question implies config is active.
First, edit the config file (4), then define the log_format (1), then set access_log with that format (3), finally reload nginx (2) to apply.
Disabling logs (B) loses valuable data. Writing to a single large file (C) risks disk space and slowdowns. Logging only errors (D) misses access info. Using asynchronous logging with a log processor and rotating logs (A) balances performance and data retention.