Skip to main content

Data Access Logs

还没翻译译自英文(developers.cloudflare.com)本页 33 段都还没译

R2 Data Access Logs provide per-request records for object operations in a bucket. The logs are generally available for R2 buckets without a jurisdiction.

Data Access Logs differ from Audit Logs, which record bucket configuration changes. They also differ from R2 metrics, which provide aggregated request and storage data.

Note

Data Access Logs include requests with HTTP status codes below 400, including 304 Not Modified. Log delivery is asynchronous and best effort, and events may be delayed or omitted. Requests with status codes of 400 or greater are excluded. Do not rely on Data Access Logs as a complete record of bucket activity.

Supported interfaces

Data Access Logs record requests from these interfaces:

InterfaceSource
S3Requests through the S3-compatible API.
APIObject operations from the Cloudflare dashboard or API.
WorkersObject operations through an R2 binding. These events include the Worker script name.
PublicRequests to public buckets through r2.dev or custom domains. These requests are unauthenticated.

Logged operations

Data Access Logs record the following operations:

CategoryOperations
ReadGetObject, HeadObject
Write and copyPutObject, CopyObject
ListListObjectsV1, ListObjectsV2
Multipart uploadCreateMultipartUpload, UploadPart, UploadPartCopy, CompleteMultipartUpload, AbortMultipartUpload, ListMultipartUploads, ListParts
DeleteDeleteObject, DeleteObjects, DeleteObjectsByPrefix

Bucket and configuration operations are not included. Failed requests with an HTTP status code of 400 or greater are also not included.

Turn on Data Access Logs

  1. In the Cloudflare dashboard, go to the bucket you wish to enable.

    dash.cloudflare.com

  2. Under Data Access Logs, select Enabled.

R2 records new supported operations after you turn on Data Access Logs. Earlier operations are not added retroactively.

Data Access Logs have seven-day retention. Beginning December 1, 2026, they use Cloudflare Observability pricing.

View Data Access Logs

In the Data Access Logs section of the bucket settings, select View logs in Workers Observability. The Events view opens with the r2 dataset and current bucket selected for the previous hour.

Use the Query Builder to change the time range, add filters, or aggregate events.

Turn off Data Access Logs

  1. In the Cloudflare dashboard, go to the bucket you wish to disable.

    dash.cloudflare.com

  2. In Data Access Logs, select Disabled.

Log fields

Every event can include these fields:

FieldDescription
$metadata.timestampEvent timestamp in Unix milliseconds.
$metadata.serviceBucket name used as the service name.
$metadata.namespaceEvent namespace. The value is r2.
actionR2 operation name.
actor.typeActor type: user or service. Public bucket requests use service.
actor.idIdentifier for the authenticated actor. Public bucket requests use public.
actor.emailEmail address for a user actor.
actor.accessKeyIdAccess key ID for a request authenticated with AWS Signature Version 4.
bucketTarget bucket name.
interfaceRequest interface: S3, API, Workers, or Public.
request.bytesRequest Content-Length value in bytes.
response.bytesResponse Content-Length value in bytes.
response.errorCodeResponse error code. This value is NotModified for a 304 response and null for a 2xx response.
response.errorMessageResponse error message. This value describes a 304 response and is null for a 2xx response.
requestMetadata.coloCloudflare data center code, or XXX when the data center is unavailable.

S3-compatible API, Cloudflare API, and public bucket events can also include these fields:

FieldDescription
request.methodHTTP request method.
request.uriRequest path.
response.statusHTTP response status code.
requestMetadata.ipClient IP address.
requestMetadata.userAgentClient user agent.

Workers binding events include this additional field:

FieldDescription
scriptNameName of the Worker script that triggered the operation.

Workers binding events do not include the HTTP method, URI, response status, client IP address, or user agent.

An event can include these operation-specific fields:

FieldDescription
resource.keyObject key.
resource.typeResource type: object or multipart_upload.
resource.sizeObject size in bytes when available.
resource.uploadIdUpload ID for a multipart upload.
sourceResourceSource bucket, key, and resource type for a copy operation.
prefixPrefix used by a list or prefix-delete operation.
delimiterDelimiter used by a list operation.
maxKeysMaximum keys requested by an object list operation.
maxUploadsMaximum uploads requested by a multipart upload list operation.
objectsObject keys included in a bulk delete operation.

The request.bytes and response.bytes fields reflect Content-Length values, not exact transferred-byte measurements. A byte count or resource size of 0 can mean either zero bytes or that the value was unavailable when R2 created the event.