[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-03。"],[],[],null,["# Cloud Logging for Storage Transfer Service\n\nThis page describes how to configure and view Cloud Logging for\nStorage Transfer Service logs.\n\nCloud Logging for Storage Transfer Service is supported for all transfers. `FIND`\noperations are not logged for agent-based transfers.\n\nFile system transfers can additionally configure\n[file system transfer logs](/storage-transfer/docs/on-prem-transfer-log-format).\n\nBefore you begin\n----------------\n\nBefore you begin, verify that you have access to Cloud Logging. We recommend\nthe **Logs Viewer (roles/logging.viewer)** Identity and Access Management role.\nFor more information on Logging access, see [Access control\nwith IAM](/logging/docs/access-control).\n\nThe following describe how to verify and grant IAM access:\n\n- [View current access](/iam/docs/granting-changing-revoking-access#view-access) to verify the access that each principal has.\n- [Grant a role](/iam/docs/granting-changing-revoking-access#single-role) to relevant principals in your project.\n\nLoggable actions\n----------------\n\nThe following actions can be logged:\n\n- `FIND`: Finding work to do, such as listing files in a directory, listing objects in a bucket, or listing managed folders in a bucket. Not supported for agent-based transfers.\n- `COPY`: Copying files or objects to Cloud Storage.\n- `DELETE`: Deleting files or objects at the source or the destination. For transfers between two file systems, also logs the deletion of files from the intermediary Cloud Storage bucket.\n\nLoggable states\n---------------\n\nFor each action, you can choose to log one or more of the following states:\n\n- `SUCCEEDED`: The action was successful.\n- `FAILED`: The action failed.\n- `SKIPPED`: Only applies to the COPY action, and only supported for agent-based transfer jobs. Must be set using `gcloud` or REST API. This state means that the copy was skipped. This occurs when the file already exists in the sink, and your transfer job is configured to ignore existing files.\n\nEnable logging\n--------------\n\nTo enable logging, specify the actions and the states to log. \n\n### gcloud CLI\n\nWhen creating a transfer job with `gcloud transfer jobs create`, use the\nfollowing flags to enable logging: \n\n gcloud transfer jobs create \u003cvar translate=\"no\"\u003eSOURCE\u003c/var\u003e \u003cvar translate=\"no\"\u003eDESTINATION\u003c/var\u003e \\\n --log-actions=copy,delete,find \\\n --log-action-states=succeeded,failed,skipped\n\nYou must specify at least one value for each flag.\n\n### REST\n\nTo create a logging configuration, use\n[`transferJobs.create`](/storage-transfer/docs/reference/rest/v1/transferJobs/create) with a\n[`LoggingConfig`](/storage-transfer/docs/reference/rest/v1/transferJobs#LoggingConfig): \n\n {\n \"name\":\"transferJobs/myFirstTransfer\",\n \"status\": \"ENABLED\",\n \"projectId\": \"test-id-001\",\n \"loggingConfig\": {\n \"logActions\": [\"FIND\", \"DELETE\", \"COPY\"],\n \"logActionStates\": [\"SUCCEEDED\", \"FAILED\", \"SKIPPED\"], #SKIPPED is only supported for agent-based transfers\n },\n \"transferSpec\": {\n \"awsS3DataSource\": {\n \"bucketName\": \"AWS_SOURCE_NAME\",\n \"awsAccessKey\": {\n \"accessKeyId\": \"AWS_ACCESS_KEY_ID\",\n \"secretAccessKey\": \"AWS_SECRET_ACCESS_KEY\"\n }\n },\n \"gcsDataSink\": {\n \"bucketName\": \"destination_bucket\",\n \"path\": \"foo/bar/\"\n },\n }\n }\n\nAdjust `loggingConfig` to include the specific `logActions` and\n`logActionStates` to log. For example, to log when copy and find actions fail,\nprovide the following `loggingConfig`: \n\n \"loggingConfig\": {\n \"logActions\": [\"COPY\", \"FIND\"],\n \"logActionStates\": [\"FAILED\"],\n }\n\nUpdate a logging configuration\n------------------------------\n\n### gcloud CLI\n\nTo update an existing job's logging configuration, use the appropriate\nflags with the [`gcloud transfer jobs update`](/sdk/gcloud/reference/transfer/jobs/update) command: \n\n gcloud transfer jobs update \u003cvar translate=\"no\"\u003eNAME\u003c/var\u003e \\\n --log-actions=copy,delete,find \\\n --log-action-states=succeeded,failed,skipped\n\nTo disable logging for this job, specify `--clear-log-config`: \n\n gcloud transfer jobs update \u003cvar translate=\"no\"\u003eNAME\u003c/var\u003e --clear-log-config\n\n### REST\n\nTo update an existing transfer job's logging configuration, use\n[`transferJobs.patch`](/storage-transfer/docs/reference/rest/v1/transferJobs/patch) with\n[`LoggingConfig`](/storage-transfer/docs/reference/rest/v1/transferJobs#LoggingConfig): \n\n {\n \"projectId\": \"test-id-001\",\n \"transferJob\": {\n \"loggingConfig\": {\n \"logActions\": [\"FIND\", \"DELETE\", \"COPY\"],\n \"logActionStates\": [\"SUCCEEDED\", \"FAILED\", \"SKIPPED\"], #SKIPPED is only supported for agent-based transfers\n },\n },\n \"updateTransferJobFieldMask\": \"loggingConfig\"\n }\n\nThe `updateTransferJobFieldMask` specifies the field that is being updated in\nthis request and is required.\n\nTo disable logging for this job, send a `loggingConfig` with empty lists for\n`logActions` and `logActionStates`: \n\n {\n \"projectId\": \"test-id-001\",\n \"transferJob\": {\n \"loggingConfig\": {\n \"logActions\": [],\n \"logActionStates\": [],\n },\n },\n \"updateTransferJobFieldMask\": \"loggingConfig\"\n }\n\nView logs\n---------\n\nTo view transfer logs, do the following: \n\n### Google Cloud console\n\n1. Go to the Google Cloud navigation menu\n *menu* and select\n **Logging \\\u003e Logs Explorer** :\n\n [Go to the Logs Explorer](https://console.cloud.google.com/logs/query)\n2. Select a Google Cloud project.\n\n3. From the **Upgrade** menu, switch from **Legacy Logs Viewer** to\n **Logs Explorer**.\n\n4. To filter your logs to show only Storage Transfer Service entries, type\n `storage_transfer_job` into the query field and click\n **Run query**.\n\n5. In the **Query results** pane, click **Edit time** to change the time\n period for which to return results.\n\nFor more information on using the Logs Explorer, see [Using the\nLogs Explorer](/logging/docs/view/logs-viewer-interface).\n\n### gcloud CLI\n\nTo use the gcloud CLI to search for Storage Transfer Service\nlogs, use the\n[`gcloud logging read`](/logging/docs/reference/tools/gcloud-logging#reading_log_entries)\ncommand.\n\nSpecify a filter to limit your results to Storage Transfer Service logs. \n\n gcloud logging read \"resource.type=storage_transfer_job\"\n\n### Cloud Logging API\n\nUse the [`entries.list`](/logging/docs/reference/v2/rest/v2/entries/list)\nCloud Logging API method.\n\nTo filter your results to include only Storage Transfer Service-related entries,\nuse the `filter` field. A sample JSON request object is below. \n\n {\n \"resourceNames\":\n [\n \"projects/\u003cvar translate=\"no\"\u003emy-project-name\u003c/var\u003e\"\n ],\n \"orderBy\": \"timestamp desc\",\n \"filter\": \"resource.type=\\\"storage_transfer_job\\\"\"\n }\n\nTransfer log format\n-------------------\n\nThe following section describes the fields for Storage Transfer Service logs.\n\nAll Storage Transfer Service-specific fields are contained within a\n`jsonPayload` object. \n\n### `FIND` actions\n\n {\n \"jsonPayload\": {\n \"@type\": \"type.googleapis.com/google.storagetransfer.logging.TransferActivityLog\",\n \"action\": \"FIND\",\n \"completeTime\": \"2021-12-16T18:58:49.344509695Z\",\n \"destinationContainer\": {\n \"gcsBucket\": {\n \"bucket\": \"my-bucket-2\",\n },\n \"type\": \"GCS\",\n },\n \"operation\": \"transferOperations/transferJobs-7876027868280507149--3019866490856027148\",\n \"sourceContainer\": {\n \"gcsBucket\": {\n \"bucket\": \"my-bucket-1\"\n },\n \"type\": \"GCS\"\n },\n \"status\": {\n \"statusCode\": \"OK\"\n }\n }\n }\n\n### `COPY` and `DELETE` actions\n\n {\n \"jsonPayload\": {\n \"@type\": \"type.googleapis.com/google.storagetransfer.logging.TransferActivityLog\",\n \"action\": \"COPY\",\n \"completeTime\": \"2021-12-16T18:59:00.510509049Z\",\n \"destinationObject\": {\n \"gcsObject\": {\n \"bucket\": \"my-bucket-2\",\n \"objectKey\": \"README.md\"\n },\n \"type\": \"GCS\",\n },\n \"operation\": \"transferOperations/transferJobs-7876027868280507149--3019866490856027148\",\n \"sourceObject\": {\n \"gcsObject\": {\n \"bucket\": \"my-bucket-1\",\n \"lastModifiedTime\": \"2021-12-07T16:41:09.456Z\",\n \"md5\": \"WgnCOIdfCXNTUDpQJSKb2w==\",\n \"objectKey\": \"README.md\",\n },\n \"type\": \"GCS\",\n },\n \"status\": {\n \"statusCode\": \"OK\"\n }\n }\n }\n\nIn addition, the top-level `resource` field contains the following fields. \n\n \"resource\": {\n \"labels\": {\n \"job_id\": \"transferJobs/7876027868280507149\"\n \"project_id\": \"my-project-id\"\n }\n \"type\": \"storage_transfer_job\"\n }"]]