> 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/merchant-tokenization/sdk-integration/error-management/retrieve-sdk-logs/android.md).

# Android

## Secure logs <a href="#secure-logs" id="secure-logs"></a>

Configure the Thales SDK to generate secure, obfuscated log files.

### Enable or disable secure logging <a href="#how-to-enabledisable-secure-logger" id="how-to-enabledisable-secure-logger"></a>

Secure logging is enabled by default. You can disable it during Thales SDK initialization:

```java
Context context;
String serverUrl;
byte[] serverCertificate;
String keyIdentifier;
TMGClientConfiguration configuration = new TMGClientConfiguration(activity, 
                                                                  serverUrl, 
                                                                  serverCertificate, 
                                                                  keyIdentifier);

configuration.enableSecureLog(false);
```

In this example, `enableSecureLog(false)` disables log generation after `TMGClientConfiguration` is instantiated. With the default setting (`true`), the SDK writes logs for the lifetime of the app process.

You can also pause logging temporarily:

```java
// Disable Secure log temporarily.
TMGClient.getInstance().getSecureLog().setLevel(SecureLogLevel.OFF);

// Resume logging with the default log level.
TMGClient.getInstance().getSecureLog().setLevel(SecureLogLevel.WARN);
```

Setting the log level to `OFF` prevents the Thales SDK from writing any new log entries. Set the level back to `WARN` (default) or another level to resume logging.

### Retrieve secure log files <a href="#how-to-retrieve-secure-log-files" id="how-to-retrieve-secure-log-files"></a>

The Thales SDK generates log files in the application sandbox. Retrieve them like this:

```java
// Retrieve the Secure log files
List<File> secureLogFiles = TMGClient.getInstance().getSecureLog().getFiles();

// Process the files.
```

`secureLogFiles` contains a list of `File` objects for the available log files. Share these files with the Thales delivery team when investigating an issue.

## Logcat logs <a href="#logcat" id="logcat"></a>

{% hint style="info" %}
Ensure that you are using the debug built variant.
{% endhint %}

### Method 1: capture logs with adb <a href="#method-1" id="method-1"></a>

Before you capture logs from an Android device, confirm the following:

1. The Android Debug Bridge tool (ADB) is ready at the host system.
2. The USB debugging option is enabled on the device under test.
   * If not enabled, go to Settings > Developer options > USB debugging.
3. The Android device is connected to the host system using a USB cable, and the USB driver is installed.

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

```shellscript
adb devices
```

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

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

#### Recommended steps for capturing logs

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

```shellscript
adb logcat -b all -c
```

2. Start the log capturing:

```shellscript
adb logcat > LogFileName.txt
```

Replace `LogFileName.txt` with your preferred filename.

3. Perform the use case(s).
4. Press CTRL+C in the command prompt to stop the log capturing.
5. Retrieve `LogFileName.txt` from the directory where you ran step 2.

### Method 2: use Android Studio Logcat <a href="#method-2" id="method-2"></a>

View logs directly in the Android Studio Logcat tool window.

1. Bring up the Logcat tab which can be found on the side or bottom tool bar.
2. Ensure a device is connected, and run the required use cases for the program.
3. Filter the messages with `TMGSDK` tag.
4. The logs will appear in the Logcat tab.


---

# 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/merchant-tokenization/sdk-integration/error-management/retrieve-sdk-logs/android.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.
