Nginx Access Logs vs Error Logs
Two logs, two questions
An access log tells you what happened to a request; an error log helps explain operational problems. Start with the HTTP status the client received, then use relevant diagnostics to investigate why. A successful request may appear only in the access log, while a startup failure can appear without any request at all. The following directives use a private lab prefix with an existing writable logs directory.
access_log logs/access.log combined;error_log logs/error.log warn;This partial HTTP configuration uses the predefined combined format for requests and records diagnostics at warning severity or higher. In a packaged installation the actual destinations may be elsewhere, including stderr or syslog. Read the selected configuration rather than assuming a universal path.
Read a request record
192.0.2.14 - - [12/Jan/2026:10:00:00 +0000] "GET /guide.html HTTP/1.1" 200 128 "-" "LabClient/1.0"The example says a client requested /guide.html and received status 200. The 128 value is the body byte count, not the total including response headers. A dash in the identity or referrer fields represents unavailable information here. The address and date are fictional. A 200 response does not prove the page contained the intended data.
2026/01/12 10:00:01 [error] 410#410: *7 open() "/lab/site/missing.html" failed (2: No such file or directory), client: 192.0.2.14, server: learn.test, request: "GET /missing.html HTTP/1.1"The failing operation is open(); the candidate path and operating-system message are useful clues. Check whether the file is absent or the configured root is wrong. The displayed connection number *7 is not a request ID: several requests may share a connection. Correlate with time, route and connection context, not a guessed one-to-one relationship.
Severity is a filter, not an HTTP code
debug → info → notice → warn → error → crit → alert → emergA warn threshold includes warn and all more severe levels, but excludes notice and info. Debug output needs a debug-capable build and should be tightly scoped because it can be verbose and sensitive. An HTTP 404 need not produce an error record: an explicit return 404 can be intentional. Access logs normally reflect the context where processing finishes, which can differ after an internal redirect.
Client status and backend status can differ
client_status=200 upstream_status="502, 200"client_status=502 upstream_status="502"An upstream is a backend serving the proxy. The first line is consistent with a failed attempt followed by a successful attempt; the second indicates a failed client outcome. Upstream status can contain multiple entries and does not by itself prove a backend actually returned a response. Retry configuration and other diagnostics are needed. Proxy configuration is taught in the next chapter.
Practice
Read the supplied offline log fixtures. Identify one successful request, one missing file and one diagnostic without a matching request. Explain why adding more verbosity is not the first fix.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Access log interpretation
Choose the best answer based on the lesson and synthetic evidence.
Which log records the completed request outcome?
At warn threshold, which message is included?
In a combined record, what does the number after status measure?
A synthetic upstream status list says 502, 200 and client status is 200. What is consistent with it?
Why might a deliberate return 404 have no error log entry?