> 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/nfc-wallet-sdk-ios/es/additional-features/collect-logs-with-secure-logger.md).

# Recopilar registros con el registrador seguro

## Resumen

El registrador seguro recopila registros de ejecución del SDK de billetera NFC. Los almacena de forma segura en el sandbox de la aplicación.

Su aplicación de billetera digital puede recuperar archivos de registro y compartirlos con Thales para la resolución de problemas.

## Integración del SDK

### Establecer el nivel de registro

El registrador seguro está habilitado por defecto con el nivel de registro establecido en `warn`.

<table><thead><tr><th width="109">Nivel de registro</th><th>Descripción</th></tr></thead><tbody><tr><td><code>depuración</code></td><td>Registrar información detallada para la solución de problemas y la depuración.</td></tr><tr><td><code>info</code></td><td>Registrar mensajes rutinarios, como puntos de entrada/salida de la API y valores devueltos.</td></tr><tr><td><code>warn</code></td><td>Registrar advertencias y problemas críticos de flujo durante la ejecución normal.</td></tr><tr><td><code>error</code></td><td>Registrar errores que impiden que un flujo se complete con éxito.</td></tr><tr><td><code>fatal</code></td><td>Registrar errores en tiempo de ejecución que requieren acción inmediata.</td></tr><tr><td><code>off</code></td><td>Desactivar el registro.</td></tr></tbody></table>

### Obtener la instancia del registrador seguro

Obtenga la instancia del registrador seguro desde el SDK:

```swift
// obtener el objeto securelog del sdk TSHPay
let securelog = TSHPay.secureLog
```

En producción, mantenga `warn` en condiciones normales.

Para reproducir un problema, permita que el usuario final habilite un nivel más detallado. Luego reproduzca el problema y comparta los archivos de registro.

### Deshabilitar el registrador seguro

Para deshabilitar el registrador seguro:

```swift
// Al establecer el nivel en off, los registros se desactivan. MPA puede activarlo seleccionando un nivel diferente. Por ejemplo, debug
securelog.setLevel(.off)
```

### Recuperar archivos de registro

Para recuperar los archivos de registro:

```swift
// devolver lista de archivos
let files = securelog.files()
```

### Eliminar archivos de registro

Para eliminar los archivos de registro:

```swift
// eliminar archivos
securelog.deleteFiles()
```

### Compartir archivos de registro (ejemplo)

Este ejemplo comparte registros usando `UIActivityViewController`.

Su aplicación de billetera digital también puede cargar registros a un servidor de archivos.

También puede enviar registros a través de otros canales aprobados.

{% code expandable="true" %}

```swift
// compartir registros
    func archieveLogsURL(_ onComplete: @escaping (URL?) -> ()) {
        var error: NSError?
        guard let file = TSHPay.secureLog.files().first?.absoluteURL.deletingLastPathComponent(),
            let fileURL = URL(string: "file://\(file.absoluteString)") else {
            onComplete(nil)
            return
        }
        
        NSFileCoordinator().coordinate(
            readingItemAt: fileURL,
            options: [.forUploading],
            error: &error
        ) { zipUrl in
            do {
                let tmpUrl = try FileManager.default
                    .url(
                        for: .itemReplacementDirectory,
                        in: .userDomainMask,
                        appropriateFor: zipUrl,
                        create: true
                    )
                    .appendingPathComponent("archive.zip")
                
                try FileManager.default.moveItem(at: zipUrl, to: tmpUrl)
                onComplete(tmpUrl)
            } catch {
                onComplete(nil)
            }
        }
    }
```

{% endcode %}


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-ios/es/additional-features/collect-logs-with-secure-logger.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
