Log Management Best Practices Cheat Sheet
Patterns for structured logging, centralized log aggregation, retention, and querying across distributed systems.
2 PagesIntermediateFeb 2, 2026
Standard Log Levels
Common severity levels and when to use them.
- DEBUG- Detailed diagnostic info, disabled in production by default
- INFO- Routine operational events, e.g. request handled, job started
- WARN- Unexpected but recoverable condition
- ERROR- Operation failed, requires attention but process continues
- FATAL/CRITICAL- Unrecoverable error, process is about to exit
Structured JSON Logging
Emit logs as JSON so they're machine-parseable by aggregators.
json
{ "timestamp": "2026-07-08T10:22:31Z", "level": "error", "service": "checkout-api", "trace_id": "a1b2c3d4", "message": "payment gateway timeout", "http_status": 504, "user_id": "u_9182"}
Elasticsearch / Kibana Query (KQL)
Query syntax for filtering logs in Kibana Discover.
text
# Find errors from a specific service in the last 15mservice: "checkout-api" and level: "error"# Range query on a numeric fieldhttp_status >= 500 and http_status < 600# Wildcard search on message textmessage: *timeout*
logrotate Config
Rotate and compress local log files to control disk usage.
bash
# /etc/logrotate.d/myapp/var/log/myapp/*.log { daily rotate 14 compress delaycompress missingok notifempty create 0640 appuser appgroup}
Centralized Logging Pipeline
Typical components in a log aggregation pipeline.
- Shipper (Filebeat/Fluent Bit)- Lightweight agent that tails log files and forwards them
- Aggregator (Logstash/Fluentd)- Parses, enriches, and transforms log events before storage
- Storage (Elasticsearch/Loki)- Indexed store optimized for full-text or label-based search
- Visualization (Kibana/Grafana)- Dashboards and ad-hoc search UI over stored logs
Pro Tip
Always propagate a trace/correlation ID through every log line for a request — it turns scattered logs into a single searchable thread across microservices.
Was this cheat sheet helpful?
Previous
Infrastructure Monitoring Best Practices Cheat Sheet
Next
Site Reliability Engineering (SRE) Basics Cheat Sheet
Explore Topics
#LogManagementBestPractices#LogManagementBestPracticesCheatSheet#DevOps#Intermediate#StandardLogLevels#StructuredJSONLogging#Elasticsearch#Kibana#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance