Vikas Rathore
Vikas Rathore

Reputation: 8821

How to get to the end of the Kubernates containers log

By running command kubectl logs pod -c container

I am getting continuous autoscrolling list of logs. Is there any way I can get to the end or see the latest log. I don't want go through all the logs.

I have tried using -f as well. Any suggestion?

Upvotes: 3

Views: 1182

Answers (2)

Prafull Ladha
Prafull Ladha

Reputation: 13449

You have two ways to see the recent log files, based on number of lines and based on time:

kubectl logs --tail=20 nginx

It will show you 20 lines of most recent logs

kubectl logs --since=1h nginx

It will show you logs of last one hour.

Upvotes: 1

Ami Hollander
Ami Hollander

Reputation: 2545

According to kubectl logs --help you can use --tail

e.g. kubectl logs pod --tail=10

Upvotes: 7

Related Questions