Working with Logs in Testing: Structure, Types, and Tools
A log is a text record of an event in a system. Each entry includes a timestamp, logging level (INFO, DEBUG, WARN, ERROR, FATAL), source (service or module), and a description of the event. When errors occur, a stack trace—listing function calls leading to the failure—is added, showing the execution path through the code.
The stack trace reveals files, classes, and methods involved in the operation. This is critical for pinpointing bugs in backend systems or mobile apps where the UI doesn’t expose internal details.
The Role of Logs in QA
Logs confirm bug existence, identify failure severity (client, server, integration), and provide essential data for developers. They’re invaluable for intermittent bugs where DevTools or packet sniffers fall short, or when encountering unexplained 500 server errors.
Testers extract from logs:
- Request and response parameters.
- Stack traces for debugging.
- Error recurrence frequency.
This accelerates retesting and deployment of fixes.
Server Logs: Access and Analysis
Server logs capture requests, parameters, responses, and errors. Accessible via SSH to /var/log/ (syslog, access_log) or specialized monitoring platforms.
Direct SSH Access
SSH connection lets you read raw logs on Linux servers. Use grep for ERROR entries and tail -f for real-time monitoring. Ideal when no UI tools are available.
Centralized Systems
- Kibana: Search by level, time, or service. Filters for 500/422 errors; view full requests/responses.
- Sentry: Full request details, stack traces, error frequency. Automated reporting to developers.
- Grafana: Dashboards tracking 4xx/5xx errors over time and by endpoint.
- Loguru: Simple timestamped text logs for basic analysis.
| Tool | Primary Function | Use in QA |
|------|------------------|-----------|
| Kibana | Event filtering | Diagnosing flaky bugs |
| Sentry | Stack trace | Reporting to devs |
| Grafana | Error metrics | Monitoring system failures |
| Loguru | Text logs | Basic log inspection |
Message Broker Logs
In asynchronous systems (e.g., Apache Kafka), logs track message exchanges. Common issues: message loss, invalid format, delays. Analyze via Kibana, Loggly, Datadog, or Confluent Control Center.
Example: Battle history request — consumer service logs reveal processing failures.
Mobile Logs: ADB and Logcat
For Android: ADB connects devices/emulators; Logcat displays event logs (screens, actions, errors). Filter by ERROR (E), detect freezes.
Logcat is essential when the UI remains silent during crashes.
Docker Container Logs
Docker container logs are accessed with docker logs <container_id>. Capture stdout/stderr output from apps. Crucial for microservices—combine with Kubernetes (kubectl logs) for orchestration.
Filters: --tail, --since for recent entries. Integrate with ELK stack (Elasticsearch, Logstash, Kibana) for large-scale analysis.
Key Takeaways:
- Logs are the go-to tool for root cause analysis after UI-based diagnostics.
- Levels: INFO/DEBUG for tracing, ERROR/FATAL for failures.
- Stack traces are mandatory for developers.
- Tools: Kibana/Sentry for search, Grafana for metrics.
- Mobile: ADB + Logcat; Containers:
docker logs.
— Editorial Team
No comments yet.