Docs Menu
Docs Home
/ /
Atlas Device SDKs
/ /

Set the Client Log Level - Swift SDK

On this page

  • Set the Sync Log Level
  • Set a Custom Logger

You can set or change your app's log level to develop or debug your application. You might want to change the log level to log different amounts of data depending on the app's environment.

Changed in version 10.39.0:: Deprecated in favor of Realm Logger

Warning

This page shows how to set a Sync client log level in Realm Swift SDK versions 10.38.3 and earlier. Realm Swift SDK v10.39.0 supersedes this logging implementation with a Realm logger you can set and configure. For information on how to set a Realm logger in a later version, refer to Logging - Swift SDK.

You can set the Device Sync client log level on the RLMSyncManager instance on your RLMApp.

// Access your app
RLMApp *app = [RLMApp appWithId:YOUR_APP_ID];
// Access the sync manager for the app
RLMSyncManager *syncManager = [app syncManager];
// Set the logger to provide debug logs
syncManager.logLevel = RLMSyncLogLevelDebug;

You can set the Device Sync client log level on the SyncManager instance on your App.

// This code example shows how to set the log level
// in Realm Swift 10.38.3 and lower. For 10.39.0 and higher,
// use the `Logger` API.
// Access your app
let app = App(id: YOUR_APP_SERVICES_APP_ID)
// Access the sync manager for the app
let syncManager = app.syncManager
// Set the logger to provide debug logs
syncManager.logLevel = .debug

Tip

See RLMSyncLogLevel for a description of each available log level. Note that more logging can negatively affect performance.

Tip

To diagnose and troubleshoot errors while developing your application, set the log level to debug or trace. For production deployments, decrease the log level for improved performance.

You can pipe Device Sync logs to a custom logger by setting the logger property on the SyncManager. You must set this property before you open any synced realms.

If you do not specify this property, the Realm Swift SDK outputs log strings to Apple System Logger.

let app = App(id: YOUR_APP_SERVICES_APP_ID)
// Access the sync manager for the app
let syncManager = app.syncManager
// Set the logger to provide debug logs
syncManager.logLevel = .all
syncManager.logger = { logLevel, message in
AnalyticsProvider.shared.logEvent("\(logLevel) : \(message)", category: "Engineering debugging")
}

Back

Manage Sync Sessions

Next

Record Realm Events