- How do I install Log Viewer in a Laravel 11 project?
- Run `composer require opcodesio/log-viewer` and then `php artisan log-viewer:publish` to publish assets and config. The package auto-detects Laravel logs in `storage/logs` and supports additional log sources like Horizon or Nginx out of the box. No extra configuration is needed for basic usage.
- Does Log Viewer work with Laravel Octane?
- Yes, Log Viewer supports Laravel Octane starting from version 3.24.0. The package uses scoped bindings to ensure compatibility with Octane’s serverless and queue worker environments. No additional setup is required beyond the standard installation.
- Can I restrict access to the Log Viewer UI in production?
- The UI is publicly accessible by default, but you can secure it using Laravel middleware. Add `Route::middleware(['auth', 'admin'])` to the route in `routes/web.php` or use Laravel’s built-in auth guards. The API endpoints also support authentication via Laravel’s auth system.
- What Laravel versions does Log Viewer support?
- Log Viewer officially supports Laravel 8.x, 9.x, 10.x, 11.x, and 12.x. The package is regularly updated to maintain compatibility with new Laravel releases. Check the [Packagist page](https://packagist.org/packages/opcodesio/log-viewer) for the latest version details.
- How do I handle large log files (e.g., 100MB+) without performance issues?
- For large log files, use the `IndexedLogReader` (introduced in v3.22.0), which preserves file metadata for faster loading. Additionally, configure Laravel’s `LOG_MAX_FILES` to rotate logs and avoid excessive file sizes. For production, consider pairing this with an external log aggregation tool like ELK Stack or Loki.
- Can Log Viewer parse custom log formats (e.g., JSON, CSV, or proprietary logs)?
- Yes, Log Viewer supports custom log parsers. You can define a custom parser in the config file or extend the package’s `LogParser` class. The documentation provides detailed instructions, but you’ll need PHP knowledge to handle unsupported formats. For complex formats, you may need to write a custom parser.
- Is there an API to fetch logs programmatically?
- Yes, Log Viewer exposes a RESTful API for accessing logs, folders, and files. Endpoints include `/api/logs`, `/api/files`, and `/api/folders`, all authenticated via Laravel’s auth system. This is useful for integrating logs into monitoring tools or custom dashboards.
- How do I serve Log Viewer assets without publishing them manually?
- Since version 3.19.0, Log Viewer assets can be served directly from the vendor directory. No manual publishing is required. Ensure your web server has read permissions for the `vendor/opcodesio/log-viewer/resources` directory.
- What are the alternatives to Log Viewer for Laravel log management?
- Alternatives include Laravel Debugbar (for debugging), Sentry (for error tracking), and dedicated log aggregation tools like ELK Stack or Datadog. Log Viewer is unique in offering a self-contained, UI-driven solution for browsing and managing logs directly in Laravel without external dependencies.
- How do I troubleshoot issues like 'logs not loading' in production?
- Common causes include file permission issues (e.g., web server user lacks access to log files) or misconfigured log paths. Verify permissions for directories like `storage/logs` and external logs (e.g., `/var/log/nginx/`). Check the [troubleshooting docs](https://github.com/opcodesio/log-viewer#troubleshooting) for step-by-step guidance.