

# Amazon CloudWatch로 로그를 게시하는 옵션 설정
<a name="AuroraPostgreSQL.CloudWatch.Publishing"></a>

Aurora PostgreSQL DB 클러스터의 PostgreSQL 로그를 CloudWatch Logs에 게시하려면 클러스터에 대한 **Log export**(로그 내보내기) 옵션을 선택합니다. Aurora PostgreSQL DB 클러스터를 생성할 때 로그 내보내기 설정을 선택할 수 있습니다. 클러스터는 나중에 수정해도 됩니다. 기존 클러스터를 수정하면 해당 시점부터 각 인스턴스의 PostgreSQL 로그가 CloudWatch 클러스터에 게시됩니다. Aurora PostgreSQL의 경우 PostgreSQL 로그(`postgresql.log`)는 Amazon CloudWatch에 게시되는 유일한 로그입니다.

AWS Management Console, AWS CLI 또는 RDS API를 사용하여 Aurora PostgreSQL DB 클러스터에 대한 로그 내보내기 기능을 설정 수 있습니다.

## 콘솔
<a name="AuroraPostgreSQL.CloudWatch.Console"></a>

로그 내보내기 옵션을 선택하여 Aurora PostgreSQL DB 클러스터에서 CloudWatch Logs로 PostgreSQL 로그 게시를 시작합니다.

**콘솔에서 로그 내보내기 기능을 켜려면**

1. [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)에서 Amazon RDS 콘솔을 엽니다.

1. 탐색 창에서 **데이터베이스**를 선택합니다.

1. CloudWatch Logs에 게시하려는 로그 데이터가 있는 Aurora PostgreSQL DB 클러스터를 선택합니다.

1. **수정**을 선택합니다.

1. **Log exports**(로그 내보내기) 섹션에서 **PostgreSQL log**(PostgreSQL 로그를 선택합니다.

1. **계속**을 선택한 후, 요약 페이지에서 **클러스터 수정**을 선택합니다.

## AWS CLI
<a name="AuroraPostgreSQL.CloudWatch.CLI"></a>

로그 내보내기 옵션을 켜서 AWS CLI를 사용하여 Amazon CloudWatch Logs에 Aurora PostgreSQL 로그 게시를 시작할 수 있습니다. 이를 위해서는 [modify-db-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-db-cluster.html) AWS CLI 명령을 다음 옵션과 함께 실행해야 합니다.
+ `--db-cluster-identifier` - DB 클러스터 식별자입니다.
+ `--cloudwatch-logs-export-configuration` - DB 클러스터에 대하여 CloudWatch Logs로 내보내기를 설정할 로그 유형의 구성 설정입니다.

또한 다음 AWS CLI 명령 중 하나를 실행하여 Aurora PostgreSQL 로그를 게시할 수 있습니다.
+ [create-db-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-cluster.html)
+ [restore-db-cluster-from-s3](https://docs.aws.amazon.com/cli/latest/reference/rds/restore-db-cluster-from-s3.html)
+ [restore-db-cluster-from-snapshot](https://docs.aws.amazon.com/cli/latest/reference/rds/restore-db-cluster-from-snapshot.html)
+ [restore-db-cluster-to-point-in-time](https://docs.aws.amazon.com/cli/latest/reference/rds/restore-db-cluster-to-point-in-time.html)

다음 옵션으로 AWS CLI 명령 중 하나를 실행합니다.
+ `--db-cluster-identifier`—DB 클러스터 식별자입니다.
+ `--engine`—데이터베이스 엔진입니다.
+ `--enable-cloudwatch-logs-exports`—DB 클러스터에 대하여 CloudWatch Logs로 내보내기를 활성화할 로그 유형의 구성 설정입니다.

실행하는 AWS CLI 명령에 따라 다른 옵션이 필요할 수 있습니다.

**Example**  
다음 명령은 CloudWatch Logs에 로그 파일을 게시하도록 Aurora PostgreSQL DB 클러스터를 생성합니다.  
대상 LinuxmacOS, 또는Unix:  

```
1. aws rds create-db-cluster \
2.     --db-cluster-identifier my-db-cluster \
3.     --engine aurora-postgresql \
4.     --enable-cloudwatch-logs-exports postgresql
```
Windows의 경우:  

```
1. aws rds create-db-cluster ^
2.     --db-cluster-identifier my-db-cluster ^
3.     --engine aurora-postgresql ^
4.     --enable-cloudwatch-logs-exports postgresql
```

**Example**  
다음 명령은 CloudWatch Logs에 로그 파일을 게시하도록 기존 Aurora PostgreSQL DB 클러스터를 수정합니다. `--cloudwatch-logs-export-configuration` 값은 JSON 객체입니다. 이 객체의 키는 `EnableLogTypes`이고 그 값은 `postgresql` 및 `instance`입니다.  
대상 LinuxmacOS, 또는Unix:  

```
1. aws rds modify-db-cluster \
2.     --db-cluster-identifier my-db-cluster \
3.     --cloudwatch-logs-export-configuration '{"EnableLogTypes":["postgresql","instance"]}'
```
Windows의 경우:  

```
1. aws rds modify-db-cluster ^
2.     --db-cluster-identifier my-db-cluster ^
3.     --cloudwatch-logs-export-configuration '{\"EnableLogTypes\":[\"postgresql\",\"instance\"]}'
```
Windows 명령 프롬프트를 사용하는 경우 백슬래시(\$1)를 접두사로 추가하여 JSON 코드에서 큰 따옴표(")를 이스케이프해야 합니다.

**Example**  
다음 예에서는 CloudWatch Logs에 로그 파일 게시를 비활성화하도록 기존 Aurora PostgreSQL DB 클러스터를 수정합니다. `--cloudwatch-logs-export-configuration` 값은 JSON 객체입니다. 이 객체의 키는 `DisableLogTypes`이고 그 값은 `postgresql` 및 `instance`입니다.  
대상 LinuxmacOS, 또는Unix:  

```
aws rds modify-db-cluster \
    --db-cluster-identifier mydbinstance \
    --cloudwatch-logs-export-configuration '{"DisableLogTypes":["postgresql","instance"]}'
```
Windows의 경우:  

```
aws rds modify-db-cluster ^
    --db-cluster-identifier mydbinstance ^
    --cloudwatch-logs-export-configuration "{\"DisableLogTypes\":[\"postgresql\",\"instance\"]}"
```
Windows 명령 프롬프트를 사용하는 경우 백슬래시(\$1)를 접두사로 추가하여 JSON 코드에서 큰 따옴표(")를 이스케이프해야 합니다.

## RDS API
<a name="AuroraPostgreSQL.CloudWatch.API"></a>

로그 내보내기 옵션을 켜서 AWS CLI를 사용하여 Amazon CloudWatch Logs에 Aurora PostgreSQL 로그 게시를 시작할 수 있습니다. 이를 위해서는 다음 옵션과 함께 [ModifyDBCluster](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_ModifyDBCluster.html) 작업을 실행해야 합니다.
+ `DBClusterIdentifier` - DB 클러스터 식별자입니다.
+ `CloudwatchLogsExportConfiguration` - DB 클러스터에 대하여 CloudWatch Logs로 내보내기를 활성화할 로그 유형의 구성 설정입니다.

또한 다음 RDS API 작업 중 하나를 실행하여 RDS API로 Aurora MySQL 로그를 게시할 수 있습니다.
+ [CreateDBCluster](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBCluster.html)
+ [RestoreDBClusterFromS3](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBClusterFromS3.html)
+ [RestoreDBClusterFromSnapshot](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBClusterFromSnapshot.html)
+ [RestoreDBClusterToPointInTime](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBClusterToPointInTime.html)

다음 파라미터로 RDS API 작업을 실행합니다.
+ `DBClusterIdentifier`—DB 클러스터 식별자입니다.
+ `Engine`—데이터베이스 엔진입니다.
+ `EnableCloudwatchLogsExports`—DB 클러스터에 대하여 CloudWatch Logs로 내보내기를 활성화할 로그 유형의 구성 설정입니다.

실행하는 AWS CLI 명령에 따라 다른 파라미터가 필요할 수 있습니다.