netojose/laravel-log-viewer
Composer 安装命令:
composer require netojose/laravel-log-viewer
包简介
A Laravel package for viewing and managing application log files.
关键字:
README 文档
README
A Laravel 11+ package for viewing, filtering, downloading and clearing application log files — directly in the browser.
Features
- View and parse
storage/logs/laravel.log(and additional log files) - Filter entries by log level (EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG)
- Pagination for large log files
- Download any log file
- Clear (truncate) any log file
- Route protection via Laravel Gate
- Pure HTML/CSS UI — zero JavaScript/CSS framework dependencies
- Publishable config and views
Requirements
- PHP
^8.2 - Laravel
^11.0 || ^12.0 || ^13.0
Installation
composer require netojose/laravel-log-viewer
The service provider is registered automatically via Laravel's package auto-discovery.
Publish the config (optional)
php artisan vendor:publish --tag=log-viewer-config
This copies config/log-viewer.php to your application's config directory.
Publish the views (optional)
php artisan vendor:publish --tag=log-viewer-views
Usage
After installation, visit:
http://your-app.test/log-viewer
Configuration
// config/log-viewer.php return [ // Enable or disable the log viewer entirely 'enabled' => env('LOG_VIEWER_ENABLED', true), // URL prefix for all routes 'prefix' => env('LOG_VIEWER_PREFIX', 'log-viewer'), // Middleware applied to all routes (authorization middleware is appended automatically) 'middleware' => ['web'], // Gate name used for authorization (set to null to disable) 'gate' => 'viewLogViewer', // Extra log files to expose (storage/logs/laravel.log is always included) 'logs' => [ // 'Worker' => storage_path('logs/worker.log'), // 'Scheduler' => storage_path('logs/scheduler.log'), ], // Entries per page 'per_page' => env('LOG_VIEWER_PER_PAGE', 50), ];
Authorization
By default, the viewLogViewer gate allows access only in the local environment. In any other environment (staging, production) access is denied with a 403.
To customize access, define the gate in your AppServiceProvider (or any service provider):
use Illuminate\Support\Facades\Gate; public function boot(): void { Gate::define('viewLogViewer', function ($user) { return in_array($user->email, [ 'admin@example.com', ]); }); }
To allow access for guests (unauthenticated users), accept a nullable user:
Gate::define('viewLogViewer', function (?User $user) { // custom logic return true; });
To disable gate checks entirely, set 'gate' => null in your config.
Adding extra log files
Any entry in the logs config key becomes available in the log viewer:
'logs' => [ 'Worker' => storage_path('logs/worker.log'), 'Scheduler' => storage_path('logs/scheduler.log'), 'Nginx' => '/var/log/nginx/error.log', ],
Security note: Only files explicitly listed in the config can be accessed. User input is never used to derive file paths.
Available Routes
| Method | URI | Name | Description |
|---|---|---|---|
| GET | /log-viewer |
log-viewer.index |
List all log files |
| GET | /log-viewer/{file} |
log-viewer.show |
View log entries (?level=ERROR&page=2) |
| GET | /log-viewer/{file}/download |
log-viewer.download |
Download log file |
| DELETE | /log-viewer/{file} |
log-viewer.destroy |
Clear (truncate) log file |
Disabling the package
Set the environment variable:
LOG_VIEWER_ENABLED=false
Routes will not be registered and the viewer will return 404.
License
MIT
netojose/laravel-log-viewer 适用场景与选型建议
netojose/laravel-log-viewer 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 94 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「log」 「laravel」 「logs」 「log-viewer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 netojose/laravel-log-viewer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 netojose/laravel-log-viewer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 netojose/laravel-log-viewer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The tenancy/tenancy logs mutations
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
Laravel 5.x.x library for integration Monolog Sentry
Pacote simplificado para persistência de logs
Change logs for orchid platform.
Collection of tools to use the full power of the Enyalius framework
统计信息
- 总下载量: 94
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 40
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-15
