The Atatus mobile SDK lets you send logs from your Flutter applications directly to Atatus. Logs are sent over HTTP, batched on the device, and can be enriched with attributes and tags and correlated with your RUM sessions.
Prerequisites
- The Atatus SDK is initialized in your application. See Flutter (Android) setup for the initialization steps.
- A RUM application created in Atatus, which gives you a License Key.
Setup
1. Add the Plugin
If you have not already added the SDK, add the atatus_flutter_plugin dependency to your pubspec.yaml:
dependencies:
atatus_flutter_plugin: ^1.0.0
Then fetch the package:
flutter pub get
2. Enable Logging
Enable logging by passing a loggingConfiguration when you initialize the SDK. See Flutter (Android) setup for the full initialization:
import 'package:atatus_flutter_plugin/atatus_flutter_plugin.dart';
import 'package:flutter/widgets.dart';
void main() {
final configuration = AtatusConfiguration(
licenseKey: '<LICENSE_KEY>',
env: '<ENV_NAME>',
variant: 'release',
loggingConfiguration: AtatusLoggingConfiguration(),
rumConfiguration: AtatusRumConfiguration(),
);
AtatusSdk.runApp(configuration, TrackingConsent.granted, () async {
runApp(const MyApp());
});
}
3. Create a Logger
After the SDK is initialized, create a logger and configure it with the options you need:
final logConfiguration = AtatusLoggerConfiguration(
remoteLogThreshold: LogLevel.debug,
networkInfoEnabled: true,
bundleWithRumEnabled: true,
);
final logger = AtatusSdk.instance.logs?.createLogger(logConfiguration);
AtatusLoggerConfiguration options:
| Option | Description |
|---|---|
service |
Sets the service name attribute for this logger. |
name |
Sets the logger name attribute. |
networkInfoEnabled |
Adds network connectivity attributes to each log. |
bundleWithRumEnabled |
Links logs to the current RUM context. |
remoteLogThreshold |
Minimum LogLevel that is sent to Atatus. |
remoteSampleRate |
Percentage of logs sent to Atatus, from 0.0 to 100.0. |
4. Send Log Messages
Use the logger to send messages at the level you need:
logger?.debug('A debug message.');
logger?.info('Some relevant information.');
logger?.warn('An important warning.');
logger?.error('An error was met!');
Attach custom attributes to a single log entry:
logger?.info('User tapped checkout', attributes: {
'cart.items': 3,
'cart.total': 49.99,
});
5. Create Additional Loggers
You can create multiple loggers, each with its own service and name, to separate logs from different parts of your application:
final myLogger = AtatusSdk.instance.logs?.createLogger(
AtatusLoggerConfiguration(
service: 'com.example.custom_service',
name: 'Additional logger',
),
);
6. Manage Attributes and Tags
Attributes are key-value pairs attached to your logs. Add or remove them on a logger at any time:
logger?.addAttribute('version_name', '1.4.0');
logger?.removeAttribute('version_name');
Tags help you filter and group your logs in Atatus:
logger?.addTag('build_type', 'release');
logger?.removeTag('build_type');
7. Sending Data When the Device Is Offline
Logs are batched locally and sent to Atatus when network availability and battery levels permit. Even if your users open the application while offline, no data is lost. Batches are uploaded once connectivity is restored, and old data automatically expires to keep disk usage bounded.
Next Steps
- Set up RUM for Flutter (Android) to track views, actions, and errors.
- Collect logs from your native Android apps with Android Log Collection.
- Explore your logs in Logs Monitoring.
+1-415-800-4104