home / skills / salesforcecommercecloud / b2c-developer-tooling / b2c-logs

This skill retrieves and monitors Salesforce B2C Commerce logs, enabling rapid error detection and contextual debugging across services.

npx playbooks add skill salesforcecommercecloud/b2c-developer-tooling --skill b2c-logs

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
4.4 KB
---
name: b2c-logs
description: Retrieve or monitor log from B2C Commerce instances with the b2c cli. When a user reports something like 'throwing an error,' 'broken,' or 'not working,' use this in addition to searching code. Use to fetch recent errors, searching log entries, filtering by level/time, or real-time tailing. Use when investigating issues with controllers, script APIs, custom API backend, jobs, or other SFCC server-side issues.
---

# B2C Logs Skill

Use the `b2c` CLI to retrieve and monitor log files on Salesforce B2C Commerce instances. The `logs get` command is designed for agent-friendly, non-interactive log retrieval with structured JSON output.

> **Tip:** If `b2c` is not installed globally, use `npx @salesforce/b2c-cli` instead (e.g., `npx @salesforce/b2c-cli logs get`).

## Agent-Friendly Log Retrieval

The `logs get` command is optimized for coding agents:
- Exits immediately after retrieving logs (non-interactive)
- Supports `--json` for structured output
- Filters by time, level, and text search
- Auto-normalizes file paths for IDE click-to-open

## Examples

### Get Recent Logs

```bash
# Get last 20 entries from error and customerror logs (default)
b2c logs get

# Get last 50 entries
b2c logs get --count 50

# JSON output for programmatic parsing
b2c logs get --json
```

### Filter by Time

```bash
# Entries from the last 5 minutes
b2c logs get --since 5m

# Entries from the last 1 hour
b2c logs get --since 1h

# Entries from the last 2 days
b2c logs get --since 2d

# Entries after a specific time (ISO 8601)
b2c logs get --since "2026-01-25T10:00:00"
```

### Filter by Log Level

```bash
# Only ERROR level entries
b2c logs get --level ERROR

# ERROR and FATAL entries
b2c logs get --level ERROR --level FATAL
```

### Search Text

```bash
# Search for "OrderMgr" in messages
b2c logs get --search OrderMgr

# Search for payment errors
b2c logs get --search "PaymentProcessor"
```

### Combined Filters

```bash
# Recent errors containing "PaymentProcessor"
b2c logs get --since 1h --level ERROR --search "PaymentProcessor" --json

# Last hour of errors and fatals from specific log types
b2c logs get --filter error --filter warn --since 1h --level ERROR --level FATAL
```

### List Available Log Files

```bash
# List all log files
b2c logs list

# List specific log types
b2c logs list --filter error --filter customerror

# JSON output
b2c logs list --json
```

### Real-Time Tailing (Human Use)

For interactive log monitoring (not for agents):

```bash
# Tail error and customerror logs
b2c logs tail

# Tail specific log types
b2c logs tail --filter debug --filter error

# Tail only ERROR and FATAL level entries
b2c logs tail --level ERROR --level FATAL

# Tail with text search
b2c logs tail --search "PaymentProcessor"

# Combined filtering
b2c logs tail --filter customerror --level ERROR --search "OrderMgr"

# Stop with Ctrl+C
```

## Downloading Full Log Files

To download the complete log file, use the `file` field from the JSON output with `b2c-cli:b2c-webdav`:

```bash
b2c webdav get error-odspod-0-appserver-20260126.log --root=logs -o -
```

## JSON Output Structure

When using `--json`, `logs get` returns:

```json
{
  "count": 1,
  "entries": [
    {
      "file": "error-odspod-0-appserver-20260126.log",
      "timestamp": "2026-01-26 04:38:03.022 GMT",
      "level": "ERROR",
      "message": "PipelineCallServlet|156679877|Sites-Site|...",
      "raw": "[2026-01-26 04:38:03.022 GMT] ERROR PipelineCallServlet|..."
    }
  ]
}
```

| Field | Description |
|-------|-------------|
| `file` | Source log file name (use with `b2c-cli:b2c-webdav` to download full file) |
| `level` | Log level: ERROR, WARN, INFO, DEBUG, FATAL, TRACE |
| `timestamp` | Entry timestamp |
| `message` | Log message (paths normalized for IDE click-to-open) |
| `raw` | Raw unprocessed log line |

## Log Types

Common log file prefixes:

| Prefix | Description |
|--------|-------------|
| `error` | System errors |
| `customerror` | Custom script errors (`Logger.error()`) |
| `warn` | Warnings |
| `debug` | Debug output (when enabled) |
| `info` | Informational messages |
| `jobs` | Job execution logs |
| `api` | API problems and violations |
| `deprecation` | Deprecated API usage |
| `quota` | Quota warnings |

## More Commands

See `b2c logs --help` for all available commands and options.

## Related Skills

- `b2c-cli:b2c-webdav` - Direct WebDAV file access for downloading full log files
- `b2c-cli:b2c-config` - Verify configuration and credentials

Overview

This skill uses the b2c CLI to retrieve and monitor logs from Salesforce B2C Commerce instances. It provides agent-friendly, non-interactive log retrieval with structured JSON output and supports filtering by time, level, and text. Use it to fetch recent errors, search log messages, or tail logs in real time for human troubleshooting.

How this skill works

The skill runs b2c logs get to return recent entries and supports --json for structured results that include file, timestamp, level, message, and raw fields. It accepts filters such as --since (relative or ISO time), --level, --search, and --filter (log type) to narrow results, and it normalizes file paths so IDEs can open referenced files. For interactive monitoring, b2c logs tail streams entries until interrupted.

When to use it

  • Investigating user reports like "throwing an error", "broken", or "not working" on server side.
  • Fetching recent ERROR or FATAL entries after a failed controller call, job run, or custom API request.
  • Searching for specific text such as exception class names, module names, or transaction IDs across recent logs.
  • Filtering logs by time window to correlate errors with deployments or external events.
  • Tailing logs in real time during manual reproduction or live debugging (human use).

Best practices

  • Use --json for programmatic analysis and to get file names for full downloads via WebDAV.
  • Combine --since, --level, and --search to quickly isolate relevant failures and reduce noise.
  • Prefer recent relative times (e.g., 5m, 1h) when investigating live incidents; use ISO timestamps for historical lookups.
  • List available log types with b2c logs list before querying to confirm which files exist.
  • Use tail only for interactive troubleshooting; non-interactive agents should rely on logs get with --json.

Example use cases

  • Run b2c logs get --since 1h --level ERROR --search "PaymentProcessor" --json to find recent payment failures.
  • After a failing job, fetch job logs with b2c logs get --filter jobs --since 2h to inspect execution details.
  • When a controller throws, search for controller class or pipeline names across error and customerror logs.
  • List available logs with b2c logs list --json, then download a full file via the WebDAV skill using the returned file name.
  • During a live demo or reproduction, use b2c logs tail --filter error --level ERROR to watch errors as they occur.

FAQ

What does --json return?

--json returns structured output with count and entries; each entry includes file, timestamp, level, message, and raw fields for parsing or linking to full files.

How do I download a complete log file?

Use the file field from --json output with b2c webdav get <filename> --root=logs -o - to stream or save the full log file.