# Logging

A class used to configure Logging during AwsCustomResource SDK calls.

Obtainable from: Logging.all, Logging.withDataHidden

- Source: [`custom-resources/lib/aws-custom-resource/logging.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/logging.ts#L20)
- Type last changed: v2.138.0 · 18 Apr 2024

## Example

TypeScript:

```ts
const getParameter = new cr.AwsCustomResource(this, 'GetParameter', {
  onUpdate: {
    service: 'SSM',
    action: 'GetParameter',
    parameters: {
      Name: 'my-parameter',
      WithDecryption: true,
    },
    physicalResourceId: cr.PhysicalResourceId.of(Date.now().toString()),
    logging: cr.Logging.withDataHidden(),
  },
  policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
    resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
  }),
});
```

Python:

```python
get_parameter = cr.AwsCustomResource(self, "GetParameter",
    on_update=cr.AwsSdkCall(
        service="SSM",
        action="GetParameter",
        parameters={
            "Name": "my-parameter",
            "WithDecryption": True
        },
        physical_resource_id=cr.PhysicalResourceId.of(Date.now().to_string()),
        logging=cr.Logging.with_data_hidden()
    ),
    policy=cr.AwsCustomResourcePolicy.from_sdk_calls(
        resources=cr.AwsCustomResourcePolicy.ANY_RESOURCE
    )
)
```

Java:

```java
AwsCustomResource getParameter = AwsCustomResource.Builder.create(this, "GetParameter")
        .onUpdate(AwsSdkCall.builder()
                .service("SSM")
                .action("GetParameter")
                .parameters(Map.of(
                        "Name", "my-parameter",
                        "WithDecryption", true))
                .physicalResourceId(PhysicalResourceId.of(Date.now().toString()))
                .logging(Logging.withDataHidden())
                .build())
        .policy(AwsCustomResourcePolicy.fromSdkCalls(SdkCallsPolicyOptions.builder()
                .resources(AwsCustomResourcePolicy.ANY_RESOURCE)
                .build()))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var getParameter = new AwsCustomResource(this, "GetParameter", new AwsCustomResourceProps {
    OnUpdate = new AwsSdkCall {
        Service = "SSM",
        Action = "GetParameter",
        Parameters = new Dictionary<string, object> {
            { "Name", "my-parameter" },
            { "WithDecryption", true }
        },
        PhysicalResourceId = PhysicalResourceId.Of(Date.Now().ToString()),
        Logging = Logging.WithDataHidden()
    },
    Policy = AwsCustomResourcePolicy.FromSdkCalls(new SdkCallsPolicyOptions {
        Resources = AwsCustomResourcePolicy.ANY_RESOURCE
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
getParameter := cr.NewAwsCustomResource(this, jsii.String("GetParameter"), &AwsCustomResourceProps{
	OnUpdate: &AwsSdkCall{
		Service: jsii.String("SSM"),
		Action: jsii.String("GetParameter"),
		Parameters: map[string]interface{}{
			"Name": jsii.String("my-parameter"),
			"WithDecryption": jsii.Boolean(true),
		},
		PhysicalResourceId: cr.PhysicalResourceId_Of(date.now().toString()),
		Logging: cr.Logging_WithDataHidden(),
	},
	Policy: cr.AwsCustomResourcePolicy_FromSdkCalls(&SdkCallsPolicyOptions{
		Resources: cr.AwsCustomResourcePolicy_ANY_RESOURCE(),
	}),
})
```

## Methods

- `all(): Logging // chainable` (static) — Enables logging of all logged data in the lambda handler.

  This includes the event object, the API call response, all fields in the response object
  returned by the lambda, and any errors encountered.

- `withDataHidden(): Logging // chainable` (static) — Hides logging of data associated with the API call response.

  This includes hiding the raw API
  call response and the `Data` field associated with the lambda handler response.
