Bartosz Bierkowski - Low dose cloud

OpenShift Morsels: troubleshooting with logs

On Day #5 a small entry about getting logs of a pod.

Everyone knows and uses logging. My favourite one is the println in the code, but of course it is not the best. One can much better. In OpenShift, all the logs should be printed out to standard output. Then they can be collected for further processing and indexing.

Getting the logs is straightforward: oc logs <pod-name>

These are the first lines logged after starting the nodejs pod.

The command comes with just a few, but very useful parameters.

oc logs --timestamps <pod> – will extend the log output with  the timestamp, which can be quite useful if you used println for “logging”

oc logs <pod> -c <container>  – gives you logs from specific container in the pod. This parameter is required if you have multiple containers in  the pod.

oc logs --since=1h <pod>  – print out logs only from last hour. Isn’t this useful when an application produces lots of logs? You can use other units like 10m or 30s.

oc logs --tail=10 <pod>  – display last 10 messages that were logged.

Of course you can mix them to get a better overview on what was happening with your application and when.


Check out the help from the command with oc logs --help . And anyway do it often for any command you use, maybe you discover something useful that I omitted.


The commands were executed using minishift and the following client/server versions of OpenShift.

oc v3.6.1+008f2d5
client kubernetes v1.6.1+5115d708d7
openshift v3.6.0+c4dd4cf
server kubernetes v1.6.1+5115d708d7


Thanks for reading the OpenShift morsels. To get updates about new articles, you can sign up to the newsletter below.

As a thank you message, you will also get access to OpenShift CLI CheatSheet listing most commonly used commands together with a short explanation.

Did you like the article?
Join the newsletter to receive notifications about new articles.
I respect your privacy.