Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions docs/cli/logs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
title: "Logs"
sidebar_order: 5
description: "Learn how to view and stream logs using the Sentry CLI."
---

The `sentry-cli` tool can be used to view and stream logs from your Sentry projects. This allows you to monitor your application logs directly from the command line.

## Requirements

To use the logs command, you need to:

- [Install](/cli/installation) the Sentry CLI
- [Authenticate](/cli/configuration) with Sentry using an auth token
- Have logs enabled for your project

## Configuration

The logs command uses your Sentry auth token for authentication. You can configure this using:

```bash
sentry-cli login
```

Or by setting the `SENTRY_AUTH_TOKEN` environment variable:

```bash
export SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

Learn more about the CLI's [configuration file](/cli/configuration#configuration-file).

## Basic Usage

The logs command supports two main operations: listing logs and streaming logs in real-time.

### List Logs

To fetch and display logs:

```bash
sentry-cli logs list --project=my-project --org=my-org
```

### Stream Logs

To continuously stream logs in real-time:

```bash
sentry-cli logs list --project=my-project --org=my-org --live
```

The live streaming mode will continuously poll for new logs and display them as they arrive.

## Command Options

### Project and Organization

Specify the project and organization explicitly:

```bash
sentry-cli logs list --project=my-project --org=my-org
```

Or use the default values from your configuration file.

## Examples

### Monitor Application Logs

Stream logs from your production application:

```bash
sentry-cli logs list --project=my-app --org=my-org --live
```

### View Recent Logs

Fetch and display logs from your project:

```bash
sentry-cli logs list --project=my-app --org=my-org
```

## Output Format

The logs command displays log entries with the following information:

- Timestamp
- Log level
- Message
- Trace ID (if present)

Log entries are displayed in a readable format, making it easy to monitor your application's logging output directly from the command line.
Loading