Kubernetes log location in pod

6/15/2018

I am just trying to find the log location in the pod.

I just logged into the pod as below.

kubectl exec -it POD_NAME bash

But, the logs are not available under /var/logs. Not sure what is the actual log location and how to change that.

Thanks

-- user1578872
kubernetes
logging

4 Answers

6/15/2018

The log file in your containers depend on the application you are running, different applications output logs to different location, for instance, the tomcat in my environment output logs into /usr/local/tomcat/logs directory.

The logs of pod, we mean console output here, will be saved into a container directory in your host, then linked to /var/log/pods/$pod_name directory, you can find logs there.

-- Kun Li
Source: StackOverflow

12/6/2018

Please check /opt/logs/app.log

If you are unable to find this directory then just search app.log using find command.

 find / -name "app.log"

In worst case

find / -name "*.log"
-- Aditya
Source: StackOverflow

6/15/2018

It's impossible to answer your question, because no one other than you knows how your application configured and deployed.

I can only guess your application writes logs to stdout via Docker json logging driver and your logs are stored on the one of your k8s nodes:

$ sudo find /var/lib/docker/containers -name "*-json.log"

By default you can find pod's logs with kubectl -n <namespace> logs <pod_name> command

More info: https://kubernetes.io/docs/concepts/cluster-administration/logging/

-- Konstantin Vustin
Source: StackOverflow

11/18/2019

If your application is writing logs to file, then the location of that log file within the container depends on your application. The location of the log file on the host depends on whether you've mounted the log directory on the host.


If your application is writing logs to stdout, then your container runtime would capture each line and store it on the host. For Docker, this is stored in the /var/lib/docker/containers directory.

But Kubernetes also makes it easier for you to find the log files on the Kubernetes node, by symlinking the relevant log file to /var/log/pods/<namespace>_<pod_name>_<pod_id>/<container_name>/.

-- d4nyll
Source: StackOverflow