Skip to main content

📜 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.

info

Logs are queried with kubectl. The Nuvion Panel does not have a pod logs screen.


🚀 Before you start​

🚀 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​

GoalCommand
Last 5 lineskubectl logs gerador-logs --tail=5
Last minutekubectl logs gerador-logs --since=1m
With date and timekubectl logs gerador-logs --timestamps
Specific containerkubectl 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.

warning

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​

SymptomCauseSolution
container ... is waiting to startThe container has not started yetSee Events
a container name must be specifiedThe pod has more than one containerUse -c CONTAINER-NAME
previous terminated container not foundThe container never restartedUse --previous only after a restart
No outputThe application does not write to standard outputConfigure 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!