Set the Client Log Level - Swift SDK
On this page
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.
Set the Sync Log Level
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.
Set a Custom Logger
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") }