Il bucket di log soddisfa una delle seguenti condizioni:
Il bucket di log viene archiviato nello stesso progetto in cui hanno avuto origine le voci di log.
Le voci di log sono state instradate a un progetto, che le ha archiviate
in un bucket di log di sua proprietà.
Per visualizzare un elenco dei sink che hai configurato, esegui questo comando:
gcloud logging sinks list
Il comando restituisce un output simile al seguente:
NAME DESTINATION FILTER
_Default logging.googleapis.com/projects/my-team-project/locations/global/buckets/_Default NOT LOG_ID("cloudaudit.googleapis.com/activity") AND NOT LOG_ID("externalaudit.googleapis.com/activity") AND NOT LOG_ID("cloudaudit.googleapis.com/system_event") AND NOT LOG_ID("externalaudit.googleapis.com/system_event") AND NOT LOG_ID("cloudaudit.googleapis.com/access_transparency") AND NOT LOG_ID("externalaudit.googleapis.com/access_transparency")
_Required logging.googleapis.com/projects/my-team-project/locations/global/buckets/_Required LOG_ID("cloudaudit.googleapis.com/activity") OR LOG_ID("externalaudit.googleapis.com/activity") OR LOG_ID("cloudaudit.googleapis.com/system_event") OR LOG_ID("externalaudit.googleapis.com/system_event") OR LOG_ID("cloudaudit.googleapis.com/access_transparency") OR LOG_ID("externalaudit.googleapis.com/access_transparency")
logs-from-samples logging.googleapis.com/projects/my-team-project/locations/global/buckets/sample-bucket (empty filter)
regional_logs logging.googleapis.com/projects/my-team-project/locations/europe-west1/buckets/bucket_for_regional_logs (empty filter)
test-logs logging.googleapis.com/projects/team-b-project/locations/global/buckets/test-bucket (empty filter)
In questo esempio, il progetto Google Cloud di origine delle voci di log è
my-team-project. Di conseguenza:
Error Reporting può analizzare le voci di log instradate dai sink
_Default,
_Required e logs-from-samples perché il bucket di log è
memorizzato dallo stesso progetto che instrada le voci di log.
Error Reporting non può analizzare le voci di log archiviate nel bucket di log denominato test-logs perché il sink in my-team-project indirizza le voci di log a un bucket di log in un progetto diverso.
Questa sezione fornisce assistenza per la risoluzione dei problemi quando i dati sugli errori vengono scritti
nei bucket Cloud Logging e ti affidi a Error Reporting
per analizzare automaticamente questi bucket di log.
Genera una voce di log di esempio
Per confermare le impostazioni del progetto, puoi generare a livello di programmazione una voce di log
che verrà rilevata da Error Reporting con il seguente comando gcloud:
gcloudloggingwrite--payload-type=jsontest-errors-log\
'{"serviceContext":{"service":"manual-testing"},"message":"Test Error\n at /test.js:42:42","context":{"httpRequest":{"url":"/test","method":"GET","responseStatusCode":500}}}'
Quindi apri Error Reporting e verifica
che l'errore appena creato sia visibile.
Conferma il formato della voce di log
Vai alla pagina Cloud Logging e individua
una voce di log che contiene i dati delle eccezioni inviati dalla tua applicazione.
Prova a inviare manualmente un errore al servizio.
Puoi segnalare un errore di test a Error Reporting utilizzando il seguente comando
gcloud:
gcloudbetaerror-reportingeventsreport--serviceManual--service-versiontest1\--message"java.lang.TestError: msg at com.example.TestClass.test(TestClass.java:51) at com.example.AnotherClass(AnotherClass.java:25)"
Puoi utilizzare un comando cURL per testare le chiamate API REST. Sostituisci
PROJECT_ID e API_KEY con i tuoi valori validi prima di inviare il seguente
comando:
Assicurati che la tua applicazione invii i dati delle eccezioni all'API nel
formato corretto e che
contenga gli attributi richiesti.
Viene registrata un'analisi dello stack, ma non viene riconosciuta da Error Reporting
Registri un errore utilizzando il campo message di un jsonPayload e ti aspetti
che Error Reporting lo acquisisca. Tuttavia, i dati relativi agli errori
non vengono acquisiti.
Per risolvere questo errore, prova quanto segue:
Assicurati che jsonPayload non includa un campo stack_trace o exception. Quando questi campi sono presenti, il campo message non viene valutato.
Assicurati che la struttura dello analisi dello stack sia in
uno dei formati dei linguaggi di programmazione supportati.
Lo analisi dello stack non viene acquisito da Error Reporting
quando viene utilizzato un formato non supportato.
[[["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-03 UTC."],[[["\u003cp\u003eError Reporting analyzes log entries if Assured Workloads and Customer-Managed Encryption Keys (CMEK) are disabled, and the log bucket is in the same project as the log entries or routed to a project that stores them.\u003c/p\u003e\n"],["\u003cp\u003eIf using CMEK-enabled log buckets, utilize Error Reporting client libraries or the API, and verify project settings by generating a sample log entry via the \u003ccode\u003egcloud\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eConfirm log entries follow the expected format, as detailed in the documentation, by checking a log entry with exception data in Cloud Logging.\u003c/p\u003e\n"],["\u003cp\u003eWhen using the Error Reporting API, ensure it is enabled and send test errors using \u003ccode\u003egcloud\u003c/code\u003e commands or cURL, and verify that the exception data sent by the application is in the correct format with required attributes.\u003c/p\u003e\n"],["\u003cp\u003eIf a stack trace is not captured by Error Reporting, ensure that \u003ccode\u003ejsonPayload\u003c/code\u003e does not contain \u003ccode\u003estack_trace\u003c/code\u003e or \u003ccode\u003eexception\u003c/code\u003e fields, and that the stack trace format is one of the supported programming language formats.\u003c/p\u003e\n"]]],[],null,["If your application errors are not showing up in Error Reporting,\nthen use the following steps to troubleshoot.\n\nBefore you begin\n\n1. Verify that Error Reporting can analyze your log entries.\n\n Error Reporting is a global service built on\n Cloud Logging and can analyze log entries when all of the following are true:\n\n - Assured workloads are disabled. For more information, see [Overview of Assured Workloads](/assured-workloads/docs/overview).\n - [Customer-managed encryption keys (CMEK)](/logging/docs/routing/managed-encryption-storage) are disabled on all log buckets that store the log entry. Error Reporting can't store log entries in log buckets that have CMEK enabled. For information about how to determine the CMEK configuration for a log bucket, see [Verify key enablement](/logging/docs/routing/managed-encryption-storage#verify-key).\n - The log bucket satisfies one of the following:\n - The log bucket is stored in the same project where the log entries originated.\n - The log entries were routed to a project, and then that project stored those log entries in a log bucket that it owns.\n\n \u003cbr /\u003e\n\n To see a list of sinks you have configured, run the following command: \n\n gcloud logging sinks list\n\n The command returns an output similar to the following: \n\n NAME DESTINATION FILTER\n _Default logging.googleapis.com/projects/my-team-project/locations/global/buckets/_Default NOT LOG_ID(\"cloudaudit.googleapis.com/activity\") AND NOT LOG_ID(\"externalaudit.googleapis.com/activity\") AND NOT LOG_ID(\"cloudaudit.googleapis.com/system_event\") AND NOT LOG_ID(\"externalaudit.googleapis.com/system_event\") AND NOT LOG_ID(\"cloudaudit.googleapis.com/access_transparency\") AND NOT LOG_ID(\"externalaudit.googleapis.com/access_transparency\")\n _Required logging.googleapis.com/projects/my-team-project/locations/global/buckets/_Required LOG_ID(\"cloudaudit.googleapis.com/activity\") OR LOG_ID(\"externalaudit.googleapis.com/activity\") OR LOG_ID(\"cloudaudit.googleapis.com/system_event\") OR LOG_ID(\"externalaudit.googleapis.com/system_event\") OR LOG_ID(\"cloudaudit.googleapis.com/access_transparency\") OR LOG_ID(\"externalaudit.googleapis.com/access_transparency\")\n logs-from-samples logging.googleapis.com/projects/my-team-project/locations/global/buckets/sample-bucket (empty filter)\n regional_logs logging.googleapis.com/projects/my-team-project/locations/europe-west1/buckets/bucket_for_regional_logs (empty filter)\n test-logs logging.googleapis.com/projects/team-b-project/locations/global/buckets/test-bucket (empty filter)\n\n In this example, the source Google Cloud project of the log entries is\n `my-team-project`. As a result:\n - Error Reporting can analyze the log entries routed by the `_Default`, `_Required`, and `logs-from-samples` sinks because the log bucket is stored by the same project that routes the log entries.\n - Error Reporting can't analyze the log entries stored in the log bucket named `test-logs` because the sink in `my-team-project` routes the log entries to a log bucket in a different project.\n2. Ensure that you have the\n [Google Cloud CLI installed](/sdk/docs/install#installation_instructions).\n\n3. Ensure that you have the\n [`beta` component enabled for the gcloud CLI](/sdk/docs/components#alpha_and_beta_components).\n\nWhen using logs\n\nThis section provides troubleshooting support when your error data is written\nto Cloud Logging buckets, and you rely on Error Reporting\nto automatically analyze those log buckets.\n\nGenerate a sample log entry\n\nTo confirm your project settings, you can programmatically generate a log entry\nthat will be picked up by Error Reporting with the following `gcloud`\ncommand: \n\n gcloud logging write --payload-type=json test-errors-log \\\n '{\"serviceContext\":\n {\"service\": \"manual-testing\"},\n \"message\": \"Test Error\\n at /test.js:42:42\",\n \"context\": {\"httpRequest\":\n {\"url\": \"/test\",\"method\": \"GET\",\"responseStatusCode\": 500}}}'\n\nThen open [Error Reporting](https://console.cloud.google.com/errors) and confirm\nthat you see the newly created error.\n\nConfirm the log entry format\n\nNavigate to the [Cloud Logging page](https://console.cloud.google.com/logs) and locate\na log entry that contains exception data sent from your application.\n\nConfirm that the log entry uses the\n[expected format](/error-reporting/docs/formatting-error-messages).\n\nWhen using the Error Reporting API\n\n1.\n\n\n Enable the required API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=clouderrorreporting.googleapis.com)\n2. Send a test error\n\n Try sending an error to the service manually.\n\n You can report a test error to Error Reporting using the following\n `gcloud` command: \n\n gcloud beta error-reporting events report --service Manual --service-version test1 \\\n --message \"java.lang.TestError: msg\n at com.example.TestClass.test(TestClass.java:51)\n at com.example.AnotherClass(AnotherClass.java:25)\"\n\n You can use a cURL command to test your REST API calls. Replace\n `PROJECT_ID` and `API_KEY` with your valid values before sending the following\n command: \n\n curl -X POST -H \"Content-Type: application/json\" \\\n -d '{\"message\":\"java.lang.TestError: msg\\n\\tat com.example.TestClass.test(TestClass.java:51)\\n\\tat com.example.AnotherClass(AnotherClass.java:25)\",\"serviceContext\":{\"service\":\"manual-testing\"}}' \\\n https://clouderrorreporting.googleapis.com/v1beta1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/events:report?key=\u003cvar translate=\"no\"\u003eAPI_KEY\u003c/var\u003e\n\n3. Confirm the sent payload\n\n Ensure that your application is sending exception data to the API in the\n [correct format](/error-reporting/docs/formatting-error-messages) and that it\n contains the required attributes.\n\nA stack trace is logged but not recognized by Error Reporting\n\nYou log an error by using the `message` field of a `jsonPayload`, and you expect\nError Reporting to capture the error. However, the error data\nisn't captured.\n\nTo resolve this failure, try the following:\n\n- Ensure that the `jsonPayload` doesn't include a `stack_trace` or `exception`\n field. When those fields are present, the `message` field isn't evaluated.\n\n- Ensure that the structure of the stack trace is in\n [one of the supported programming language formats](/error-reporting/reference/rest/v1beta1/projects.events/report#ReportedErrorEvent).\n The stack trace isn't captured by Error Reporting\n when an unsupported format is used.\n\nFor more information, see\n[Format errors in logs](/error-reporting/docs/formatting-error-messages)."]]