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.
{ "awsCloudWatchLoggingPlugin": { "enable": true, "logGroupName": "<log-group-name>", "region": "<region>", "localStoreMaxSizeInMB": 2, "flushIntervalInSeconds": 60, "loggingConstraints": { "defaultLogLevel": "WARN" } }}
Provide a localStoreMaxSizeInMB
parameter initialization and configuration of the AWSCloudWatchLoggingPlugin
.
do { let loggingConfiguration = AWSCloudWatchLoggingPluginConfiguration(logGroupName: "<log-group-name>", region: "<region>", localStoreMaxSizeInMB: 2) let loggingPlugin = AWSCloudWatchLoggingPlugin(loggingPluginConfiguration: loggingConfiguration) try Amplify.add(plugin: loggingPlugin) try Amplify.configure(with: .amplifyOutputs)} catch { assert(false, "Error initializing Amplify: \(error)")}