---
title: "Laravel Options"
description: "Learn about Sentry's integration with Laravel and its options for logs, breadcrumbs, and tracing."
url: https://docs.sentry.io/platforms/php/guides/laravel/configuration/laravel-options/
---

# Laravel Options | Sentry for Laravel

Most configuration for Laravel is done in your `.env` file. You can also add additional config options to your `config/sentry.php` file.

## [Logs](https://docs.sentry.io/platforms/php/guides/laravel/configuration/laravel-options.md#logs)

To send Laravel logs to Sentry, enable logs in your `.env` file or in `config/sentry.php`. If a single request, command, or job can produce a high volume of logs, `SENTRY_LOG_FLUSH_THRESHOLD` lets the SDK send partial log batches before it finishes.

For setup and usage details, see the [Laravel logs docs](https://docs.sentry.io/platforms/php/guides/laravel/logs.md).

### [`enable_logs`](https://docs.sentry.io/platforms/php/guides/laravel/configuration/laravel-options.md#enable_logs)

This configures the base SDK [`enable_logs`](https://docs.sentry.io/platforms/php/configuration/options.md#enable_logs) option.

### [`log_flush_threshold`](https://docs.sentry.io/platforms/php/guides/laravel/configuration/laravel-options.md#log_flush_threshold)

`.env`

```bash
SENTRY_LOG_FLUSH_THRESHOLD=5
```

When this is unset, the SDK does not auto flush buffered logs. Set it to a positive integer to flush as soon as that many logs have been buffered.

## [Breadcrumbs](https://docs.sentry.io/platforms/php/guides/laravel/configuration/laravel-options.md#breadcrumbs)

The Laravel SDK will create [breadcrumbs](https://docs.sentry.io/platforms/php/guides/laravel/enriching-events/breadcrumbs.md) for certain events occurring in the framework, the capture of this information can be configured using the following environment variables:

`config/sentry.php`

```php
'breadcrumbs' => [
    // Capture Laravel logs as breadcrumbs
    'logs' => env('SENTRY_BREADCRUMBS_LOGS_ENABLED', true),

    // Capture Laravel cache events (hits, writes etc.) as breadcrumbs
    'cache' => env('SENTRY_BREADCRUMBS_CACHE_ENABLED', true),

    // Capture Livewire components like routes as breadcrumbs
    'livewire' => env('SENTRY_BREADCRUMBS_LIVEWIRE_ENABLED', true),

    // Capture SQL queries as breadcrumbs
    'sql_queries' => env('SENTRY_BREADCRUMBS_SQL_QUERIES_ENABLED', true),

    // Capture SQL query bindings (parameters) in SQL query breadcrumbs
    'sql_bindings' => env('SENTRY_BREADCRUMBS_SQL_BINDINGS_ENABLED', false),

    // Capture queue job information as breadcrumbs
    'queue_info' => env('SENTRY_BREADCRUMBS_QUEUE_INFO_ENABLED', true),

    // Capture command information as breadcrumbs
    'command_info' => env('SENTRY_BREADCRUMBS_COMMAND_JOBS_ENABLED', true),

    // Capture HTTP client request information as breadcrumbs
    'http_client_requests' => env('SENTRY_BREADCRUMBS_HTTP_CLIENT_REQUESTS_ENABLED', true),

    // Capture send notifications as breadcrumbs
    'notifications' => env('SENTRY_BREADCRUMBS_NOTIFICATIONS_ENABLED', true),
],
```

## [Tracing](https://docs.sentry.io/platforms/php/guides/laravel/configuration/laravel-options.md#tracing)

To enable tracing, set `SENTRY_TRACES_SAMPLE_RATE` to a value greater than `0.0`:

`.env`

```bash
# You may need to adjust this value in your production environment to prevent quota issues
SENTRY_TRACES_SAMPLE_RATE=1.0
```

### [Advanced Sample Rate](https://docs.sentry.io/platforms/php/guides/laravel/configuration/laravel-options.md#advanced-sample-rate)

If you want more control over which requests are monitored, use the [`traces_sampler`](https://docs.sentry.io/platforms/php/guides/laravel/configuration/options.md#traces-sampler) option as a callable:

`config/sentry.php`

```php
'traces_sampler' => [App\Exceptions\Sentry::class, 'tracesSampler'],
```

Then implement the sampler:

`app/Exceptions/Sentry.php`

```php
class Sentry
{
    public static function tracesSampler(\Sentry\Tracing\SamplingContext $context): float
    {
        // Keep front-end and back-end traces connected.
        if ($context->getParentSampled()) {
            return 1.0;
        }

        if (some_condition()) {
            // Drop this transaction.
            return 0.0;
        }

        // Default sample rate for all other transactions.
        return 0.25;
    }
}
```

### [More Configuration](https://docs.sentry.io/platforms/php/guides/laravel/configuration/laravel-options.md#more-configuration)

You can also configure which parts of your application are traced automatically. These settings have no effect if `SENTRY_TRACES_SAMPLE_RATE` is set to `0.0` or if the environment variable is not set:

`config/sentry.php`

```php
'tracing' => [
    // Trace queue jobs as their own transactions (this enables tracing for queue jobs)
    'queue_job_transactions' => env('SENTRY_TRACE_QUEUE_ENABLED', true),

    // Capture queue jobs as spans when executed on the sync driver
    'queue_jobs' => env('SENTRY_TRACE_QUEUE_JOBS_ENABLED', true),

    // Capture SQL queries as spans
    'sql_queries' => env('SENTRY_TRACE_SQL_QUERIES_ENABLED', true),

    // Capture SQL query bindings (parameters) in SQL query spans
    'sql_bindings' => env('SENTRY_TRACE_SQL_BINDINGS_ENABLED', false),

    // Capture where the SQL query originated from on the SQL query spans
    'sql_origin' => env('SENTRY_TRACE_SQL_ORIGIN_ENABLED', true),

    // Define a threshold in milliseconds for SQL queries to resolve their origin
    'sql_origin_threshold_ms' => env('SENTRY_TRACE_SQL_ORIGIN_THRESHOLD_MS', 100),

    // Capture views rendered as spans
    'views' => env('SENTRY_TRACE_VIEWS_ENABLED', true),

    // Capture Livewire components as spans
    'livewire' => env('SENTRY_TRACE_LIVEWIRE_ENABLED', true),

    // Capture HTTP client requests as spans
    'http_client_requests' => env('SENTRY_TRACE_HTTP_CLIENT_REQUESTS_ENABLED', true),

    // Capture Laravel cache events (hits, writes etc.) as spans
    'cache' => env('SENTRY_TRACE_CACHE_ENABLED', true),

    // Capture Redis operations as spans (this enables Redis events in Laravel)
    'redis_commands' => env('SENTRY_TRACE_REDIS_COMMANDS', false),

    // Capture where the Redis command originated from on the Redis command spans
    'redis_origin' => env('SENTRY_TRACE_REDIS_ORIGIN_ENABLED', true),

    // Capture send notifications as spans
    'notifications' => env('SENTRY_TRACE_NOTIFICATIONS_ENABLED', true),

    // Enable tracing for requests without a matching route (404's)
    'missing_routes' => env('SENTRY_TRACE_MISSING_ROUTES_ENABLED', false),

    // Configures if the performance trace should continue after the response has been sent to the user until the application terminates
    // This is required to capture any spans that are created after the response has been sent like queue jobs dispatched using `dispatch(...)->afterResponse()` for example
    'continue_after_response' => env('SENTRY_TRACE_CONTINUE_AFTER_RESPONSE', true),

    // Enable the tracing integrations supplied by Sentry (recommended)
    'default_integrations' => env('SENTRY_TRACE_DEFAULT_INTEGRATIONS_ENABLED', true),
],
```
