이 페이지에는 Google Kubernetes Engine(GKE) 및 Cloud Run과 같은 다양한Google Cloud 플랫폼에서 앱을 계측하기 위한 권장사항이 포함되어 있습니다. 앱이 아직 계측되지 않은 경우 Google Cloud로 원격 분석 데이터를 전송하도록 앱을 계측하는 방법에 대한 안내로 이 권장사항을 사용하세요.
이 페이지의 권장사항이 유일한 솔루션은 아니며 다른 방법도 사용할 수 있습니다. 자세한 안내는 Google Cloud 지원팀에 문의하세요.
JSON 구조화된 로그를 stdout 및 stderr로 출력하도록 앱을 구성합니다.
프레임워크 목록은 권장 로깅 프레임워크를 참조하세요.
App Engine은 stdout 및 stderr에 작성된 로그를 자동으로 수집합니다.
자세한 내용은 로그 작성 및 보기를 참조하세요.
권장 로깅 프레임워크
로그를 수집하려면 직렬화된 JSON 객체를 stdout, stderr 또는 파일로 출력하도록 구성할 수 있는 프레임워크를 사용하는 것이 좋습니다. Logging 에이전트는 통합 또는 설치 여부와 관계없이 파일을 스크래핑하여 Cloud Logging을 위한 구조화된 로그를 작성합니다.
로그 데이터를 작성하려면 다음을 사용하는 것이 좋습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Choose an instrumentation approach\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis page contains recommendations for instrumenting your app on different\nGoogle Cloud platforms, such as Google Kubernetes Engine (GKE) and\nCloud Run. If your app isn't already instrumented,\nthen use these recommendations for guidance as to how to instrument your\napp to send telemetry data to Google Cloud.\nThe recommendations on this page aren't the only solutions, and other\napproaches can work. For additional guidance,\ncontact [Google Cloud Support](/support).\n\nThere are recommendations for the following:\n\n- [GKE](#containers)\n- [Compute Engine](#instances)\n- [Cloud Run](#run)\n- [Cloud Run functions](#functions)\n- [App Engine](#app_engine)\n- [Logging frameworks](#logging-frameworks)\n\nFor information about instrumentation examples, see the documents listed in the\n[Code samples](#samples) section.\n\nGKE\n---\n\nFor general information about GKE, see\n[GKE overview](/kubernetes-engine/docs/concepts/kubernetes-engine-overview).\n\nCompute Engine\n--------------\n\nFor general information about Compute Engine, see\n[Virtual machine instances](/compute/docs/instances).\n\nCloud Run\n---------\n\nFor general information about Cloud Run, see\n[What is Cloud Run](/run/docs/overview/what-is-cloud-run).\n\nCloud Run functions\n-------------------\n\nFor general information about Cloud Run functions, see\n[Cloud Run functions overview](/functions/docs/concepts/overview).\n\nApp Engine\n----------\n\nFor general information about App Engine, see\n[An overview of App Engine](/appengine/docs/an-overview-of-app-engine).\n\nRecommended logging frameworks\n------------------------------\n\nTo collect logs, we recommend that you use a framework which can be\nconfigured to output serialized JSON objects to `stdout`, `stderr`, or to a\nfile. The logging agent, whether integrated or installed, scrapes the file\nand writes [structured logs for Cloud Logging](/logging/docs/structured-logging).\nFor writing log data, we recommend the following:\n\n- Go: [`slog`](https://pkg.go.dev/log/slog).\n- Python: [`logging`](https://docs.python.org/3/library/logging.html).\n- JavaScript: [Pino](https://getpino.io/).\n- Java: [SLF4J](https://www.slf4j.org/) with [Log4j2](https://logging.apache.org/log4j/2.x/).\n\nCode samples\n------------\n\nFor code samples that illustrate how to instrument your application to\nsend telemetry to Google Cloud, see the following:\n\n- [Sample overview](/stackdriver/docs/instrumentation/setup/sample-overview).\n- [Go instrumentation sample](/stackdriver/docs/instrumentation/setup/go).\n- [Java instrumentation sample](/stackdriver/docs/instrumentation/setup/java).\n- [Node.js instrumentation sample](/stackdriver/docs/instrumentation/setup/nodejs).\n- [Python instrumentation sample](/stackdriver/docs/instrumentation/setup/python).\n\nReferences to OpenTelemetry\n---------------------------\n\nThis section provides links to the OpenTelemetry SDK, and the exporters for\nOTLP, Cloud Trace, and Cloud Monitoring.\n\nGeneral references:\n\n- [Language APIs \\& SDKs](https://opentelemetry.io/docs/languages/)\n- [OTLP exporter](https://opentelemetry.io/docs/specs/otel/protocol/exporter/)\n\n### Go\n\n- [Go SDK](https://opentelemetry.io/docs/languages/go/)\n- [Go OTLP exporter](https://opentelemetry.io/docs/languages/go/exporters/#otlp)\n- [Go Cloud Trace exporter](https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/main/exporter/trace)\n- [Go Cloud Monitoring exporter](https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/tree/main/exporter/metric)\n\n### Java\n\n- [Java SDK](https://opentelemetry.io/docs/languages/java/)\n- [Java OTLP exporter](https://opentelemetry.io/docs/languages/java/configuration/#properties-exporters)\n- [Java Cloud Trace exporter](https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/blob/main/exporters/trace)\n- [Java Cloud Monitoring exporter](https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/tree/main/exporters/metrics)\n\n### JavaScript\n\n- [JavaScript SDK](https://opentelemetry.io/docs/languages/js/)\n- [JavaScript OTLP exporter](https://opentelemetry.io/docs/languages/js/exporters/#otlp)\n- [JavaScript Cloud Trace exporter](https://github.com/GoogleCloudPlatform/opentelemetry-operations-js/tree/main/packages/opentelemetry-cloud-trace-exporter)\n- [JavaScript Cloud Monitoring exporter](https://github.com/GoogleCloudPlatform/opentelemetry-operations-js/tree/main/packages/opentelemetry-cloud-monitoring-exporter)\n\n### Python\n\n- [Python SDK](https://opentelemetry.io/docs/languages/python/)\n- [Python OTLP exporter](https://opentelemetry.io/docs/languages/python/exporters/)\n- [Python Cloud Trace exporter](https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/tree/main/opentelemetry-exporter-gcp-trace)\n- [Python Cloud Monitoring exporter](https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/tree/main/opentelemetry-exporter-gcp-monitoring)"]]