Get the session ID
Obtain the session ID to trace the parsing procedure. If a parsing error occurs, provide this ID to technical support through a DingTalk group or a ticket.
The session ID is a randomly generated 12-character string that remains unchanged during the app lifecycle.
getSessionId
API definition
String getSessionId()
Version introduced
1.3.2
Class
HttpDnsService
Return value
Type | Description |
String | Returns the session ID. |
Code example
val httpdns = HttpDns.getService(accountID)
val sessionId = httpdns?.getSessionId()HttpDnsService httpdns = HttpDns.getService(accountID);
String sessionId = httpdns.getSessionId();Enable HTTPDNS log printing
You can specify whether to print HTTPDNS debug logs to the console. This feature is disabled by default.
To prevent the leakage of parameters, such as accountID and secretKey, or data generated during app runtime, you must disable log printing in the production version.
enable
API definition
void enable(boolean enable)
Version introduced
2.0.2
Class
HttpDnsLog
Parameters
Parameter | Type | Required | Description |
enable | boolean | Yes | Specifies whether to print logs to logcat. |
Code example
HttpDnsLog.enable(shouldPrintLog)HttpDnsLog.enable(shouldPrintLog);Set a callback class for SDK logs
You can set a callback class to obtain internal logs from the SDK.
setLogger
Adds a log callback class.
API definition
void setLogger(ILogger logger)
Version introduced
2.0.2
Class
HttpDnsLog
Parameters
Parameter | Type | Required | Description |
logger | Yes | After you set this interface, the SDK's internal logs are sent through the ILogger interface callback. This lets you control how the logs are printed and stored. |
Code example
HttpDnsLog.setLogger { s ->
Log.d(
"HttpDnsSDK",
"resultILogger:$s"
)
}HttpDnsLog.setLogger(new ILogger() {
@Override
public void log(String s) {
Log.d("HttpDnsSDK", "resultILogger:" + s);
}
});removeLogger
Removes a log callback class.
API definition
void removeLogger(ILogger logger)
Version introduced
2.0.2
Class
HttpDnsLog
Parameters
Parameter | Type | Required | Description |
logger | Yes | The logger that was previously added. |
Code example
HttpDnsLog.removeLogger(logger)HttpDnsLog.removeLogger(logger);Troubleshoot parsing failures with logs
If parsing fails, filter for "RESOLVE FAIL" in the console to find the cause.
If the parsing API reports an error, the following logs are output:
Network connectivity failed for a single-host resolution.

Network connectivity failed for a batch resolution.

A signature error was reported for a single-host resolution.

A signature error was reported for a batch resolution.

An encryption error was reported for a single-host resolution.

An encryption error was reported for a batch resolution.

The log indicates the reason for an empty resolution result.

The preceding logs show only some of the reasons for parsing failures. Other failure logs are also printed when you filter for "RESOLVE FAIL".