# sf-debug-log

> Manage Salesforce Debug Logs

Latest version **1.0.0** (published 2026-11-18) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install sf-debug-log
pnpm add sf-debug-log
yarn add sf-debug-log
bun add sf-debug-log
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-11-18 |
| First published | 2023-10-21 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.0.0 |
| Dependencies | 4 |
| Unpacked size | 85.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Raffaele Preziosi |
| Maintainers | preziosiraffaele |
| Keywords | force, salesforce, sfdx, salesforcedx, sfdx-plugin, sf-plugin, sf |

## Links

- npm: https://www.npmjs.com/package/sf-debug-log
- npm.io page: https://npm.io/package/sf-debug-log

## Dependencies (4)

- [@oclif/core](https://npm.io/package/@oclif/core.md) ^5.1.12
- [@salesforce/core](https://npm.io/package/@salesforce/core.md) ^9.5.0
- [@inquirer/prompts](https://npm.io/package/@inquirer/prompts.md) ^7.8.0
- [@salesforce/sf-plugins-core](https://npm.io/package/@salesforce/sf-plugins-core.md) ^13.0.9

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2026-11-18
- 0.7.0 — 2026-04-18
- 0.6.0 — 2026-04-17
- 0.5.0 — 2026-04-17
- 0.4.0 — 2026-04-13
- 0.3.0 — 2026-04-12
- 0.2.5 — 2025-10-26
- 0.2.4 — 2025-09-14
- 0.2.3 — 2025-08-12
- 0.2.2 — 2025-08-08
- 0.2.0 — 2025-08-03
- 0.1.2 — 2024-01-18
- 0.1.1 — 2024-01-14
- 0.0.23 — 2023-11-27
- 0.0.22 — 2023-11-04
- … 20 more at https://npm.io/package/sf-debug-log/versions

## README

# sf-debug-log

A Salesforce CLI plugin to make managing debug logs easier.

I built this because I found the official `sf` CLI was missing some commands I regularly need. For example, I wanted to put a specific user under debug and retrieve only their logs, delete logs more easily, or set a new debug level from the command line. This plugin adds those missing pieces and more to make debugging faster.

## Features

*   Create trace flags for any user in the org, selecting the debug level and time.
*   List all debug levels in the org.
*   Retrieve Apex logs for a specific user or all users in the org.
*   Delete Apex logs for a specific user or all users in the org.

## Install

```bash
sf plugins install sf-debug-log
```

## Commands
<!-- commands -->
* [`sf debug delete`](#sf-debug-delete)
* [`sf debug retrieve`](#sf-debug-retrieve)
* [`sf debuglevel list`](#sf-debuglevel-list)
* [`sf debuglevel new`](#sf-debuglevel-new)
* [`sf trace new`](#sf-trace-new)

## `sf debug delete`

Delete Apex log files from a Salesforce org.

```
USAGE
  $ sf debug delete -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [-u <value>] [-t <value>]
    [-a]

FLAGS
  -a, --all-users               Retrieve logs for all users in the org.
  -o, --targetusername=<value>  (required) Username or alias of the target Salesforce org.
  -t, --time=<value>            Delete logs older than the specified number of minutes.
  -u, --user=<value>            [default: targetusername] Username, Name, or ID of the user for whom you want to delete
                                the logs.
      --api-version=<value>     API version to use.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Delete Apex log files from a Salesforce org.

  Deletes Apex log files from a Salesforce org.

EXAMPLES
  $ sf debug delete -u "Raffaele Preziosi" -t 60

FLAG DESCRIPTIONS
  --api-version=<value>  API version to use.

    Override the api version used for api requests made by this command
```

## `sf debug retrieve`

Retrieve Apex log files from the Salesforce platform.

```
USAGE
  $ sf debug retrieve -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [-u <value> | -a] [-t
    <value>] [-l <value> | -q <value>] [-d <value>] [--output-format text|ndjson]

FLAGS
  -a, --all-users               Retrieve logs for all users in the org.
  -d, --folder=<value>          The folder where the retrieved log files will be stored. If omitted, the selected logs
                                are streamed to stdout.
  -l, --limit=<value>           [default: 100] The max number of log files to retrieve. This flag can't be used with
                                `--query`.
  -o, --targetusername=<value>  (required) Username or alias of the target Salesforce org.
  -q, --query=<value>           Full SOQL query used to select `ApexLog` records to retrieve. This flag can't be used
                                with `--user`, `--time`, `--all-users`, or `--limit`. The command always replaces the
                                query `SELECT` list with the fields it needs.
  -t, --time=<value>            Retrieve logs created in the last specified number of minutes.
  -u, --user=<value>            [default: targetusername] Username, Name, or ID of the user for whom you want to
                                retrieve the logs.
      --api-version=<value>     API version to use.
      --output-format=<option>  [default: text] How to write logs to stdout when `--folder` is omitted. Use `text` for
                                raw log content or `ndjson` for one JSON object per log.
                                <options: text|ndjson>

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Retrieve Apex log files from the Salesforce platform.

  This command allows you to retrieve Apex log files from a Salesforce org. If you don't specify `--folder`, the
  selected logs are streamed to stdout either as raw text or as NDJSON.

EXAMPLES
  $ sf debug retrieve -o MyDeveloperEdition -u "Raffaele Preziosi" -t 10
  $ sf debug retrieve -o MyDeveloperEdition -q "SELECT Id FROM ApexLog WHERE Operation = 'ApexTestHandler' ORDER BY SystemModstamp DESC LIMIT 1" | rg "EXCEPTION"
  $ sf debug retrieve -o MyDeveloperEdition -q "SELECT Id FROM ApexLog WHERE Operation = 'ApexTestHandler' ORDER BY SystemModstamp DESC LIMIT 1" --output-format ndjson

FLAG DESCRIPTIONS
  --api-version=<value>  API version to use.

    Override the api version used for api requests made by this command
```

## `sf debuglevel list`

List the debug levels in your org.

```
USAGE
  $ sf debuglevel list -o <value> [--json] [--flags-dir <value>] [--api-version <value>]

FLAGS
  -o, --targetusername=<value>  (required) Username or alias of the target Salesforce org.
      --api-version=<value>     API version to use.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  List the debug levels in your org.

  List the debug levels in your org.

EXAMPLES
  $ sf debuglevel list -o MyDeveloperEdition

FLAG DESCRIPTIONS
  --api-version=<value>  API version to use.

    Override the api version used for api requests made by this command
```

## `sf debuglevel new`

Create a new DebugLevel.

```
USAGE
  $ sf debuglevel new -o <value> -n <value> [--json] [--flags-dir <value>] [--api-version <value>]

FLAGS
  -n, --developername=<value>   (required) The developer name of the new DebugLevel.
  -o, --targetusername=<value>  (required) Username or alias of the target Salesforce org.
      --api-version=<value>     API version to use.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Create a new DebugLevel.

  Create a new DebugLevel assigning level for each category.

EXAMPLES
  $ sf debuglevel new

FLAG DESCRIPTIONS
  --api-version=<value>  API version to use.

    Override the api version used for api requests made by this command
```

## `sf trace new`

Create a trace flag for a user.

```
USAGE
  $ sf trace new -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [-u <value>] [-t <value>]
    [-f] [-d <value>]

FLAGS
  -d, --debuglevel=<value>      The debug level for the trace flag.
  -f, --force                   Force the creation of the trace flag.
  -o, --targetusername=<value>  (required) Username or alias of the target Salesforce org.
  -t, --time=<value>            [default: 60] The time for the trace flag.
  -u, --user=<value>            [default: targetusername] Username, Name, or ID of the user for whom you want to
                                retrieve the logs.
      --api-version=<value>     API version to use.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

EXAMPLES
  $ sf trace new -o MyDeveloperEdition -u "Raffaele Preziosi" -t 10

FLAG DESCRIPTIONS
  --api-version=<value>  API version to use.

    Override the api version used for api requests made by this command
```
<!-- commandsstop -->
DESCRIPTION
  Create a new DebugLevel assigning level for each category.

EXAMPLES
  sf debuglevel new -o DeveloperEdition -n "DebugLevel"
```

---
_Source: https://npm.io/package/sf-debug-log · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
