> 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/ja/sdk-tong-he/error-management/retrieve-sdk-logs/android.md).

# Android

## セキュアログ <a href="#secure-logs" id="secure-logs"></a>

Thales SDK を構成してセキュアで難読化されたログファイルを生成します。

### セキュアログの有効化または無効化 <a href="#how-to-enabledisable-secure-logger" id="how-to-enabledisable-secure-logger"></a>

セキュアログはデフォルトで有効です。Thales SDK の初期化時に無効にすることができます：

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

configuration.enableSecureLog(false);
```

この例では、 `enableSecureLog(false)` はインスタンス化後のログ生成を無効にします。 `TMGClientConfiguration` デフォルト設定では（`true`）では、SDK はアプリプロセスのライフタイム中にログを書き込みます。

ログ記録を一時的に一時停止することもできます：

```java
// セキュアログを一時的に無効にします。
TMGClient.getInstance().getSecureLog().setLevel(SecureLogLevel.OFF);

// デフォルトのログレベルでログを再開します。
TMGClient.getInstance().getSecureLog().setLevel(SecureLogLevel.WARN);
```

ログレベルを `OFF` はThales SDKが新しいログエントリを書き込むのを防ぎます。レベルを `WARN` （デフォルト）または別のレベルに戻してください。

### セキュアログファイルの取得 <a href="#how-to-retrieve-secure-log-files" id="how-to-retrieve-secure-log-files"></a>

Thales SDKはアプリケーションのサンドボックス内にログファイルを生成します。次のように取得します：

```java
// セキュアログファイルを取得します
List<File> secureLogFiles = TMGClient.getInstance().getSecureLog().getFiles();

// ファイルを処理します。
```

`secureLogFiles` はのリストを含みます `File` 利用可能なログファイルのオブジェクトです。問題を調査する際にはこれらのファイルを Thales デリバリーチームと共有してください。

## Logcatログ <a href="#logcat" id="logcat"></a>

{% hint style="info" %}
デバッグビルドバリアントを使用していることを確認してください。
{% endhint %}

### 方法 1: adbでログを取得する <a href="#method-1" id="method-1"></a>

Androidデバイスからログを取得する前に、次を確認してください：

1. ホストシステムにAndroid Debug Bridgeツール（ADB）が準備されていること。
2. テスト対象デバイスでUSBデバッグオプションが有効になっていること。
   * 有効になっていない場合は、設定 > 開発者向けオプション > USBデバッグに移動してください。
3. AndroidデバイスがUSBケーブルでホストシステムに接続されており、USBドライバがインストールされていること。

セットアップを確認するためにコマンドプロンプトで次のコマンドを実行できます：

```shellscript
adb devices
```

次のコードスニペットに類似した応答が表示されれば、ADBツールからデバイスに到達できることを示します：

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

#### ログを取得するための推奨手順

1. コマンドプロンプトを開き、デバイスのすべてのログバッファをクリアします：

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

2. ログの取得を開始します：

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

を置き換えます `LogFileName.txt` をお好みのファイル名にしてください。

3. ユースケースを実行します。
4. ログの取得を停止するには、コマンドプロンプトでCTRL+Cを押します。
5. から取得します `LogFileName.txt` ステップ2を実行したディレクトリから。

### 方法 2: Android StudioのLogcatを使用する <a href="#method-2" id="method-2"></a>

Android StudioのLogcatツールウィンドウで直接ログを表示します。

1. サイドまたは下部のツールバーにあるLogcatタブを表示します。
2. デバイスが接続されていることを確認し、プログラムの必要なユースケースを実行します。
3. メッセージを次でフィルタリングします `TMGSDK` タグ。
4. ログはLogcatタブに表示されます。


---

# 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/ja/sdk-tong-he/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.
