# Introduction



Flare can collect and display your application's log messages. This gives you insight into what your application is doing, beyond just error tracking.

Log collection requires Laravel 10 or newer.

## Enabling log collection

Log collection is disabled by default. To enable it, set the `log` key to `true` in your `config/flare.php` file:

```php
'log' => true,
```

You can also set a minimal log level so that only logs at or above that severity are sent:

```php
'minimal_log_level' => \Monolog\Level::Warning,
```

## Shipping logs under high load

By default, logs are shipped over HTTP at the end of each request together with the rest of the request's telemetry. That works well for most applications, but once log volume picks up the per request HTTP round trip can start to weigh on your workers.

If you're sending a lot of logs, run the [Flare daemon](/docs/laravel/general/flare-daemon) alongside your application. The daemon takes the upstream delivery off the request path entirely so log volume doesn't slow your application down. See the [Flare daemon](/docs/laravel/general/flare-daemon) page for setup details.

## Setting up the logging channel

To feed logs from Laravel to Flare, add the following channel to your `config/logging.php` file:

```php
'channels' => [

    // other channels...

    'flare' => [
        'driver' => 'flare',
    ],
],
```

Then add the Flare channel to the `LOG_STACK` variable in your `.env` file:

```bash
LOG_STACK=single,flare
```

Now any log call in your application will also be sent to Flare:

```php
Log::info('User signed in', ['user_id' => 42]);
Log::warning('Slow query detected');
```

The array passed as the second argument is attached as context to that single log entry. If you want a value to be attached to every log entry (and every error report) instead, use [custom context](/docs/laravel/data-collection/custom-context). Anything you store via Laravel's `Context` facade is also picked up automatically. See [Laravel context](/docs/laravel/data-collection/laravel-context) for details.

### Laravel Vapor

When using Laravel Vapor, you should use a `vapor` channel that combines the Flare channel with `stderr`:

```php
'channels' => [

    // other channels...

    'flare' => [
        'driver' => 'flare',
    ],

    'vapor' => [
        'driver' => 'stack',
        'channels' => ['flare', 'stderr'],
        'ignore_exceptions' => false,
    ],
],
```

Then set the log channel in your `.env` file:

```bash
LOG_CHANNEL=vapor
```

## Manually recording logs

If you're writing log messages outside of Laravel's logging system, you can record them manually. The [PHP documentation](/docs/php/logs/introduction) provides a full overview of all available recorder methods. When using these methods in Laravel, use the `Flare` facade instead of `$flare`:

```php
use Spatie\LaravelFlare\Facades\Flare;
use Monolog\Level;

Flare::log()->record(
    message: 'This is a log message',
    level: Level::Info,
    context: ['team_id' => 1],
);
```

## Disabling log collection

To disable log collection, set the `log` key to `false` in your `config/flare.php` file:

```php
// config/flare.php
'log' => false,
```
