> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squarecloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI でアプリのログを確認する

> squarecloud app logs で Square Cloud アプリケーションの最新ログを表示し、app realtime で出力とステータスの変化をターミナルでリアルタイムに追跡します。

`[appID]` は省略できます。[CLI がアプリを特定する仕組み](/ja/cli-reference/quickstart#cli-がアプリを特定する仕組み)を参照してください。

## `squarecloud app logs`

```bash 使い方 theme={"system"}
squarecloud app logs [appID] [--json]
```

アプリケーションの最新のログを表示して終了します。

```bash theme={"system"}
squarecloud app logs
# Logs of the app in the ID= line, or pick one.
```

```bash theme={"system"}
squarecloud app logs <appID> --json
# Prints {"logs": "..."} instead of plain text.
```

## `squarecloud app realtime`

```bash 使い方 theme={"system"}
squarecloud app realtime [appID]
```

アプリケーションのライブストリームに接続し、`Ctrl+C` を押すまで接続を維持します。

* ログの行は、アプリケーションが書き込んだとおりに表示されます。アプリケーションが stderr に書き込んだ行は stderr に出力されるため、リダイレクトで分けられます。
* ステータスは、変化したときだけ `[status] <state>` として表示されます。

```bash theme={"system"}
squarecloud app realtime <appID> 2> errors.log
# Follows the app live and saves its stderr lines to errors.log.
```

```bash 出力 theme={"system"}
Connected to the realtime stream of <appID> (Ctrl+C to exit)
[status] running
<log lines>
```

`realtime` には JSON 出力はありません。

## 関連項目

| コマンド | API | JavaScript SDK | VS Code |
| - | - | - | - |
| `logs` | [`GET .../logs`](/ja/api-reference/endpoint/apps/logs) | [`api.apps.logs()`](/ja/sdks/js/managing_application) | [ログを表示](/ja/vscode-extension/features#アプリケーション) |
| `realtime` | [`GET .../realtime`](/ja/api-reference/endpoint/apps/realtime) | [`api.apps.realtime()`](/ja/sdks/js/realtime) | [リアルタイムストリームを切り替え](/ja/vscode-extension/features#アプリケーション) |

Web サイトのエッジのリクエストログについては、[`squarecloud app network logs`](/ja/cli-reference/edge-analytics#squarecloud-app-network-logs) を参照してください。
