diarsa / logview
Fast, memory-safe, zero-build log viewer for Laravel. Reads multi-GB log files backwards with cursor pagination.
Requires
- php: ^8.2
- illuminate/cache: ^10.0|^11.0|^12.0|^13.0
- illuminate/http: ^10.0|^11.0|^12.0|^13.0
- illuminate/routing: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- illuminate/view: ^10.0|^11.0|^12.0|^13.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0|^11.0
- phpunit/phpunit: ^10.5|^11.0|^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-12-04 06:44:01 UTC
README
A fast, lightweight log viewer for Laravel. No build step is needed: the UI is a single Blade file that uses Tailwind CSS and Alpine.js. Both libraries are bundled inside the package (resources/dist), so it works offline and on private networks without any CDN. Large log files (even several GB) are read backwards in small chunks (fseek), so the whole file is never loaded into memory.
Features
- Newest entries first, with cursor-based pagination (by byte offset)
- Supports
singleanddailylogs, plus sub-folders insidestorage/logs - Splits each entry into timestamp, environment, level, message, JSON context, exception and stack trace (vendor frames can be collapsed)
- Filter by level (with a count for each level), search on the server (limited by bytes and time, so it never times out), and filter by date range
- Sort the file list by last modified, name, size or number of entries
- Dark and light mode, word wrap or horizontal scroll, copy raw entry, JSON pretty-print, live tail
- Download (streamed), clear (truncate) and delete log files
- Protected by the
viewLogviewGate, safe against path traversal (realpath()), and hides sensitive data automatically
Structure
logview/
├── composer.json
├── config/logview.php
├── routes/web.php
├── resources/views/index.blade.php
├── resources/dist/ # bundled Tailwind CSS + Alpine.js (no CDN needed)
├── src/
│ ├── LogviewServiceProvider.php
│ ├── Http/Controllers/LogviewController.php
│ ├── Http/Middleware/Authorize.php
│ ├── Services/LogStreamReader.php # reads the file backwards and builds multi-line entries
│ ├── Services/LogParser.php # parses header, context, exception and stack frames
│ ├── Services/LogFileRepository.php # lists files and resolves paths safely
│ ├── Services/LogStatsService.php # counts levels step by step, with caching
│ └── Support/{LogFile,Masker}.php
└── tests/
Installation
composer require diarsa/logview
php artisan vendor:publish --tag=logview-config # optional
Open /logview in your browser. By default, only the local environment can access it. To allow access in production, define the Gate (the same way as Laravel Horizon):
// app/Providers/AppServiceProvider.php -> boot() Gate::define('viewLogview', fn ($user) => in_array($user->email, ['admin@example.com']));
or
Gate::define('viewLogview', function (?User $user = null) { return $user && $user->hasRole('superadmin'); });
JSON Endpoints
| Method | URI | Description |
|---|---|---|
| GET | /logview/api/files |
List log files |
| GET | /logview/api/entries?file=&cursor=&per_page=&levels[]=&q=&from=&to= |
Log entries, newest first |
| GET | /logview/api/stats?file= |
Number of entries per level (counted step by step) |
| GET | /logview/download?file= |
Download the file (streamed) |
| POST | /logview/api/files/clear |
Clear (truncate) the file |
| DELETE | /logview/api/files |
Delete the file |
The entries response includes meta.next_cursor for loading the next page. If meta.partial is true, the search reached its scan limit before finding enough results, and the UI shows a "Continue searching" button.
License
MIT