Backend

Server Logs

You might say

There's an error in production. Where can I see what happened on the server?

Record what the server did so problems can be tracedServer logs capture requests, errors, background jobs, and important state changes. Useful logs include time, severity, and a request or job identifier. Avoid recording passwords, tokens, and unnecessary personal data, and connect related events so one failure can be followed across services.
Server logreq_8fa2
12:08:31Request receivedPOST /api/orders12:08:31Order writtenorder=o_91184msResponse sent201
One request id connects the whole request
Anatomy
12:08:31 · INFOreq_8fa2order created · 184ms
Indicates when it occurred, whether it was a general message, warning, or error
String together multiple lines of logs generated by the same request to facilitate cross-step tracking
Record actions, results, time taken and necessary identification, but do not write passwords, tokens or complete personal information
Variants
INFO
Request completed · 201
Record important successful business actions.
WARN
Retry 2nd time
Something recovered but deserves attention.
ERROR
Database connection failed
A failed request requiring diagnosis or alerting.
Typical use cases
API error
Function logSee what happened in a request
12:08:31 INFO req_8fa2POST /api/ordersorder created · 201 · 184ms
Deployment issue
Request trackingUse the same request id to string together multiple steps
req_8fa2 · request receivedreq_8fa2 · payment checkedreq_8fa2 · order savedreq_8fa2 · response 201
Background job
500 errorUsers see a brief prompt and the log retains details
Page cannot be saved temporarily, please try againLogDB timeout · stack line 42
Security event
Run monitoringCollect error rate and time consumption from logs
Request volume12.4kP95 latency820msError rate8.2%AlarmNotified