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.

Note: This guide covers Android targets only. iOS instrumentation is not part of this guide.

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.
Note: The SDK requires a License Key. Do not use your account API key in a mobile application, because it would be exposed in the application's byte code.

Setup

1. Add the Plugin

If you have not already added the SDK, add the atatus_flutter_plugin dependency to your pubspec.yaml:

copy
icon/buttons/copy
dependencies:
  atatus_flutter_plugin: ^1.0.0

Then fetch the package:

copy
icon/buttons/copy
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:

copy
icon/buttons/copy
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:

copy
icon/buttons/copy
final logConfiguration = AtatusLoggerConfiguration(
  remoteLogThreshold: LogLevel.debug,
  networkInfoEnabled: true,
  bundleWithRumEnabled: true,
);

final logger = AtatusSdk.instance.logs.createLogger(logConfiguration);

AtatusLoggerConfiguration options:

Option Default Description
service Application bundle identifier Sets the service name attribute for this logger.
name Not set Sets the logger name attribute.
networkInfoEnabled true Adds network connectivity attributes to each log.
bundleWithRumEnabled true Links logs to the current RUM view and session.
bundleWithTraceEnabled true Links logs to the active APM trace.
remoteLogThreshold LogLevel.debug Minimum LogLevel that is sent to Atatus.
remoteSampleRate 100.0 Percentage of logs sent to Atatus, from 0.0 to 100.0.
customConsoleLogFunction simpleConsolePrint Function used to print logs to the local console. Pass null to disable console output.

LogLevel has eight members, in ascending order of severity: debug, info, notice, warning, error, critical, alert, emergency.

Note:

Only debug, info, warning, and error have a matching logger method. The remaining levels are accepted by remoteLogThreshold but are not yet emitted by the Flutter SDK. Note that the enum member is LogLevel.warning while the method is logger.warn().

4. Send Log Messages

Use the logger to send messages at the level you need:

copy
icon/buttons/copy
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:

copy
icon/buttons/copy
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:

copy
icon/buttons/copy
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:

copy
icon/buttons/copy
logger.addAttribute('version_name', '1.4.0');
logger.removeAttribute('version_name');

Tags help you filter and group your logs in Atatus. A tag is added as a key:value pair, or as a plain string when you pass no value:

copy
icon/buttons/copy
logger.addTag('build_type', 'release');

// Remove every tag with this key
logger.removeTagWithKey('build_type');

// Or remove one exact tag
logger.removeTag('build_type:release');
Note:

removeTag matches the complete tag string, so removeTag('build_type') does not remove build_type:release. To remove a tag by its key alone, use removeTagWithKey.

To attach an attribute to every logger rather than just one, set it on the logs feature:

copy
icon/buttons/copy
AtatusSdk.instance.logs.addAttribute('version_code', 1420);
AtatusSdk.instance.logs.removeAttribute('version_code');

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