Logging
In one line
Logging is the practice of recording application events and errors to centralized storage for debugging and analysis.
In simple words
Logging is the practice of recording what your application does — events, errors, warnings, info messages — so you can debug problems and understand behavior. In a containerized environment, logs are especially important because you cannot SSH into a container to look around.
In DevOps, logs from all your services are collected and sent to a centralized log store where you can search and analyze them. This is crucial because in a microservices architecture, a single user request might touch many services, and you need to trace the problem across all of them.
Popular logging stacks include the ELK Stack (Elasticsearch, Logstash, Kibana) and Loki (by Grafana Labs). Logs are typically structured (JSON format) so they can be searched and filtered easily.
Example
# View logs from a Kubernetes Pod
kubectl logs my-app-pod
# View logs from a Docker container
docker logs my-container
# Tail logs in real-time
kubectl logs -f my-app-podThese commands show logs from a Kubernetes Pod and a Docker container. The -f flag follows the log output in real-time.
How it works
- Applications write logs to stdout/stderr.
- A log collector (Fluentd, Filebeat) reads and forwards them.
- Logs are stored in a centralized store (Elasticsearch, Loki).
- You search and visualize logs using a tool like Kibana or Grafana.
Common confusions
Confused with: Monitoring
The difference: Logging records discrete events (text); monitoring collects numeric metrics (CPU, memory) over time. Both are needed for full observability.
Related terms
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.