📜 Logs
Logs are the application's "diary": everything it writes to standard output shows up here. It is the first thing to check when something goes wrong.
Logs are queried with kubectl. The Nuvion Panel does not have a pod logs screen.
🚀 Before you start
- Have cluster access configured (see Cluster Access).
🚀 1. Create a pod that generates logs
kubectl run gerador-logs --image=busybox -- sh -c 'i=0; while true; do echo "Linha $i"; i=$((i+1)); sleep 2; done'
Wait for the pod to be Running.
🚀 2. See the logs
kubectl logs gerador-logs
🚀 3. Follow in real time
kubectl logs -f gerador-logs
New lines appear as they are generated. Exit with Ctrl+C.
🚀 4. Filter what to show
| Goal | Command |
|---|---|
| Last 5 lines | kubectl logs gerador-logs --tail=5 |
| Last minute | kubectl logs gerador-logs --since=1m |
| With date and time | kubectl logs gerador-logs --timestamps |
| Specific container | kubectl logs POD-NAME -c CONTAINER-NAME |
🚀 5. See logs from a Deployment or multiple pods
kubectl logs deployment/DEPLOYMENT-NAME
kubectl logs -l app=APP-NAME --all-containers --tail=20
The first shows the logs of one of the pods. The second gathers all pods with the given label.
🚀 6. See the logs from before the restart
When the container fails and restarts, the logs from the moment of failure are in the previous run. To test:
kubectl run pod-crash --image=busybox -- sh -c 'echo "vou falhar"; exit 1'
kubectl logs pod-crash --previous
Expected output: vou falhar
✅ How to know it worked
Step 3 shows the lines Linha 0, Linha 1... being generated, and step 6
shows the message from the container that failed.
Logs are kept only while the pod exists. When you delete or recreate the pod, they are lost. To keep the history, send the logs to an external system.
❗ Common problems
| Symptom | Cause | Solution |
|---|---|---|
container ... is waiting to start | The container has not started yet | See Events |
a container name must be specified | The pod has more than one container | Use -c CONTAINER-NAME |
previous terminated container not found | The container never restarted | Use --previous only after a restart |
| No output | The application does not write to standard output | Configure the application to log to stdout |
🧹 Cleanup
kubectl delete pod gerador-logs pod-crash
➡️ Next step: Events
🧠 Questions?
Talk to our SaveinCloud technical support team!