Warning
This package is no longer maintained.
We have decided to stop maintaining this package. We don't use this package anymore and don't have the time to maintain this package.
Feel free to fork our code and adapt it to your needs.
LogViewer enables you to view and filter your Laravel logs in the browser.
Version | Release |
---|---|
10.x | ^3.0 |
9.x | ^3.0 |
8.x | ^2.1 |
Add the package to your application.
composer require label84/laravel-logviewer
You can also manually update your composer.json.
Add the config file to your application.
php artisan vendor:publish --provider="Label84\LogViewer\LogViewerServiceProvider" --tag="config"
To change the default views, you can publish the views to your application.
php artisan vendor:publish --provider="Label84\LogViewer\LogViewerServiceProvider" --tag="views"
Visit the following url in your application: /admin/logviewer
You can change the url in the config file.
You can filter the logs in the overview with query parameters - example /admin/logviewer?date=today&message=kiss
.
Parameter | Value | Example |
---|---|---|
level= | string | DEBUG |
date= | Carbon | today |
from= | Carbon | yesterday |
till= | Carbon | 2021-01-01 |
logger= | string | local |
message= | string | love |
To use the package in your own Controllers you can use the following settings. If you use the default package features and views you probably won't need this.
To dynamically set the channel:
use LogViewer;
LogViewer::setChannel(string $channel);
To dynamically set the path:
use LogViewer;
LogViewer::setPath(string $path);
To dynamically set the file:
use LogViewer;
LogViewer::setFile(string $file);
The LogViewerCollection
extends Illuminate\Support\Collection
with the following methods:
- whereLevel(int|string $level)
- whereMinLevel(int|string $level)
- whereMaxLevel(int|string $level)
- whereDate(Carbon|string $date)
- whereDateFrom(Carbon|string $date)
- whereDateTill(Carbon|string $date)
- whereDateBetween(Carbon|string $startDate, Carbon|string $startDate)
- whereLogger(string|array $logger)
- whereMessage(string|array $query)
- whereNotMessage(string|array $query)
- whereUser(int $user)
List all logs.
use LogViewer;
public function index(Request $request): View
{
$items = LogViewer::logs()->paginate(50);
return view('dashboard', compact('items'));
}
List all logs created today with a minimum level of ERROR.
use Label84\LogViewer\Support\LogViewerLevel;
use LogViewer;
public function index(Request $request): View
{
$items = LogViewer::logs()
->whereDate(today())
->whereMinLevel(LogViewerLevel::ERROR)
->paginate(50);
return view('dashboard', compact('items'));
}
List all logs with a minium level of DEBUG that contains the words 'Foo' and/or 'Bar'.
use Label84\LogViewer\Support\LogViewerLevel;
use LogViewer;
public function index(Request $request): View
{
$items = LogViewer::logs()
->whereLevel(LogViewerLevel::DEBUG)
->whereMessage(['Foo', 'Bar'])
->paginate(50);
return view('dashboard', compact('items'));
}
Level | |
---|---|
Emergency | 600 |
Alert | 550 |
Critical | 500 |
Error | 400 |
Warning | 300 |
Notice | 250 |
Info | 200 |
Debug | 100 |
composer analyse
composer test