Logging and log levels
In short: Logging means a program writes important events to lines of text. Log levels such as DEBUG, INFO, WARN and ERROR show how important a message is.
In more detail: Logs are an application’s diary. When something goes wrong, the only trace is often what the program reported earlier. Good logs are structured, contain time, place and context, and do not reveal secrets.
In Depth
- Levels: DEBUG (development), INFO (normal flow), WARN (unusual but harmless), ERROR (failure), FATAL (crash).
- Structured: JSON lines with fields such as
time,level,requestIdcan be filtered by machines. - Correlation: A request ID on every line ties together all messages of one call.
- Never log: Passwords, tokens, full card numbers, unnecessary personal data.
- Operations: Logs are collected, searched and retained (for example with Loki or Elasticsearch) and deleted after a retention period.
See also: Observability: logs, metrics and traces