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

# Send application logs

> Send application logs to Braintrust from the Python SDK, TypeScript SDK, or OpenTelemetry, then browse, filter, and query them alongside your traces.

Send application logs to Braintrust to inspect events such as retries and payment failures alongside your AI traces. A log doesn't require an LLM call, an agent, or an active trace. When a failure occurs during an agent run, you can inspect both the message and the surrounding model behavior.

Get logs into Braintrust in three ways:

* [Send logs from the Python SDK](#send-logs-from-the-python-sdk), either by emitting messages or by forwarding standard-library `logging` records.
* [Send logs from the TypeScript SDK](#send-logs-from-the-typescript-sdk), either by emitting messages or by forwarding `console` output.
* [Send OpenTelemetry logs](#send-opentelemetry-logs) from any language that exports OTLP.

> [!WARNING]
>
> Application logs are in [public preview](https://docs.braintrust.dev/feature-lifecycle.md) and can change before reaching general availability.

![Application logs](https://mintcdn.com/braintrust/fFVJDcT2FWRWOjXn/images/observe/application-logs.png?fit=max\&auto=format\&n=fFVJDcT2FWRWOjXn\&q=85\&s=efb6fd24550c1f424363b4d8cacf210d)

Messages share the fields, queries, filters, and IDs used by spans. A message:

* Records a point in time, with zero duration.
* Has no children.
* Carries a severity level.

Emit a message to record an event. Open a [span](https://docs.braintrust.dev/instrument/trace-application-logic.md) to time an operation or nest other rows under it.

## Send logs from the Python SDK

To send logs from Python, [emit messages](https://docs.braintrust.dev/sdks/python/application-logs.md#emit-logs-from-the-sdk) with a project logger's severity methods, such as `info()` and `error()`, or [forward existing records](https://docs.braintrust.dev/sdks/python/application-logs.md#capture-existing-python-logs) from the standard-library `logging` module with `BraintrustLogHandler`. The guide covers stored fields, message templates, and associating logs with a trace.

## Send logs from the TypeScript SDK

To send logs from TypeScript, [emit messages](https://docs.braintrust.dev/sdks/typescript/application-logs.md#emit-logs-from-the-sdk) with a project logger's severity methods, such as `info()` and `error()`, or [forward existing `console` output](https://docs.braintrust.dev/sdks/typescript/application-logs#capture-console-output) with `wrapConsole()`. The guide covers stored fields, message templates, and associating logs with a trace.

## Send OpenTelemetry logs

To forward OpenTelemetry logs, [configure your exporter or Collector](https://docs.braintrust.dev/integrations/sdk-integrations/opentelemetry/send-traces-and-logs.md#send-logs).

You can also [send Claude Code events to Braintrust](https://docs.braintrust.dev/integrations/developer-tools/claude-code.md#trace-with-opentelemetry) as OpenTelemetry logs, including API requests, errors, and tool results.

## Inspect logs

> [tab] UI
>
> The  **Logs** row type shows SDK messages, OTLP log records, and OpenTelemetry span events. The **Traces** and **Spans** row types also include log rows. A log that isn't attached to a trace, such as an OTLP log record without a trace ID, appears in **Traces** as its own row. Log rows don't offer scoring or human review actions.
>
> 1. Go to [\*\* Logs\*\*](https://www.braintrust.dev/app/~/logs) in your project. In the toolbar's row type selector, choose  **Logs**. This loads **All logs view**, with **Dense** rows and an all-time range.
> 2. Choose a time range and use the search field to filter messages. The chart above the table groups messages by log level by default. See [Explore the logs chart](https://docs.braintrust.dev/observe/view-logs.md#explore-the-logs-chart).
> 3. Select a message to inspect its contents:
>
>    * **Output**: The full message.
>    * **Details**: Log level, timestamp, span ID, and log ID.
>    * **Metadata** and **Context**: Additional fields, when present.
>
>    ![Application logs](https://mintcdn.com/braintrust/fFVJDcT2FWRWOjXn/images/observe/application-logs.png?fit=max\&auto=format\&n=fFVJDcT2FWRWOjXn\&q=85\&s=efb6fd24550c1f424363b4d8cacf210d)

> [tab] SQL
>
> To query messages with [SQL](https://docs.braintrust.dev/reference/sql.md), use the [\*\* Query\*\*](https://www.braintrust.dev/app/~/sql) page, the [`bt sql`](https://docs.braintrust.dev/reference/cli/sql) CLI, or the [API](https://docs.braintrust.dev/reference/sql.md#api). Filter on `span_attributes.type = 'log'` to select messages, and include a range filter on `created` to bound the query.
>
> ```sql Recent messages in a project theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> SELECT created, output, span_attributes.log_level, metadata
> FROM project_logs('<PROJECT_ID>') -- Replace with your project ID
> WHERE span_attributes.type = 'log'
>   AND created > NOW() - INTERVAL 1 DAY
> ORDER BY created DESC
> LIMIT 100
> ```

### Filter by severity

> [tab] UI
>
> In the  **Logs** row type, select the empty search field. It suggests a filter for each severity level, such as `span_attributes.log_level = 'warn'` or `span_attributes.log_level = 'error'`. Choose one to apply it.
>
> ![Application logs filter by severity](https://mintcdn.com/braintrust/fFVJDcT2FWRWOjXn/images/observe/application-logs-filter-by-severity.png?fit=max\&auto=format\&n=fFVJDcT2FWRWOjXn\&q=85\&s=a55ed7929bd8c50305afb39342e0f281)
>
> To filter on a message's own level, open the  menu beside **Log level** in **Details** and select  **Filter by this value**.
>
> ![Application logs filter by value](https://mintcdn.com/braintrust/fFVJDcT2FWRWOjXn/images/observe/application-logs-filter-by-value.png?fit=max\&auto=format\&n=fFVJDcT2FWRWOjXn\&q=85\&s=3498e92d996496d95cb7d37c8f376d91)

> [tab] SQL
>
> ```sql Error and fatal messages theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> SELECT created, output, error, metadata
> FROM project_logs('<PROJECT_ID>') -- Replace with your project ID
> WHERE span_attributes.type = 'log'
>   AND span_attributes.log_level IN ('error', 'fatal')
>   AND created > NOW() - INTERVAL 7 DAY
> ORDER BY created DESC
> LIMIT 100
> ```

Messages without a `span_attributes.log_level` value don't match a severity filter. For OpenTelemetry logs and span events, see how Braintrust [derives log levels](https://docs.braintrust.dev/integrations/sdk-integrations/opentelemetry/attributes.md#log-levels-and-exceptions).

### View logs in a trace

> [tab] UI
>
> To inspect a message in context, select it in its trace's hierarchy or **Timeline**. Log icons and timeline markers reflect the recorded severity, when present.
>
> Older messages can lack a preview in the trace hierarchy until you open them. The full message remains available in **Output**.
>
> ![Application log in trace](https://mintcdn.com/braintrust/fFVJDcT2FWRWOjXn/images/observe/application-log-in-trace.png?fit=max\&auto=format\&n=fFVJDcT2FWRWOjXn\&q=85\&s=48678633e7b9c6fb5ea387f07f6538a7)

> [tab] SQL
>
> ```sql Messages emitted during one trace theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> SELECT created, output, span_attributes.log_level, span_id
> FROM project_logs('<PROJECT_ID>') -- Replace with your project ID
> WHERE span_attributes.type = 'log'
>   AND root_span_id = '<ROOT_SPAN_ID>' -- Replace with the trace's root span ID
> ORDER BY created
> ```

## Next steps

* [Filter and search](https://docs.braintrust.dev/observe/filter.md) to find records from a specific operation.
* [Examine traces](https://docs.braintrust.dev/observe/examine-traces.md) to inspect the operations surrounding a message.
* [Send logs from the Python SDK](https://docs.braintrust.dev/sdks/python/application-logs.md) to emit messages or forward `logging` records.
* [Send logs from the TypeScript SDK](https://docs.braintrust.dev/sdks/typescript/application-logs.md) to emit messages or forward `console` output.
* [Configure OpenTelemetry](https://docs.braintrust.dev/integrations/sdk-integrations/opentelemetry/send-traces-and-logs.md) to connect existing instrumentation to Braintrust.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.