How to check the historical logs of pods in k8s?
To view the historical logs of a Pod in Kubernetes, you can follow these steps:
- First, use the following command to list all running Pods:
kubectl get pods
- Choose the Pod to view the historical logs for and use the following command to list the Pod’s log files:
kubectl logs --previous <pod-name>
This will display the historical logs of the selected Pod. Please note that if the Pod has been deleted or restarted, its historical logs may not be viewable.
Furthermore, you can use the following command to obtain a summary of the logs for the Pod:
kubectl logs --previous --tail=<number-of-lines> <pod-name>
By replacing
Please note that the above command is only applicable to Pods with a single container. If the Pod has multiple containers, you need to specify the container name.
kubectl logs --previous <pod-name> -c <container-name>
Replace