Docs Menu
Docs Home
/ /
Atlas Device SDKs
/

Logging - Flutter SDK

On this page

  • Set or Change the Realm Log Level
  • Customize the Logger
  • Turn Off Logging

Changed in version v2.0.0.

You can set or change your app's log level when developing or debugging your application. You might want to change the log level to log different amounts of data depending on your development needs. You can specify different log levels or custom loggers on a per-isolate basis.

Tip

See also:

This page shows how to set a Realm logger. For information on how to set the Sync client log level in an earlier version, refer to Set the Client Log Level - Flutter SDK.

In the Flutter SDK, you can set the level of detail in different parts of your app. To configure the log level, pass a valid LogLevel value to setLogLevel.

// If no category is set, default is LogCategory.realm
Realm.logger.setLogLevel(LogLevel.all, category: LogCategory.realm);

You can change the log level to increase or decrease verbosity at different points in your code. This behavior differs from the deprecated sync client log level, which had to be set before opening a synced realm and could not be changed.

Realm.logger.setLogLevel(LogLevel.off);
await executeAppCode();
Realm.logger.setLogLevel(LogLevel.debug, category: LogCategory.realm);
await executeComplexCodeToDebug();

The Flutter SDK logger conforms to the Dart Logger class.

To get started, set a log level:

Realm.logger.onRecord.listen((record) {
// Do something with the log record
print(record.message);
});

Define custom logging behavior by listening to Realm.logger.onRecord:

Realm.logger.onRecord.listen((event) {
// Do something with the log event - for example, print to console
print("Realm log message: '$event'");
});

You can turn off logging by passing LogLevel.off to setLogLevel():

Realm.logger.setLogLevel(LogLevel.off);

Back

Test & Debug