이 페이지에서는 Service Infrastructure를 사용하여 관리형 서비스가 서비스 제작자 및 서비스 소비자 프로젝트 모두에 로그를 보낼 수 있도록 하는 방법을 설명합니다.
Service Control API는 구조화된 로그 데이터나 구조화되지 않은 로그 데이터를 받아들이고 일괄 처리하여 Cloud Logging에 전달합니다.
개발자 및 개발자의 관리형 서비스 사용자 모두 Google Cloud Console 및 Google API Console을 사용하여 로그 데이터를 보거나 Cloud Logging API를 사용하여 데이터에 프로그래매틱 방식으로 액세스할 수 있습니다.
Logging만으로도 관리형 서비스는 관리형 서비스의 개발자가 사용할 로그를 생성할 수 있지만, Service Control API에서는 사용자까지도 사용할 수 있는 로그를 생성할 수 있습니다. 그러면 사용자들이 자신이 관리형 서비스를 어떻게 사용하고 있는지를 이해하고 진단할 수 있습니다.
로그 구성
Service Control API에 로그를 보내기 전에 서비스 구성에서 세 가지 정보를 지정해야 합니다.
로그 이름: 하나 이상의 개별 로그가 있을 수 있습니다. 각 로그는 고유한 이름으로 식별됩니다. 개별 로그를 사용하여 데이터를 더 쉽게 시각화하거나 사용할 수 있도록 함으로써 개별 데이터 유형을 격리할 수 있습니다.
모니터링 리소스: 모니터링 리소스는 일부 로깅 데이터를 생성하는 클라우드 항목을 나타냅니다.
서비스 구성에서 모니터링 리소스를 정의하려면 기술 사양에서 monitored_resource.proto를 참조하세요.
모니터링과 로깅 모두에 동일한 모니터링 리소스를 사용하는 것이 좋습니다.
로그 구성: 로그 스트림과 연관된 모니터링되는 리소스 그리고 각 로그를 받아야 하는 서비스 프로듀서 또는 서비스 소비자 프로젝트를 지정할 수 있습니다. 로그 연결을 구성하려면 기술 사양에서 logging.proto를 참조하세요.
다음 서비스 구성 예시에서 activity_log 로그는 서비스 소비자에게 전송되도록 구성되어 있습니다.
[[["이해하기 쉬움","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-04-24(UTC)"],[],[],null,["# Reporting Logs\n\nThis page describes how to use the Service Infrastructure to enable\n[managed services](/service-infrastructure/docs/glossary#managed) to send logs to both\n[service producer](/service-infrastructure/docs/glossary#producer) and\n[service consumer](/service-infrastructure/docs/glossary#consumer) projects.\n\nThe Service Control API accepts structured or unstructured log data,\nwhich it batches and forwards to [Cloud Logging](/logging).\nBoth you and users of your managed services can use\nGoogle Cloud console and Google API Console to view the log data, or use the\nCloud Logging API to access the data programmatically.\n\nWhereas Logging alone allows a managed service to generate logs\nfor use by you as the developer of the managed service, the\nService Control API also lets you generate logs that are intended for\nyour users. This makes it possible for your users to understand and diagnose\ntheir use of your managed service.\n\nConfiguring logs\n----------------\n\nBefore you send logs to the Service Control API, you need to specify\nthree different bits of information in your\n[service configuration](/service-infrastructure/docs/service-management/reference/rpc/google.api#google.api.Service):\n\n- **Log names**: You can have one or more distinct logs. Each log is identified\n by a unique name. Individual logs make it possible for you to isolate\n distinct types of data if it makes the data easier to visualize or use.\n\n- **Monitored resources** :\n A [monitored resource](/logging/docs/api/v2#monitored-resources)\n represents a cloud entity that produces some logging data.\n To define a monitored resource in the service configuration, see\n [monitored_resource.proto](https://github.com/googleapis/googleapis/blob/master/google/api/monitored_resource.proto)\n for the technical specification.\n We strongly recommend you to use the same monitored resource for both\n [monitoring](/service-infrastructure/docs/reporting-metrics) and logging.\n\n- **Log configuration** : Lets you specify the monitored resource associated\n with any log stream and the service producer or service consumer project where\n each log should be sent. To configure the log association, see\n [logging.proto](https://github.com/googleapis/googleapis/blob/master/google/api/logging.proto)\n for the technical specification.\n\nIn the following example of [service configuration](/service-infrastructure/docs/glossary#config),\nthe log `activity_log` is configured to be sent to the service consumer. \n\n # The definition of the monitored resource to be used.\n monitored_resources:\n - type: library.appspot.com/Branch\n description: A library branch\n display_name: Library Branch\n launch_stage: ALPHA\n labels:\n - key: resource_container\n description: The Google Cloud resource container (ie. project id) for\n the branch.\n - key: location\n description: The Google Cloud region the branch is located.\n - key: branch_id\n description: The ID of the branch.\n\n # The log name to be used.\n logs:\n - name: activity_log\n\n # The logging configuration.\n logging:\n consumer_destinations:\n - monitored_resource: library.appspot.com/Branch\n logs:\n - activity_log\n\nAfter you have authored such configuration, you will need to follow\n[Managing Service Configurations](/service-infrastructure/docs/manage-config)\nand\n[Managing Service Rollouts](/service-infrastructure/docs/rollout) to push\nthe service configuration to the Service Management API, which will configure\nthe monitored resource in [Cloud Logging](/logging).\n\nReporting logs\n--------------\n\nAfter the service configuration push finishes, you can call the\nService Control API to report log entries. The following example uses the\n`gcurl` command to demonstrate the call. To learn how to set this up, see\n[Getting Started with the Service Control API](/service-infrastructure/docs/service-control/getting-started). \n\n```\ngcurl -d \"{\n 'operations': [ {\n 'operationId': 'e8bf36ef-f9b5-4274-b4f9-079a3731e6e5',\n 'operationName': 'New book arrived',\n 'consumerId': 'projects/library-consumer',\n 'startTime': '`date +%FT%T%:z`',\n 'endTime': '`date +%FT%T%:z`',\n 'labels': {\n 'location': 'us-east1',\n 'branch_id': 'my-test-library-branch'\n },\n 'logEntries': [ {\n 'severity': 'INFO',\n 'textPayload': 'new book arrived',\n 'name': 'activity_log'\n } ]\n } ]\n}\" https://servicecontrol.googleapis.com/v1/services/endpointsapis.appspot.com:report\n```"]]