Page updated Jan 16, 2024

Change local storage

When using the Amplify Logger, all logged messages are saved locally on the user's device first before sending them to CloudWatch.

In this section, you will learn about how to configure the maximum amount of local logs are stored. This can be helpful to determine how much logs are stored locally depending on your network availability and offline use cases.

Change local storage maximum size

Below is an example of setting the local storage size to 2 MB:

Update the localStoreMaxSizeInMB field in the configuration file.

1{
2 "awsCloudWatchLoggingPlugin": {
3 "enable": true,
4 "logGroupName": "<log-group-name>",
5 "region": "<region>",
6 "localStoreMaxSizeInMB": 2,
7 "flushIntervalInSeconds": 60,
8 "loggingConstraints": {
9 "defaultLogLevel": "WARN"
10 }
11 }
12}
1AWSCloudWatchLoggingPluginConfiguration config = new AWSCloudWatchLoggingPluginConfiguration (<log-group-name>, <region>, true, 2);
2Amplify.addPlugin(new AWSCloudWatchLoggingPlugin(config));
1val config = AWSCloudWatchLoggingPluginConfiguration(logGroupName = <log-group-name>, region = <region>, localStoreMaxSizeInMB = 2)
2Amplify.addPlugin(AWSCloudWatchLoggingPlugin(config))
1AWSCloudWatchLoggingPluginConfiguration config = new AWSCloudWatchLoggingPluginConfiguration (<log-group-name>, <region>, true, 2);
2Amplify.addPlugin(new AWSCloudWatchLoggingPlugin(config));