Page updated Nov 11, 2023

Change log levels

In this section, you will learn about how to configure the logging level in your application when using the Amplify logger. This is helpful to help you determine the logging level that works best for your use cases, and which levels of errors or warnings you want to capture in Amazon Cloudwatch.

Change Default Log Level

Below is an example of setting the default log level to WARN:

Update the defaultLogLevel field under loggingConstraints.

{ "awsCloudWatchLoggingPlugin": { "enable": true, "logGroupName": "<log-group-name>", "region": "<region>", "localStoreMaxSizeInMB": 1, "flushIntervalInSeconds": 60, "loggingConstraints": { "defaultLogLevel": "WARN" } } }
1{
2 "awsCloudWatchLoggingPlugin": {
3 "enable": true,
4 "logGroupName": "<log-group-name>",
5 "region": "<region>",
6 "localStoreMaxSizeInMB": 1,
7 "flushIntervalInSeconds": 60,
8 "loggingConstraints": {
9 "defaultLogLevel": "WARN"
10 }
11 }
12}

The following are supported log levels:

  • ERROR
  • WARN
  • INFO
  • DEBUG
  • VERBOSE
  • NONE

Setting the log level to NONE effectively disables logging.

Configure Log Level by Category

Each Amplify category can be configured to have its own logging level.

Below is an example of setting different logging levels for the Storage and Auth categories.

Add a categoryLogLevel section and specify each category and its log level.

{ "awsCloudWatchLoggingPlugin": { "enable": true, "logGroupName": "<log-group-name>", "region": "<region>", "localStoreMaxSizeInMB": 1, "flushIntervalInSeconds": 60, "loggingConstraints": { "defaultLogLevel": "ERROR", "categoryLogLevel": { "Authentication": "VERBOSE", "Storage": "DEBUG" } } } }
1{
2 "awsCloudWatchLoggingPlugin": {
3 "enable": true,
4 "logGroupName": "<log-group-name>",
5 "region": "<region>",
6 "localStoreMaxSizeInMB": 1,
7 "flushIntervalInSeconds": 60,
8 "loggingConstraints": {
9 "defaultLogLevel": "ERROR",
10 "categoryLogLevel": {
11 "Authentication": "VERBOSE",
12 "Storage": "DEBUG"
13 }
14 }
15 }
16}

To disable logging for a specific category, set the log level to NONE.

The following are existing Amplify category names that are used by default by Amplify when automatically logging errors from the library.

  • Analytics
  • API
  • Authentication
  • DataStore
  • Geo
  • Hub
  • Logging
  • Predictions
  • PushNotifications
  • Storage