> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/push-provisioning/ja/integrate-the-d1-sdk/troubleshooting/retrieving-log-files/retrieve-d1-sdk-logs.md).

# D1 SDKログを取得

{% tabs %}
{% tab title="Android" %}

### Secure logs

D1 SDK can be configured to generate secure encrypted log files.

{% hint style="info" %}
These files can only be read by the Thales delivery team.
{% endhint %}

#### Enable or disable secure logging

The Secure Log feature is enabled by default. It can however be disabled during the initialisation of D1 SDK as follows.

{% code title="Configuration for D1 SDK V4.3.0 and Later" overflow="wrap" lineNumbers="true" expandable="true" %}

```kotlin
fun setupD1Task() {
        // Integrator should assign the Activity class that is used to receive callback for D1Task.handleCardResult
        val activity: FragmentActivity? = null

        // Ask Thales delivery team for the following information.
        val d1ServiceUrl = "https://www.123.com"
        val issuerID = "IssuerID"
        val digitalCardUrl = "https://www.456.com"
        val applicationContext: Context? = null // Integrator should assign the application context.

        // Initialize all necessary settings for D1 SDK.
        val d1Task: D1Task = D1Task.Builder()
            .setContext(applicationContext!!)
            .setD1ServiceURL(d1ServiceUrl)
            .setIssuerID(issuerID)
            .setDigitalCardURL(digitalCardUrl)
            .disableLogService() // disable Secure Log
            .build()

        // Initialize the required SDKs.
        // Application is required to provide consumerId.
        val consumerID = "consumerID"
        val coreConfig = ConfigParams.buildConfigCore(consumerID)

        // Required for Card Processing and OEM Pay.
        // Last parameter is used for Samsung Pay Service ID.
        // Last parameter is used for Samsung Pay Service ID.
        val cardConfig = ConfigParams.buildConfigCard(activity, OEMPayType.GOOGLE_PAY, null, null)

        val configCallback: ConfigCallback<Void?> = object : ConfigCallback<Void?> {
            override fun onSuccess(ignored: Void?) {
                // D1 config is successful.
            }

            override fun onError(exceptions: MutableList<D1Exception?>) {
                // D1 config failed, check exception for more details.
            }
        }

        d1Task.configure(configCallback, coreConfig, cardConfig)
    }
```

{% endcode %}

{% code title="Configuration for D1 SDK Version 4.2.0 and Earlier" overflow="wrap" lineNumbers="true" expandable="true" %}

```kotlin
fun setupD1TaskVer420() {
        // Integrator should assign the Activity class that is used to receive callback for D1Task.handleCardResult
        val activity: FragmentActivity? = null

        // Ask Thales delivery team for the following information.
        val d1ServiceUrl = "https://www.123.com"
        val issuerID = "IssuerID"
        val digitalCardUrl = "https://www.456.com"
        val applicationContext: Context? = null // Integrator should assign the application context.

        // Initialize all necessary settings for D1 SDK.
        val d1Task = D1Task.Builder()
            .setContext(applicationContext!!)
            .setD1ServiceURL(d1ServiceUrl)
            .setIssuerID(issuerID)
            .setDigitalCardURL(digitalCardUrl)
            .enableSecureLog(false) // disable Secure Log
            .build()

        // Initialize the required SDKs.
        // Application is required to provide consumerId.
        val consumerID = "consumerID"
        val coreConfig = ConfigParams.buildConfigCore(consumerID)

        // Required for Card Processing and OEM Pay.
        // Last parameter is used for Samsung Pay Service ID.
        val cardConfig = ConfigParams.buildConfigCard(activity, OEMPayType.GOOGLE_PAY, null, null)

        val configCallback: ConfigCallback<Void?> = object : ConfigCallback<Void?> {
            override fun onSuccess(ignored: Void?) {
                // D1 config is successful.
            }

            override fun onError(exceptions: MutableList<D1Exception?>) {
                // D1 config failed, check exception for more details.
            }
        }

        d1Task.configure(configCallback, coreConfig, cardConfig)
    }
```

{% endcode %}

In this example, the `disableLogService` method of the `D1Task.Builder` structure is called so that the SDK does not generate logs after the `D1Task` object has been instantiated. If the default setting is used where the `disableLogService` method is not called, the SDK will generate logs for the duration of the application runtime.

There is an option to disable the logs temporarily, if necessary:

{% code title="Disable logs for D1 SDK V4.3.0 and Later" overflow="wrap" lineNumbers="true" %}

```kotlin
fun setSecureLogLevel(d1Task: D1Task) {
   // Disable logs temporarily.
   d1Task.getLogService().setLevel(LogService.Level.OFF)

   // Resume logging with the default log level.
   d1Task.getLogService().setLevel(LogService.Level.WARN)
}
```

{% endcode %}

{% code title="Disable logs for D1 SDK V4.2.0 and Earlier" overflow="wrap" lineNumbers="true" %}

```kotlin
fun setSecureLogLevelVer420(d1Task: D1Task) {
    // Disable logs temporarily.
    d1Task.getSecureLog().setLevel(SecureLogLevel.OFF)

   // Resume logging with the default log level.
    d1Task.getSecureLog().setLevel(SecureLogLevel.WARN)
}
```

{% endcode %}

Setting the log level to `OFF` will prevent any subsequent calls to D1 SDK from generating entries in the secure logs. It is necessary to set the log level back to another value (`WARN` by default) in order to resume the generating of logs.

#### Retrieve secure log files

The D1 SDK secure log files are generated within the application sandbox. Retrieving these files can be done as follows:

{% code title="Log retrieval for D1 SDK V4.3.0 and Later" overflow="wrap" lineNumbers="true" %}

```kotlin
fun getSecureLogFiles(d1Task: D1Task): MutableList<File?>? {
   val logFiles: MutableList<File?>? = d1Task.getLogService().getFiles()
   return logFiles
}
// Process the files.
```

{% endcode %}

{% code title="Log retrieval for D1 SDK V4.2.0 and Earlier" overflow="wrap" lineNumbers="true" %}

```kotlin
fun getSecureLogFilesVer420(d1Task: D1Task): MutableList<File?>? { 
     val logFiles = d1Task.getSecureLog().getFiles()
     return logFiles
 }
// Process the files.
```

{% endcode %}

The `logFiles` variable will contain an array of `File` objects pointing to the available log files. These files are used by the Thales delivery team when investigating an issue.

### Logcat

Before you can retrieve the log files from an Android device, ensure that you have done the following setup:

* The Android Debug Bridge tool (ADB) is ready at the host system.
* The USB debugging option is enabled on the device under test.
* The Android device is connected to the host system by means of an USB cable and the USB driver has been installed.

You may execute the following command in the command prompt to verify your setup:

{% code overflow="wrap" %}

```bash
adb devices
```

{% endcode %}

A response similar to the following code snippet indicates that the device can be reached by the ADB tool:

{% code overflow="wrap" %}

```
List of devices attached
228b0e100d047ece device
```

{% endcode %}

If this is not the case, check that the prerequisites are met as specified above.

There are guides available covering these steps on the web.

For setup from the beginning, you may refer to <https://support.citrix.com/article/CTX232375>.

{% hint style="warning" %}
**Warning**

Some devices require the device logging to be enabled from a vendor's specific configuration menu.

For example on Huawei devices, this is hidden under a menu that could be reached by dialing `*#*#2846579#*#*` You may check the information at <https://stackoverflow.com/questions/18124334/huawei-logcat-not-showing-the-log-for-my-app> for more details.
{% endhint %}

#### Recommended steps for capturing logs

1. Open the command prompt and clear all the log buffers in the device:

   ```bash
   adb logcat -b all -c
   ```
2. Start the log capturing:

   ```bash
   adb logcat > TestLogFileName.txt
   ```
3. Perform the use case(s).
4. Press `CTRL+C` in the command prompt to stop the log capturing.
5. Recover the resulting log file `TestLogFileName.txt` in the same command execution folder as mentioned in step 2.

{% hint style="info" %}
**SDK variant and log filters**

* In order to obtain the most detailed logging, ensure that the application version used has been built with an SDK variant named `debug`. See [Deliverables section](https://thales-dis-dbp.stoplight.io/sdk-configuration/1.binary/android.md) for more details.
* Avoid using [log filters](https://developer.android.com/studio/command-line/logcat#filteringOutput) that will limit the log messages captured as these data will be useful for troubleshooting purposes.
* It is recommended to limit the size of the log by limiting the time the log is captured. This means that start capturing just before the use case begins and stop capturing immediately after the use case has been completed as described in the the above steps.
  {% endhint %}

#### Log filters

Different D1 SDK services use different log filters:

* D1 Push filter: `TPCSDK`
* D1 Pay filter: `SDK_ENTRY_POINT`, `util.h`
  {% endtab %}

{% tab title="iOS" %}

### Secure logs

D1 SDK can be configured to generate secure encrypted log files.

{% hint style="info" %}
These files can only be read by the Thales delivery team.
{% endhint %}

#### Enable or disable secure logging

The Secure Log feature is enabled by default. It can however be disabled during the initialization of D1 SDK as follows.

{% code overflow="wrap" lineNumbers="true" expandable="true" %}

```swift
var d1Task: D1Task!
 
var comp = D1Task.Components()
comp.d1ServiceURLString = ""
comp.issuerID = ""
comp.digitalCardURLString = ""
comp.enableSecureLog = false // disable Secure Log
d1Task = comp.task()
 
// Initialize required SDKs
// Application is required to provide consumerID
let consumerID = "" // obtained e.g. from server
let coreConfig = ConfigParams.coreConfig(consumerID: consumerID)
// required for Card Processing & OEM Pay
let cardConfig = ConfigParams.cardConfig()
 
d1Task.configure([coreConfig, cardConfig]) { (errors) in
    if let errors = errors {
        for error in errors {
            // Check error details to see whose config cause the errors
        }
    }
}
```

{% endcode %}

In this example, `enableSecureLog` property of the `D1Task.Components` structure is set to `false` so that the SDK does not generate logs after `D1Task` object has been instantiated. If the default setting is used where the `enableSecureLog` method is set to `true`, the SDK will generate logs for the duration of the application runtime.

There is an option to disable the logs temporarily, if necessary:

{% code lineNumbers="true" %}

```swift
// disable logs temporarily.
d1Task.getSecureLog()?.setLevel(.off)
 
// resume logging with the default log level.
d1Task.getSecureLog().setLevel(.warn)
```

{% endcode %}

Setting the log level to `off` will prevent any subsequent calls to D1 SDK from generating entries in the secure logs. It is necessary to set the log level back to another value (`warn` by default) in order to resume the generating of logs.

#### How to retrieve secure log files

The D1 SDK secure log files are generated within the application sandbox. Retrieving these files can be done as follows:

{% code lineNumbers="true" %}

```swift
if let logFiles: [URL] = d1Task.getSecureLog()?.files() {
    // process the files.
}
```

{% endcode %}

The `logFiles` variable will contain an array of URL objects pointing to the available log files. These files are used by the Thales delivery team when investigating an issue.

### Console

The logs can retrieved using the `debug` library of D1 SDK by performing the following steps:

1. Open the Console app on your Mac.
2. Ensure that both options `Include Info Messages` and `Include Debug Messages` are checked as follows:<br>

<div align="left"><figure><img src="/spaces/62lLFDcmLCeqqwmy4Fee/files/AzVkiRyMK4VHtlusZdrW" alt="" width="272"><figcaption><p>Enable info and debug messages in Console.app.</p></figcaption></figure></div>

{% hint style="info" %}
Console logs is only available for D1 Push on iOS devices. To see the log in the `Console.app`, add the `TPCSDK` filter in the **Search** field.
{% endhint %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.payments.thalescloud.io/push-provisioning/ja/integrate-the-d1-sdk/troubleshooting/retrieving-log-files/retrieve-d1-sdk-logs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
