alex-kudrya/laravel-log-viewer
Composer 安装命令:
composer require alex-kudrya/laravel-log-viewer
包简介
A Laravel package for browsing application log files from a protected web UI.
README 文档
README

Laravel Log Viewer is a package for browsing Laravel log files from a protected web interface.
It lists regular .log files from storage/logs, displays parsed records, supports search and filters,
and can let authorized users download the selected log file.
Features
- Lists only regular readable
.logfiles fromstorage/logs. - Ignores archives and rotated non-log files such as
.log.gz,.log.1,.zip,.tar, and.php. - Parses standard Laravel records with date, time, environment, level, message, JSON context, and stack trace.
- Supports search, date/time filters, environment filters, and log level filters.
- Supports light, dark, and system themes.
- Includes English, Russian, and Ukrainian translations.
- Reads large files with bounded memory usage and shows the latest records by default.
- Limits scanned bytes, displayed records, displayed payload, listed files, search input, parsed context, stack traces, and single-record size to avoid exhausting server resources.
- Marks partial results and truncated records instead of failing on very large logs or stack traces.
- Can disable raw log downloads while keeping the bounded web viewer available.
- Uses published local UI assets instead of loading Bootstrap, Bootstrap Icons, or jQuery from external CDNs.
Requirements
- PHP
>= 8.2 - Laravel
10.x,11.x,12.x, or13.x
Installation
Install the package with Composer:
composer require alex-kudrya/laravel-log-viewer
The service provider is registered through Laravel package auto-discovery. If package discovery is disabled in your application, register the provider manually:
// config/app.php
'providers' => [
AlexKudrya\LaravelLogViewer\Providers\LogViewerServiceProvider::class,
],
If you are upgrading from an older version where the provider was registered manually, remove the manual registration after enabling auto-discovery to avoid loading the package twice.
Publishing
Publish the configuration file:
php artisan vendor:publish \
--provider="AlexKudrya\LaravelLogViewer\Providers\LogViewerServiceProvider" \
--tag=config
Publish public assets and translations:
php artisan vendor:publish \
--provider="AlexKudrya\LaravelLogViewer\Providers\LogViewerServiceProvider" \
--tag=laravel-assets
To publish everything at once:
php artisan vendor:publish \
--provider="AlexKudrya\LaravelLogViewer\Providers\LogViewerServiceProvider"
The viewer is available at:
https://your-host.example/log-viewer
Security
Log files can contain secrets, tokens, personal data, stack traces, database queries, server paths, and other sensitive application details. Do not expose this route publicly.
The route is protected by the web middleware and the configured log_viewer.middleware.
By default, log_viewer.middleware is set to auth. For production, prefer a stricter
admin-only middleware or policy:
// config/log_viewer.php
'middleware' => ['auth', 'can:view-log-viewer'],
Adding Disallow: /log-viewer to robots.txt is still recommended, but it is not a security control:
User-agent: *
Allow: /
Disallow: /log-viewer
Downloads return the original log file, not the redacted display output. If operators should only inspect bounded, redacted UI output, disable downloads:
// config/log_viewer.php
'download_enabled' => false,
Configuration
The package configuration is published to config/log_viewer.php.
| Option | Default | Description |
|---|---|---|
route_prefix | log-viewer | URI prefix for the viewer route. |
app_title | Log Viewer | Page title displayed in the browser and sidebar. |
middleware | auth | Additional middleware applied after Laravel's web middleware. |
download_enabled | true | Whether the sidebar and download route allow original log file downloads. |
max_display_records | 10000 | Maximum number of parsed records rendered for one request. |
max_listed_files | 1000 | Maximum number of newest log files shown in the sidebar. |
max_display_bytes | 16777216 | Approximate maximum parsed payload accumulated before rendering stops. |
scan_mode | latest | Default scan mode. latest reads from the end of the file, full scans from the beginning. |
initial_scan_bytes | 8388608 | Initial bytes scanned for the default latest-records view. |
max_scan_bytes | 134217728 | Hard cap for bytes scanned by one UI request. |
read_chunk_size | 65536 | File read chunk size in bytes. |
max_record_bytes | 1048576 | Maximum bytes kept in memory for one parsed log record before truncation. |
max_search_terms | 8 | Maximum number of search terms applied to one request and highlighted in the browser. |
max_search_length | 256 | Maximum search query length accepted from the request. |
max_filter_values | 100 | Maximum number of level/environment filter values accepted from the request. |
max_filter_value_length | 128 | Maximum length for each level/environment filter value. |
max_json_context_bytes | 1048576 | Maximum JSON context candidate size parsed from one record. |
max_context_depth | 8 | Maximum nested depth rendered for parsed JSON context tables. |
max_context_items | 200 | Maximum parsed context entries rendered for one record. |
max_stacktrace_rows | 200 | Maximum stack trace rows rendered for one record. |
redact_patterns | [] | Optional PCRE patterns applied to parsed display text before rendering. |
redaction_replacement | [REDACTED] | Replacement used for list-style redact_patterns. |
locales | en, ru, uk | Available interface locales. |
You can tune large-file handling and operational defaults with environment variables:
LOG_VIEWER_MAX_LINES_DISPLAY=10000
LOG_VIEWER_DOWNLOAD_ENABLED=true
LOG_VIEWER_MAX_LISTED_FILES=1000
LOG_VIEWER_MAX_DISPLAY_BYTES=16777216
LOG_VIEWER_SCAN_MODE=latest
LOG_VIEWER_INITIAL_SCAN_BYTES=8388608
LOG_VIEWER_MAX_SCAN_BYTES=134217728
LOG_VIEWER_READ_CHUNK_SIZE=65536
LOG_VIEWER_MAX_RECORD_BYTES=1048576
LOG_VIEWER_MAX_SEARCH_TERMS=8
LOG_VIEWER_MAX_SEARCH_LENGTH=256
LOG_VIEWER_MAX_FILTER_VALUES=100
LOG_VIEWER_MAX_FILTER_VALUE_LENGTH=128
LOG_VIEWER_MAX_JSON_CONTEXT_BYTES=1048576
LOG_VIEWER_MAX_CONTEXT_DEPTH=8
LOG_VIEWER_MAX_CONTEXT_ITEMS=200
LOG_VIEWER_MAX_STACKTRACE_ROWS=200
For large production logs, keep LOG_VIEWER_SCAN_MODE=latest. Users can explicitly scan from
the beginning or request a deeper latest scan from the interface, but each request remains bounded
by LOG_VIEWER_MAX_SCAN_BYTES.
Optional redaction can hide secrets in the web UI without changing the original log file or download response:
'redact_patterns' => [
'/(api[_-]?key=)[^\s&]+/i' => '$1[REDACTED]',
'/(token=)[^\s&]+/i',
],
'redaction_replacement' => '[REDACTED]',
File Handling
The package reads files from Laravel's storage/logs directory only.
Accepted files:
laravel.loglaravel-2026-06-07.logworker.log
Rejected files:
laravel.log.gzlaravel.log.1laravel.log.php../laravel.log- symlinks
- directories
- unreadable files
Compressed or archived logs are intentionally excluded from the list and cannot be downloaded through the viewer.
If max_listed_files is reached, the sidebar keeps the newest readable .log files by modification time and marks the list as limited.
License
Laravel Log Viewer is open-sourced software licensed under the MIT license.
Author
Alexander Kudria alexkudrya91@gmail.com
alex-kudrya/laravel-log-viewer 适用场景与选型建议
alex-kudrya/laravel-log-viewer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 106 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 06 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「monitoring」 「laravel」 「logs」 「log-viewer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 alex-kudrya/laravel-log-viewer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alex-kudrya/laravel-log-viewer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alex-kudrya/laravel-log-viewer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The tenancy/tenancy logs mutations
A Symfony bundle for chameleon-system/sanitycheck
SoftWax Health Check Bundle for Symfony framework
1Pilot client for Symfony
Statsd (Object Oriented) client library for PHP
APM agent for laravel projects to monitor the application with elastic apm tools.
统计信息
- 总下载量: 106
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-12