kubectl logs - continuously

I needed to access the logs of a long running pod, and -f began streaming logs from days ago, which would have taken hours to get to where I needed to view ( just the last couple minutes or so ).

There is a --since=10m flag, but that didn't seem to work for me.

What did wonders was --tail=100, where 100 is the number of recent lines to display.


kubectl logs --help will guide you:

Example:

# Begin streaming the logs of the ruby container in pod web-1
kubectl logs -f -c ruby web-1

Flags:

-f, --follow[=false]: Specify if the logs should be streamed.

You can also add --since=10m or so start from that relative time ago.


kubectl logs -f <pod-id>

You can use the -f flag:

-f, --follow=false: Specify if the logs should be streamed.

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#logs