Visualizzare i log di Kubernetes in Cloud Code per Cloud Shell
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina descrive come visualizzare i log di streaming della tua applicazione e controllare lo stato delle risorse da Cloud Code.
La visualizzazione Sessioni di sviluppo fornisce una visualizzazione strutturata dell'output di logging che mostra attività, artefatti e risorse di cui è stato eseguito il deployment. Questa visualizzazione ti consente di visualizzare lo stato di ogni attività di deployment e di trovare ulteriori informazioni nell'output completo dei log.
Il Visualizzatore log fornisce strumenti per la ricerca e
il filtraggio dei log.
Visualizzare lo stato di attività e risorse
Quando avvii una sessione di sviluppo o di debug, la sezione Sessioni di sviluppo visualizza la vista di registrazione strutturata.
Per visualizzare la sezione Sessioni di sviluppo, apri la tavolozza dei comandi (premi Ctrl/Cmd+Shift+P) ed esegui il comando Cloud Code: Esplorare le sessioni di sviluppo.
All'inizio di un'attività viene visualizzato un indicatore di avanzamento semicircolare in rotazione
progress_activity.
Se un'attività va a buon fine, accanto al passaggio viene visualizzato un segno di spunta check_circle.
Se un'attività non va a buon fine, accanto al passaggio viene visualizzato un segno di errore.
Per visualizzare i dettagli di un passaggio, fai clic sul passaggio nella sezione Sessioni di sviluppo. La scheda Output mostra il passaggio nell'output del logging.
Per visualizzare i log completi di Skaffold, fai clic sul nodo Stato.
Per visualizzare i log di un contenitore, espandi Stato, espandi Stream
log applicazione e poi fai clic sul nome del contenitore. I log del
contenitore vengono visualizzati nella scheda Output.
Avvia il visualizzatore log
Per avviare il Visualizzatore log, apri la tavolozza dei comandi (premi Ctrl/Cmd+Shift+P o fai clic su Visualizza > Tavolozza comandi) e poi esegui Cloud Code: Visualizza log.
Trasmettere i log da un pod
Per riprodurre in streaming i log da un pod:
Fai clic su Cloud Code ed espandi la sezione Kubernetes.
Espandi il cluster minikube, quindi espandi Pod.
Fai clic con il tasto destro del mouse su un pod e poi su Stream log.
Se il pod contiene più contenitori, selezionane uno quando richiesto.
Visualizzare i log da un pod
Fai clic su Cloud Code ed espandi la sezione Kubernetes.
Espandi il cluster minikube, quindi espandi Pod.
Fai clic con il tasto destro del mouse su un pod, quindi su Visualizza log.
Se il pod contiene più contenitori, selezionane uno quando richiesto.
Visualizzare i log per una risorsa specifica
Per visualizzare i log di una risorsa specifica:
Fai clic su Cloud Code ed espandi la sezione Kubernetes.
Nella sezione Kubernetes, espandi quanto segue:
Il cluster di cui vuoi visualizzare i log
Spazi dei nomi
Lo spazio dei nomi di cui vuoi visualizzare i log
Deployment
Fai clic con il tasto destro del mouse sulla distribuzione e seleziona Visualizza log.
Visualizza i log in streaming
Per fare in modo che il visualizzatore log mostri i log aggiornati man mano che vengono generati, attiva il cursore Streaming nel visualizzatore log.
Visualizzare i log di Kubernetes utilizzando Cloud Logging
Per visualizzare i log dei cluster GKE con Cloud Logging abilitato, segui questi passaggi:
Per aprire il visualizzatore log, apri la tavolozza dei comandi (premi Ctrl/Cmd+Shift+P o fai clic su Visualizza > Tavolozza comandi) e poi esegui Cloud Code: Visualizza log.
Seleziona Log delle applicazioni Kubernetes dall'elenco Tipo di log.
Per eseguire lo streaming dei log da più pod, attiva il cursore Streaming e seleziona Tutti nell'elenco Pod.
Per impostazione predefinita, i log vengono visualizzati per il cluster attivo. Per passare a un altro cluster, seleziona il nome del cluster dall'elenco Cluster.
Visualizzare i log di Kubernetes utilizzando kubectl
Per visualizzare i log di un cluster non GKE o di un
cluster GKE senza Cloud Logging abilitato, segui
questi passaggi:
Per aprire il visualizzatore log, apri la tavolozza dei comandi (premi Ctrl/Cmd+Shift+P o fai clic su Visualizza > Tavolozza comandi) e poi esegui Cloud Code: Visualizza log.
Seleziona Log Kubectl dall'elenco Tipo di log.
Nell'elenco Deployment o Pod, seleziona un deployment o un pod da cui visualizzare i log.
Per perfezionare i risultati di ricerca, fai clic su Log di ricerca e digita i termini di ricerca. Questa ricerca include lo spazio dei nomi, il deployment, il pod, il contenitore
e l'ora. Per i cluster con Cloud Logging abilitato, puoi anche filtrare in base al livello di gravità.
Modificare l'ora visualizzata
Per modificare l'ora visualizzata in un fuso orario diverso, fai clic su
more_vertAltro accanto all'intestazione della colonna Ora e poi scegli un fuso orario.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThis guide explains how to use Cloud Code to view application streaming logs and check resource status.\u003c/p\u003e\n"],["\u003cp\u003eThe Development sessions view provides a structured output of tasks, artifacts, and deployed resources, showing the status of each deployment task.\u003c/p\u003e\n"],["\u003cp\u003eThe Log Viewer can be launched to search, filter, and stream logs from pods, resources, and Kubernetes clusters with or without Cloud Logging.\u003c/p\u003e\n"],["\u003cp\u003eLogs can be accessed by right-clicking on a pod or specific resource in the Kubernetes section of Cloud Code and selecting "Stream Logs" or "View Logs".\u003c/p\u003e\n"],["\u003cp\u003eYou can change the time zone displayed in the logs viewer by clicking the more options menu next to the time column header.\u003c/p\u003e\n"]]],[],null,["# View Kubernetes logs in Cloud Code for Cloud Shell\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/shell/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/shell/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/shell/debug).\n- Explore the Kubernetes documentation on [troubleshooting containerized applications](https://kubernetes.io/docs/tasks/debug/debug-application/)."]]