# TargetObjectKeyFormat

The key format for the log object.

- Source: [`aws-s3/lib/bucket.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-s3/lib/bucket.ts#L1539)
- Type last changed: v2.124.0 · 26 Jan 2024

## Example

```ts
const accessLogsBucket = new s3.Bucket(this, 'AccessLogsBucket');

const bucket = new s3.Bucket(this, 'MyBucket', {
  serverAccessLogsBucket: accessLogsBucket,
  serverAccessLogsPrefix: 'logs',
  // You can use a simple prefix with `TargetObjectKeyFormat.simplePrefix()`, but it is the same even if you do not specify `targetObjectKeyFormat` property.
  targetObjectKeyFormat: s3.TargetObjectKeyFormat.simplePrefix(),
});
```

## Initializer

```ts
new TargetObjectKeyFormat()
```

## Methods

- `partitionedPrefix(dateSource?: PartitionDateSource): TargetObjectKeyFormat // chainable` (static) — Use partitioned prefix for log objects. If you do not specify the dateSource argument, the default is EventTime.

  The partitioned prefix format as follow:
  [DestinationPrefix][SourceAccountId]/​[SourceRegion]/​[SourceBucket]/​[YYYY]/​[MM]/​[DD]/​[YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]

- `simplePrefix(): TargetObjectKeyFormat // chainable` (static) — Use the simple prefix for log objects.

  The simple prefix format as follow:
  [DestinationPrefix][YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]
