Flare by Spatie
    • Error Tracking
    • Performance Monitoring
    • Logs Coming soon
  • Pricing
  • Docs
  • Insights
  • Changelog
  • Back to Flare ⌘↵ Shortcut: Command or Control Enter
  • Sign in
  • Try Flare for free
  • Error Tracking
  • Performance Monitoring
  • Logs Coming soon
  • Pricing
  • Docs
  • Insights
  • Changelog
    • Back to Flare ⌘↵ Shortcut: Command or Control Enter
    • Try Flare for free
    • Sign in
Flare Flare Laravel Laravel PHP PHP JavaScript JavaScript React React Vue Vue Protocol Protocol
  • General
  • Installation
  • Integrating into a framework
  • Attribute providers
  • Application lifecycle
  • Censoring collected data
  • Ignoring collected data
  • Flare daemon
  • Errors
  • Adding custom context
  • Customise error report
  • Customising error grouping
  • Handling errors
  • Linking to errors
  • Reporting errors
  • Logs
  • Introduction
  • Levels
  • With errors
  • Performance
  • Introduction
  • Sampling
  • Limits
  • Modify spans and events
  • Data Collection
  • Application info
  • Cache events
  • Console commands
  • Database transactions
  • Dumps
  • Errors when tracing
  • Exception context
  • External http requests
  • Filesystem operations
  • Git information
  • Glows
  • Identifying users
  • Jobs and queues
  • Queries
  • Redis commands
  • Requests
  • Routing
  • Server info
  • Spans
  • Stacktrace arguments
  • Views
  • Older Packages
  • Flare Client PHP V2
  • Flare Client PHP V1

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.

Enabling log collection

Log collection is disabled by default. To enable it:

$config->log(true);

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

use Monolog\Level;

$config->log(true, minimalLevel: Level::Warning);

Recording logs

We cannot automatically collect logs in the framework-agnostic version of the package. You can manually record logs using the Logger:

use Monolog\Level;

$flare->log()->record('Something happened', Level::Info);

You can also pass additional context:

$flare->log()->record(
    message: 'User signed in',
    level: Level::Info,
    context: ['user_id' => 42],
);

You can read more about the available log levels and how they interact in the levels documentation.

Using the Monolog handler

Flare ships with a Monolog handler that you can add to any Monolog logger instance:

use Monolog\Logger;
use Monolog\Level;
use Spatie\FlareClient\Support\FlareLogHandler;

$monolog = new Logger('app');
$monolog->pushHandler(new FlareLogHandler($flare->logger, Level::Debug));

$monolog->info('This will be sent to Flare');

This is especially useful if your application already uses Monolog for logging.

Shipping logs under high load

By default, logs are shipped over HTTP when the application lifecycle flushes (typically at the end of a request, job, or command). 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 alongside your application. The daemon takes the upstream delivery off your application's hot path entirely so log volume doesn't slow your application down. See the Flare daemon page for setup details.

Disabling log collection

To disable log collection:

$config->log(false);
Reporting errors Levels
  • On this page
  • Enabling log collection
  • Recording logs
  • Using the Monolog handler
  • Shipping logs under high load
  • Disabling log collection

Catch errors and fix slowdowns with Flare, the full-stack application monitoring platform for Laravel, PHP & JavaScript.

  • Platform
  • Error Tracking
  • Performance Monitoring
  • Pricing
  • Support
  • Resources
  • Insights
  • Newsletter
  • Changelog
  • Documentation
  • Affiliate program
  • uptime status badge Service status
  • Terms of use
  • DPA
  • Privacy & cookie Policy
Made in by
Flare