General Logging
2026-02-14
Edited: 2026-02-14
Logging is hard. Some tips on logging taken from
- https://betterstack.com/community/guides/logging/log-levels-explained/
- https://betterstack.com/community/guides/logging/logging-best-practices/
- https://betterstack.com/community/guides/logging/nodejs-logging-best-practices/
I know it says for Node.js but it is applicable elsewhere.
Just going to do a brief rundown
- log levels
- structured logging (like json)
- aggregate and centralize logs (more for web)
- logging performance (this can have an issue)
- log to stdout
- add timestamps and context (like req for express)
- add stack trace
For log levels, I like
- FATAL/CRITICAL: bad, unrecoverable
- ERROR: bad, but recoverable
- WARN: not too bad
- INFO: operation summary, general stuff
- DEBUG: nitty gritty, database queries, timing, configuration stuff
- TRACE: entering and leaving functions (rust has cool stuff with this)