Search by

tailcove / laravel

akcybex

Monolog handler and Laravel service provider for sending application logs to Tailcove.

v0.3.1 2026-11-30 15:06 UTC

README

tailcove/laravel: Tailcove for Laravel. Version, runtime support, size and license.

Documentation  ·  Get started free  ·  View on Packagist  ·  Report a bug

Send your Laravel logs to Tailcove with one composer require.

tailcove/laravel features

Install

composer require tailcove/laravel

Requires PHP 8.1+ and Laravel 10, 11, 12 or 13. Laravel's package auto-discovery registers the service provider for you.

Quick start

The quickest way is one command:

php artisan tailcove:install

It shows a code and opens Tailcove in your browser. Check that the page shows the same code and approve: Tailcove creates a source, and the command writes its token to .env, adds tailcove to LOG_STACK and sends a test line you can watch arrive. Already have a source? Pass its ingest token instead: php artisan tailcove:install --token=your-source-ingest-token.

To set it up by hand:

1. Get a token. Create a source in your Tailcove dashboard and copy its ingest token. It is shown only once, so save it straight into your .env.

2. Add two lines to .env.

TAILCOVE_TOKEN=your-source-ingest-token
LOG_STACK=single,tailcove

3. Optionally, add the channel to config/logging.php. The package registers a tailcove channel when your app has none, so this is only needed to change its settings there.

'channels' => [
    // ...
    'tailcove' => [
        'driver' => 'tailcove',
        'level' => env('LOG_LEVEL', 'debug'),
    ],
],

On Laravel 10, the default config/logging.php has no LOG_STACK: its stack channel is hard-coded to ['single']. Make it read the variable, and keep LOG_CHANNEL=stack:

'stack' => [
    'driver' => 'stack',
    'channels' => explode(',', env('LOG_STACK', 'single')),
    'ignore_exceptions' => false,
],

Never put single,tailcove in LOG_CHANNEL. Laravel reads it as one channel name and fails with Log [single,tailcove] is not defined.

That's it. Log::info(...), Log::error(...) and any exception you report now appear in Tailcove search and live tail within a couple of seconds.

Follow your logs in the terminal

php artisan tailcove:tail streams your source's lines from Tailcove, from every server and queue worker at once, the way php artisan pail does for the machine it runs on:

php artisan tailcove:tail
php artisan tailcove:tail --level=error
php artisan tailcove:tail shop-production --user=42 --since=10m
php artisan tailcove:tail --query='status>=500 OR timeout'

It needs TAILCOVE_API_TOKEN, an API token with the logs:read ability. tailcove:install creates one; you can also make one under Settings → API tokens. --filter matches text in the message, --query takes Tailcove's query language, --since starts further back (30s, 5m, 1h) and --once prints what matches and stops. It checks for new lines every two seconds.

Configuration

Publish the config file if you want to edit it:

php artisan vendor:publish --tag=tailcove-config

Every option lives in config/tailcove.php and can be set with an environment variable. To run more than one Tailcove channel, set the same key directly on a channel in config/logging.php to override it for that channel.

Environment variable Default What it does
TAILCOVE_TOKEN — Your source's ingest token. Required. Never commit it.
TAILCOVE_ENDPOINT https://ingest.tailcove.dev/api/v1/logs The ingest URL. Only change this if you self-host.
TAILCOVE_API_TOKEN — An API token with logs:read, for php artisan tailcove:tail. Not the ingest token.
TAILCOVE_SOURCE — The source tailcove:tail follows when you don't name one.
TAILCOVE_URL https://tailcove.dev Tailcove's address, for the console commands. Only change this if you self-host.
TAILCOVE_ENABLED true Set false to keep the channel registered but silent.
TAILCOVE_LEVEL debug Lowest Monolog level the handler processes.
TAILCOVE_BATCH_SIZE 50 Send once this many records are buffered.
TAILCOVE_BATCH_SECONDS 2.0 Send once this many seconds have passed since the first buffered record.
TAILCOVE_DISPATCH shutdown shutdown sends after the response. queue uses a queued job. See Sending modes.
TAILCOVE_QUEUE_CONNECTION — Queue connection to use when TAILCOVE_DISPATCH=queue.
TAILCOVE_HTTP_TIMEOUT 2.0 Seconds a delivery attempt may take before giving up.
TAILCOVE_EXCEPTION_TRACE_LIMIT 10 Most stack frames kept when an exception is logged.
TAILCOVE_MASK_SECRETS true Mask passwords, tokens and keys before a line leaves your server. See Secret masking.
TAILCOVE_SECRET_KEYS — Extra key names to mask, comma separated.
TAILCOVE_LOG_SLOW_QUERIES false Log slow queries. See Extras.
TAILCOVE_SLOW_QUERY_THRESHOLD_MS 500 How slow a query must be to be logged.
TAILCOVE_SLOW_QUERY_BINDINGS false Send the slow query's bindings too.
TAILCOVE_LOG_FAILED_JOBS false Log failed queue jobs.
TAILCOVE_LOG_SCHEDULE_FAILURES false Log failed scheduled tasks.

What gets added automatically

Field Value
environment app()->environment()
hostname gethostname()
user_id The signed-in user's id, when a guard has one
request_id Shared by every line in one request. Reuses an incoming X-Request-Id header, or creates a UUID.

If adding any of these fails, for example when no auth guard exists in that context, the line is still sent without that field. It never breaks the log call.

When a line's context has an exception key, as with report($e) or Log::error('...', ['exception' => $e]), it is sent as structured data:

'exception' => [
    'class' => 'RuntimeException',
    'message' => 'Something broke',
    'location' => '/app/Http/Controllers/OrderController.php:42',
    'trace' => ['#0 /app/...', '#1 /app/...'],  // up to TAILCOVE_EXCEPTION_TRACE_LIMIT frames
],

Secret masking

Secrets are masked in your app, before a line is buffered, so they never cross the network. It's on by default and covers the message, the context, fields added by your own Monolog processors and any logged exception (its message and trace).

  • A context key that names a secret has its whole value replaced with [redacted]. That's password, pwd, passphrase, auth, jwt, dsn, cookies, credentials and anything ending in password, secret, token, api_key, private_key, access_key, authorization, cookie or signature. Case, -, _, . and spaces are ignored, so DB_PASSWORD, x-api-key and apiKey all match. max_tokens, token_count and password_changed_at don't. A null or true/false value is left alone, so has_password => true still tells you something.
  • In text, the value after such a key becomes [redacted]: ?token=abc123, db_password=hunter2, "password": "hunter 2", Authorization: Bearer abc. A colon in plain prose doesn't count, so password: too short stays as written.
  • Keys you can recognise by their shape become [key] wherever they appear: JWTs, AWS access key ids, Stripe secret and webhook keys, GitHub, Slack and Google API tokens, and whole -----BEGIN ... PRIVATE KEY----- blocks. Stripe pk_ keys and public keys stay.

The fields the package adds itself (environment, hostname, user_id, request_id) aren't touched. If masking ever fails on a line, the line is still sent, but with the message [redacted: masking failed] and no context, never unmasked.

To add your own key names, list them in .env or in secret_keys in config/tailcove.php. They match whole names, with the same case and separator rules:

TAILCOVE_SECRET_KEYS=customer_ssn,iban

To turn masking off, set TAILCOVE_MASK_SECRETS to false, 0, off or no. Any other value, a typo included, keeps it on. You can also set mask_secrets or secret_keys on a single channel in config/logging.php.

Changing or dropping lines yourself

Closures can't live in a cached config file, so the hook is registered in code, usually in AppServiceProvider::boot(). It runs after masking, with the entry that's about to be queued (message, level, context, host, ts). Return the entry, changed or not, or null to drop it:

use Tailcove\Laravel\Tailcove;

Tailcove::beforeSend(function (array $entry): ?array {
    if (str_starts_with($entry['message'], 'GET /health')) {
        return null;
    }

    unset($entry['context']['customer_email']);

    return $entry;
});

The hook runs even with masking off. If it throws or returns anything other than an array or null, the error goes to error_log() and the masked entry is sent as it was, so a bug in the hook never costs you a line or breaks the request. Tailcove::beforeSend(null) removes it.

Sending modes

shutdown (default). Sends from a shutdown function, right after the response. No queue worker needed.

queue. Dispatches a Tailcove\Laravel\Jobs\SendLogBatch job instead, for apps that want sending off the web worker completely. A failed delivery uses your queue's own retries (3 tries, waiting 5, 30 and 120 seconds) and isn't dropped straight away.

TAILCOVE_DISPATCH=queue
TAILCOVE_QUEUE_CONNECTION=redis

Long-running processes never reach the shutdown function between units of work, so the package also sends what is buffered after every queue job (processed, failed or thrown) and when the worker stops (queue:work, Horizon), and after every request, task and tick under Octane. Nothing to configure.

Security note: in queue mode the ingest token travels inside the serialized job on your queue backend, and is stored in failed_jobs if every retry fails. Anyone who can read that store can read the token. If that matters, stay on shutdown, or lock down your queue store as you would any table holding secrets.

Extras

Each is off by default and logs through the tailcove channel, so the data ships even if you never call Log:: yourself. A failure in any of them is caught and dropped.

TAILCOVE_LOG_SLOW_QUERIES=true
TAILCOVE_SLOW_QUERY_THRESHOLD_MS=500

TAILCOVE_LOG_FAILED_JOBS=true

TAILCOVE_LOG_SCHEDULE_FAILURES=true
Setting What is logged
Slow queries Queries at or above the threshold, with sql, time_ms and connection.
Failed queue jobs Each JobFailed event, with the job name, connection and the exception.
Scheduled task failures Each ScheduledTaskFailed event, with the command and the exception.

Slow queries no longer include their bindings by default (earlier versions sent them). Bindings are the real values in the query, which often means emails, tokens and password hashes. If you want them, turn them on. They still go through secret masking, but masking only catches values it can recognise, and a bare email or password hash in a binding list has no key name next to it:

TAILCOVE_SLOW_QUERY_BINDINGS=true

Only true, 1, on or yes turn it on.

When delivery fails

A failed delivery never throws into your app. It is caught and written to PHP's error_log() as a local fallback. Logging is best-effort by design.

Help and feedback


Tailcove.

Documentation  ·  Get started free  ·  Report a bug  ·  MIT License

More Tailcove libraries: Node.js  ·  Python  ·  Browser  ·  Agent