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

Nova Log Viewer Laravel Package

laravel/nova-log-viewer

View and search your Laravel application logs directly inside Laravel Nova. Nova Log Viewer adds a simple tool UI with real-time polling support, making it easy to inspect errors, stack traces, and recent log entries without leaving the admin panel.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation Run composer require laravel/nova-log-viewer in your Laravel project. Ensure your project uses Laravel Nova (v3+ recommended).

  2. Registration Add the tool to Nova’s tools() method in app/Providers/NovaServiceProvider.php:

    public function tools()
    {
        return [
            \Laravel\Nova\LogViewer\LogViewer::make(),
        ];
    }
    
  3. First Use Case

    • Access the tool via Nova’s sidebar (under "Tools").
    • View real-time logs with auto-refresh (polling enabled by default).
    • Filter logs by level (e.g., error, info) or keyword (e.g., auth).

Implementation Patterns

Core Workflows

  1. Log Monitoring

    • Use the live-updating feature to track logs in real-time (adjust polling interval via config).
    • Example: Monitor error logs during deployment:
      // In NovaServiceProvider::tools()
      LogViewer::make()->withPollingInterval(5); // Refresh every 5 seconds
      
  2. Debugging with Nova

    • Filter by level: Quickly isolate error or debug logs.
    • Search logs: Use the search bar to find specific entries (e.g., failed job).
    • Copy log entries: Click the copy button to paste logs into Slack/email.
  3. Integration with Nova Features

    • Link to resources: Use the viaResource() method to attach the tool to a Nova resource (e.g., User):
      LogViewer::make()->viaResource(User::class);
      
    • Customize appearance: Override the tool’s view by publishing its assets:
      php artisan vendor:publish --tag=nova-log-viewer
      
  4. Log Management

    • Clear logs: Use Laravel’s Log::clear() via Nova’s tool (if extended).
    • Log retention: Configure LOG_MAX_FILES in .env to manage log file size.

Gotchas and Tips

Pitfalls

  1. Polling Overhead

    • High polling intervals (e.g., 1s) may strain the server. Default (10s) is recommended.
    • Fix: Adjust LOG_VIEWER_POLLING_INTERVAL in config/services.php or via the tool’s settings.
  2. Log File Permissions

    • Nova may fail to read logs if storage permissions are restrictive.
    • Fix: Ensure storage/logs/ is writable:
      chmod -R 775 storage/logs/
      
  3. Large Log Files

    • Nova buffers logs in memory; very large files (e.g., laravel.log > 100MB) may cause timeouts.
    • Fix: Use Laravel’s Log::clear() to rotate logs or increase LOG_MAX_FILES.
  4. Monolog-Specific Quirks

    • Custom Monolog handlers (e.g., SingleFileHandler) may not display properly.
    • Fix: Ensure logs are written to storage/logs/laravel.log (default).

Debugging Tips

  1. Check Nova Logs

    • If the tool fails to load, inspect Nova’s logs at storage/logs/nova.log.
  2. Disable Polling for Testing

    • Temporarily disable polling to test static log rendering:
      LogViewer::make()->withoutPolling();
      
  3. Extend Log Levels

    • Add custom log levels (e.g., alert) by extending the tool’s view:
      // Publish the tool first, then modify `resources/js/tools/LogViewer/Levels.vue`.
      

Extension Points

  1. Custom Log Filters

    • Override the tool’s query logic in a service provider:
      public function boot()
      {
          \Laravel\Nova\LogViewer\LogViewer::extend(function ($tool) {
              $tool->withCustomFilter(fn ($query) => $query->where('context.user_id', auth()->id()));
          });
      }
      
  2. Add Log Actions

    • Attach buttons to log entries (e.g., "Replay Job") by extending the tool’s view:
      // resources/js/tools/LogViewer/LogEntry.vue
      methods: {
          replayJob(entry) {
              Nova.request().post(`/nova-vendor/log-viewer/replay`, { entry });
          }
      }
      
  3. Localization

    • Translate the tool’s UI by publishing its language files:
      php artisan vendor:publish --tag=nova-log-viewer-lang
      
    • Then add translations to resources/lang/vendor/nova-log-viewer/.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport