> 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/ios.md).

# iOS

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

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

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

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

```swift
let serverUrl;
let serverCertificate;
let keyIdentifier;
let enableSecureLog; //Optional
let configurationBuilder = TMGClientConfiguration.Builder(serverUrl: serverUrl, 
                                                          serverCertificate: Data(serverCertificate.utf8), 
                                                          serverKeyId: keyIdentifier,
                                                          enableSecureLog: false)
```

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

You can also pause logging temporarily:

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

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

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

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

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

`logFiles` contains an array of `URL` objects for the available log files. Share these files with the Thales delivery team when investigating an issue.

## Console logs <a href="#console" id="console"></a>

View logs in console using the `debug` library:

1. Open the Console app on your Mac.
2. In the Console **Action** menu, enable both `Include Info Messages` and `Include Debug Messages`.

{% hint style="info" %}
To see the logs in `Console.app`, filter on `TMGSDK` in the **Search** field.
{% endhint %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.payments.thalescloud.io/merchant-tokenization/sdk-integration/error-management/retrieve-sdk-logs/ios.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
