The Service Control API accepts structured or unstructured log data,
which it batches and forwards to Cloud Logging.
Both you and users of your managed services can use
Google Cloud console and Google API Console to view the log data, or use the
Cloud Logging API to access the data programmatically.
Whereas Logging alone allows a managed service to generate logs
for use by you as the developer of the managed service, the
Service Control API also lets you generate logs that are intended for
your users. This makes it possible for your users to understand and diagnose
their use of your managed service.
Configuring logs
Before you send logs to the Service Control API, you need to specify
three different bits of information in your
service configuration:
Log names: You can have one or more distinct logs. Each log is identified
by a unique name. Individual logs make it possible for you to isolate
distinct types of data if it makes the data easier to visualize or use.
Monitored resources:
A monitored resource
represents a cloud entity that produces some logging data.
To define a monitored resource in the service configuration, see
monitored_resource.proto
for the technical specification.
We strongly recommend you to use the same monitored resource for both
monitoring and logging.
Log configuration: Lets you specify the monitored resource associated
with any log stream and the service producer or service consumer project where
each log should be sent. To configure the log association, see
logging.proto
for the technical specification.
In the following example of service configuration,
the log activity_log is configured to be sent to the service consumer.
After the service configuration push finishes, you can call the
Service Control API to report log entries. The following example uses the
gcurl command to demonstrate the call. To learn how to set this up, see
Getting Started with the Service Control API.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 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```"]]