# LoggingConfig

A logging configuration for delivery status of messages sent from SNS topic to subscribed endpoints.

- Source: [`aws-sns/lib/topic.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-sns/lib/topic.ts#L145)
- Type last changed: v2.224.0 · 13 Nov 2025

## Example

TypeScript:

```ts
declare const role: iam.Role;
const topic = new sns.Topic(this, 'MyTopic');

topic.addLoggingConfig({
  protocol: sns.LoggingProtocol.SQS,
  failureFeedbackRole: role,
  successFeedbackRole: role,
  successFeedbackSampleRate: 50,
});
```

Python:

```python
# role: iam.Role

topic = sns.Topic(self, "MyTopic")

topic.add_logging_config(
    protocol=sns.LoggingProtocol.SQS,
    failure_feedback_role=role,
    success_feedback_role=role,
    success_feedback_sample_rate=50
)
```

Java:

```java
Role role;

Topic topic = new Topic(this, "MyTopic");

topic.addLoggingConfig(LoggingConfig.builder()
        .protocol(LoggingProtocol.SQS)
        .failureFeedbackRole(role)
        .successFeedbackRole(role)
        .successFeedbackSampleRate(50)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Role role;

var topic = new Topic(this, "MyTopic");

topic.AddLoggingConfig(new LoggingConfig {
    Protocol = LoggingProtocol.SQS,
    FailureFeedbackRole = role,
    SuccessFeedbackRole = role,
    SuccessFeedbackSampleRate = 50
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var role Role

topic := sns.NewTopic(this, jsii.String("MyTopic"))

topic.AddLoggingConfig(&LoggingConfig{
	Protocol: sns.LoggingProtocol_SQS,
	FailureFeedbackRole: role,
	SuccessFeedbackRole: role,
	SuccessFeedbackSampleRate: jsii.Number(50),
})
```

## Properties

- `failureFeedbackRole`: [IRoleRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_iam.IRoleRef.html) = None — The IAM role to be used when logging failed message deliveries in Amazon CloudWatch.

- `protocol`: [LoggingProtocol](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sns.LoggingProtocol.html) (required) — Indicates one of the supported protocols for the SNS topic.

- `successFeedbackRole`: [IRoleRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_iam.IRoleRef.html) = None — The IAM role to be used when logging successful message deliveries in Amazon CloudWatch.

- `successFeedbackSampleRate`: number = None — The percentage of successful message deliveries to be logged in Amazon CloudWatch.

  Valid values are integer between 0-100
