Viewing and saving log files

About this task

To begin, you need to decided which logs to view based upon the problem. Each pod and container performs a specific task, deciding which one to look at its log is the first step. Review the Pods in Sametime topic to understand what each does. Some pods have multiple containers. When you run the command to view the logs, the pods that have multiple containers need to have the container argument as well. For pods that only have one container, you do not need to specify the container name.

Procedure

  1. Get the name of the pod.
    Pod name have hashes in it that change each time a pod is started. To get the name of the current pods, issue the kubectl get pods command.
    The following example shows output from the command. The output includes all current pod names.
    
    kubectl get pods 
    
    NAME                                                     READY   STATUS             RESTARTS  AGE 
    
    activity-5675f8bc9d-49b4f                                1/1     Running            0         21h 
    
    app-registry-84d89cfdd4-62z9s                            1/1     Running            0         21h 
    
    auth-7459fc7cd7-cqnjt                                    1/1     Running            0         21h 
    
    backgrounds-c9fb7b87c-m2gpc                              1/1     Running            0         21h 
    
    catalog-6cdd48b6d6-8k669                                 1/1     Running            0         21h 
    
    click2call-578d49d876-227fw                              1/1     Running            0         21h 
    
    community-695c867bfb-6tl42                               2/2     Running            0         21h 
    
    files-8454687cd8-xwsr8                                   2/2     Running            0         21h 
    
    jibri-web-64c6d478fc-sfz9j                               1/1     Running            0         21h 
    
    jitsi-7b86fc4f64-vtrrb                                   3/3     Running            0         21h 
    
    lobby-5ccf4bcb-s8mbr                                     1/1     Running            0         21h 
    
    location-5868588458-htxtj                                1/1     Running            0         21h 
    
    mux-6b4bdc46d7-86768                                     1/1     Running            0         21h 
    
    nginx-ingress-ingress-nginx-controller-5765f86f6-2dxq6   1/1     Running            0         21h 
    
    outlook-5f946d99fd-nxhrc                                 1/1     Running            0         21h 
    
    proxy-5697bc66f5-l88sf                                   1/1     Running            0         21h 
    
    recorder-6b4d9d4598-jqpss                                2/2     Running            0         21h 
    
    recordings-bd9f7b94f-5hhzq                               1/1     Running            0         21h 
    
    video-778749bc5d-jhj5j                                   2/2     Running            0         21h 
    
    web-5b5f4578d4-qmckq                                     1/1     Running            0         21h 
    
  2. To view the log for a specific pod. Run the following command, using the name of the pod including the hashes. If there is a specific container to gather the log, include both the pod name and container name on the command.
    kubectl logs pod_name container_name 
    For example, if you want to view the jvb logs from the video pod, enter the command:
     kubectl logs video-58f8589f99-f4tcd jvb 
    You can also use the --all-containers argument to see logs from all the containers on the pod.
    kubectl logs video-58f8589f99-f4tcd --all-containers 
    To redirect the output to a file, add the greater than character ( >) as an argument on the command and specifying a location that you have access to put the file. For example:
     kubectl logs video-58f8589f99-f4tcd --all-containers > /tmp/video.txt