Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Tail Laravel Package

spatie/laravel-tail

Tail your Laravel application logs from the command line. Run php artisan tail to follow local single or daily logs, or tail remote environment logs over SSH (e.g., production) with configurable host, user, log directory, and optional file selection.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package via Composer: composer require spatie/laravel-tail. No additional service provider registration needed — it’s auto-discovered. Run php artisan tail to stream the current storage/logs/laravel.log. For a snapshot of recent entries, add --lines=10 (or any number). To filter output in real time, use --grep="ERROR" — perfect for spotlighting failures during debugging.

Implementation Patterns

  • Local Development Flow: Use php artisan tail --clear in a split terminal to keep only the latest log line visible — ideal for hot-reloading apps. Combine with --grep and --lines to create custom logging dashboards (e.g., php artisan tail --grep="^WARN" --lines=30 --clear).
  • Remote Debugging: Configure environments in config/tail.php (via env vars: TAIL_HOST_PRODUCTION, TAIL_USER_PRODUCTION, etc.). Run php artisan tail staging to tail logs from a remote server over SSH — no manual tail -f commands needed.
  • Automation: Wrap common tail tasks in custom Artisan commands (e.g., php artisan debug:tail-error) that internally invoke Artisan::call('tail', ['--grep' => 'ERROR']) for reusable diagnostics.
  • CI/CD Safety: Use --file="custom.log" to target specific logs (e.g., during feature testing where logs are rotated or redirected), avoiding interference with app logs.

Gotchas and Tips

  • SSH Requirements: Remote tailing requires passwordless SSH (public key auth) — ensure ssh access works before using php artisan tail production. Private keys must be in ~/.ssh/id_rsa or configured via SSH config.
  • Shell Safety: All shell commands are prefixed with \ to bypass aliases — but be cautious if your shell has custom tail/ssh functions. Check .env env vars match config keys exactly (case-sensitive).
  • File Selection: When no --file is specified, the command uses the most recently modified .log file in the log directory — ensure production logs aren’t rotated mid-stream (use --file="laravel.log" for stability).
  • Grep Gotcha: --grep uses grep -E (extended regex) — use --grep="ERROR|WARN" safely, but avoid complex patterns needing backslashes. On Windows, grep might be missing — install GNU grep or fallback to --file="laravel.log" | tail -f manually.
  • Laravel Compatibility: Supports Laravel 8–12 and PHP 8.0+. After Laravel 5, the native tail command was removed; this package restores core functionality — ideal for upgrades where legacy workflows relied on it.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport