Skip to content

Commit 1ffd6b7

Browse files
authored
feat: new doc page for enable logging for defineData (#8199)
* added enable logging page * update link
1 parent f2561f6 commit 1ffd6b7

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@
494494
"dataaccess",
495495
"dataacess",
496496
"databinding",
497+
"datalogconfig",
497498
"dataset",
498499
"datasource",
499500
"DataSource",

src/directory/directory.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ export const directory = {
340340
},
341341
{
342342
path: 'src/pages/[platform]/build-a-backend/data/aws-appsync-apollo-extensions/index.mdx'
343+
},
344+
{
345+
path: 'src/pages/[platform]/build-a-backend/data/enable-logging/index.mdx'
343346
}
344347
]
345348
},
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import { getCustomStaticPath } from '@/utils/getCustomStaticPath';
2+
3+
export const meta = {
4+
title: 'Enable logging',
5+
description: 'Learn how to enable logging for your Amplify data resource',
6+
platforms: [
7+
'android',
8+
'angular',
9+
'flutter',
10+
'javascript',
11+
'nextjs',
12+
'react',
13+
'react-native',
14+
'swift',
15+
'vue'
16+
]
17+
};
18+
19+
export function getStaticPaths() {
20+
return getCustomStaticPath(meta.platforms);
21+
}
22+
23+
export function getStaticProps(context) {
24+
return {
25+
props: {
26+
platform: context.params.platform,
27+
meta
28+
}
29+
};
30+
}
31+
32+
You can enable logging to debug your GraphQL API using Amazon CloudWatch logs. To learn more about logging and monitoring capabilities for your GraphQL API, visit the [AWS AppSync documentation for logging and monitoring](https://docs.aws.amazon.com/appsync/latest/devguide/monitoring.html).
33+
34+
## Enable default logging configuration
35+
36+
Default logging can be enabled by setting the `logging` property to `true` in the call to `defineData`. For example:
37+
38+
```ts title="amplify/data/resource.ts"
39+
export const data = defineData({
40+
// ...
41+
logging: true
42+
});
43+
```
44+
45+
Using `logging: true` applies the default configuration:
46+
- `excludeVerboseContent: true` (see [AppSync's Request-level logs](https://docs.aws.amazon.com/appsync/latest/devguide/monitoring.html#cwl))
47+
- `fieldLogLevel: 'none'` (see [AppSync's Field-level logs](https://docs.aws.amazon.com/appsync/latest/devguide/monitoring.html#cwl))
48+
- `retention: '1 week'` (see [Enum RetentionDays](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.RetentionDays.html))
49+
50+
## Customize logging configuration
51+
52+
You can customize individual configuration values by providing a [`DataLogConfig`](#datalogconfig-fields) object. For example:
53+
54+
```ts title="amplify/data/resource.ts"
55+
export const data = defineData({
56+
// ...
57+
logging: {
58+
excludeVerboseContent: false,
59+
fieldLogLevel: 'all',
60+
retention: '1 month'
61+
}
62+
});
63+
```
64+
65+
<Callout warning>
66+
**WARNING**: Setting `excludeVerboseContent` to `false` logs full queries and user parameters, which can contain sensitive data. We recommend limiting CloudWatch log access to only those roles or users (e.g., DevOps or developers) who genuinely require it, by carefully scoping your IAM policies.
67+
</Callout>
68+
69+
## Configuration Properties
70+
71+
### `logging`
72+
- `true`: Enables default logging.
73+
- `DataLogConfig` object: Overrides one or more default fields.
74+
75+
### `DataLogConfig` Fields
76+
77+
- **`excludeVerboseContent?: boolean`**
78+
- Defaults to `true`
79+
- When `false`, logs can contain request-level logs. See [AppSync's Request-Level Logs](https://docs.aws.amazon.com/appsync/latest/devguide/monitoring.html#cwl).
80+
81+
- **`fieldLogLevel?: DataLogLevel`**
82+
- Defaults to `'none'`
83+
- Supported values of [AppSync's Field Log Levels](https://docs.aws.amazon.com/appsync/latest/devguide/monitoring.html#cwl):
84+
- `'none'`
85+
- `'error'`
86+
- `'info'`
87+
- `'debug'`
88+
- `'all'`
89+
90+
- **`retention?: LogRetention`**
91+
- Number of days to keep the logs
92+
- Defaults to `'1 week'`
93+
- Supported values of [Enum RetentionDays](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.RetentionDays.html):
94+
- `'1 day'`
95+
- `'3 days'`
96+
- `'5 days'`
97+
- `'1 week'`
98+
- `'2 weeks'`
99+
- `'1 month'`
100+
- `'2 months'`
101+
- `'3 months'`
102+
- `'4 months'`
103+
- `'5 months'`
104+
- `'6 months'`
105+
- `'1 year'`
106+
- `'13 months'`
107+
- `'18 months'`
108+
- `'2 years'`
109+
- `'5 years'`
110+
- `'10 years'`
111+
- `'infinite'`

0 commit comments

Comments
 (0)