SDK Logging

Overview

This page documents the logs printed by the SDK and features to support enabling and writing logs to a file in the event troubleshooting needs to occur.

Customize SDK Log Levels

The OneTrust SDK supports the ability to customize log types printed to the console. You can control this log level by passing in your preferred minimum log level.

// Swift
OTPublishersHeadlessSDK.shared.enableOTSDKLog(.debug)

// ObjC
[OTPublishersHeadlessSDK.shared enableOTSDKLog:debug];

Log LevelDescription
OTLoggerConstant.errorLogs only errors.
OTLoggerConstant.warningLogs warnings and everything above.
OTLoggerConstant.infoLogs info and everything above.
OTLoggerConstant.debugLogs debug and everything above.
OTLoggerConstant.verboseLogs verbose and everything above.
OTLoggerConstant.noLogsTurns off all SDK logging.

Write SDK Logs to a File

The OneTrust SDK supports the ability to write debug logs to file in the event of an issue where the OneTrust team needs to support. Enabling SDK verbose logging will write all the SDK logs to OTPublisherHeadlessSDKLogs.txt file under Document Directory.

// Swift
OTPublishersHeadlessSDK.shared.writeLogsToFile(true, debugLog: true)

// ObjC
[OTPublishersHeadlessSDK.shared writeLogsToFile:true debugLog:true];

ParameterDescription
writeLogsLogs will only be written to file when passed as true
debugLogPassing true will write all types of logs to the file.
Passing false will omit all log types other than error, warning, and info.

Error Logs

Error CodeDescription
5Thrown when invalid language code passed during startSDK() call.

Note: This error code is deprecated. The startSDK() method will fallback to en language code when not specifically passed on latest SDK versions.
6- Thrown when invalid domain identifier passed during startSDK() call.
- Thrown when there is no internet connectivity during startSDK() call.
9Thrown when invalid request URL generated as part of startSDK() call.
11Thrown when incorrect request is generated for a request of type GET.
13Thrown when a valid response is received for a request, but the status code is not 200.
14Thrown when a network request has failed as part of retry of a request (except for time out).
16Thrown when the data returned for POST request is nil (empty).
18Thrown when maximum retry attempts have been reached.
19Thrown when a network request has failed (except for time out).
20Thrown when a network request has failed (generic).
22Thrown when unable to fetch the original request URL after receiving a response for a POST request.
38Invalid response received for the OT SDK network request. Thrown when 1) there is version mismatch between published version and SDK version 2) when incorrect CDN location is used or 3) when app id is wrong or has not been published to.
ManagerErrorRepresents the HeadlessSDK manager related errors in OT SDK.
NetworkErrorRepresents the network layer related errors in OT SDK.

SDK Initialization

MessageLog TypeLog TagDescriptionComments
error while fetching OT banner dataErrorNetworkRequestHandlerLogged when SDK cannot give callback to app on Downloading dataThis is caused when the OTSDK Callback passed by Application was null. The Application can pass a valid OTCallBack instance on getting the error.
network call response error out = + error messageErrorNetworkRequestHandlerLogged when OT SDK data network call failed
empty parameters passedWarningOTPublishersHeadlessSDKLogged when the Application has initialized the SDK with empty parameters.SDK will throw failure callback and pass error code
Invalid language code passedWarningOTPublishersHeadlessSDKThis is logged when the Application has initialized SDK with an invalid language code.Removed from SDK on latest versions, SDK will now return data in default lang configured even if lang code is not passed
IAB Vendorlist Api FailedErrorNetworkRequestHandlerLogged when VendorList API failed while initialising SDK for an IAB Template.SDK won't be rendering Vendor List UI and encoding vendor values in TCstring if this error is logged.
Cannot parse the data received from Server because it is corruptedErrorOneTrustLogged when API response is non-empty but does not contain the json required for SDK initialisation/UI renderingSDK will return failure callback with error code as 7 mainly related to publish issues. Republish and re-download the data in this scenario.
Error while parsing Global vendor listErrorIABHelperLogged when parsing and saving went wrong with the vendor list data fetched.This might cause SDK to render blank Vendor list UI or generate corrupted TC string.

Banner and Preference Center Shown - Reason Codes

Whenever the banner or preference center is surfaced to the user, a reason code will be logged to provide more insight as to why it has surfaced.

This can be useful in a few different use cases:

  • Collecting analytics for consent management
  • Troubleshooting issues related to surfacing the UI

This can be used to feed any analytics the app is looking to collect such as consents expiring, re-consent triggered, etc.) as well as provide a tool for debugging.

Banner Logging

These codes (except 110) will only work when the banner is surfaced with the setupUI() method.

CodeDescription
101Banner shown because 'Show Banner' has been enabled in geolocation rules + user's first time consent + setup() used to surface the banner
102Banner shown as re-consent was enabled
103Banner shown as consent has expired
104Banner shown as TC String has expired
105Banner shown as consent has expired (time period set in geolocation rules)
106Banner shown because 'service specific' is off (comes down as part of the TC String details).
107Banner shown because 100% sync is not complete (for cross device sync setup)
108Banner shown because we entered backward compatibility mode and banner has never been shown until now.
109Banner shown because region has changed (from non-IAB to IAB region)
110Banner shown because the app has called the show banner API.

Preference Center (PC) Logging

These codes (except 210) will only work when the PC is surfaced with the setupUI() method.

CodeDescription
201PC shown because 'Show Banner' has been enabled in geolocation rules + user's first time consent + setupUI() used to surface the PC
202PC shown as re-consent was enabled
203PC shown as consent has expired
204PC shown as TC String has expired
205PC shown as consent has expired (time period set in geolocation rules)
206PC shown because 'service specific' is off (comes down as part of the TC String details).
207PC shown because 100% sync is not complete (for cross device sync setup)
208PC shown because we entered backward compatibility mode and banner has never been shown until now.
209PC shown because region has changed (from non-IAB to IAB region)
210PC shown because the app has called the show PC API.

SDK Performance

The timer for these performance metrics begins as soon as startSDK() is called.

MessageLog TypeLog TagDescriptionComments
Time taken for OT SDK setup data fetch: {x} secondsInfoOTPublishersHeadlessSDK+PublicAPITime taken for the startSDK() method to fetch data via Network call.This log can be used to measure the performance of the SDK's initialization, specifically the initial network call to OneTrust CDN.
Time taken for IAB vendor list data setup: {x} secondsInfoVendorListDataModelTime taken for startSDK() method to fetch the IAB TCF Global Vendor list data.This log can be used to measure the performance of the SDK's initialization, specifically the network call to fetch IAB TCF Global Vendor list for regions where IAB TCF template is in scope.
Time taken for Google vendor list data setup: {x} secondsInfoVendorListDataModelTime taken for startSDK() method to fetch the IAB TCF Google Vendor list data.This log can be used to measure the performance of the SDK's initialization, specifically the network call to fetch IAB TCF Google Vendor list for regions where IAB TCF template is in scope.
Time taken for OT SDK data setup: {x} secondsInfoOTPublishersHeadlessSDK+PublicAPITime taken for the startSDK() method to complete, including Network call + all data parsing and saving.This log can be used to measure the performance of the complete SDK's initialization.

Updating Consent

MessageLog TypeLog TagDescriptionComments
No categories found to updateErrorCustomGroupDetailsLogged when SDK could not find any categories to update.This error will be thrown on calling functions to update consent of all categories and SDK could not find one to update. Application can check their configuration on getting this error.
error while fetching all categoriesErrorCustomGroupDetailsLogged when Exception occurred while parsing groups data on updating all categories.
Error while getting updated value of Purpose Legit InterestErrorCustomGroupDetailsLogged when Exception occurred on parsing LI values for an IAB categoryApplication will get -1 as the LI value for a category if this error is logged.Error while getting updated value of Purpose ConsentErrorCustomGroupDetailsLogged when Exception occurred on parsing consent values for a categoryApplication will get -1 as the consent value for a category if this error is logged
error in updating purpose legitimate interest statusErrorCustomGroupDetailsLogged when Exception occurred on updating LI values for an IAB category
Invalid ID " + purposeID + " passed to update Purpose LegitInterestWarningOTPublishersHeadlessSDKLogged when a non IAB category id passed to update LI value.
Purpose Legitimate Interest Update for id " + purposeID + " : -1, Invalid purposeIdWarningOTPublishersHeadlessSDKLogged when a non IAB category id passed to get LI value.
Purpose Consent Update for id " + purposeID + " : -1, SDK not finished processingWarningOTPublishersHeadlessSDKLogged when a update methods called before SDK initialization
Empty purpose id passed to get Purpose Consent UpdateWarningOTPublishersHeadlessSDKLogged when empty id passed to update consent
Empty vendor id passed to updateVendorConsent method.WarningOTPublishersHeadlessSDKLogged when empty vendor id passed to update consent.
Empty vendor id passed to updateVendorLegitInterest method.WarningOTPublishersHeadlessSDKLogged when empty vendor id passed to update LI
save consent status called without modifying anythingWarningCustomGroupDetailsLogged when save consent method called without updating consent.This warning could also mean that application called update consent methods and save methods using two different SDK objects. Same SDK object has to be used to call all the SDK methods.

Broadcasting Consent

MessageLog TypeLog TagDescriptionComments
Failed to broadcast SDK consent changes, No SDK ids foundWarningOTConsentChangesLogged when failed to broadcast consent changes for SDKs belong to a category.
error in broadcasting status. err = " + e.getMessage() + " changedConsents =ErrorOTConsentChangesLogged when failed to broadcast consent changes for categories
error while broadcasting default consent values :ErrorOTDataLogged while broadcasting default consent values on SDK initialisation failed due to parsing errors.

Capture Records of Consent

MessageLog TypeLog TagDescriptionComments
consentLogging not initialized, Consent Logging not enabled Created consent logging template contains no payloadWarningConsentLoggingLogged when SDK could not find consent logging data from application data. Consent Logging feature is not configured for the application id passed.This can be also due to errors occured while publishing an application
setDataSubjectIdentifier: Pass a valid identifier!!InfoOTUtilsLogged when invalid DSID passed by application.
Error on merging appendedCustomDSElements. Error msg =ErrorDsDataElementPayloadLogged when failed to sync the DsData elements set by App and the SDK constructed consent payloadThe details set by the app won't be shown on admin UI consent module for the desired fields.Error on getting Application versionName. Error msg =ErrorDsDataElementPayloadLogged when SDK was unable to read the version of the app using the native methods.DS data element will have empty version for the user agent string shown in admin UI.
Error on getting Application versionName. Error msg =ErrorDsDataElementPayloadLogged when SDK was unable to read the version of the app using the native methods.DS data element will have empty version for the user agent string shown in admin UI.

IAB CCPA

MessageLog TypeLog TagDescriptionComments
Update called without initializing CCPAWarningIABCCPA_ConsentLogged when CCPA direct opt-in or opt-out methods called w/o initialising it.Application has to initialise CCPA before calling opt-in, opt-out methods or before showing UI.
Do not sale GroupId not foundInfoIABCCPA_ConsentLogged when SDK cannot find CCPA parent id from the subgroup ids passed by appSDK won't generate IAB CCPA string if this is logged. Application has to pass valid subgroups of CCPA parent group on getting this error.
No need update CCPA for location {ccpaLocation}. Banner loaded location = {consentGivenLocation}InfoIABCCPA_ConsentLogged when location passed by application while initialising CCPA does not cover user’s location.

IAB TCF 2.0

MessageLog TypeLog TagDescriptionComments
error while constructing IAB encoder inputErrorIABHelperLogged when error occurred on constructing data for encoding IAB TC stringSDK won't write TCString if this error is logged.
Could not fetch Vendor details for IDErrorVendorUtilsLogged when SDK could not parse vendor details for a particular vendor Id.SDK will return null while fetching details for a specific vendor id.
Error while fetching IAB Vendor Disclosure details: IAB Vendor Disclosure API Failed :ErrorNetworkRequestHandlerLogged when IAB vendor disclosure API call failed / the data response is corrupt.Disclosure details won't be shown on vendor details view if this error is logged.