Edit in GitHubLog an issue

Java

Copied to your clipboard
CacheService cacheService = ServiceProvider.getInstance().getCacheService();

Swift

Copied to your clipboard
private var cacheService: Caching { return ServiceProvider.shared.cacheService }

Java

First, implement a class that conforms to the Logging interface. Below is an example of a logging service that only prints out messages with a log level of Error.

Copied to your clipboard
class ErrorLogger implements Logging {
@Override
public void trace(String tag, String message) {}
@Override
public void debug(String tag, String message) {}
@Override
public void warning(String tag, String message) {}
@Override
public void error(String tag, String message) {
Log.e("ErrorLogger", message);
}
}

Next, use the setLoggingService API of ServiceProvider to update the logging service used by the SDK.

Copied to your clipboard
ServiceProvider.getInstance().setLoggingService(new ErrorLogger());

To revert to the default implementation of the LoggingService, you can set the logging service to nil using setLoggingService API.

Copied to your clipboard
ServiceProvider.getInstance().setLoggingService(null);

Swift

First, implement a type that conforms to the Logging protocol, as defined above. Below is an example of a logging service that only prints out messages with a log level of Error.

Copied to your clipboard
class ErrorLogger: Logging {
func log(level: LogLevel, label: String, message: String) {
guard level == .error else { return }
print("\(label): \(message)")
}
}

Next, set the loggingService on the shared ServiceProvider used by the SDK.

Copied to your clipboard
ServiceProvider.shared.loggingService = ErrorLogger()

To revert to the default implementation of the LoggingService, you can set the loggingService to nil.

Copied to your clipboard
ServiceProvider.shared.loggingService = nil
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2025 Adobe. All rights reserved.