使用 Amazon CLI 指定日志传输 - Amazon ElastiCache for Redis
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门

使用 Amazon CLI 指定日志传输

创建将慢日志传输到 CloudWatch Logs 的复制组。

对于 Linux、macOS 或 Unix:

aws elasticache create-replication-group \ --replication-group-id test-slow-log \ --replication-group-description test-slow-log \ --engine redis \ --cache-node-type cache.r5.large \ --num-cache-clusters 2 \ --log-delivery-configurations '{ "LogType":"slow-log", "DestinationType":"cloudwatch-logs", "DestinationDetails":{ "CloudWatchLogsDetails":{ "LogGroup":"my-log-group" } }, "LogFormat":"json" }'

对于 Windows:

aws elasticache create-replication-group ^ --replication-group-id test-slow-log ^ --replication-group-description test-slow-log ^ --engine redis ^ --cache-node-type cache.r5.large ^ --num-cache-clusters 2 ^ --log-delivery-configurations '{ "LogType":"slow-log", "DestinationType":"cloudwatch-logs", "DestinationDetails":{ "CloudWatchLogsDetails":{ "LogGroup":"my-log-group" } }, "LogFormat":"json" }'

修改复制组以将慢日志传输到 CloudWatch Logs

对于 Linux、macOS 或 Unix:

aws elasticache modify-replication-group \ --replication-group-id test-slow-log \ --apply-immediately \ --log-delivery-configurations ' { "LogType":"slow-log", "DestinationType":"cloudwatch-logs", "DestinationDetails":{ "CloudWatchLogsDetails":{ "LogGroup":"my-log-group" } }, "LogFormat":"json" }'

对于 Windows:

aws elasticache modify-replication-group ^ --replication-group-id test-slow-log ^ --apply-immediately ^ --log-delivery-configurations ' { "LogType":"slow-log", "DestinationType":"cloudwatch-logs", "DestinationDetails":{ "CloudWatchLogsDetails":{ "LogGroup":"my-log-group" } }, "LogFormat":"json" }'

修改复制组以禁用慢日志传递

对于 Linux、macOS 或 Unix:

aws elasticache modify-replication-group \ --replication-group-id test-slow-log \ --apply-immediately \ --log-delivery-configurations ' { "LogType":"slow-log", "Enabled":false }'

对于 Windows:

aws elasticache modify-replication-group ^ --replication-group-id test-slow-log ^ --apply-immediately ^ --log-delivery-configurations ' { "LogType":"slow-log", "Enabled":false }'