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.
When to use it
- Investigate failed requests
- Monitor background jobs
- Trace one request across several steps
- Record important operational events
When NOT to use it
- Log passwords, tokens, or full private payloads
- Write only a generic message with no context
- Use console output as the only monitoring plan
- Keep unlimited logs without retention and access rules
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