Sebelum memulai, pastikan Anda memiliki akses ke Cloud Logging. Sebaiknya gunakan peran Identity and Access Management Logs Viewer (roles/logging.viewer).
Untuk mengetahui informasi selengkapnya tentang akses Logging, lihat Kontrol akses dengan IAM.
Berikut ini penjelasan cara memverifikasi dan memberikan akses IAM:
Berikan peran kepada akun utama yang relevan dalam project Anda.
Tindakan yang dapat dicatat ke dalam log
Tindakan berikut dapat dicatat ke dalam log:
FIND: Menemukan pekerjaan yang harus dilakukan, seperti mencantumkan file dalam direktori, mencantumkan objek dalam bucket, atau mencantumkan folder terkelola dalam bucket. Tidak didukung untuk
transfer berbasis agen.
COPY: Menyalin file atau objek ke Cloud Storage.
DELETE: Menghapus file atau objek di sumber atau tujuan. Untuk
transfer antar-sistem file, juga catat penghapusan file dari
bucket Cloud Storage perantara ke dalam log.
Status yang dapat dicatat ke dalam log
Untuk setiap tindakan, Anda dapat memilih untuk mencatat satu atau beberapa status berikut ke dalam log:
SUCCEEDED: Tindakan berhasil.
FAILED: Tindakan gagal.
SKIPPED: Hanya berlaku untuk tindakan COPY, dan hanya didukung untuk tugas transfer berbasis agen. Harus ditetapkan menggunakan gcloud atau REST API. Status ini berarti bahwa
salinan dilewati. Hal ini terjadi jika file sudah ada di sink, dan tugas transfer Anda dikonfigurasi untuk mengabaikan file yang ada.
Aktifkan logging
Untuk mengaktifkan logging, tentukan tindakan dan status yang akan dicatat ke dalam log.
gcloud CLI
Saat membuat tugas transfer dengan gcloud transfer jobs create, gunakan
flag berikut untuk mengaktifkan logging:
Sesuaikan loggingConfig untuk menyertakan logActions dan
logActionStates tertentu ke dalam log. Misalnya, untuk mencatat ke dalam log saat tindakan salin dan temukan gagal,
berikan loggingConfig berikut:
Nilainya selalu
type.googleapis.com/google.storagetransfer.logging.TransferActivityLog.
action
Menjelaskan tindakan tugas tertentu ini. Salah satu dari berikut ini:
FIND: Menemukan pekerjaan yang harus dilakukan, seperti mencantumkan file dalam direktori atau mencantumkan objek dalam bucket. Tidak dilaporkan untuk
transfer berbasis agen.
COPY: Menyalin file atau objek ke Cloud Storage.
DELETE: Menghapus file atau objek di bucket sumber, tujuan, atau perantara.
findAction
Menentukan apakah subjek tindakan temukan adalah objek atau
folder terkelola.
completeTime
Stempel waktu yang sesuai dengan ISO 8601 saat operasi selesai.
destinationContainer
Hanya ada untuk operasi FIND.
Operasi FIND tidak dicatat ke dalam log untuk transfer berbasis agen.
Penampung tujuan untuk transfer ini. Berisi dua
sub-kolom:
gcsBucket.bucket: Nama bucket Cloud Storage tujuan.
type: Selalu GCS.
destinationObject
Hanya ada untuk operasi COPY dan DELETE.
Informasi tentang objek di tujuan. Berisi dua
sub-kolom:
Salah satu dari gcsObject, gcsManagedFolder, atau
posixFile, bergantung pada tujuan. Semua opsi
berisi beberapa sub-kolom yang menentukan nama, lokasi, info tanggal/waktu, dan hash objek atau file.
Informasi tentang objek sumber. Berisi dua sub-kolom:
Entri khusus untuk host objek sumber. Kolom diberi nama
sesuai dengan jenis sumber dan berisi subkolom untuk metadata.
Kemungkinan kolom adalah sebagai berikut.
Status tindakan. Jika status.statusCode adalah
OK, tindakan berhasil. Jika tidak, tindakan akan gagal. Kolom
status.errorType dan status.errorMessage
hanya diisi jika statusnya bukan OK.
Selain itu, kolom resource level atas berisi kolom berikut.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-18 UTC."],[],[],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 }"]]