Configure SDK logging
Learn how to configure logging in the MATTR Verifier SDKs, including log levels, callback handlers, and accessing log files across iOS, Android, and React Native platforms.
The MATTR Verifier SDKs include a built-in logging system that records internal SDK operations. This is useful for debugging integration issues, monitoring SDK behavior, and capturing diagnostic information during development, testing, and in production.
By default, SDK logs are stored on the device. The SDK itself does not transmit logs to any external service, although your application can choose to forward log events elsewhere if you register a callback.
What information the SDK can log
The SDK can log information about its internal operations, including errors and warnings encountered during SDK operations.
All log entries include the log level and a descriptive message. This information helps you diagnose issues and understand how the SDK operates within your application.
Log entries do not include credential claim values or other personal information. They can include session IDs, which let you and MATTR support match a log entry to a specific session.
Log levels
The SDK supports the following log levels, ordered from most to least verbose:
| Level | Description |
|---|---|
Verbose | Fine-grained informational events, most detailed output. |
Debug | Detailed information useful during development. |
Info | General informational messages about SDK operations. |
Warning | Potentially harmful situations or unexpected behavior (Warn in React Native). |
Error | Error events that might still allow the SDK to continue running. |
Off | Disables logging entirely. |
The SDK uses the configured log level as a threshold: it records log events at the specified level
and any less verbose levels. For example, setting the level to Info captures Info, Warning,
and Error events, but not Debug or Verbose.
Recommended configuration for production
SDK logging is off by default. Turn it on in every build you release, not only in development builds. When a user reports a problem, the log on their device is often the only record of what the SDK did, and MATTR support needs it to diagnose SDK issues.
Use the following settings in production:
logLevel:Info. This records SDK operations, warnings, and errors without the volume ofDebugandVerboseoutput.callbackLogLevel:Off, orWarning(Warnin React Native) if you forward SDK warnings and errors to your own monitoring service.
Also give your app a way to get the log file off the device, for example a Share diagnostics option in a settings or help screen. See Access the log file.
Share logs with MATTR support
When you raise an SDK issue through the MATTR service desk or your existing support channel, include:
- The log file from an affected device.
- The SDK name, version, and platform.
- The approximate date and time the issue occurred.
Configure logging
The way you configure logging depends on the SDK:
- iOS and Android: Call the SDK's
configureLoggermethod. The SDK produces no logs untilconfigureLoggeris called, so call it beforeinitializeto capture logs from initialization. The configuration is kept when the SDK is deinitialized, and callingconfigureLoggeragain replaces it. - React Native: Pass a
loggerConfigurationobject to the SDK'sinitializemethod.
The logger configuration accepts two separate log levels:
logLevel: Controls which log events are written to the log file.callbackLogLevel: Controls which log events trigger the optional callback function.
mobileCredentialVerifier.configureLogger(
LoggerConfiguration(
logLevel: .Info,
callbackLogLevel: .Warning
)
)
try await mobileCredentialVerifier.initialize(platformConfiguration: platformConfiguration)logLevel: Sets the minimum level for writing log entries to the log file. Defaults to.Off.callbackLogLevel: Sets the minimum level for invoking the callback closure. Defaults to.Off.
Refer to the
LoggerConfiguration
reference documentation for additional details.
Handle log events with a callback
You can register a callback function in the logger configuration to receive log events in real time. This allows your application to process log events as they occur, for example to forward them to a custom logging service, display them in a debug console, or filter specific events for monitoring.
The callback is only invoked for log events at or above the callbackLogLevel threshold.
mobileCredentialVerifier.configureLogger(
LoggerConfiguration(
logLevel: .Info,
callbackLogLevel: .Warning,
callback: { logEvent in
print("\(logEvent.timestamp) [\(logEvent.level)] \(logEvent.message)")
}
)
)The callback receives a
LogEvent
object with the following properties:
level: TheLogLevelof the event.message: A string describing the log event.timestamp: The date and time the event was created.
Access the log file
The SDK writes log entries to a file that you can access for debugging and diagnostics. The log file contains entries from the previous two calendar days.
let logFilePath = mobileCredentialVerifier.getCurrentLogFilePath()The
getCurrentLogFilePath
method returns the file path as a string, or nil if no log file is available.
The file is a plaintext snapshot of the current log entries, with one entry per line. Each line starts with a timestamp formatted in the device locale, followed by the level name and the call site, for example:
26-11-25 14:03:07.412 ERROR - MobileCredentialVerifier.swift initialize(...) [Line 120]: messageThe line format is intended for reading and sharing. To process log events in your app, use the callback instead of parsing the file.
if let path = mobileCredentialVerifier.getCurrentLogFilePath(),
let url = URL(string: path) {
let text = try String(contentsOf: url, encoding: .utf8)
let entries = text.split(separator: "\n")
}How would you rate this page?
Last updated on