kadiaak / log-viewer
A beautiful, fast log viewer for Laravel applications.
Requires
- php: ^8.2
- illuminate/contracts: ^10.0|^11.0|^12.0|^13.0
- illuminate/http: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.0|^11.0
This package is auto-updated.
Last update: 2026-06-29 09:42:58 UTC
README
A beautiful, fast and self-contained log viewer for your Laravel application โ built with Blade, Alpine.js and Tailwind CSS. Inspired by opcodesio/log-viewer.
- ๐จ Polished UI with light / dark / system themes
- ๐ Full-text and regex search across messages and stack traces
- ๐ท๏ธ Filter by log level with live per-level counts
- ๐ Automatic discovery of every
*.logfile (grouped by sub-folder) - ๐งต Collapsible stack traces & context, one-click copy
- โ๏ธ Newest / oldest ordering, configurable pagination
- ๐ Manual & automatic refresh
- ๐๏ธ Download, clear or delete files from the UI (toggleable)
- ๐ฆ Zero build step โ compiled assets ship with the package
Requirements
- PHP 8.2+
- Laravel 10, 11 or 12
Installation
composer require kadiaak/log-viewer
That's it. Visit /log-viewer in your browser.
By default the viewer is only reachable in the
localenvironment. To open it elsewhere, define a gate (see Authorization).
Publishing the config (optional)
php artisan vendor:publish --tag=log-viewer-config
Authorization
Access is controlled by a viewLogViewer gate. Define it in your
app/Providers/AppServiceProvider.php (or AuthServiceProvider):
use Illuminate\Support\Facades\Gate; public function boot(): void { Gate::define('viewLogViewer', function ($user = null) { return in_array(optional($user)->email, [ 'you@example.com', ]); }); }
- If the gate is defined, it authorizes every request (in all environments).
- If it is not defined, access is restricted to the
localenvironment.
You may also attach your own middleware in the config (route.middleware), e.g.
['web', 'auth'].
Configuration
The most useful options (see config/log-viewer.php for everything):
| Key | Description | Default |
|---|---|---|
enabled |
Master switch for the whole package | true |
route.prefix |
URL prefix for the UI & API | log-viewer |
route.middleware |
Middleware applied to all routes | ['web'] |
include_files |
Glob patterns of files to list | storage/logs/**/*.log |
exclude_files |
Glob patterns to skip | [] |
per_page |
Entries per page | 50 |
max_log_size |
Skip parsing files larger than this (bytes) | 150 MB |
allow_delete |
Show clear/delete buttons | true |
allow_download |
Allow downloading files | true |
theme |
system, light or dark |
system |
All boolean/scalar options can be driven by environment variables, e.g.
LOG_VIEWER_ENABLED, LOG_VIEWER_PREFIX, LOG_VIEWER_THEME.
Programmatic usage
use Kadiaak\LogViewer\Facades\LogViewer; // All discovered files $files = LogViewer::files(); // A single file + a paginated, filtered scan $file = LogViewer::files()->first(); $result = $file->scan([ 'query' => '/SQLSTATE\[\d+\]/', // plain text or /regex/ 'levels' => ['error', 'critical'], 'page' => 1, 'per_page' => 50, 'direction' => 'desc', ]); // $result['entries'], $result['level_counts'], $result['pagination']
Development
The shipped assets in resources/dist are pre-compiled. To work on the UI:
npm install
npm run dev # watch CSS + JS (or `npm run build` for a one-off minified build)
Run the test suite:
composer install vendor/bin/phpunit
Preview the UI against sample data:
php workbench/sample-logs.php APP_ENV=local vendor/bin/testbench serve
License
MIT โ see LICENSE.md.