View Kubernetes logs in Cloud Code for VS Code

Cloud Code provides multiple ways to views logs. The Development sessions view provides a structured view of the logging output that surfaces tasks, artifacts, and deployed resources. This view lets you see the status of each task in your deployment and locate more information in the full logging output. The Log Viewer provides tools for searching and filtering logs.

Viewing the status of tasks and resources

When you start a development or debugging session, the Development sessions section displays the structured logging view.

Development sessions pane

  • To view the Development sessions section, click Cloud Code icon Cloud Code and then expand the Development sessions section.

  • As a task begins, the task is displayed with a spinning semi-circle icon Progress icon.

  • If a task succeeds, a green checkmark Success icon is displayed next to the step.

  • If a task fails, a red exclamation mark Failure icon is displayed next to the step.

  • To see details of a step, click the step in the Development sessions section. The Output tab displays the step in the logging output.

  • To view the full Skaffold logs, click the Status node.

  • To view the logs for a container, expand Status, expand Stream Application Logs, and then click the container name. The logs for the container are displayed in the Output tab.

Launching the Log Viewer

To launch the Log Viewer, open the Command Palette (press Ctrl/Cmd+Shift+P or click Manage icon Manage > Command Palette) and then type Cloud Code: View Logs.

Viewing logs for a specific resource

To view the logs for a specific resource, follow these steps:

  1. Click Cloud Code icon Cloud Code and then expand the Kubernetes section.

  2. In the Kubernetes section, expand the following:

    • Your preferred cluster's section
    • Namespaces
    • Your preferred namespace
    • Deployments
  3. Right-click the deployment and select View logs.

    View deployment logs

Viewing streaming logs

To have the Log Viewer display updated logs as the logs are generated, in the Log Viewer, turn the Streaming slider on.

Viewing Kubernetes logs using Cloud Logging

To display logs from GKE clusters with Cloud Logging enabled, follow these steps:

  1. To open the Log Viewer, open the Command Palette (press Ctrl/Cmd+Shift+P or click Manage icon Manage > Command Palette) and then type Cloud Code: View Logs.
  2. Select Kubernetes Application Logs from the Log Type list.
  3. To stream logs from multiple pods, turn on the Streaming slider and select all in the Pod list.
  4. Logs are displayed for the active cluster by default. To switch to a different cluster, select the cluster name from the Cluster list.

    Log Viewer showing Kubernetes Application Logs setting

Viewing Kubernetes logs using kubectl

To display logs from a non-GKE cluster or a GKE cluster without Cloud Logging enabled, follow these steps:

  1. To open the Log Viewer, open the Command Palette (press Ctrl/Cmd+Shift+P or click Manage icon Manage > Command Palette) and then type Cloud Code: View Logs.
  2. Select Kubectl Logs from the Log Type list.
  3. In the Deployment or Pod list, select a deployment or pod to view logs from.

    Viewing logs for a non-Cloud Logging cluster by setting the deployment
field within the Log Viewer search box to 'node-hello-world'

  4. To refine your search results, click Search Logs and then type search terms. This search includes the namespace, deployment, pod, container, and time. For clusters with Cloud Logging enabled, you can also filter by severity level.

Changing the display time

To change the display time to your preferred time zone, click the three-dot menu More menu next to the Time column and then choose a time zone.

Getting Support

To send feedback, report issues on GitHub, or ask a question on Stack Overflow.