When using kubectl logs
to log a given Kubernetes pod’s messages (link), the logs shown are truncated when there are too many logs, it seems.
Even when adding a flag such as --since
:
kubectl logs -f <pod name> --since=1h
The logs shown by kubectl logs
are truncated at about 106K characters, which is too little for what I need.
Ideally, I want to see all the logs of the past hour, regardless of how many characters/lines.
Isn't that possible?
You can use --tail flag in kubectl logs
specifying the maximum number of lines to return. Setting it to a large number (e.g., 1000) that may fetch more logs, potentially bypassing truncation.
kubectl logs <pod-name> --since=1h --tail=1000
You can also use -f and redirect to a file. The -f flag
streams logs redirecting to a file that may ensure that all logs are saved without being limited by terminal.
kubectl logs -f <pod-name> --since=1h > pod_logs.txt
For more logs flag you can refer to this documentation.