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}

Provide a localStoreMaxSizeInMB parameter initialization and configuration of the AWSCloudWatchLoggingPlugin.

1do {
2 let loggingConfiguration = AWSCloudWatchLoggingPluginConfiguration(logGroupName: "<log-group-name>", region: "<region>", localStoreMaxSizeInMB: 2)
3 let loggingPlugin = AWSCloudWatchLoggingPlugin(loggingPluginConfiguration: loggingConfiguration)
4 try Amplify.add(plugin: loggingPlugin)
5 try Amplify.configure()
6} catch {
7 assert(false, "Error initializing Amplify: \(error)")
8}