> 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/ja/additional-features/collect-logs-with-secure-logger.md).

# セキュアロガーでログを収集する

## 概要

セキュアロガーは NFC Wallet SDK の実行ログを収集します。アプリケーションのサンドボックス内に安全に保存されます。

お使いのデジタルウォレットアプリケーションは、ログファイルを取得し、トラブルシューティングのために Thales と共有できます。

## SDK統合

### ログレベルを設定する

セキュアロガーは既定で有効になっており、ログレベルは `warn`.

<table><thead><tr><th width="109">ログレベル</th><th>説明</th></tr></thead><tbody><tr><td><code>debug</code></td><td>トラブルシューティングとデバッグのために詳細な情報を記録します。</td></tr><tr><td><code>info</code></td><td>API のエントリ／エグジットポイントや戻り値などの通常メッセージを記録します。</td></tr><tr><td><code>warn</code></td><td>通常実行中の警告および重大なフローの問題を記録します。</td></tr><tr><td><code>error</code></td><td>フローが正常に完了するのを妨げるエラーを記録します。</td></tr><tr><td><code>fatal</code></td><td>直ちに対応が必要な実行時エラーを記録します。</td></tr><tr><td><code>off</code></td><td>ログ記録を無効にします。</td></tr></tbody></table>

### セキュアロガーのインスタンスを取得する

SDK からセキュアロガーのインスタンスを取得します:

```swift
// TSHPay SDK から securelog オブジェクトを取得
let securelog = TSHPay.secureLog
```

本番環境では、 `warn` 通常の状態に保ってください。

問題を再現するには、エンドユーザーにより詳細なレベルを有効にしてもらいます。その後、問題を再現し、ログファイルを共有してください。

### セキュアロガーを無効にする

セキュアロガーを無効にするには:

```swift
// レベルを off に設定すると、ログは無効になります。MPA は別のレベルを選択することで有効にできます。たとえば debug
securelog.setLevel(.off)
```

### ログファイルを取得する

ログファイルを取得するには:

```swift
// ファイル一覧を返す
let files = securelog.files()
```

### ログファイルを削除する

ログファイルを削除するには:

```swift
// ファイルを削除
securelog.deleteFiles()
```

### ログファイルを共有する（例）

この例では、ログを次の方法で共有します: `UIActivityViewController`.

デジタルウォレットアプリケーションは、ログをファイルサーバーにもアップロードできます。

承認済みの他のチャネルを通じてログを送信することもできます。

{% code expandable="true" %}

```swift
// ログを共有
    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/ja/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.
