Laravel Log Reader


Logs are very important to audit the application state. The laravel framework gives the facility out of the box but laravel log files are not easy to read and by default, there is no facility to view the logs from the application. The laravel log reader package gives you the facility to view your all laravel log files with a fresh UI. You can view logs date by date and filter with log types and clearing logs so easy.

Features of Laravel Log Reader

  • Clean and fresh looking UI
  • Date by date log viewing
  • Filtering logs
  • Clearing logs
  • Configurable route
  • Custom middleware support
  • Responsive design
  • JSON API available

 

Installation

composer require haruncpi/laravel-log-reader

Installation is done! Yah it's a really simple process. Now you are ready to use Laravel Log Reader.

Just browse the http://example.com/admin/log-reader . You must be authenticated to view the logs.

log-reader-desktop.png

Make sure your log channel set for daily 'channels' => ['daily'] in config/logging.php 

 

Customizations

 

1. JSON API [OPTIONAL]

If you want to make your won UI then this package also provides the JSON API for log files. You will get the API link here /admin/api/log-reader

API response example

{
  "success": true,
  "data": {
    "available_log_dates": [
      "2020-01-27"
    ],
    "date": "2020-01-27",
    "filename": "laravel-2020-01-27.log",
    "logs": [
      {
        "timestamp": "2020-01-27 12:26:45",
        "env": "local",
        "type": "INFO",
        "message": "Backup success"
      },
      {
        "timestamp": "2020-01-27 12:26:45",
        "env": "local",
        "type": "EMERGENCY",
        "message": "Backup failed"
      }
    ]
  }
}

Get JSON data by date

use Haruncpi\LaravelLogReader\LaravelLogReader;

return (new LaravelLogReader(['date' => '2020-01-27']))->get();

 

2. Config file [OPTIONAL]

If you want to change the route URL for viewing the logs then run the command for publishing laravel log reader configuration file.

php artisan vendor:publish --provider="Haruncpi\LaravelLogReader\ServiceProvider" --tag="config"

 

3. Custom Middleware [OPTIONAL]

Laravel log reader >= v1.0.6 support custom middleware. So you can easily add more restriction to view your application logs. To use custom middleware, add middleware key into laravel-log-reader.php config file.

'middleware' => ['web','auth','your_middleware']

Note: By default laravel log reader shipped with web and auth middleware.

 

Hope the Laravel Log Reader package will help you to read, manage your Laravel log files easily! If this package helpful for you then please share the post with others.


Share on



Social Links


Related Post - Latest Post


Laravel Barcode generation tutorial

Laravel User Activity

Laravel Breeze - Starting with Laravel has been easy!

Laravel API mailer

Laravel H package

Laravel Simple Filemanager