Laravel logging: ship logs and exceptions to Tailcove
Set up Laravel logging with a Tailcove channel. Ship every Log call, capture exceptions as issues and add slow-query and failed-job telemetry.
Before you start
- A Laravel application
- A Tailcove account with a source
By the end of this guide every Log:: call and every reported exception in your Laravel app will land in Tailcove, batched off the request's critical path, with request ids and user ids attached automatically.
On this page10 sections
The quickest way is two commands, which do steps 1 to 3 for you and send a test line:
composer require tailcove/laravel
php artisan tailcove:install
tailcove:install opens Tailcove in your browser to approve a new source, then writes the tokens to .env. The steps below do the same by hand.
1. Create a source and copy its token#
In Tailcove, open Sources and click New source. Name it after the app and environment, for example shop-production, and pick Laravel as the platform so the setup snippets match.
The ingest token is shown once. Copy it now: Tailcove only stores a hash, so if you lose it you will need to rotate it.
2. Install the package#
composer require tailcove/laravel
Package auto-discovery registers the service provider. Add your token to .env:
TAILCOVE_TOKEN=your-source-ingest-token
3. Add the channel#
Register a tailcove channel in config/logging.php:
'channels' => [
// ...
'tailcove' => [
'driver' => 'tailcove',
'level' => env('LOG_LEVEL', 'debug'),
],
],
Then add it to your log stack, keeping your local file log alongside it:
LOG_STACK=single,tailcove
4. Log with context#
Keep the message constant and put the details in context, so every occurrence is the same searchable event:
use Illuminate\Support\Facades\Log;
Log::info('Order placed', ['order_id' => $order->id, 'total_cents' => $order->total]);
Log::warning('Payment retry', ['order_id' => $order->id, 'attempt' => 2]);
Every line also gets environment, hostname, user_id (when someone is signed in) and a request_id shared by all lines from the same request, so you can follow a single request end to end.
5. Report exceptions#
Laravel's exception handler already logs unhandled exceptions through your stack. For handled ones, pass the exception in context or call report():
try {
$gateway->charge($order);
} catch (CardDeclined $e) {
Log::error('Payment failed', ['order_id' => $order->id, 'exception' => $e]);
}
The exception is sent as structured data (class, message, location and trace), which is what lets Tailcove group repeats into a single issue.
6. Verify it works#
Open the source in Tailcove and switch to Live tail, then trigger a log line:
php artisan tinker --execute 'Log::info("Hello from Laravel");'
The line appears within a second or two. If nothing shows up, check that TAILCOVE_TOKEN is set in the environment the process actually runs with (queue workers and Horizon read their own environment).
7. Turn on extra telemetry (optional)#
The package can also ship slow queries, failed queue jobs and failed scheduled tasks, each off by default:
TAILCOVE_LOG_SLOW_QUERIES=true
TAILCOVE_SLOW_QUERY_THRESHOLD_MS=500
TAILCOVE_LOG_FAILED_JOBS=true
TAILCOVE_LOG_SCHEDULE_FAILURES=true
Secrets are masked before they leave#
From v0.2.0 the package masks passwords, tokens and API keys in your app before a line is buffered: a context key like password or api_key becomes [redacted], and so does the value after token= or Authorization: Bearer in a message. It's on by default, so Log::info('Login', ['password' => $request->password]) never sends the password. Add your own field names with TAILCOVE_SECRET_KEYS=customer_ssn,iban, and use Tailcove::beforeSend() to change or drop lines yourself. Details are in the package reference.
How delivery works#
Records are buffered in memory and sent as one batch every 50 records or 2 seconds. By default the batch goes out from a shutdown function, after the response has been sent. To move delivery onto your queue instead:
TAILCOVE_DISPATCH=queue
TAILCOVE_QUEUE_CONNECTION=redis
In queue workers (queue:work, Horizon) the buffered lines are also sent after every job, and under Octane after every request, so a long-running process never holds them until it restarts.
A delivery failure never throws into your app; it falls back to PHP's error_log().
Next steps#
- Learn the query language to search by any context field.
- Alert on 5xx spikes so you hear about problems first.
- See every option in the Laravel package reference.
Ready to try it on your own logs?
The Free plan includes a source, live tail, search and alerts. No credit card.