> 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).

# secure loggerでログを収集する

## 概要

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

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

## SDK 統合

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

セキュアロガーはデフォルトで有効になっており、ログレベルは次に設定されています `warn`.

<table><thead><tr><th width="109">ログレベル</th><th>説明</th></tr></thead><tbody><tr><td><code>デバッグ</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:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-ios/ja/additional-features/collect-logs-with-secure-logger.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.
