Melihat log Kubernetes di Cloud Code untuk VS Code
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara melihat log streaming aplikasi Anda dan untuk memeriksa status resource dari dalam Cloud Code.
Tampilan
Sesi pengembangan
memberikan tampilan terstruktur dari output logging yang
menampilkan tugas, artefak, dan resource yang di-deploy. Tampilan ini memungkinkan Anda melihat status setiap tugas dalam deployment dan menemukan informasi selengkapnya dalam output logging lengkap.
Log Viewer menyediakan alat untuk menelusuri dan memfilter log.
Melihat status tugas dan resource
Saat Anda memulai sesi pengembangan atau proses debug, bagian Sesi pengembangan
akan menampilkan tampilan logging terstruktur.
Untuk melihat bagian Sesi pengembangan, buka Command Palette
(tekan Ctrl/Cmd+Shift+P), lalu jalankan perintah
Cloud Code: Fokus pada penjelajah sesi pengembangan.
Saat tugas dimulai, progress_activity
indikator progres setengah lingkaran yang berputar akan muncul.
Jika tugas berhasil, tanda centang
check_circle
akan muncul di samping langkah.
Jika tugas gagal, tanda error
error
akan muncul di samping langkah.
Untuk melihat detail langkah, klik langkah di bagian Sesi pengembangan. Tab Output menampilkan langkah dalam output logging.
Untuk melihat log Skaffold lengkap, klik node Status.
Untuk melihat log penampung, luaskan Status, luaskan Stream
Application Logs, lalu klik nama penampung. Log untuk penampung ditampilkan di tab Output.
Meluncurkan Log Viewer
Untuk meluncurkan Log Viewer, buka palet perintah
(tekan Ctrl/Cmd+Shift+P atau klik View > Command Palette), lalu jalankan Cloud Code: View Logs.
Men-streaming log dari pod
Untuk melakukan streaming log dari pod:
Klik Cloud Code, lalu luaskan bagian Kubernetes.
Luaskan cluster minikube, lalu luaskan Pod.
Klik kanan pod, lalu klik Stream Logs.
Jika ada beberapa penampung di pod, pilih penampung saat
diminta.
Melihat log dari pod
Klik Cloud Code, lalu luaskan bagian Kubernetes.
Luaskan cluster minikube, lalu luaskan Pod.
Klik kanan pod, lalu klik Lihat Log
Jika ada beberapa penampung di pod, pilih penampung saat
diminta.
Melihat log untuk resource tertentu
Untuk melihat log resource tertentu, ikuti langkah-langkah berikut:
Klik Cloud Code, lalu luaskan bagian Kubernetes.
Di bagian Kubernetes, luaskan hal berikut:
Cluster yang lognya ingin Anda lihat
Namespace
Namespace yang log-nya ingin Anda lihat
Deployment
Klik kanan deployment, lalu pilih View logs.
Melihat log streaming
Agar Log Viewer menampilkan log yang diperbarui saat log dibuat, di
Log Viewer, aktifkan penggeser Streaming.
Melihat log Kubernetes menggunakan Cloud Logging
Untuk menampilkan log dari cluster GKE dengan Cloud Logging diaktifkan, ikuti langkah-langkah berikut:
Untuk membuka Log Viewer, buka palet perintah (tekan
Ctrl/Cmd+Shift+P atau klik View > Command Palette), lalu jalankan Cloud Code: View Logs.
Pilih Log Aplikasi Kubernetes dari daftar Jenis Log.
Untuk melakukan streaming log dari beberapa pod, aktifkan penggeser Streaming dan
pilih all dalam daftar Pod.
Log ditampilkan untuk cluster aktif secara default. Untuk beralih ke
cluster lain, pilih nama cluster dari daftar Cluster.
Melihat log Kubernetes menggunakan kubectl
Untuk menampilkan log dari cluster non-GKE atau
cluster GKE tanpa mengaktifkan Cloud Logging, ikuti
langkah-langkah berikut:
Untuk membuka Log Viewer, buka palet perintah (tekan
Ctrl/Cmd+Shift+P atau klik View > Command Palette), lalu jalankan Cloud Code: View Logs.
Pilih Kubectl Logs dari daftar Log Type.
Dalam daftar Deployment atau Pod, pilih deployment atau pod untuk melihat log.
Untuk menyaring hasil penelusuran, klik Log Penelusuran, lalu ketik
istilah penelusuran. Penelusuran ini mencakup namespace, deployment, pod, penampung,
dan waktu. Untuk cluster yang mengaktifkan Cloud Logging, Anda juga dapat memfilter
berdasarkan tingkat keparahan.
Mengubah waktu tampilan
Untuk mengubah waktu tampilan ke zona waktu yang berbeda, klik
more_vertLainnya
di samping header kolom Waktu, lalu pilih zona waktu.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-11 UTC."],[[["\u003cp\u003eThis page outlines how to access and view streaming logs for your application and check resource statuses using Cloud Code.\u003c/p\u003e\n"],["\u003cp\u003eThe Development sessions section provides a structured logging view, indicating task progress with visual cues like checkmarks and error indicators.\u003c/p\u003e\n"],["\u003cp\u003eThe Log Viewer can be launched via the command palette to search, filter, and display application and Kubernetes logs from various sources.\u003c/p\u003e\n"],["\u003cp\u003eLogs can be streamed from specific pods, viewed for individual resources like deployments, or aggregated for GKE clusters using Cloud Logging.\u003c/p\u003e\n"],["\u003cp\u003eUsers can view Kubernetes logs using either Cloud Logging for GKE or kubectl for non-GKE clusters, with search and time zone customization options available.\u003c/p\u003e\n"]]],[],null,["# View Kubernetes logs in Cloud Code for VS Code\n\nThis page describes how to view the streaming logs of your application and to\ncheck the status of resources from within Cloud Code.\n\nThe\n[Development sessions](#view_the_status_of_tasks_and_resources)\nview provides a structured view of the logging output that\nsurfaces tasks, artifacts, and deployed resources. This view lets you\nsee the status of each task in your deployment and locate more information in\nthe full logging output.\n\nThe [Log Viewer](#launch_the_log_viewer) provides tools for searching and\nfiltering logs.\n\nView the status of tasks and resources\n--------------------------------------\n\nWhen you start a development or debugging session, the\n[**Development sessions** section](/code/docs/vscode/k8s-overview#development-section)\ndisplays the structured logging view.\n\n- To view the **Development sessions** section, open the Command Palette\n (press `Ctrl`/`Cmd`+`Shift`+`P`) and then run the\n **Cloud Code: Focus on development sessions explorer** command.\n\n- As a task begins, a\n progress_activity\n spinning semi-circle progress indicator appears.\n\n- If a task succeeds, a\n check_circle\n checkmark appears next to the step.\n\n- If a task fails, an\n error\n error mark appears next to the step.\n\n- To see details of a step, click the step in the **Development sessions**\n section. The **Output** tab displays the step in the logging output.\n\n- To view the full [Skaffold](/skaffold) logs, click the **Status** node.\n\n- To view the logs for a container, expand **Status** , expand **Stream\n Application Logs** , and then click the container name. The logs for the\n container are displayed in the **Output** tab.\n\nLaunch the Log Viewer\n---------------------\n\nTo launch the [Log Viewer](/code/docs/vscode/k8s-overview#view_logs), open the command palette\n(press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e **Command Palette** ) and\nthen run **Cloud Code: View Logs**.\n\nStream logs from a pod\n----------------------\n\nTo stream logs from a pod:\n\n1. Click **Cloud Code** and then expand the **Kubernetes** section.\n2. Expand your minikube cluster and then expand **Pods**.\n3. Right-click a pod and then click **Stream Logs**.\n4. If there are multiple containers in the pod, select a container when prompted.\n\nView logs from a pod\n--------------------\n\n1. Click **Cloud Code** and then expand the **Kubernetes** section.\n2. Expand your minikube cluster and then expand **Pods**.\n3. Right-click a pod and then click **View Logs**\n4. If there are multiple containers in the pod, select a container when prompted.\n\nView logs for a specific resource\n---------------------------------\n\nTo view the logs for a specific resource, follow these steps:\n\n1. Click **Cloud Code** and then expand the **Kubernetes** section.\n2. In the **Kubernetes** section, expand the following:\n\n - The cluster whose logs you want to view\n - **Namespaces**\n - The namespace whose logs you want to view\n - **Deployments**\n3. Right-click the deployment and select **View logs**.\n\nView streaming logs\n-------------------\n\nTo have the Log Viewer display updated logs as the logs are generated, in\nthe Log Viewer, turn the **Streaming** slider on.\n\nView Kubernetes logs using Cloud Logging\n----------------------------------------\n\nTo display logs from GKE clusters with\n[Cloud Logging](/logging/docs) enabled, follow these steps:\n\n1. To open the Log Viewer, open the command palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e **Command Palette** ) and then run **Cloud Code: View Logs**.\n2. Select **Kubernetes Application Logs** from the **Log Type** list.\n3. To stream logs from multiple pods, turn on the **Streaming** slider and select **all** in the **Pod** list.\n4. Logs are displayed for the active cluster by default. To switch to a different cluster, select the cluster name from the **Cluster** list.\n\nView Kubernetes logs using kubectl\n----------------------------------\n\nTo display logs from a non-GKE cluster or a\nGKE cluster without Cloud Logging enabled, follow\nthese steps:\n\n1. To open the Log Viewer, open the command palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e **Command Palette** ) and then run **Cloud Code: View Logs**.\n2. Select **Kubectl Logs** from the **Log Type** list.\n3. In the **Deployment** or **Pod** list, select a deployment or pod to view logs from.\n4. 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.\n\nChange the display time\n-----------------------\n\nTo change the display time to a different time zone, click\nmore_vert**More**\nnext to the **Time** column header and then choose a time zone.\n\nWhat's next\n-----------\n\n- [Debug a Kubernetes application in Cloud Code](/code/docs/vscode/debug).\n- Explore the Kubernetes documentation on [troubleshooting containerized applications](https://kubernetes.io/docs/tasks/debug/debug-application/).\n\nGet Support\n-----------\n\nTo send feedback, report issues on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-vscode/issues), or ask a question on [Stack Overflow](https://stackoverflow.com/questions/ask?tags=cloud-code-vscode)."]]