Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Si les erreurs détectées dans vos applications ne s'affichent pas dans Error Reporting, suivez la procédure ci-dessous pour corriger les problèmes.
Avant de commencer
Vérifiez qu'Error Reporting peut analyser vos entrées de journaux.
Error Reporting est un service mondial basé sur Cloud Logging. Il peut analyser les entrées de journaux lorsque toutes les conditions suivantes sont remplies :
Les clés de chiffrement gérées par le client (CMEK) sont désactivées sur tous les buckets de journaux qui stockent l'entrée de journal. Error Reporting ne peut pas stocker les entrées de journaux dans des buckets de journaux pour lesquels CMEK est activé. Pour savoir comment déterminer la configuration CMEK d'un bucket de journaux, consultez Vérifier l'activation des clés.
Le bucket de journaux remplit l'une des conditions suivantes :
Le bucket de journaux est stocké dans le même projet que celui d'où proviennent les entrées de journal.
Les entrées de journal ont été acheminées vers un projet, puis ce projet les a stockées dans un bucket de journaux dont il est propriétaire.
Pour afficher la liste des récepteurs que vous avez configurés, exécutez la commande suivante :
gcloud logging sinks list
La commande renvoie un résultat semblable à celui-ci :
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)
Dans cet exemple, le projet source Google Cloud des entrées de journal est my-team-project. En conséquence :
Error Reporting peut analyser les entrées de journaux acheminées par les récepteurs _Default, _Required et logs-from-samples, car le bucket de journaux est stocké par le même projet qui achemine les entrées de journaux.
Error Reporting ne peut pas analyser les entrées de journaux stockées dans le bucket de journaux nommé test-logs, car le récepteur dans my-team-project achemine les entrées de journaux vers un bucket de journaux dans un autre projet.
Cette section fournit une aide au dépannage lorsque vos données d'erreur sont écrites dans des buckets Cloud Logging et que vous vous appuyez sur Error Reporting pour analyser automatiquement ces buckets de journaux.
Générer un exemple d'entrée de journal
Pour confirmer les paramètres de votre projet, vous pouvez générer une entrée de journal de façon automatisée. Celle-ci sera récupérée par Error Reporting avec la commande gcloud suivante :
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}}}'
Ouvrez ensuite Error Reporting, puis vérifiez que vous voyez l'erreur tout juste créée.
Confirmer le format d'entrée de journal
Accédez à la page Cloud Logging, puis recherchez une entrée de journal contenant les données d'exceptions envoyées par votre application.
Vérifiez que l'entrée de journal utilise le format attendu.
Essayez d'envoyer manuellement une erreur au service.
Vous pouvez signaler une erreur de test à Error Reporting à l'aide de la commande gcloud suivante :
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)"
Vous pouvez exécuter une commande cURL pour tester vos appels d'API REST. Remplacez PROJECT_ID et API_KEY par des valeurs valides avant d'envoyer la commande suivante :
Assurez-vous que votre application transmet à l'API les données d'exceptions dans le format approprié, et que ces données contiennent les attributs requis.
Une trace de pile est journalisée, mais n'est pas reconnue par Error Reporting
Vous consignez une erreur à l'aide du champ message d'un jsonPayload et vous vous attendez à ce qu'Error Reporting la détecte. Toutefois, les données d'erreur ne sont pas capturées.
Pour résoudre ce problème, procédez comme suit :
Assurez-vous que le jsonPayload n'inclut pas de champ stack_trace ni exception. Lorsque ces champs sont présents, le champ message n'est pas évalué.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/03 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)."]]