Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Log Viewer Laravel Package

elkadrey/laravel-log-viewer

Lightweight Laravel/Lumen log viewer. Install via Composer, register the service provider, and add a route to LogViewerController@index to browse your app logs in the browser. No public assets or vendor routes; supports rotated logs.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Monolithic vs. Modular: Fits seamlessly into Laravel’s monolithic architecture (Lumen/5-8) without requiring microservice-level integration. Lightweight enough for modular setups if logs are centralized.
  • Observability Stack: Complements existing tools (e.g., Sentry, Datadog) by providing a self-hosted, UI-driven log inspection layer for development/staging. Avoids vendor lock-in (unlike SaaS alternatives).
  • Log Format Agnostic: Works with Laravel’s default Monolog setup (single/multi-file, rotated logs) but lacks explicit support for structured JSON logs or external log shippers (e.g., Fluentd). Assumes logs are stored locally.

Integration Feasibility

  • Low Friction: Zero public assets or vendor routes reduce merge conflicts. Installation is a single Composer dependency + route definition.
  • Dependency Risks:
    • Laravel Version Lock: Explicitly supports L4.2–8 but may lag behind minor releases (e.g., Laravel 9+ features like improved logging).
    • Monolog Dependency: Relies on Laravel’s default logging stack; custom log handlers (e.g., syslog, database) may require adjustments.
  • Database Impact: None (logs are file-based). No schema migrations or ORM dependencies.

Technical Risk

Risk Area Severity Mitigation Strategy
Log Rotation Gaps Medium Test with logrotate and Laravel’s single vs. daily log channels. May need custom log retention policies.
Performance Low UI renders logs client-side; risk of high memory usage if viewing large log files (>100MB). Add pagination or lazy-loading.
Security Medium Logs may contain PII/sensitive data. Restrict access via middleware (e.g., auth:sanctum + IP whitelisting).
Custom Log Formats High If using structured logs (JSON), parsing may fail. Extend LogViewerServiceProvider or pre-process logs.
Lumen Compatibility Low Test in Lumen; may need adjustments for middleware/route binding differences.

Key Questions

  1. Log Volume/Retention:
    • How large are production logs? Will the UI handle real-time streaming (e.g., tail -f) or only static files?
    • Are logs rotated? If so, does the viewer support multi-file reconstruction?
  2. Access Control:
    • Who needs access? Will you use Laravel’s built-in auth or a dedicated service (e.g., OAuth2 proxy)?
  3. Log Sensitivity:
    • Are logs scrubbed for PII before viewing? Plan for redaction (e.g., via Monolog processors).
  4. Alternatives:
    • Why not use Laravel Forge/Telescope or a SaaS tool (e.g., Logflare)? Justify self-hosting costs (devops overhead).
  5. Future-Proofing:
    • Will this replace or augment existing observability tools? Define SLOs for log availability.

Integration Approach

Stack Fit

  • Laravel Core: Native integration with Monolog; no conflicts with Laravel’s logging stack.
  • Frontend: Zero dependencies (pure PHP/Blade). Works with any Laravel frontend (Livewire, Inertia, vanilla Blade).
  • Infrastructure:
    • Self-Hosted: Deploy alongside Laravel (shared host, VPS, or Kubernetes).
    • Air-Gapped: No external APIs; logs remain on-disk.
  • CI/CD: Minimal impact. Add to composer.json and deploy as part of the Laravel stack.

Migration Path

  1. Discovery Phase (1 day):
    • Audit current logging setup (channels, handlers, rotation).
    • Verify log file locations (default: storage/logs/laravel.log).
  2. Installation (0.5 day):
    composer require elkadrey/laravel-log-viewer
    php artisan vendor:publish --provider="Elkadrey\LogViewer\LogViewerServiceProvider"
    
    • Publish config (adjust log_path, max_files, per_page).
  3. Route Integration (0.5 day):
    Route::middleware(['auth:sanctum'])->get('/logs', [\Elkadrey\LogViewer\Controllers\LogViewerController::class, 'index']);
    
  4. Testing (1 day):
    • Validate with:
      • Default Laravel logs.
      • Rotated logs (if used).
      • Custom log channels (if applicable).
    • Load test with large log files (>10MB).
  5. Security Hardening (0.5 day):
    • Add middleware to restrict access (e.g., CanAccessLogs policy).
    • Implement log redaction if needed.

Compatibility

Component Compatibility Notes
Laravel 4.2–8 Tested; may need tweaks for L9+.
Lumen Supported but verify middleware/route differences.
Log Rotation Works with logrotate but may miss files if retention policies delete logs.
Custom Handlers Untested with database/syslog handlers. Extend LogViewerServiceProvider if needed.
Structured Logs Assumes plaintext. JSON logs require preprocessing (e.g., Monolog formatter).

Sequencing

  1. Phase 1: Deploy in staging with read-only access for devs.
  2. Phase 2: Gradually roll out to production with limited access (e.g., SREs only).
  3. Phase 3: Integrate with incident workflows (e.g., link logs to Jira/PagerDuty).
  4. Phase 4: (Optional) Extend for custom log sources (e.g., database logs).

Operational Impact

Maintenance

  • Vendor Updates: Monitor for Laravel version support. Fork if upstream lags.
  • Log Management:
    • Retention: Ensure log rotation policies align with viewer’s max_files config.
    • Cleanup: Add cron job to purge old logs if storage grows unchecked.
  • Dependencies:
    • Composer: Update elkadrey/laravel-log-viewer alongside Laravel.
    • Blade Templates: No changes expected unless extending UI.

Support

  • Troubleshooting:
    • Logs Missing: Verify log_path in config and file permissions (storage/logs/).
    • Performance Issues: Add per_page limit or implement client-side pagination.
    • Access Denied: Check middleware and user roles.
  • Documentation: None provided; create internal runbook for:
    • Setup steps.
    • Common issues (e.g., rotated logs not appearing).
    • Access control rules.

Scaling

  • Horizontal Scaling: Stateless UI; scale Laravel app as usual. Log files must be shared storage (e.g., NFS, S3 via log_channel).
  • Vertical Scaling: UI performance degrades with large log files (>100MB). Mitigate with:
    • Client-side pagination.
    • Pre-filtering logs (e.g., by severity).
    • Offloading to a dedicated log service (e.g., ELK) for production.
  • High Availability: Log files are single points of failure. Replicate logs if uptime is critical.

Failure Modes

Failure Scenario Impact Mitigation
Log File Corruption UI shows garbled logs. Use logrotate with copytruncate.
Permission Denied 403 errors. Ensure storage/logs/ is writable by web server.
Disk Full Laravel logs fail to write. Set up log retention policies.
UI Freeze (Large Logs) Client-side rendering hangs. Add per_page limit or lazy-load.
Laravel Update Breaks Viewer Viewer stops working. Test compatibility early; fork if needed.

Ramp-Up

  • Developer Onboarding (0.5 day):
    • Train team on:
      • Accessing logs via /logs route.
      • Filtering by date/severity.
      • Customizing the viewer (extending LogViewerController).
  • Incident Response (1 day):
    • Integrate with alerting (e.g., Slack notifications for critical logs).
    • Document how to export logs for analysis (e.g., curl + jq for JSON).
  • Feedback Loop:
    • Gather input from devs/SREs on missing features (e.g., search, annotations).
    • Plan for Phase 2 enhancements (e.g., log tailing, team sharing).
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor