An artisan command to tail your application logs

Overview

Easily tail your logs

Latest Version GitHub Workflow Status Software License Total Downloads

This package offers an artisan command to tail the application log. It supports daily and single logs on your local machine.

To tail the log you can use this command:

php artisan tail

It can also tail logs on other environments:

php artisan tail production

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/laravel-tail

You can publish the config file with:

php artisan vendor:publish --provider="Spatie\Tail\TailServiceProvider"

This is the contents of the file that will be published at config/tail.php:

return [
    'production' => [
        
        /*
         * The host that contains your logs.
         */
        'host' => env('TAIL_HOST_PRODUCTION', ''),

        /*
         * The user to be used to SSH to the server.
         */
        'user' => env('TAIL_USER_PRODUCTION', ''),

        /*
         * The path to the directory that contains your logs.
         */
        'log_directory' => env('TAIL_LOG_DIRECTORY_PRODUCTION', ''),

        /*
         * The filename of the log file that you want to tail.
         * Leave null to let the package automatically select the file.
         */
        'file' => env('TAIL_LOG_FILE_PRODUCTION', null),
        
    ],
];

Usage

To tail the local log you can use this command:

php artisan tail

You can start the output with displaying the last lines in the log by using the lines-option.

php artisan tail --lines=50

By default, the most-recently modified file in the directory will be used. You can specify the file that you would like to tail by using the file option.

php artisan tail --file="other-file.log"

It's also possible to fully clear the output buffer after each log item. This can be useful if you're only interested in the last log entry when debugging.

php artisan tail --clear

Should you wish to filter the log to return only certain keywords then you can also use the grep feature.

php artisan tail --grep="only display lines that contain this string"

Tailing remote logs

To tail remote logs, you must first specify values for host, user, log_directory, and file keys of an environment in the tail config file.

After that you can tail that logs of an environment like this

php artisan tail production

You can also use the --clear, --file, and --lines options described above.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

This package was created because the awesome tail command present in Laravel 4 was dropped in Laravel 5. The tail command from this package is equivalent to Laravel's old one minus the remote tailing features.

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Add '--hide-stack-traces' option

    Add '--hide-stack-traces' option

    Took a crack at adding this option, as per Freek's tweet: https://twitter.com/freekmurze/status/1031241488427114496

    Let me know if you'd like to see any changes!

    opened by aryehraber 11
  • Prefix all shell commands with backslashes to ignore aliases

    Prefix all shell commands with backslashes to ignore aliases

    I recently began using exa to replace ls. To make the switch easier, I aliased ls:

    $ which ls
    ls: aliased to exa --icons --classify --header --git
    

    As a result, the command this package uses to get the latest log file (ls -t) throws an error instead of listing the sorted files:

    $ ls -t
    exa: Flag -t needs a value (choices: modified, changed, accessed, created)
    To sort newest files last, try "--sort newest", or just "-snew"
    

    The package uses the ls, head, tail, and grep shell commands, and they all could potentially be aliased/overwritten on the user's system. This could break the package, and there is no way of knowing because the output is suppressed:

    image

    This PR simply adds backslashes to the beginning of each shell command so that aliases are ignored and the native shell commands are used instead.

    I can manually specify the escaped command with --file to get it to work, but it's janky and you'll only know to do it this way if you know why it's throwing the error in the first place:

    php artisan tail --file="\`\\ls -t | \\head -1\`"
    

    Thanks!

    opened by squatto 5
  • Fix filter argument order

    Fix filter argument order

    Hopefully this one does the trick!

    As mentioned in the comments of the previous PR, there seems to be a slight limitation when mixing the --lines & --hide-stack-traces options. What seems to happen is tail -n [num] selects the log file lines before the filter is applied, so when using tail -n 50, for example, fewer lines might be output because the stack traces will be filtered from those 50 lines.

    Perhaps someone else can find a way around this, but I don't know if it's possible natively using tail's own options.

    opened by aryehraber 4
  • Laravel 8.x Compatibility

    Laravel 8.x Compatibility

    This is an automated pull request from Shift to update your package code and dependencies to be compatible with Laravel 8.x.

    Before merging, you need to:

    • Checkout the l8-compatibility branch
    • Review all comments for additional changes
    • Thoroughly test your package

    If you do find an issue, please report it by commenting on this PR to help improve future automation.

    opened by laravel-shift 3
  • Refactor the registration to work with Laravel 5.4

    Refactor the registration to work with Laravel 5.4

    This PR seeks to resolve the error encountered in #7 with Laravel 5.4

    I am not 100% sure if this is the best possible fix, but it follows the way that Laravel Dusk does its registration and it works on my Laravel 5.4 install.

    Let me know how this looks!

    Cheers :)

    opened by jkudish 2
  • Add file option

    Add file option

    I've had a number of instances where I needed to tail a specific log file (for example, I log third-party API calls to a different file for each service). This PR adds a --file option that lets you specify the file that you want to tail, rather than only being able to see the last-modified file in the directory.

    The relevant test was added, and I updated the readme to describe the use case and usage. I also added a config value to allow the file to specified per-environment (optional, of course).

    Please let me know any feedback or requested changes. Thank you!

    opened by squatto 1
  • fix --grep option

    fix --grep option

    Without the equal sign I get an error The "--grep" option does not accept a value. But the tests still pass which is incorrect.

    From Laravel Docs: https://laravel.com/docs/7.x/artisan#options-with-values

    Next, let's take a look at an option that expects a value. If the user must specify a value for an option, suffix the option name with a = sign:

    opened by ilzrv 1
  • Updates required packages to remove 5.5-dev references.

    Updates required packages to remove 5.5-dev references.

    Composer.json file still had references to 5.5-dev that is preventing installation.

    Updated to:

        "require": {
            "php" : "^7.0",
            "illuminate/support": "^5.5",
            "illuminate/console": "^5.5",
            "symfony/process": "^3.3"
        },
    
    opened by faasie 1
Releases(4.4.0)
Owner
Spatie
Webdesign agency based in Antwerp, Belgium
Spatie
This package connects a Laravel Octance application with Tideways for PHP Monitoring, Profiling and Exception Tracking.

Tideways Middleware for Laravel Octane This package connects a Laravel Octance application with Tideways for PHP Monitoring, Profiling and Exception T

Tideways 7 Jan 6, 2022
Php Debugger to run in terminal to debug your code easily.

What is Dephpugger? Dephpugger (read depugger) is an open source lib to make a debug in php direct in terminal, without necessary configure an IDE. Th

Renato Cassino 190 Dec 3, 2022
Generate Laravel test factories from your existing models

Laravel Test Factory Generator php artisan generate:model-factory This package will generate factories from your existing models so you can get starte

Marcel Pociot 923 Dec 16, 2022
Clockwork - php dev tools in your browser - server-side component

Clockwork is a development tool for PHP available right in your browser. Clockwork gives you an insight into your application runtime - including requ

its 4.8k Dec 29, 2022
Test your routes without hassle

Laravel Api Tester Live demo Try it out: laravel-api-tester.asva.by Docs Those are short and easy to read. Take a look. Interface FAQ Installation Req

Yauheni Prakopchyk 343 Nov 6, 2022
Ray server is a beautiful, lightweight php app build on Laravel that helps you debug your app. It runs without installation on multiple platforms.

RayServer is a beautiful, lightweight web server built on Laravel and VueJs that helps debugging your app. It runs without installation on multiple platforms.

Pavel Buchnev 310 Jan 2, 2023
Buggregator is a beautiful, lightweight web server built on Laravel and VueJs that helps debugging your app.

A server for debugging more than just Laravel applications. Buggregator is a beautiful, lightweight web server built on Laravel and VueJs that helps d

Buggregator 311 Jan 4, 2023
Php Debugger to run in terminal to debug your code easily.

What is Dephpugger? Dephpugger (read depugger) is an open source library that allows a developer to debug in php direct in terminal, without necessary

Renato Cassino 190 Dec 3, 2022
A simple Craft module, inspired by Mildly Geeky's "Kint", to debug Twig within your browser

A simple Craft module, inspired by Mildly Geeky's "Kint", to debug Twig within your browser

TrendyMinds 4 Feb 2, 2022
Dispatcher is a Laravel artisan command scheduling tool used to schedule artisan commands within your project so you don't need to touch your crontab when deploying.

Dispatcher Dispatcher allows you to schedule your artisan commands within your Laravel project, eliminating the need to touch the crontab when deployi

Indatus 1.1k Jan 5, 2023
Dispatcher is a Laravel artisan command scheduling tool used to schedule artisan commands within your project so you don't need to touch your crontab when deploying.

Dispatcher Dispatcher allows you to schedule your artisan commands within your Laravel project, eliminating the need to touch the crontab when deployi

Indatus 1.1k Dec 21, 2022
An event stream library based on tail

TailEventStream An event stream library based on tail. Note: I don't think you should use this library in a real project, but it's great for education

Matthias Noback 4 Feb 19, 2022
A powerful command line application framework for PHP. It's an extensible, flexible component, You can build your command-based application in seconds!

CLIFramework CLIFramework is a command-line application framework, for building flexiable, simple command-line applications. Commands and Subcommands

Yo-An Lin 428 Dec 13, 2022
Runs artisan command in web application

Laravel Terminal Installation composer require recca0120/terminal --dev OR Add Presenter to your composer.json file: "require-dev": { "recca0120/t

Recca Tsai 783 Dec 27, 2022
📝 Artisan Menu - Use Artisan via an elegant console GUI

?? Artisan Menu Use Artisan via an elegant console GUI Features Run built-in and custom Artisan commands from a console GUI Prompts to enter required

Jordan Hall 149 Dec 29, 2022
📝 Artisan Menu - Use Artisan via an elegant console GUI

?? Artisan Menu Use Artisan via an elegant console GUI Features Run built-in and custom Artisan commands from a console GUI Prompts to enter required

Jordan Hall 148 Nov 29, 2022
Tango is a command-line tool for analyzing access logs 💃

Tango Tool to get insights from the server access logs Tango is a dependency-free command-line tool for analyzing access logs ?? Currently, work on th

Roman Glushko 94 Nov 22, 2022
Backup your laravel database by a simple artisan command

Backup your laravel database by a simple artisan command This package will allow you to backup your laravel app database and you can also choose to se

Mohammed Omer 23 Feb 10, 2022
Your performance & security consultant, an artisan command away.

Enlightn A Laravel Tool To Boost Your App's Performance & Security Introduction Think of Enlightn as your performance and security consultant. Enlight

Enlightn 726 Jan 1, 2023