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.

Set SDK Log Level

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. The SDK will not log anything below INFO level without any configurations.

OTPublishersHeadlessSDK.enableOTSDKLog(debug)

Log LevelDescription
log.fatalLogs only fatal errors.
log.errorLogs errors and everything above.
log.warnLogs warnings and everything above.
log.infoLogs info and everything above.
log.debugLogs debug and everything above.
log.traceLogs trace and everything above.
OTLoggerConstant.NO_OT_SDK_LOGTurns off all SDK logging.

Write SDK Logs to File

OneTrust has ability to write SDK logs to a file by enabling writeToFile and share it for debugging SDK related issues. Enabling SDK verbose logging will write all the SDK logs to OTPublisherHeadlessSDKLogs.log file under Files directory.

We recommend you enable verbose logging and share above mentioned file with OneTrust on encountering an issue with the SDK.

new OTPublishersHeadlessSDK(context).writeLogsToFile(false, false)

Parameters
| Position | Name | Type | Description |
|-|-|-|-|
|1| writeToFile | boolean | Pass true as first parameter to write logs to file. |
|2| debugLog | boolean | Pass true to write all types of logs to the file.
Pass false for to omit all log types other than error, warning, and info.

Error Logs

Android SDK passes error codes as a part of OTResponse object returned to application via callbacks. Following are the response codes:

Error CodeDescription
2Empty response received from Server
3OTT Data Network call failed
4Empty parameters passed by application
5Invalid language code passed by application
6Network not available

SDK Initialization

MessageLog typeLog TagDescriptionComments
error while fetching OT banner dataErrorNetworkRequestHandlerLogged when SDK cannot give callback to app on Downloading dataCaused when OTSDK Callback passed by Application was null.
Application can pass a valid OTCallBack instance on getting the error.
network call response error out = + error message
ErrorNetworkRequestHandlerLogged when OT SDK data network call failed
empty parameters passedWarningOTPublishersHeadlessSDKLogged when Application has initialized SDK with empty parametersSDK will throw failure callback and pass error code 4.
Invalid language code passedWarningOTPublishersHeadlessSDKLogged when Application has initialized SDK with invalid language codeSDK will throw failure callback and pass error code 5.
IAB Vendor List Api FailedErrorNetworkRequestHandlerLogged when VendorList API failed while initializing SDK for an IAB Template.SDK won't be rendering Vendor List UI and encoding vendor values in TCstring if this error is logged.

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.
|Message|Log Type|Log Tag|Description|Comments|
|-|-|-|-|-|
| Time taken for OT SDK setup data fetch: {x} seconds | Info | OTPublishersHeadlessSDK | Time 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} seconds | Info | NetworkRequestHandler | Time 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} seconds | Info | NetworkRequestHandler | Time 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} seconds | Info | OTPublishersHeadlessSDK | Time 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 category.Application 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 category.Application 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 initialization failed due to parsing errors.

Capture Records of Consent

MessageLog typeLog TagDescriptionComments
Consent Logging not initialized
Consent Logging not enabled
Created consent logging template contains no payload
WarningConsentLoggingLogged 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 occurred 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.

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 app.SDK won't generate IAB CCPA string if this is logged.
Application has to pass valid subgroups of CCPA parent group on getting this error.
Do not sale GroupId not foundInfoIABCCPA_ConsentLogged when SDK cannot find CCPA parent id from the subgroup ids passed by app.SDK 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 = " + consentGivenLocationInfoIABCCPA_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 string.SDK 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.

Google Ad Id

MessageLog typeLog TagDescriptionComments
Error when checking Google ad consent logging state. Error = <br> Error on saveAndConsentLogGooglePermissionState. Error =ErrorGoogleAdInfoSomething went wrong while logging consent for Google Ad Id.
Error when getting the Google Ad purposeID. Error =ErrorGoogleAdInfoSomething went wrong while getting the purpose Id for Google Ad id consent.
Error in creating Google Ad CL payload :ErrorGoogleAdInfoLogged when the SDK could not construct payload for Google Ad Id.SDK won't trigger Google ad id consent logging if this is logged.
Adding google play services library as a dependency in app’s gradle is a pre-requisite to configure for Google ad id in SDK.
implementation 'com.google.android.gms:play-services-ads: Failing to do so will cause crashes.

Universal Consent Purposes

MessageLog typeLog TagDescriptionComments
Error in parseUCPData :ErrorAppDataParserSomething went wrong while parsing UCP data.
No purposes data configured for UC Purposes!WarningUCPurposesDataHandlerLogged when purposes are empty in the UCP data received from serverApp will have to configure purposes for UCP from admin UI, republish and re-initialize SDK.
Invalid id passed to update custom preference optionsWarningUCPurposesDataHandlerLogged when the id passed is invalid to update custom preference optionsApp will have to check the custom preference id passed.
Error in updating consent for CP options :ErrorUCPurposesDataHandler
Logged when SDK could not update consent value for custom preference options due to JSON exception.
Invalid id passed to update topicsWarningUCPurposesDataHandlerLogged when the id passed is invalid to update topicsApp will have to check the topic id passed.
Error in updating consent for topics :ErrorUCPurposesDataHandlerLogged when SDK could not update consent value for topics due to JSON exception.
Error in updating consent for purposes :ErrorUCPurposesDataHandlerLogged when SDK could not update consent value for UC purposes due to JSON exception.User’s changes won't be reflecting of any of the parsing errors are logged
Error in initializing user state object :ErrorUCPurposesDataHandlerLogged when SDK could not sync the last saved user selections with the latest fetched dataUser selections won't be reflected on UI if the is logged.
failed to trigger broadcast for UC Purposes,ErrorOneTrustLogged when SDK could not trigger UCP broadcast
Error in creating UCP CL payload :ErrorUCPurposesDataHandlerLogged when SDK could not construct UCP consent logging payloadUCP consent logging will fail even if consent values are updated and saved locally on device.

Other Error Logs

MessageLog typeLog TagDescriptionComments
Could not find class androidx.browser.customtabs.CustomTabsIntent$Builder, " + "add implementation 'androidx.browser:browser:{version}' to gradle fileErrorOneTrustLogged when application tried to load external links but failed to navigate.Caused when application missed to add a dependency in gradle file for Custom tabs.
Application will have to add Chrome custom tabs gradle dependency to load external links.
No data found to render the UI, Please initialize the SDK and try again.ErrorOneTrustLogged when SDK UI methods called before initialising SDK.Application has to initialise SDK and receive success callback from SDK to call UI methods.
OT Profile Sync params not set, sending syncProfile false.InfoNetworkRequestHandlerLogged when params required to set profile sync found as empty
1 Enabling Re-consent as last user consent was computed with " + <br> 2 "isServiceSpecific value as FALSE, which is no longer validWarningShowBannerLogged when isServiceSpecific = false in the profile sync data when cross device profile sync is enabled.A very rare scenario. SDK will clear all consent values related to IAB and present the UI again for re-consent.
Migration Handler exception, error message =ErrorNetworkRequestHandlerLogged when web-native consent sync failedThis could be because the consent saved on device from Websdk is corrupted/ null data. App will have to disable webSDK sync and re-initialize SDK if this is logged on every trial.1 No data found in Web SDK for the domain id passed. Hence " + <br> 2 "cannot sync Web SDK consent data. \nTo sync Web SDK consent data, please pass " + <br> 3 "same appID as Web SDK.WarningOTPublishersHeadlessSDKLogged when SDK could not find any saved data for the appId on Web-Native SDK migrationThis is because App has passed an appId which is different from the appId saved for WebSDK on the device. The app has to publish the same application and pass the same appId as that of WebSDK while migrating.Error on constructing webviewConsentObject. Error msg =ErrorWebviewConsentHelperLogged when construction of object containing consent values/encoded strings to pass consent from native to webview went wrongSDK will return empty/incomplete JSON if this error is logged.
1 To display an Age Gate Prompt, " + <br> 2 "you need to enable Age Gate Prompt from Admin UI and republish the SDKErrorOneTrustLogged when Agegate UI method called even if its not configured from admin UI / SDK could it find data saved to render AgeGate prompt.Enable Age Gate UI from admin UI, republish and initialize SDK in this scenario.
1 API version has been overridden. This feature is for testing " + <br> 2 "only. Do not go live with an overridden API version.WarningOneTrustLogged when App overrides SDK version while fetching the data
App should not override SDK version on going live
1 setOtBannerHeightRatio() method is deprecated and eventually " + <br> 2 "will get removed from SDK. Please configure the banner height from OT admin " + <br> 3 "UI template settingsWarningOneTrustLogged when setOtBannerHeightRatio() is called to set banner height while initialising SDK.This method is deprecated and will get removed in couple of releases and the app will have to configure this in the template settings from the admin UI.Logo shown for Preference Center failed for url <br> Logo shown for Banner failed for url ErrorPreferenceCenter <br> OTSDKBannerLogged when SDK could not render the logo on UI from url coming in data.This could be because the url is invalid or image is large to be downloaded in slow networks. App can configure a valid logo url/a smaller image size, republish and re-initialize SDK.
error while populating PC fieldsErrorPreferenceCenterLogged when SDK could not parse the data / data required to render PC view was corrupt.App needs to re-initialize the SDK to fetch app data which matches the SDK version. This could also mean that JSON parsing going wrong due to proguard rules if minify enabled for app. App can add the below rule to the proguard rules and try again for this specific scenario.-keep class org.json.*_ { _; }