> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.pensar.dev/apex/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.pensar.dev/apex/_mcp/server.

# pensar logs

> View and search agent execution logs via the Pensar Console API

## Overview

The `pensar logs` command provides access to agent execution logs for a given issue. You can list logs with filters or search for specific content within the log entries.

## Usage

```bash
pensar logs <issueId> [filters]                 # List agent logs
pensar logs search <issueId> <query> [options]  # Search agent logs
```

> **Note**
>
> `<issueId>` accepts either the issue UUID or its label — e.g. `VULN-000123`.

## Prerequisites

You must be connected to Pensar Console via [`pensar login`](/apex/cli-commands/pensar-login) before using this command.

## Subcommands

### List Logs

```bash
pensar logs <issueId> [filters]
```

Lists agent execution logs for an issue. Returns a JSON object with `issueId`, `totalLogs`, `returnedLogs`, and a `logs` array.

| Filter            | Description                                                          |
| ----------------- | -------------------------------------------------------------------- |
| `--level <level>` | Filter by: `debug`, `info`, `warn`, `error`                          |
| `--role <role>`   | Filter by: `assistant`, `user`, `system`, `tool-call`, `tool-result` |
| `--limit <n>`     | Max entries to return (default: 100, max: 500)                       |

### Search Logs

```bash
pensar logs search <issueId> <query> [options]
```

Searches log entries for a given query string.

| Option            | Description                                                          |
| ----------------- | -------------------------------------------------------------------- |
| `--level <level>` | Filter by: `debug`, `info`, `warn`, `error`                          |
| `--role <role>`   | Filter by: `assistant`, `user`, `system`, `tool-call`, `tool-result` |
| `--context <n>`   | Number of context lines around matches (default: 3)                  |

## Examples

```bash
# List all logs for an issue
pensar logs VULN-000123

# List only error-level logs
pensar logs VULN-000123 --level error

# List tool call logs with a limit
pensar logs VULN-000123 --role tool-call --limit 50

# Search logs for a specific term
pensar logs search VULN-000123 "SQL injection"

# Search with filters
pensar logs search VULN-000123 "timeout" --level warn --context 5
```

## Related Commands

#### [pensar issues](/apex/cli-commands/pensar-issues)

View the issues these logs relate to

#### [pensar fixes](/apex/cli-commands/pensar-fixes)

View suggested fixes for issues